@nbtca/prompt 1.5.17 → 1.5.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/chrome.js +8 -10
- package/dist/app/fields/list-field.js +1 -2
- package/dist/app/views/docs.js +19 -9
- package/dist/app/views/events.js +8 -4
- package/dist/app/views/home.js +1 -1
- package/dist/app/views/schedule-grid-cursor.js +1 -1
- package/dist/app/views/schedule-render.js +11 -2
- package/dist/app/views/schedule.js +3 -1
- package/dist/config/preferences.js +1 -1
- package/dist/core/components/menu.js +6 -4
- package/dist/core/text.js +22 -0
- package/dist/core/theme.js +4 -0
- package/dist/features/calendar-heatmap.js +4 -5
- package/dist/features/calendar.js +5 -5
- package/dist/features/docs.js +16 -5
- package/dist/features/schedule-render.js +31 -17
- package/dist/i18n/locales/en.json +10 -11
- package/dist/i18n/locales/zh.json +22 -23
- package/package.json +2 -2
package/dist/app/chrome.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c, type, space, glyph, brandMark, bodyEdge } from '../core/theme.js';
|
|
1
|
+
import { c, type, space, glyph, brandMark, bodyEdge, bodyWidth } from '../core/theme.js';
|
|
2
2
|
import { pickIcon } from '../core/icons.js';
|
|
3
3
|
import { t } from '../i18n/index.js';
|
|
4
4
|
import { clipAnsiToVisualWidth, visualWidth, wrapAnsiWithIndent } from '../core/text.js';
|
|
@@ -25,7 +25,7 @@ function renderRule(cols) {
|
|
|
25
25
|
return indent + type.hint(glyph.rule().repeat(ruleWidth));
|
|
26
26
|
}
|
|
27
27
|
function renderTabs(views, active, cols) {
|
|
28
|
-
const dot =
|
|
28
|
+
const dot = glyph.sep();
|
|
29
29
|
const full = space.indent +
|
|
30
30
|
views
|
|
31
31
|
.map((view) => view.id === active ? type.active(`[${view.title}]`) : type.hint(` ${view.title} `))
|
|
@@ -61,9 +61,7 @@ function renderTabs(views, active, cols) {
|
|
|
61
61
|
export function renderContextPath(segments, cols) {
|
|
62
62
|
const chevron = pickIcon('›', '>');
|
|
63
63
|
const ellipsis = pickIcon('…', '...');
|
|
64
|
-
const width =
|
|
65
|
-
? bodyEdge(Math.max(1, Math.floor(cols)))
|
|
66
|
-
: Number.POSITIVE_INFINITY;
|
|
64
|
+
const width = bodyWidth(cols);
|
|
67
65
|
for (let start = 0; start < segments.length; start += 1) {
|
|
68
66
|
const shown = segments.slice(start);
|
|
69
67
|
const last = shown.length - 1;
|
|
@@ -106,16 +104,16 @@ export function fitFooterHint(cols, ...candidates) {
|
|
|
106
104
|
}
|
|
107
105
|
export function captureFooterHint(cols = Number.POSITIVE_INFINITY) {
|
|
108
106
|
const trans = t();
|
|
109
|
-
const dot =
|
|
110
|
-
return fitFooterHint(cols, `${glyph.enter()} ${trans.
|
|
107
|
+
const dot = glyph.sep();
|
|
108
|
+
return fitFooterHint(cols, `${glyph.enter()} ${trans.menu.hintConfirm} ${dot} Esc ${trans.menu.hintBack} ${dot} Ctrl+C ${trans.menu.hintQuit}`, `${glyph.enter()} Esc Ctrl+C`, 'Ctrl+C Esc', 'Ctrl+C');
|
|
111
109
|
}
|
|
112
110
|
export function digitTabHint(tabCount) {
|
|
113
|
-
const dot =
|
|
111
|
+
const dot = glyph.sep();
|
|
114
112
|
return tabCount > 1 ? `1-${tabCount} / Tab ${t().menu.hintTabs} ${dot} ` : '';
|
|
115
113
|
}
|
|
116
114
|
export function passiveFooterHint(tabCount, cols = Number.POSITIVE_INFINITY, canGoBack = true) {
|
|
117
115
|
const trans = t();
|
|
118
|
-
const dot =
|
|
116
|
+
const dot = glyph.sep();
|
|
119
117
|
const compactTabs = tabCount > 1 ? `1-${tabCount}/Tab ${dot} ` : '';
|
|
120
118
|
const back = canGoBack ? `Esc ${trans.menu.hintBack} ${dot} ` : '';
|
|
121
119
|
const backKey = canGoBack ? `Esc ${dot} ` : '';
|
|
@@ -123,7 +121,7 @@ export function passiveFooterHint(tabCount, cols = Number.POSITIVE_INFINITY, can
|
|
|
123
121
|
}
|
|
124
122
|
function interactiveFooterHint(tabCount, cols) {
|
|
125
123
|
const trans = t();
|
|
126
|
-
const dot =
|
|
124
|
+
const dot = glyph.sep();
|
|
127
125
|
const compactTabs = tabCount > 1 ? `1-${tabCount}/Tab ${dot} ` : '';
|
|
128
126
|
const move = `${glyph.updown()} ${trans.menu.hintMove} ${dot} ${glyph.enter()} ${trans.menu.hintOpen}`;
|
|
129
127
|
const quit = `q ${trans.menu.hintQuit}`;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { renderMenu, renderMenuOption, menuColumns, nextIndex, parseKey, } from '../../core/components/menu.js';
|
|
2
2
|
import { bodyEdge, glyph, space, type } from '../../core/theme.js';
|
|
3
|
-
import { pickIcon } from '../../core/icons.js';
|
|
4
3
|
import { t, fmt } from '../../i18n/index.js';
|
|
5
4
|
import { visualWidth, wrapAnsiToVisualWidth } from '../../core/text.js';
|
|
6
5
|
export function computeMaxVisible(bodyRows) {
|
|
@@ -64,7 +63,7 @@ export class ListField {
|
|
|
64
63
|
above > 0 ? fmt(trans.common.moreAbove, { count: above }) : null,
|
|
65
64
|
below > 0 ? fmt(trans.common.moreBelow, { count: below }) : null,
|
|
66
65
|
].filter((part) => part !== null);
|
|
67
|
-
lines.push(...renderIndentedOutput(type.hint(parts.join(` ${
|
|
66
|
+
lines.push(...renderIndentedOutput(type.hint(parts.join(` ${glyph.sep()} `)), cols, `${space.indent}${' '.repeat(visualWidth(glyph.cursor()) + 1)}`));
|
|
68
67
|
}
|
|
69
68
|
if (footer)
|
|
70
69
|
lines.push('', ...renderIndentedOutput(type.hint(footer), cols));
|
package/dist/app/views/docs.js
CHANGED
|
@@ -68,18 +68,22 @@ async function openUrlFromView(ctx, url, open, generation = lifecycleGeneration)
|
|
|
68
68
|
return;
|
|
69
69
|
state = {
|
|
70
70
|
...state,
|
|
71
|
-
errorMessage: sanitizeTerminalLine(
|
|
71
|
+
errorMessage: sanitizeTerminalLine(fmt(t().docs.browserErrorManual, { url })),
|
|
72
72
|
};
|
|
73
73
|
ctx.rerender();
|
|
74
74
|
}
|
|
75
|
+
function countHints(counts) {
|
|
76
|
+
const width = Math.max(0, ...counts.map((count) => String(count).length));
|
|
77
|
+
return counts.map((count) => String(count).padStart(width));
|
|
78
|
+
}
|
|
75
79
|
function buildSectionsField() {
|
|
76
80
|
const trans = t();
|
|
77
|
-
const
|
|
81
|
+
const counts = countHints(sections.map((sec) => sec.count));
|
|
78
82
|
const options = [
|
|
79
|
-
...sections.map((sec) => ({
|
|
83
|
+
...sections.map((sec, index) => ({
|
|
80
84
|
value: sec.key,
|
|
81
85
|
label: sec.label,
|
|
82
|
-
hint:
|
|
86
|
+
hint: counts[index] ?? '',
|
|
83
87
|
})),
|
|
84
88
|
{ value: '__search__', label: trans.docs.searchPrompt },
|
|
85
89
|
{ value: '__refresh__', label: trans.docs.refreshCache },
|
|
@@ -116,8 +120,9 @@ function buildArchivedGroupsField(groups, maxVisible, initialIndex = 0) {
|
|
|
116
120
|
return 1;
|
|
117
121
|
return a.localeCompare(b);
|
|
118
122
|
});
|
|
123
|
+
const counts = countHints(sortedKeys.map((k) => groups.get(k)?.length ?? 0));
|
|
119
124
|
const options = [
|
|
120
|
-
...sortedKeys.map((k) => ({ value: k, label: k, hint:
|
|
125
|
+
...sortedKeys.map((k, index) => ({ value: k, label: k, hint: counts[index] ?? '' })),
|
|
121
126
|
{ value: '__back__', label: backLabel() },
|
|
122
127
|
];
|
|
123
128
|
return new ListField({ title: trans.docs.categoryArchived, options, maxVisible, initialIndex });
|
|
@@ -132,14 +137,14 @@ function buildArchivedFilesField(groupKey, groupFiles, maxVisible, initialIndex
|
|
|
132
137
|
value: f.path,
|
|
133
138
|
...docLabel(f),
|
|
134
139
|
...optionalHint(subDirs.size > 1
|
|
135
|
-
? [sanitizeTerminalLine(sub), f.summary].filter(Boolean).join(
|
|
140
|
+
? [sanitizeTerminalLine(sub), f.summary].filter(Boolean).join(` ${glyph.sep()} `)
|
|
136
141
|
: f.summary),
|
|
137
142
|
};
|
|
138
143
|
}),
|
|
139
144
|
{ value: '__back__', label: backLabel() },
|
|
140
145
|
];
|
|
141
146
|
return new ListField({
|
|
142
|
-
title: `${trans.docs.categoryArchived}
|
|
147
|
+
title: `${trans.docs.categoryArchived} ${glyph.sep()} ${groupKey}`,
|
|
143
148
|
options,
|
|
144
149
|
maxVisible,
|
|
145
150
|
initialIndex,
|
|
@@ -171,11 +176,16 @@ function buildSearchResultsField(matches, maxVisible, initialIndex = 0) {
|
|
|
171
176
|
(result.path.includes('/')
|
|
172
177
|
? sanitizeTerminalLine(result.path.split('/').slice(0, -1).join('/'))
|
|
173
178
|
: undefined)),
|
|
179
|
+
hintFocus: currentSearchQuery,
|
|
174
180
|
})),
|
|
175
181
|
{ value: '__back__', label: backLabel() },
|
|
176
182
|
];
|
|
177
183
|
return new ListField({
|
|
178
|
-
title: fmt(trans.docs.searchResultsTitle, {
|
|
184
|
+
title: fmt(trans.docs.searchResultsTitle, {
|
|
185
|
+
query: currentSearchQuery,
|
|
186
|
+
count: matches.length,
|
|
187
|
+
sep: glyph.sep(),
|
|
188
|
+
}),
|
|
179
189
|
options,
|
|
180
190
|
maxVisible,
|
|
181
191
|
initialIndex,
|
|
@@ -581,7 +591,7 @@ export const docsView = {
|
|
|
581
591
|
}
|
|
582
592
|
if (state.mode === 'reader' && !state.readerLinksField) {
|
|
583
593
|
const trans = t();
|
|
584
|
-
const dot =
|
|
594
|
+
const dot = glyph.sep();
|
|
585
595
|
const hasLinks = (state.readerLinks?.length ?? 0) > 0;
|
|
586
596
|
const linkHint = hasLinks ? `f ${trans.docs.readerLinksHint} ${dot} ` : '';
|
|
587
597
|
const pageHint = `${glyph.updown()} PgUp/PgDn ${dot} `;
|
package/dist/app/views/events.js
CHANGED
|
@@ -3,7 +3,7 @@ import { ListField, computeMaxVisible } from '../fields/list-field.js';
|
|
|
3
3
|
import { TextField } from '../fields/text-field.js';
|
|
4
4
|
import { hubShowsHeatmap, renderEvents } from './events-render.js';
|
|
5
5
|
import { setVimKeysActive } from '../../core/vim-keys.js';
|
|
6
|
-
import {
|
|
6
|
+
import { glyph } from '../../core/theme.js';
|
|
7
7
|
import { padEndV, visualWidth } from '../../core/text.js';
|
|
8
8
|
import { fmt, t } from '../../i18n/index.js';
|
|
9
9
|
import { eventTimeRange, eventWhen, exportEventIcs, loadCalendarOrCache, recurringMark, toDisplayEvent, yearHeatmap, } from '../../features/calendar.js';
|
|
@@ -46,7 +46,7 @@ function syncHubField(bodyRows) {
|
|
|
46
46
|
}
|
|
47
47
|
function showList(ctx, title, events, emptyMessage, isEnded = () => false) {
|
|
48
48
|
const trans = t();
|
|
49
|
-
const dot =
|
|
49
|
+
const dot = glyph.sep();
|
|
50
50
|
const display = events.map(toDisplayEvent);
|
|
51
51
|
const whenWidth = Math.max(0, ...display.map((event) => visualWidth(eventWhen(event))));
|
|
52
52
|
const options = [
|
|
@@ -94,7 +94,7 @@ function showDetail(raw) {
|
|
|
94
94
|
const trans = t();
|
|
95
95
|
listState = state;
|
|
96
96
|
const e = toDisplayEvent(raw);
|
|
97
|
-
const dot =
|
|
97
|
+
const dot = glyph.sep();
|
|
98
98
|
state = {
|
|
99
99
|
mode: 'detail',
|
|
100
100
|
detailTitle: e.title,
|
|
@@ -280,7 +280,11 @@ export const eventsView = {
|
|
|
280
280
|
const now = new Date();
|
|
281
281
|
const { upcoming, past } = searchEvents(calendar, query, now);
|
|
282
282
|
const trans = t();
|
|
283
|
-
showList(ctx,
|
|
283
|
+
showList(ctx, fmt(trans.calendar.searchResultsTitle, {
|
|
284
|
+
query,
|
|
285
|
+
count: upcoming.length + past.length,
|
|
286
|
+
sep: glyph.sep(),
|
|
287
|
+
}), [...upcoming, ...past], fmt(trans.calendar.searchNoResultsFor, { query }), (event) => hasEnded(event, now));
|
|
284
288
|
}
|
|
285
289
|
return;
|
|
286
290
|
}
|
package/dist/app/views/home.js
CHANGED
|
@@ -101,7 +101,7 @@ export function renderHome(data, now, bodyRows = 100, cols = 80) {
|
|
|
101
101
|
}
|
|
102
102
|
const unresolvedCount = data.schedule?.timetable.unresolvedItems.length ?? 0;
|
|
103
103
|
if (unresolvedCount > 0) {
|
|
104
|
-
lines.push(...wrappedIndentedLines(`${pickIcon('⚠', '!')} ${trans.timetable.hubUnresolved}
|
|
104
|
+
lines.push(...wrappedIndentedLines(`${pickIcon('⚠', '!')} ${trans.timetable.hubUnresolved} ${glyph.sep()} ${unresolvedCount}`, cols, c.warn));
|
|
105
105
|
lines.push('');
|
|
106
106
|
}
|
|
107
107
|
lines.push(...panelHeading(trans.menu.events, cols));
|
|
@@ -42,7 +42,7 @@ export function handleGridKey(key, cursor, tt, week) {
|
|
|
42
42
|
return { kind: 'moveCursor', cursor: moveCursorPeriod(cursor, tt.periods, 1) };
|
|
43
43
|
if (key === KEY_ENTER_CR || key === KEY_ENTER_LF) {
|
|
44
44
|
const meeting = createTimetableSchedule(tt).meetingAt(week, cursor.weekday, cursor.period);
|
|
45
|
-
return meeting ? { kind: 'openDetail', meeting } : { kind: '
|
|
45
|
+
return meeting ? { kind: 'openDetail', meeting } : { kind: 'emptyCell' };
|
|
46
46
|
}
|
|
47
47
|
return { kind: 'none' };
|
|
48
48
|
}
|
|
@@ -91,6 +91,7 @@ function hubPreGridLines(state, now, cols) {
|
|
|
91
91
|
lines.push(hint(fmt(trans.timetable.termStartsIn, {
|
|
92
92
|
date: state.weekOne,
|
|
93
93
|
days: String(daysUntil(now, state.weekOne)),
|
|
94
|
+
sep: glyph.sep(),
|
|
94
95
|
})));
|
|
95
96
|
lines.push('');
|
|
96
97
|
lines.push(heading(trans.timetable.termPreviewWeek));
|
|
@@ -103,6 +104,7 @@ function hubPreGridLines(state, now, cols) {
|
|
|
103
104
|
heading(fmt(trans.timetable.todayHeading, {
|
|
104
105
|
weekday: weekdayShortLabel(todayWd),
|
|
105
106
|
week: String(week),
|
|
107
|
+
sep: glyph.sep(),
|
|
106
108
|
})),
|
|
107
109
|
...renderTodayTimeline(today, tt.periods, now, cols).split('\n'),
|
|
108
110
|
'',
|
|
@@ -267,11 +269,18 @@ function renderPublicBody(state, now, bodyRows, cols) {
|
|
|
267
269
|
lines.push(...hintLines(trans.timetable.publicUnavailable, cols));
|
|
268
270
|
}
|
|
269
271
|
else if (w.status === 'onBreak') {
|
|
270
|
-
lines.push(...headingLines(fmt(trans.timetable.onBreak, {
|
|
272
|
+
lines.push(...headingLines(fmt(trans.timetable.onBreak, {
|
|
273
|
+
title: sanitizeTerminalLine(w.breakTitle),
|
|
274
|
+
sep: glyph.sep(),
|
|
275
|
+
}), cols));
|
|
271
276
|
}
|
|
272
277
|
else {
|
|
273
278
|
const semesterLabel = w.semester === '1' ? trans.timetable.semester1 : trans.timetable.semester2;
|
|
274
|
-
lines.push(...headingLines(
|
|
279
|
+
lines.push(...headingLines([
|
|
280
|
+
fmt(trans.timetable.academicYearSuffix, { year: sanitizeTerminalLine(w.academicYear) }),
|
|
281
|
+
semesterLabel,
|
|
282
|
+
fmt(trans.timetable.weekLabel2, { week: String(w.currentWeek) }),
|
|
283
|
+
].join(` ${glyph.sep()} `), cols));
|
|
275
284
|
const bar = renderTermProgressBar(w, cols);
|
|
276
285
|
if (bar)
|
|
277
286
|
lines.push(...bar);
|
|
@@ -34,7 +34,7 @@ function gridKeys() {
|
|
|
34
34
|
}
|
|
35
35
|
function gridFooterHint(tabCount, cols) {
|
|
36
36
|
const trans = t();
|
|
37
|
-
const dot =
|
|
37
|
+
const dot = glyph.sep();
|
|
38
38
|
const keys = gridKeys();
|
|
39
39
|
const local = `${keys.days} ${trans.timetable.footerDay} ${dot} ${keys.periods} ${trans.timetable.footerClass} ${dot} ${keys.enter} ${trans.timetable.footerDetail}`;
|
|
40
40
|
const labelled = `Esc ${trans.menu.hintBack} ${dot} q ${trans.menu.hintQuit}`;
|
|
@@ -594,6 +594,8 @@ export const scheduleView = {
|
|
|
594
594
|
};
|
|
595
595
|
return;
|
|
596
596
|
}
|
|
597
|
+
if (nav.kind === 'emptyCell')
|
|
598
|
+
return;
|
|
597
599
|
returnToHub();
|
|
598
600
|
return;
|
|
599
601
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { glyph, type, space, bodyEdge } from '../theme.js';
|
|
2
|
-
import { visualWidth, padEndV, wrapAnsiToVisualWidth, clipAnsiToVisualWidth } from '../text.js';
|
|
2
|
+
import { visualWidth, padEndV, wrapAnsiToVisualWidth, clipAnsiToVisualWidth, excerptAround, } from '../text.js';
|
|
3
3
|
import { pickIcon } from '../icons.js';
|
|
4
4
|
import { createPainter } from './painter.js';
|
|
5
5
|
import { startRawInput } from './input-session.js';
|
|
@@ -78,11 +78,11 @@ function renderIndentedText(label, cols, style) {
|
|
|
78
78
|
}
|
|
79
79
|
const MIN_LABEL_COLUMN = 24;
|
|
80
80
|
const MIN_HINT_COLUMN = 16;
|
|
81
|
+
const ellipsis = () => pickIcon('…', '~');
|
|
81
82
|
function clipWithEllipsis(value, width) {
|
|
82
83
|
if (visualWidth(value) <= width)
|
|
83
84
|
return value;
|
|
84
|
-
|
|
85
|
-
return clipAnsiToVisualWidth(value, width - visualWidth(ellipsis)) + ellipsis;
|
|
85
|
+
return clipAnsiToVisualWidth(value, width - visualWidth(ellipsis())) + ellipsis();
|
|
86
86
|
}
|
|
87
87
|
function fitColumns(columns, contentWidth) {
|
|
88
88
|
if (columns.label + 2 + columns.hint <= contentWidth)
|
|
@@ -100,7 +100,9 @@ function optionCells(option, columns, contentWidth) {
|
|
|
100
100
|
return fitted
|
|
101
101
|
? {
|
|
102
102
|
label: padEndV(clipWithEllipsis(option.label, fitted.label), fitted.label),
|
|
103
|
-
hint:
|
|
103
|
+
hint: option.hintFocus
|
|
104
|
+
? excerptAround(hint, option.hintFocus, fitted.hint, ellipsis())
|
|
105
|
+
: clipWithEllipsis(hint, fitted.hint),
|
|
104
106
|
}
|
|
105
107
|
: { label: option.label, hint: '' };
|
|
106
108
|
}
|
package/dist/core/text.js
CHANGED
|
@@ -118,6 +118,28 @@ export function truncateStart(str, maxWidth, marker = '...') {
|
|
|
118
118
|
}
|
|
119
119
|
return fittedMarker + value;
|
|
120
120
|
}
|
|
121
|
+
function indexOfIgnoreCase(text, needle) {
|
|
122
|
+
const target = needle.toLowerCase();
|
|
123
|
+
for (let index = 0; index + needle.length <= text.length; index += 1) {
|
|
124
|
+
if (text.slice(index, index + needle.length).toLowerCase() === target)
|
|
125
|
+
return index;
|
|
126
|
+
}
|
|
127
|
+
return -1;
|
|
128
|
+
}
|
|
129
|
+
export function excerptAround(text, needle, maxWidth, marker = '...') {
|
|
130
|
+
if (visualWidth(text) <= maxWidth)
|
|
131
|
+
return text;
|
|
132
|
+
const at = needle ? indexOfIgnoreCase(text, needle) : -1;
|
|
133
|
+
const markerWidth = visualWidth(marker);
|
|
134
|
+
if (at <= 0 || visualWidth(text.slice(0, at + needle.length)) + markerWidth <= maxWidth) {
|
|
135
|
+
return truncate(text, maxWidth, marker);
|
|
136
|
+
}
|
|
137
|
+
const rest = text.slice(at);
|
|
138
|
+
const available = maxWidth - markerWidth;
|
|
139
|
+
const lead = Math.max(Math.floor(available / 4), available - visualWidth(rest));
|
|
140
|
+
const head = truncateStart(text.slice(0, at), lead + markerWidth, marker);
|
|
141
|
+
return head + truncate(rest, maxWidth - visualWidth(head), marker);
|
|
142
|
+
}
|
|
121
143
|
function osc8State(sequence) {
|
|
122
144
|
const match = OSC8_RE.exec(sequence);
|
|
123
145
|
if (!match)
|
package/dist/core/theme.js
CHANGED
|
@@ -54,6 +54,7 @@ export const glyph = {
|
|
|
54
54
|
rule: () => pickIcon('─', '-'),
|
|
55
55
|
bar: () => pickIcon('│', '|'),
|
|
56
56
|
bullet: () => pickIcon('·', '.'),
|
|
57
|
+
sep: () => pickIcon('·', '-'),
|
|
57
58
|
dot: () => pickIcon('●', '*'),
|
|
58
59
|
updown: () => pickIcon('↑↓', 'up/down'),
|
|
59
60
|
enter: () => pickIcon('⏎', 'enter'),
|
|
@@ -74,6 +75,9 @@ const RIGHT_MARGIN_MIN_COLS = 40;
|
|
|
74
75
|
export function bodyEdge(cols) {
|
|
75
76
|
return cols >= RIGHT_MARGIN_MIN_COLS ? cols - space.indent.length : cols;
|
|
76
77
|
}
|
|
78
|
+
export function bodyWidth(cols) {
|
|
79
|
+
return Number.isFinite(cols) ? bodyEdge(Math.max(1, Math.floor(cols))) : Number.POSITIVE_INFINITY;
|
|
80
|
+
}
|
|
77
81
|
export const type = {
|
|
78
82
|
heading: (s) => chalk.bold(s),
|
|
79
83
|
label: (s) => s,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { pickIcon } from '../core/icons.js';
|
|
2
|
-
import { c, space, type } from '../core/theme.js';
|
|
2
|
+
import { bodyWidth, c, space, type } from '../core/theme.js';
|
|
3
3
|
import { t, getCurrentLanguage } from '../i18n/index.js';
|
|
4
4
|
import { visualWidth } from '../core/text.js';
|
|
5
5
|
function parseBucketDate(date) {
|
|
@@ -49,10 +49,9 @@ function placeMonthLabels(anchors, width, format, strict) {
|
|
|
49
49
|
export function renderHeatmap(buckets, today, options) {
|
|
50
50
|
const useColor = options?.color === true;
|
|
51
51
|
const trans = t();
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
: Math.floor((options.cols - GRID_PREFIX_WIDTH) / cellWidth);
|
|
52
|
+
const cols = bodyWidth(options?.cols ?? Number.POSITIVE_INFINITY);
|
|
53
|
+
const cellWidth = cols < GRID_PREFIX_WIDTH + MAX_WEEK_COLUMNS * 2 ? 1 : 2;
|
|
54
|
+
const availableColumns = Math.floor((cols - GRID_PREFIX_WIDTH) / cellWidth);
|
|
56
55
|
const numCols = Math.max(1, Math.min(MAX_WEEK_COLUMNS, availableColumns));
|
|
57
56
|
const countByDate = new Map();
|
|
58
57
|
for (const b of buckets) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fetchFeedConditional, parseCalendar, createCalendar, FeedFetchError, FeedParseError, eventToICS, } from '@nbtca/nbtcal';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
-
import { c, type, space, glyph } from '../core/theme.js';
|
|
3
|
+
import { c, type, space, glyph, bodyWidth } from '../core/theme.js';
|
|
4
4
|
import { pickIcon } from '../core/icons.js';
|
|
5
5
|
import { padEndV, sanitizeTerminalLine, sanitizeTerminalText, truncate, visualWidth, wrapAnsiWithIndent, wrapAnsiToVisualWidth, } from '../core/text.js';
|
|
6
6
|
import { t } from '../i18n/index.js';
|
|
@@ -202,7 +202,7 @@ export function recurringMark(e) {
|
|
|
202
202
|
return e.recurring ? ` ${pickIcon('↻', '~')}` : '';
|
|
203
203
|
}
|
|
204
204
|
function hangingLines(marker, content, cols) {
|
|
205
|
-
const width =
|
|
205
|
+
const width = bodyWidth(cols);
|
|
206
206
|
const prefixes = [`${space.indent}${marker} `, `${marker} `, marker, ''];
|
|
207
207
|
const prefix = prefixes.find((candidate) => visualWidth(candidate) < width) ?? '';
|
|
208
208
|
const continuation = ' '.repeat(visualWidth(prefix));
|
|
@@ -210,7 +210,7 @@ function hangingLines(marker, content, cols) {
|
|
|
210
210
|
return wrapAnsiToVisualWidth(content, contentWidth).map((line, index) => `${index === 0 ? prefix : continuation}${line}`);
|
|
211
211
|
}
|
|
212
212
|
export function renderEventBriefLines(e, now, cols = Number.POSITIVE_INFINITY) {
|
|
213
|
-
const dot =
|
|
213
|
+
const dot = glyph.sep();
|
|
214
214
|
const proximity = eventProximity(e.startDate, now);
|
|
215
215
|
const dateStyle = proximity === 'today'
|
|
216
216
|
? type.active
|
|
@@ -219,7 +219,7 @@ export function renderEventBriefLines(e, now, cols = Number.POSITIVE_INFINITY) {
|
|
|
219
219
|
: proximity === 'week'
|
|
220
220
|
? type.body
|
|
221
221
|
: type.hint;
|
|
222
|
-
const marker = proximity === 'today' ? type.active(pickIcon('●', '*')) : dateStyle(
|
|
222
|
+
const marker = proximity === 'today' ? type.active(pickIcon('●', '*')) : dateStyle(glyph.sep());
|
|
223
223
|
const titleStyled = styleTitle(e.title, proximity === 'today' ? type.active : type.body);
|
|
224
224
|
const content = `${dateStyle(eventWhen(e))} ${type.hint(dot)} ${titleStyled}${type.hint(recurringMark(e))}`;
|
|
225
225
|
return hangingLines(marker, content, cols);
|
|
@@ -236,7 +236,7 @@ export function renderCountdownBanner(event, now, cols = Number.POSITIVE_INFINIT
|
|
|
236
236
|
? trans.calendar.startingNow
|
|
237
237
|
: `${trans.calendar.inPrefix} ${formatDuration(p)}`;
|
|
238
238
|
const whenStyled = isCountdownUrgent(p) ? c.warn(when) : type.hint(when);
|
|
239
|
-
const dot =
|
|
239
|
+
const dot = glyph.sep();
|
|
240
240
|
const content = `${type.label(trans.calendar.next)} ${dot} ${type.body(event.title)} ${dot} ${whenStyled}`;
|
|
241
241
|
return hangingLines(type.active(glyph.dot()), content, cols).join('\n');
|
|
242
242
|
}
|
package/dist/features/docs.js
CHANGED
|
@@ -8,6 +8,7 @@ import { warning, createSpinner } from '../core/ui.js';
|
|
|
8
8
|
import { pickIcon } from '../core/icons.js';
|
|
9
9
|
import { spawn, execFileSync } from 'child_process';
|
|
10
10
|
import { URLS } from '../config/data.js';
|
|
11
|
+
import { glyph } from '../core/theme.js';
|
|
11
12
|
import { t, fmt, getCurrentLanguage } from '../i18n/index.js';
|
|
12
13
|
import { enterScreen, breadcrumb } from '../core/transitions.js';
|
|
13
14
|
import { sanitizeTerminalLine, sanitizeTerminalText, truncate } from '../core/text.js';
|
|
@@ -642,9 +643,14 @@ function searchDoc(result) {
|
|
|
642
643
|
export async function searchDocuments(query, signal, onProgress) {
|
|
643
644
|
if (onProgress) {
|
|
644
645
|
const items = await fetchAllDocs(signal);
|
|
645
|
-
let
|
|
646
|
+
let pending = items.filter((item) => !peekDocMetadata(item));
|
|
647
|
+
if (pending.length > METADATA_CONCURRENCY) {
|
|
648
|
+
await runDocsClientOperation(signal, (client) => client.prefetch());
|
|
649
|
+
pending = pending.filter((item) => !peekDocMetadata(item));
|
|
650
|
+
}
|
|
651
|
+
let done = items.length - pending.length;
|
|
646
652
|
onProgress(done, items.length);
|
|
647
|
-
await fetchDocMetadata(
|
|
653
|
+
await fetchDocMetadata(pending, signal, () => {
|
|
648
654
|
done += 1;
|
|
649
655
|
onProgress(done, items.length);
|
|
650
656
|
});
|
|
@@ -781,12 +787,17 @@ async function displayWithLess(doc, filePath) {
|
|
|
781
787
|
const header = [
|
|
782
788
|
'',
|
|
783
789
|
chalk.bold.cyan(` ${title}`),
|
|
784
|
-
chalk.dim(` ${filePath}`) + chalk.dim(`
|
|
790
|
+
chalk.dim(` ${filePath}`) + chalk.dim(` ${glyph.sep()} ${readTime}`),
|
|
785
791
|
rule,
|
|
786
792
|
...(tocBlock ? [tocBlock] : []),
|
|
787
793
|
'',
|
|
788
794
|
].join('\n');
|
|
789
|
-
const footer = [
|
|
795
|
+
const footer = [
|
|
796
|
+
'',
|
|
797
|
+
rule,
|
|
798
|
+
chalk.dim(` ${fmt(trans.docs.endOfDocument, { sep: glyph.sep() })}`),
|
|
799
|
+
'',
|
|
800
|
+
].join('\n');
|
|
790
801
|
const plain = chalk.level === 0;
|
|
791
802
|
const fullContent = plain
|
|
792
803
|
? sanitizeTerminalText(header + rendered + footer)
|
|
@@ -865,7 +876,7 @@ async function showArchivedSection(files) {
|
|
|
865
876
|
spinner.stop();
|
|
866
877
|
const subDirs = new Set(groupFiles.map((f) => f.path.split('/')[2]).filter(Boolean));
|
|
867
878
|
const fileSelected = await runMenu({
|
|
868
|
-
title: `${trans.docs.categoryArchived}
|
|
879
|
+
title: `${trans.docs.categoryArchived} ${glyph.sep()} ${groupKey}`,
|
|
869
880
|
options: [
|
|
870
881
|
...groupFiles.map((f) => {
|
|
871
882
|
const sub = f.path.split('/').slice(2, -1).join('/');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { campusDateTime, campusIsoDate, createTimetableSchedule } from '@nbtca/nbtcal/timetable';
|
|
2
2
|
import { countdownParts, isCountdownUrgent } from './calendar-query.js';
|
|
3
|
-
import { c, type, space, glyph, MAX_FRAME_COLS } from '../core/theme.js';
|
|
3
|
+
import { c, type, space, glyph, MAX_FRAME_COLS, bodyWidth } from '../core/theme.js';
|
|
4
4
|
import { pickIcon } from '../core/icons.js';
|
|
5
5
|
import { padEndV, truncate, visualWidth, wrapAnsiToVisualWidth } from '../core/text.js';
|
|
6
6
|
import { addLocalDays, parseLocalMonday } from '../core/calendar-day.js';
|
|
@@ -33,15 +33,16 @@ function span(m, periods) {
|
|
|
33
33
|
const e = periods.find((p) => p.period === m.endPeriod)?.end ?? '';
|
|
34
34
|
return rangeLabel(s, e);
|
|
35
35
|
}
|
|
36
|
-
export function renderNextClassBanner(next, now,
|
|
36
|
+
export function renderNextClassBanner(next, now, terminalCols = Number.POSITIVE_INFINITY, labelled = true) {
|
|
37
37
|
const trans = t();
|
|
38
38
|
if (!next)
|
|
39
39
|
return '';
|
|
40
|
+
const cols = bodyWidth(terminalCols);
|
|
40
41
|
const p = countdownParts(next.start, now);
|
|
41
42
|
const when = formatClassCountdown(p);
|
|
42
43
|
const styleWhen = isCountdownUrgent(p) ? c.warn : type.hint;
|
|
43
44
|
const whenStyled = styleWhen(when);
|
|
44
|
-
const dot =
|
|
45
|
+
const dot = glyph.sep();
|
|
45
46
|
const marker = type.active(glyph.dot());
|
|
46
47
|
const separator = ` ${dot} `;
|
|
47
48
|
const detailedPrefix = labelled
|
|
@@ -120,7 +121,7 @@ function renderTimeline(meetings, periods, now, day, alwaysShowLocation, cursorP
|
|
|
120
121
|
}
|
|
121
122
|
const today = campusIsoDate(now);
|
|
122
123
|
const minute = Math.floor(now.getTime() / 60_000) * 60_000;
|
|
123
|
-
const dot =
|
|
124
|
+
const dot = glyph.sep();
|
|
124
125
|
const rule = pickIcon('─', '-');
|
|
125
126
|
const midConnector = pickIcon('┼', '+');
|
|
126
127
|
const topConnector = pickIcon('┬', '+');
|
|
@@ -214,7 +215,8 @@ export function renderTodayTimeline(meetings, periods, now, cols = Number.POSITI
|
|
|
214
215
|
export function renderDayTimeline(meetings, periods, now, day, cursorPeriod, cols = Number.POSITIVE_INFINITY) {
|
|
215
216
|
return renderTimeline(meetings, periods, now, day, true, cursorPeriod, cols);
|
|
216
217
|
}
|
|
217
|
-
export function renderDaySwitcher(selectedWeekday, todayWeekday,
|
|
218
|
+
export function renderDaySwitcher(selectedWeekday, todayWeekday, terminalCols = Number.POSITIVE_INFINITY) {
|
|
219
|
+
const cols = bodyWidth(terminalCols);
|
|
218
220
|
const leftArrow = pickIcon('←', '<');
|
|
219
221
|
const rightArrow = pickIcon('→', '>');
|
|
220
222
|
const todayMark = pickIcon('•', '*');
|
|
@@ -275,6 +277,7 @@ function spreadWidths(ideal, available) {
|
|
|
275
277
|
return widths;
|
|
276
278
|
}
|
|
277
279
|
const GRID_SEP_W = 3;
|
|
280
|
+
const GRID_CURSOR_TAIL_W = 1;
|
|
278
281
|
function weekGridMetrics(timetable, weekNumber, now) {
|
|
279
282
|
const schedule = createTimetableSchedule(timetable);
|
|
280
283
|
const week = schedule.meetingsInWeek(weekNumber);
|
|
@@ -293,7 +296,7 @@ function weekGridMetrics(timetable, weekNumber, now) {
|
|
|
293
296
|
}
|
|
294
297
|
export function weekGridFullWidth(timetable, weekNumber, now) {
|
|
295
298
|
const { rowHeadW, totalIdealColW } = weekGridMetrics(timetable, weekNumber, now);
|
|
296
|
-
return visualWidth(space.indent) * 2 + rowHeadW + totalIdealColW + 6 * GRID_SEP_W;
|
|
299
|
+
return (visualWidth(space.indent) * 2 + rowHeadW + totalIdealColW + 6 * GRID_SEP_W + GRID_CURSOR_TAIL_W);
|
|
297
300
|
}
|
|
298
301
|
export function renderWeekGrid(timetable, weekNumber, now, cols = 80, cursor) {
|
|
299
302
|
const schedule = createTimetableSchedule(timetable);
|
|
@@ -304,9 +307,10 @@ export function renderWeekGrid(timetable, weekNumber, now, cols = 80, cursor) {
|
|
|
304
307
|
const connector = pickIcon('│', '|');
|
|
305
308
|
const emptyGlyph = pickIcon('·', '.');
|
|
306
309
|
const sepGlyph = pickIcon('│', '|');
|
|
307
|
-
const
|
|
310
|
+
const gap = ` ${sepGlyph} `;
|
|
311
|
+
const sep = type.hint(gap);
|
|
308
312
|
const { rowHeadW, idealColWidths, totalIdealColW } = weekGridMetrics(timetable, weekNumber, now);
|
|
309
|
-
const availableForCols = Math.max(0, lineBudget(cols) - visualWidth(space.indent) - rowHeadW - 6 * GRID_SEP_W);
|
|
313
|
+
const availableForCols = Math.max(0, lineBudget(cols) - visualWidth(space.indent) - rowHeadW - 6 * GRID_SEP_W - GRID_CURSOR_TAIL_W);
|
|
310
314
|
const colWidths = totalIdealColW <= availableForCols
|
|
311
315
|
? spreadWidths(idealColWidths, availableForCols)
|
|
312
316
|
: idealColWidths.map((w) => Math.max(3, Math.floor(w * (availableForCols / totalIdealColW))));
|
|
@@ -326,9 +330,9 @@ export function renderWeekGrid(timetable, weekNumber, now, cols = 80, cursor) {
|
|
|
326
330
|
lines.push(space.indent + blankHead + headerCells);
|
|
327
331
|
const sorted = [...periods].sort((a, b) => a.period - b.period);
|
|
328
332
|
sorted.forEach((p, i) => {
|
|
329
|
-
const rowHead = type.hint(padEndV(rangeLabel(p.start, p.end), rowHeadW));
|
|
330
333
|
const nameCells = [];
|
|
331
334
|
const locCells = [];
|
|
335
|
+
let widened = -1;
|
|
332
336
|
for (let wdIdx = 0; wdIdx < 7; wdIdx++) {
|
|
333
337
|
const wd = wdIdx + 1;
|
|
334
338
|
const colW = colWidths[wdIdx] ?? 3;
|
|
@@ -341,7 +345,11 @@ export function renderWeekGrid(timetable, weekNumber, now, cols = 80, cursor) {
|
|
|
341
345
|
const paddedName = centerInWidth(clip(rawName, colW), colW);
|
|
342
346
|
const paddedLoc = centerInWidth(clip(rawLoc, colW), colW);
|
|
343
347
|
if (isCursor) {
|
|
344
|
-
|
|
348
|
+
const wide = visualWidth(rawName) > colW - 2;
|
|
349
|
+
if (wide)
|
|
350
|
+
widened = wdIdx;
|
|
351
|
+
const inner = wide ? colW : colW - 2;
|
|
352
|
+
nameCells.push(type.active(centerInWidth(`[${clip(rawName, inner)}]`, inner + 2)));
|
|
345
353
|
locCells.push(starting ? type.body(paddedLoc) : type.hint(paddedLoc));
|
|
346
354
|
}
|
|
347
355
|
else if (starting) {
|
|
@@ -353,7 +361,13 @@ export function renderWeekGrid(timetable, weekNumber, now, cols = 80, cursor) {
|
|
|
353
361
|
locCells.push(type.hint(paddedLoc));
|
|
354
362
|
}
|
|
355
363
|
}
|
|
356
|
-
|
|
364
|
+
const rowHead = type.hint(padEndV(rangeLabel(p.start, p.end), rowHeadW - (widened === 0 ? 1 : 0)));
|
|
365
|
+
const nameRow = nameCells
|
|
366
|
+
.map((cell, index) => index === 0
|
|
367
|
+
? cell
|
|
368
|
+
: type.hint(gap.slice(index - 1 === widened ? 1 : 0, index === widened ? 2 : 3)) + cell)
|
|
369
|
+
.join('');
|
|
370
|
+
lines.push(space.indent + rowHead + nameRow);
|
|
357
371
|
lines.push(space.indent + blankHead + locCells.join(sep));
|
|
358
372
|
const next = sorted[i + 1];
|
|
359
373
|
if (next && minutesOf(next.start) - minutesOf(p.end) > GAP_THRESHOLD_MINUTES) {
|
|
@@ -367,7 +381,7 @@ export function renderWeekAgenda(timetable, weekNumber, now, cols = Number.POSIT
|
|
|
367
381
|
const todayWd = schedule.weekdayAt(now);
|
|
368
382
|
const width = lineBudget(cols);
|
|
369
383
|
const todayMark = pickIcon('•', '*');
|
|
370
|
-
const dot =
|
|
384
|
+
const dot = glyph.sep();
|
|
371
385
|
const pointer = glyph.cursor();
|
|
372
386
|
const labels = WEEKDAY_KEYS.map((_, i) => `${weekdayShortLabel(i + 1)}${i + 1 === todayWd ? todayMark : ''}`);
|
|
373
387
|
const labelW = Math.max(...labels.map(visualWidth));
|
|
@@ -456,7 +470,7 @@ export function renderMeetingDetail(meeting, periods, cols = Number.POSITIVE_INF
|
|
|
456
470
|
]);
|
|
457
471
|
}
|
|
458
472
|
rows.push([trans.timetable.detailWeeks, formatWeekRange(meeting.weeks)]);
|
|
459
|
-
const width =
|
|
473
|
+
const width = bodyWidth(cols);
|
|
460
474
|
const indent = visualWidth(space.indent) < width ? space.indent : '';
|
|
461
475
|
const contentWidth = Math.max(1, width - visualWidth(indent));
|
|
462
476
|
const labelWidth = rows.reduce((w, [label]) => Math.max(w, visualWidth(label)), 0);
|
|
@@ -480,7 +494,7 @@ export function renderMeetingDetail(meeting, periods, cols = Number.POSITIVE_INF
|
|
|
480
494
|
}
|
|
481
495
|
export function renderUnresolvedItems(items, cols = Number.POSITIVE_INFINITY) {
|
|
482
496
|
const trans = t();
|
|
483
|
-
const width =
|
|
497
|
+
const width = bodyWidth(cols);
|
|
484
498
|
const indent = visualWidth(space.indent) < width ? space.indent : '';
|
|
485
499
|
const contentWidth = Math.max(1, width - visualWidth(indent));
|
|
486
500
|
if (items.length === 0) {
|
|
@@ -488,7 +502,7 @@ export function renderUnresolvedItems(items, cols = Number.POSITIVE_INFINITY) {
|
|
|
488
502
|
.map((part) => `${indent}${part}`)
|
|
489
503
|
.join('\n');
|
|
490
504
|
}
|
|
491
|
-
const dot =
|
|
505
|
+
const dot = glyph.sep();
|
|
492
506
|
const lines = [];
|
|
493
507
|
for (const item of items) {
|
|
494
508
|
const name = item.sourceFields.kcmc ?? trans.timetable.unresolvedUnknownItem;
|
|
@@ -552,7 +566,7 @@ function densityMarkerLines(index, width, marker, label) {
|
|
|
552
566
|
export function renderTermDensity(meetings, weekOneMonday, currentWeek, cols = Number.POSITIVE_INFINITY) {
|
|
553
567
|
const trans = t().timetable;
|
|
554
568
|
const lang = getCurrentLanguage();
|
|
555
|
-
const width =
|
|
569
|
+
const width = bodyWidth(cols);
|
|
556
570
|
const indent = visualWidth(space.indent) < width ? space.indent : '';
|
|
557
571
|
const contentWidth = Math.max(1, width - visualWidth(indent));
|
|
558
572
|
const wrap = (text) => wrapAnsiToVisualWidth(text, contentWidth).map((part) => `${indent}${part}`);
|
|
@@ -581,7 +595,7 @@ export function renderTermDensity(meetings, weekOneMonday, currentWeek, cols = N
|
|
|
581
595
|
];
|
|
582
596
|
const summaryLines = [];
|
|
583
597
|
for (const part of summary) {
|
|
584
|
-
const joined = `${summaryLines.at(-1) ?? ''} ${
|
|
598
|
+
const joined = `${summaryLines.at(-1) ?? ''} ${glyph.sep()} ${part}`;
|
|
585
599
|
if (summaryLines.length > 0 && visualWidth(joined) <= contentWidth) {
|
|
586
600
|
summaryLines[summaryLines.length - 1] = joined;
|
|
587
601
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"common": {
|
|
3
3
|
"back": "Back",
|
|
4
|
-
"exit": "Exit",
|
|
5
4
|
"cancel": "Cancel",
|
|
6
|
-
"confirm": "Confirm",
|
|
7
5
|
"loading": "Loading...",
|
|
8
6
|
"error": "Error",
|
|
9
7
|
"success": "Success",
|
|
@@ -39,14 +37,13 @@
|
|
|
39
37
|
"timetable": "My Timetable",
|
|
40
38
|
"timetableDesc": "Log in to JWXT, choose a term and export ICS",
|
|
41
39
|
"links": "Links",
|
|
42
|
-
"linksDesc": "website · GitHub · roadmap",
|
|
43
40
|
"settings": "Settings",
|
|
44
|
-
"settingsDesc": "language · theme · about",
|
|
45
41
|
"chooseAction": "nbtca",
|
|
46
42
|
"hintMove": "move",
|
|
47
43
|
"hintTabs": "switch",
|
|
48
44
|
"hintBack": "back",
|
|
49
45
|
"hintOpen": "open",
|
|
46
|
+
"hintConfirm": "confirm",
|
|
50
47
|
"hintQuit": "quit"
|
|
51
48
|
},
|
|
52
49
|
"about": {
|
|
@@ -76,7 +73,7 @@
|
|
|
76
73
|
"viewDetail": "Select an event for details:",
|
|
77
74
|
"noDescription": "No additional details",
|
|
78
75
|
"heatmap": {
|
|
79
|
-
"title": "Activity (
|
|
76
|
+
"title": "Activity (Last 12 Months)",
|
|
80
77
|
"legendLess": "Less",
|
|
81
78
|
"legendMore": "More"
|
|
82
79
|
},
|
|
@@ -95,8 +92,9 @@
|
|
|
95
92
|
"thisMonth": "This Month",
|
|
96
93
|
"search": "Search",
|
|
97
94
|
"searchPrompt": "Search events",
|
|
98
|
-
"searchPlaceholder": "keyword
|
|
95
|
+
"searchPlaceholder": "Enter keyword...",
|
|
99
96
|
"searchNoResults": "No matching events",
|
|
97
|
+
"searchResultsTitle": "Results for “{query}” {sep} {count}",
|
|
100
98
|
"exportIcs": "Export .ics",
|
|
101
99
|
"exportSuccess": "Saved",
|
|
102
100
|
"exportError": "Could not write the .ics file",
|
|
@@ -143,11 +141,12 @@
|
|
|
143
141
|
"opening": "Opening browser...",
|
|
144
142
|
"browserOpened": "Knowledge base opened in browser",
|
|
145
143
|
"browserError": "Failed to open browser",
|
|
144
|
+
"browserErrorManual": "Failed to open browser. Open manually: {url}",
|
|
146
145
|
"retry": "Retry?",
|
|
147
146
|
"tocTitle": "Table of Contents",
|
|
148
147
|
"tableHint": "diagrams and tables render better in browser",
|
|
149
148
|
"mermaidHint": "open in browser to view",
|
|
150
|
-
"endOfDocument": "end of document
|
|
149
|
+
"endOfDocument": "end of document {sep} q quit {sep} / search",
|
|
151
150
|
"githubRateLimited": "GitHub API rate limit reached. Resets at {time}.",
|
|
152
151
|
"githubForbidden": "GitHub API access denied (403).",
|
|
153
152
|
"githubTokenHint": "Tip: set GITHUB_TOKEN for a higher rate limit.",
|
|
@@ -165,7 +164,7 @@
|
|
|
165
164
|
"offlineError": "Couldn't load the docs. You may be offline.",
|
|
166
165
|
"offlineHint": "Try again later, or read them at https://docs.nbtca.space",
|
|
167
166
|
"retryLoad": "Retry",
|
|
168
|
-
"searchResultsTitle": "Results for “{query}”
|
|
167
|
+
"searchResultsTitle": "Results for “{query}” {sep} {count}",
|
|
169
168
|
"searchProgress": "Searching every document: {done} of {total} checked"
|
|
170
169
|
},
|
|
171
170
|
"links": {
|
|
@@ -288,7 +287,7 @@
|
|
|
288
287
|
"semester2": "Term 2",
|
|
289
288
|
"weekLabel2": "Week {week}",
|
|
290
289
|
"academicYearSuffix": "{year}",
|
|
291
|
-
"onBreak": "On break
|
|
290
|
+
"onBreak": "On break {sep} {title}",
|
|
292
291
|
"publicUnavailable": "Academic calendar not available yet",
|
|
293
292
|
"daysUntilBreak": "{days} days until {title}",
|
|
294
293
|
"publicLoginAction": "Log in to see my timetable",
|
|
@@ -301,13 +300,13 @@
|
|
|
301
300
|
"weekdayFri": "Fri",
|
|
302
301
|
"weekdaySat": "Sat",
|
|
303
302
|
"weekdaySun": "Sun",
|
|
304
|
-
"todayHeading": "Today
|
|
303
|
+
"todayHeading": "Today {sep} {weekday} {sep} Week {week}",
|
|
305
304
|
"classDone": "Done",
|
|
306
305
|
"classLive": "In progress",
|
|
307
306
|
"minutesRemaining": "{minutes} min left",
|
|
308
307
|
"timelineEnd": "End of day",
|
|
309
308
|
"termNotStarted": "Term hasn't started yet",
|
|
310
|
-
"termStartsIn": "Classes begin {date}
|
|
309
|
+
"termStartsIn": "Classes begin {date} {sep} {days} days to go",
|
|
311
310
|
"hubTermDensity": "Term density",
|
|
312
311
|
"termDensityTitle": "Term density",
|
|
313
312
|
"termDensityThisWeek": "This week",
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"common": {
|
|
3
3
|
"back": "返回",
|
|
4
|
-
"exit": "退出",
|
|
5
4
|
"cancel": "取消",
|
|
6
|
-
"confirm": "确认",
|
|
7
5
|
"loading": "加载中...",
|
|
8
6
|
"error": "错误",
|
|
9
7
|
"success": "成功",
|
|
@@ -39,14 +37,13 @@
|
|
|
39
37
|
"timetable": "我的课表",
|
|
40
38
|
"timetableDesc": "登录教务、查询学期并导出 ICS",
|
|
41
39
|
"links": "链接",
|
|
42
|
-
"linksDesc": "官网 · GitHub · 路线图",
|
|
43
40
|
"settings": "设置",
|
|
44
|
-
"settingsDesc": "语言 · 主题 · 关于",
|
|
45
41
|
"chooseAction": "nbtca",
|
|
46
42
|
"hintMove": "移动",
|
|
47
43
|
"hintTabs": "切换",
|
|
48
44
|
"hintBack": "返回",
|
|
49
45
|
"hintOpen": "打开",
|
|
46
|
+
"hintConfirm": "确认",
|
|
50
47
|
"hintQuit": "退出"
|
|
51
48
|
},
|
|
52
49
|
"about": {
|
|
@@ -73,7 +70,7 @@
|
|
|
73
70
|
"untitledEvent": "未命名活动",
|
|
74
71
|
"tbdLocation": "待定",
|
|
75
72
|
"subscribeHint": "订阅日历",
|
|
76
|
-
"viewDetail": "
|
|
73
|
+
"viewDetail": "选择活动查看详情:",
|
|
77
74
|
"noDescription": "暂无详细信息",
|
|
78
75
|
"heatmap": {
|
|
79
76
|
"title": "近一年活跃度",
|
|
@@ -84,7 +81,7 @@
|
|
|
84
81
|
"pastEvents": "历史活动",
|
|
85
82
|
"pastEventsDesc": "近期活动记录",
|
|
86
83
|
"noPastEvents": "近一年没有已结束的活动",
|
|
87
|
-
"viewPastDetail": "
|
|
84
|
+
"viewPastDetail": "选择活动查看详情:",
|
|
88
85
|
"next": "下一场",
|
|
89
86
|
"recentActivity": "近期安排",
|
|
90
87
|
"browse": "浏览",
|
|
@@ -95,8 +92,9 @@
|
|
|
95
92
|
"thisMonth": "本月",
|
|
96
93
|
"search": "搜索",
|
|
97
94
|
"searchPrompt": "搜索活动",
|
|
98
|
-
"searchPlaceholder": "
|
|
95
|
+
"searchPlaceholder": "输入关键词...",
|
|
99
96
|
"searchNoResults": "没有匹配的活动",
|
|
97
|
+
"searchResultsTitle": "“{query}”的搜索结果 {sep} {count} 场",
|
|
100
98
|
"exportIcs": "导出 .ics",
|
|
101
99
|
"exportSuccess": "已保存",
|
|
102
100
|
"exportError": "无法写入 .ics 文件",
|
|
@@ -143,16 +141,17 @@
|
|
|
143
141
|
"opening": "正在打开浏览器...",
|
|
144
142
|
"browserOpened": "已在浏览器中打开知识库",
|
|
145
143
|
"browserError": "无法打开浏览器",
|
|
144
|
+
"browserErrorManual": "无法打开浏览器,请手动打开:{url}",
|
|
146
145
|
"retry": "是否重试?",
|
|
147
146
|
"tocTitle": "目录",
|
|
148
147
|
"tableHint": "图表与表格在浏览器中效果更佳",
|
|
149
148
|
"mermaidHint": "在浏览器中查看图表",
|
|
150
|
-
"endOfDocument": "文档结束
|
|
149
|
+
"endOfDocument": "文档结束 {sep} q 退出 {sep} / 搜索",
|
|
151
150
|
"githubRateLimited": "GitHub API 速率限制已达上限,将在 {time} 重置。",
|
|
152
151
|
"githubForbidden": "GitHub API 拒绝访问 (403)。",
|
|
153
|
-
"githubTokenHint": "
|
|
154
|
-
"fetchDirFailed": "
|
|
155
|
-
"fetchFileFailed": "
|
|
152
|
+
"githubTokenHint": "提示:设置 GITHUB_TOKEN 环境变量可获得更高的速率限制。",
|
|
153
|
+
"fetchDirFailed": "无法获取目录内容:{error}",
|
|
154
|
+
"fetchFileFailed": "无法获取文件内容:{error}",
|
|
156
155
|
"searchPrompt": "搜索文档",
|
|
157
156
|
"searchPlaceholder": "输入关键词...",
|
|
158
157
|
"searching": "正在搜索文档...",
|
|
@@ -165,7 +164,7 @@
|
|
|
165
164
|
"offlineError": "无法加载文档目录,可能是网络没有连接。",
|
|
166
165
|
"offlineHint": "请稍后重试,或者到 https://docs.nbtca.space 阅读",
|
|
167
166
|
"retryLoad": "重试",
|
|
168
|
-
"searchResultsTitle": "“{query}”的搜索结果
|
|
167
|
+
"searchResultsTitle": "“{query}”的搜索结果 {sep} {count} 篇",
|
|
169
168
|
"searchProgress": "正在逐篇检索文档,已检索 {done} / {total} 篇"
|
|
170
169
|
},
|
|
171
170
|
"links": {
|
|
@@ -177,7 +176,7 @@
|
|
|
177
176
|
"opening": "正在打开...",
|
|
178
177
|
"opened": "已在浏览器中打开",
|
|
179
178
|
"error": "无法打开浏览器",
|
|
180
|
-
"openManually": "
|
|
179
|
+
"openManually": "请手动打开:{url}"
|
|
181
180
|
},
|
|
182
181
|
"status": {
|
|
183
182
|
"checking": "正在检查服务状态...",
|
|
@@ -288,7 +287,7 @@
|
|
|
288
287
|
"semester2": "第二学期",
|
|
289
288
|
"weekLabel2": "第 {week} 周",
|
|
290
289
|
"academicYearSuffix": "{year}学年",
|
|
291
|
-
"onBreak": "假期中
|
|
290
|
+
"onBreak": "假期中 {sep} {title}",
|
|
292
291
|
"publicUnavailable": "校历数据暂不可用",
|
|
293
292
|
"daysUntilBreak": "距离{title}还有 {days} 天",
|
|
294
293
|
"publicLoginAction": "登录查看我的课表",
|
|
@@ -301,13 +300,13 @@
|
|
|
301
300
|
"weekdayFri": "五",
|
|
302
301
|
"weekdaySat": "六",
|
|
303
302
|
"weekdaySun": "日",
|
|
304
|
-
"todayHeading": "今日
|
|
303
|
+
"todayHeading": "今日 {sep} 周{weekday} {sep} 第 {week} 教学周",
|
|
305
304
|
"classDone": "已结束",
|
|
306
305
|
"classLive": "进行中",
|
|
307
306
|
"minutesRemaining": "还剩 {minutes} 分钟",
|
|
308
307
|
"timelineEnd": "放学",
|
|
309
308
|
"termNotStarted": "本学期尚未开始",
|
|
310
|
-
"termStartsIn": "{date} 开学
|
|
309
|
+
"termStartsIn": "{date} 开学 {sep} 还有 {days} 天",
|
|
311
310
|
"hubTermDensity": "学期活跃度",
|
|
312
311
|
"termDensityTitle": "学期活跃度",
|
|
313
312
|
"termDensityThisWeek": "本周",
|
|
@@ -365,7 +364,7 @@
|
|
|
365
364
|
"colorUpdated": "颜色模式已更新",
|
|
366
365
|
"colorUpdatedSessionOnly": "颜色模式仅在当前会话生效(无法写入配置文件)",
|
|
367
366
|
"usage": "用法: nbtca theme | nbtca theme icon <auto|ascii|unicode> | nbtca theme color <auto|on|off> | nbtca theme reset",
|
|
368
|
-
"invalidValue": "
|
|
367
|
+
"invalidValue": "无效取值,可选:"
|
|
369
368
|
},
|
|
370
369
|
"language": {
|
|
371
370
|
"selectLanguage": "语言",
|
|
@@ -375,10 +374,10 @@
|
|
|
375
374
|
"changedSessionOnly": "语言仅在当前会话生效(无法写入配置文件)"
|
|
376
375
|
},
|
|
377
376
|
"update": {
|
|
378
|
-
"available": "
|
|
379
|
-
"upToDate": "
|
|
377
|
+
"available": "有新版本可用:{current} → {latest}",
|
|
378
|
+
"upToDate": "已是最新版本({version})",
|
|
380
379
|
"checkFailed": "无法检查更新",
|
|
381
|
-
"command": "
|
|
380
|
+
"command": "运行:npm i -g @nbtca/prompt"
|
|
382
381
|
},
|
|
383
382
|
"cli": {
|
|
384
383
|
"usage": "用法:",
|
|
@@ -415,16 +414,16 @@
|
|
|
415
414
|
"flagTerm": "选择学年学期(例如 2026:3)",
|
|
416
415
|
"flagOutput": "ICS 输出路径",
|
|
417
416
|
"flagWeekOne": "第一教学周周一(教务未返回日期时使用)",
|
|
418
|
-
"unknownCommand": "
|
|
417
|
+
"unknownCommand": "未知命令:{command}",
|
|
419
418
|
"unknownCommandHint": "运行 `nbtca --help` 查看可用命令。",
|
|
420
|
-
"unknownFlag": "
|
|
419
|
+
"unknownFlag": "未知选项:{flag}",
|
|
421
420
|
"unknownFlagHint": "运行 `nbtca --help` 查看可用选项。",
|
|
422
421
|
"invalidFlag": "选项 {flag} 对此命令无效。",
|
|
423
422
|
"invalidFlagHint": "运行 `nbtca --help` 查看命令用法。",
|
|
424
423
|
"invalidLang": "无效语言。请使用 `zh` 或 `en`。",
|
|
425
424
|
"invalidNext": "无效的 --next 值。请使用 --next=<数字>(>= 1)。",
|
|
426
425
|
"eventsHeatmapConflict": "--heatmap 不能与 --today、--week、--month、--next 或 --search 同时使用。",
|
|
427
|
-
"eventsRangeConflict": "
|
|
426
|
+
"eventsRangeConflict": "活动时间范围只能选择一个:--today、--week 或 --month。",
|
|
428
427
|
"unexpectedArguments": "{command} 不接受多余参数。",
|
|
429
428
|
"requiresTty": "交互模式需要 TTY 终端。",
|
|
430
429
|
"requiresTtyHint": "使用 `nbtca --help` 查看命令模式。"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nbtca/prompt",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.18",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"interactive"
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@nbtca/docs": "^0.3.
|
|
49
|
+
"@nbtca/docs": "^0.3.4",
|
|
50
50
|
"@nbtca/nbtcal": "^0.4.3",
|
|
51
51
|
"chalk": "^5.6.2",
|
|
52
52
|
"marked": "^15.0.12"
|