@nbtca/prompt 1.5.21 → 1.5.23
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/README.md +6 -2
- package/dist/app/ambient.js +98 -0
- package/dist/app/app.js +3 -2
- package/dist/app/chrome.js +6 -2
- package/dist/app/views/docs-render.js +23 -15
- package/dist/app/views/docs.js +3 -0
- package/dist/app/views/events-render.js +57 -21
- package/dist/app/views/events.js +62 -9
- package/dist/app/views/home.js +66 -31
- package/dist/app/views/schedule-render.js +10 -3
- package/dist/app/views/schedule.js +16 -5
- package/dist/app/views/settings-render.js +13 -2
- package/dist/app/views/settings.js +27 -1
- package/dist/app/views/student-records-render.js +268 -0
- package/dist/app/views/student-records.js +196 -26
- package/dist/art/bitmaps.js +76 -0
- package/dist/art/glyphs.js +101 -0
- package/dist/art/motifs.js +198 -0
- package/dist/art/noise.js +43 -0
- package/dist/art/planet.js +184 -0
- package/dist/art/scene.js +446 -0
- package/dist/config/preferences.js +8 -1
- package/dist/core/components/empty-state.js +50 -0
- package/dist/core/components/menu.js +2 -2
- package/dist/core/components/picture.js +18 -0
- package/dist/core/logo.js +62 -43
- package/dist/core/pixel-art-fine.js +157 -0
- package/dist/core/pixel-art.js +223 -0
- package/dist/core/theme.js +1 -1
- package/dist/features/calendar-heatmap.js +35 -10
- package/dist/features/calendar.js +2 -2
- package/dist/features/event-art.js +16 -0
- package/dist/features/schedule-view.js +10 -0
- package/dist/i18n/locales/en.json +56 -6
- package/dist/i18n/locales/zh.json +55 -5
- package/dist/logo/ascii-emblem-large.txt +22 -0
- package/dist/logo/ascii-emblem-medium.txt +15 -0
- package/dist/logo/ascii-emblem.txt +11 -0
- package/dist/logo/ascii-logo.txt +3 -12
- package/package.json +3 -3
package/dist/app/views/home.js
CHANGED
|
@@ -2,14 +2,14 @@ import { c, type, space, glyph } from '../../core/theme.js';
|
|
|
2
2
|
import { t, fmt } from '../../i18n/index.js';
|
|
3
3
|
import { pickIcon } from '../../core/icons.js';
|
|
4
4
|
import { padEndV, visualWidth, wrapAnsiWithIndent } from '../../core/text.js';
|
|
5
|
-
import { nextClassLine, peekSchedule, todayLines, weekAheadInfo, } from '../../features/schedule-view.js';
|
|
6
|
-
import { loadCalendarOrThrow, peekCalendar, toDisplayEvent, renderEventBrief, } from '../../features/calendar.js';
|
|
5
|
+
import { nextClassLine, peekSchedule, todayLines, isRestDay, weekAheadInfo, } from '../../features/schedule-view.js';
|
|
6
|
+
import { loadCalendarOrThrow, peekCalendar, toDisplayEvent, renderEventBrief, renderCountdownBanner, } from '../../features/calendar.js';
|
|
7
7
|
import { weekdayShortLabel } from '../../features/schedule-render.js';
|
|
8
8
|
import { offlineNotice, passiveFooterHint } from '../chrome.js';
|
|
9
9
|
import { campusDateTime, campusIsoDate } from '@nbtca/nbtcal/timetable';
|
|
10
10
|
import { isoDayDifference, localDayDifference, parseLocalDate } from '../../core/calendar-day.js';
|
|
11
11
|
import { currentEvents } from '../../features/calendar-query.js';
|
|
12
|
-
import {
|
|
12
|
+
import { emptyStateLines, loadingStateLines } from '../../core/components/empty-state.js';
|
|
13
13
|
const WEEKDAYS = [1, 2, 3, 4, 5, 6, 7];
|
|
14
14
|
function wrappedIndentedLines(label, cols, style) {
|
|
15
15
|
return wrapAnsiWithIndent(style(label), cols, space.indent);
|
|
@@ -45,23 +45,28 @@ function renderDayProgress(now, cols) {
|
|
|
45
45
|
function renderWeekAheadGrid(classDays, eventDays, cols) {
|
|
46
46
|
const trans = t();
|
|
47
47
|
const hasClassChar = pickIcon('▓▓', '##');
|
|
48
|
-
const freeChar = pickIcon('
|
|
49
|
-
const
|
|
50
|
-
const blankCell = ' ';
|
|
48
|
+
const freeChar = pickIcon('··', '..');
|
|
49
|
+
const unknownChar = '??';
|
|
51
50
|
const rowLabelW = Math.max(visualWidth(trans.timetable.weekAheadClasses), visualWidth(trans.menu.events)) + 1;
|
|
52
|
-
const days =
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
const
|
|
51
|
+
const days = WEEKDAYS;
|
|
52
|
+
const labels = days.map(weekdayShortLabel);
|
|
53
|
+
const cellWidth = Math.max(2, ...labels.map(visualWidth));
|
|
54
|
+
const width = Number.isFinite(cols) ? Math.max(1, Math.floor(cols)) : Number.POSITIVE_INFINITY;
|
|
55
|
+
const gap = visualWidth(space.indent) + rowLabelW + days.length * cellWidth + (days.length - 1) * 2 <= width
|
|
56
|
+
? ' '
|
|
57
|
+
: ' ';
|
|
58
|
+
const classCell = (wd) => (classDays[wd - 1] ? hasClassChar : freeChar);
|
|
59
|
+
const eventCell = (wd) => eventDays ? (eventDays[wd - 1] ? hasClassChar : freeChar) : unknownChar;
|
|
60
|
+
const legendText = `${hasClassChar} ${trans.timetable.weekAheadBusy} ${freeChar} ${trans.timetable.weekAheadFree}` +
|
|
61
|
+
(eventDays ? '' : ` ${unknownChar} ${trans.timetable.weekAheadUnknown}`);
|
|
62
|
+
const dayLabels = labels.map((label) => type.hint(padEndV(label, cellWidth))).join(gap);
|
|
57
63
|
const headerLine = `${space.indent}${padEndV('', rowLabelW)}${dayLabels}`;
|
|
58
|
-
const classCells = days.map((wd) => type.body(classCell(wd))).join(
|
|
64
|
+
const classCells = days.map((wd) => type.body(padEndV(classCell(wd), cellWidth))).join(gap);
|
|
59
65
|
const classLine = `${space.indent}${type.hint(padEndV(trans.timetable.weekAheadClasses, rowLabelW))}${classCells}`;
|
|
60
|
-
const eventCells = days.map((wd) => type.body(eventCell(wd))).join(
|
|
66
|
+
const eventCells = days.map((wd) => type.body(padEndV(eventCell(wd), cellWidth))).join(gap);
|
|
61
67
|
const eventLine = `${space.indent}${type.hint(padEndV(trans.menu.events, rowLabelW))}${eventCells}`;
|
|
62
68
|
const legend = `${space.indent}${type.hint(legendText)}`;
|
|
63
69
|
const wideLines = [headerLine, classLine, eventLine, legend];
|
|
64
|
-
const width = Number.isFinite(cols) ? Math.max(1, Math.floor(cols)) : Number.POSITIVE_INFINITY;
|
|
65
70
|
if (wideLines.every((line) => visualWidth(line) <= width))
|
|
66
71
|
return wideLines.join('\n');
|
|
67
72
|
const compactHeading = wrappedIndentedLines(`${trans.timetable.weekAheadClasses} / ${trans.menu.events}`, cols, type.hint);
|
|
@@ -78,7 +83,9 @@ export function renderHome(data, now, bodyRows = 100, cols = 80) {
|
|
|
78
83
|
const lines = eventsStale ? offlineNotice(cols) : [];
|
|
79
84
|
if (data.schedule === null) {
|
|
80
85
|
lines.push(...panelHeading(trans.timetable.menuTitle, cols));
|
|
81
|
-
lines.push(...wrappedIndentedLines(fmt(
|
|
86
|
+
lines.push(...wrappedIndentedLines(fmt(cols < 40 || bodyRows < 10
|
|
87
|
+
? trans.timetable.homeLoginCtaCompact
|
|
88
|
+
: trans.timetable.homeLoginCta, {
|
|
82
89
|
tab: trans.timetable.menuEntry,
|
|
83
90
|
action: trans.timetable.publicLoginAction,
|
|
84
91
|
}), cols, type.hint));
|
|
@@ -104,42 +111,61 @@ export function renderHome(data, now, bodyRows = 100, cols = 80) {
|
|
|
104
111
|
lines.push(...wrappedIndentedLines(`${pickIcon('⚠', '!')} ${trans.timetable.hubUnresolved} ${glyph.sep()} ${unresolvedCount}`, cols, c.warn));
|
|
105
112
|
lines.push('');
|
|
106
113
|
}
|
|
107
|
-
|
|
114
|
+
const eventsHeading = panelHeading(trans.menu.events, cols);
|
|
115
|
+
const firstEventRows = wrappedRenderedLines(data.eventLines?.[0] ?? '', cols).length;
|
|
116
|
+
const banner = !data.schedule && data.nextEvent
|
|
117
|
+
? [...renderCountdownBanner(data.nextEvent, now, cols).split('\n'), '']
|
|
118
|
+
: [];
|
|
119
|
+
// Only spend rows on the countdown when the first event still fits below it
|
|
120
|
+
if (banner.length > 0 &&
|
|
121
|
+
lines.length + banner.length + eventsHeading.length + firstEventRows <= bodyRows) {
|
|
122
|
+
lines.push(...banner);
|
|
123
|
+
}
|
|
124
|
+
lines.push(...eventsHeading);
|
|
108
125
|
if (data.eventLines && data.eventLines.length > 0) {
|
|
109
126
|
const remaining = Number.isFinite(bodyRows)
|
|
110
127
|
? Math.max(0, Math.floor(bodyRows) - lines.length)
|
|
111
128
|
: Number.POSITIVE_INFINITY;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
129
|
+
const rendered = data.eventLines.map((line) => wrappedRenderedLines(line, cols));
|
|
130
|
+
const moreLine = (shown) => shown < rendered.length
|
|
131
|
+
? wrappedIndentedLines(fmt(trans.calendar.moreEvents, { count: rendered.length - shown }), cols, type.hint)
|
|
132
|
+
: [];
|
|
133
|
+
let shown = 0;
|
|
134
|
+
let used = 0;
|
|
135
|
+
while (shown < rendered.length) {
|
|
136
|
+
const next = rendered[shown] ?? [];
|
|
137
|
+
const reserve = shown + 1 < rendered.length ? moreLine(shown + 1).length : 0;
|
|
138
|
+
if (used + next.length + reserve > remaining)
|
|
118
139
|
break;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
usedRows += wrapped.length;
|
|
140
|
+
used += next.length;
|
|
141
|
+
shown += 1;
|
|
122
142
|
}
|
|
143
|
+
if (shown === 0)
|
|
144
|
+
shown = 1;
|
|
145
|
+
lines.push(...rendered.slice(0, shown).flat(), ...moreLine(shown));
|
|
123
146
|
}
|
|
124
147
|
else if (data.loading) {
|
|
125
|
-
lines.push(...
|
|
148
|
+
lines.push(...loadingStateLines(trans.common.loading, cols, bodyRows - lines.length));
|
|
126
149
|
}
|
|
127
150
|
else if (data.eventsLoadFailed) {
|
|
128
151
|
lines.push(...wrappedIndentedLines(trans.calendar.error, cols, type.hint));
|
|
129
152
|
}
|
|
130
153
|
else {
|
|
131
|
-
lines.push(...
|
|
154
|
+
lines.push(...emptyStateLines('calendar', trans.calendar.noEvents, cols, bodyRows - lines.length));
|
|
132
155
|
}
|
|
133
156
|
return lines;
|
|
134
157
|
}
|
|
135
158
|
const HOME_EVENT_FETCH_CAP = 15;
|
|
136
159
|
function calendarSnapshot(cal, weekAhead) {
|
|
137
160
|
const now = new Date();
|
|
138
|
-
const
|
|
161
|
+
const current = currentEvents(cal, now);
|
|
162
|
+
const eventLines = current
|
|
139
163
|
.slice(0, HOME_EVENT_FETCH_CAP)
|
|
140
164
|
.map((event) => renderEventBrief(toDisplayEvent(event), now));
|
|
165
|
+
const upcoming = current.find((event) => event.start >= now);
|
|
166
|
+
const nextEvent = upcoming ? { nextEvent: toDisplayEvent(upcoming) } : {};
|
|
141
167
|
if (!weekAhead)
|
|
142
|
-
return { eventLines };
|
|
168
|
+
return { eventLines, ...nextEvent };
|
|
143
169
|
const { weekStart } = weekAhead;
|
|
144
170
|
const monday = campusDateTime(weekStart, '00:00');
|
|
145
171
|
const daySet = new Set(cal
|
|
@@ -150,6 +176,7 @@ function calendarSnapshot(cal, weekAhead) {
|
|
|
150
176
|
: isoDayDifference(weekStart, campusIsoDate(event.start)))));
|
|
151
177
|
return {
|
|
152
178
|
eventLines,
|
|
179
|
+
...nextEvent,
|
|
153
180
|
weekAhead: {
|
|
154
181
|
classDays: weekAhead.classDays,
|
|
155
182
|
eventDays: WEEKDAYS.map((weekday) => daySet.has(weekday)),
|
|
@@ -160,8 +187,11 @@ let data = { loading: true };
|
|
|
160
187
|
export const homeView = {
|
|
161
188
|
id: 'home',
|
|
162
189
|
title: 'Home',
|
|
163
|
-
footerHint(tabCount, cols = Number.POSITIVE_INFINITY) {
|
|
164
|
-
return passiveFooterHint(tabCount, cols, false);
|
|
190
|
+
footerHint(tabCount, cols = Number.POSITIVE_INFINITY, canScroll = false) {
|
|
191
|
+
return passiveFooterHint(tabCount, cols, false, canScroll);
|
|
192
|
+
},
|
|
193
|
+
scrollsBody() {
|
|
194
|
+
return true;
|
|
165
195
|
},
|
|
166
196
|
async load(ctx) {
|
|
167
197
|
if (ctx.signal?.aborted)
|
|
@@ -197,6 +227,11 @@ export const homeView = {
|
|
|
197
227
|
}
|
|
198
228
|
}
|
|
199
229
|
},
|
|
230
|
+
ambient() {
|
|
231
|
+
return data.schedule && isRestDay(data.schedule)
|
|
232
|
+
? { kind: 'sky', rest: true }
|
|
233
|
+
: { kind: 'sky' };
|
|
234
|
+
},
|
|
200
235
|
isBusy() {
|
|
201
236
|
return data.loading === true;
|
|
202
237
|
},
|
|
@@ -7,6 +7,7 @@ import { renderNextClassBanner, renderWeekGrid, renderUnresolvedItems, renderTod
|
|
|
7
7
|
import { sanitizeTerminalLine, truncate, truncateStart, visualWidth, wrapAnsiWithIndent, } from '../../core/text.js';
|
|
8
8
|
import { isoDayDifference } from '../../core/calendar-day.js';
|
|
9
9
|
import { loadingLines } from '../../core/components/spinner.js';
|
|
10
|
+
import { loadingStateLines } from '../../core/components/empty-state.js';
|
|
10
11
|
import { offlineNotice } from '../chrome.js';
|
|
11
12
|
function heading(label) {
|
|
12
13
|
return `${space.indent}${type.heading(label)}`;
|
|
@@ -31,7 +32,7 @@ export function hubShortcuts(tt) {
|
|
|
31
32
|
{ key: 's', label: trans.timetable.hubSwitchTerm },
|
|
32
33
|
{ key: 'e', label: trans.timetable.hubExport },
|
|
33
34
|
{ key: 'a', label: trans.records.exams },
|
|
34
|
-
{ key: '
|
|
35
|
+
{ key: 'c', label: trans.records.grades },
|
|
35
36
|
];
|
|
36
37
|
if (tt.unresolvedItems.length > 0) {
|
|
37
38
|
shortcuts.push({
|
|
@@ -237,6 +238,12 @@ function renderHubBody(state, now, bodyRows, cols) {
|
|
|
237
238
|
const withGrid = layoutHub(state, now, bodyRows, cols, shortcuts.filter((shortcut) => shortcut.key !== 'w'));
|
|
238
239
|
return withGrid.grid ? withGrid.lines : layoutHub(state, now, bodyRows, cols, shortcuts).lines;
|
|
239
240
|
}
|
|
241
|
+
export function termProgress(w) {
|
|
242
|
+
if (!w || !('currentWeek' in w) || !w.nextBreakStart)
|
|
243
|
+
return undefined;
|
|
244
|
+
const weeks = Math.max(1, Math.round(isoDayDifference(w.weekOneMonday, w.nextBreakStart) / 7));
|
|
245
|
+
return { progress: Math.min(1, Math.max(0, w.currentWeek / weeks)), weeks };
|
|
246
|
+
}
|
|
240
247
|
const TERM_PROGRESS_WIDTH = 20;
|
|
241
248
|
function renderTermProgressBar(w, cols) {
|
|
242
249
|
if (!w.nextBreakStart)
|
|
@@ -266,7 +273,7 @@ function renderPublicBody(state, now, bodyRows, cols) {
|
|
|
266
273
|
const lines = state.publicStale ? offlineNotice(cols) : [];
|
|
267
274
|
const w = state.publicWindow;
|
|
268
275
|
if (w === undefined) {
|
|
269
|
-
lines.push(...
|
|
276
|
+
lines.push(...loadingStateLines(trans.common.loading, cols, bodyRows - lines.length));
|
|
270
277
|
}
|
|
271
278
|
else if (w === null) {
|
|
272
279
|
lines.push(...hintLines(trans.timetable.publicUnavailable, cols));
|
|
@@ -304,7 +311,7 @@ export function renderSchedule(state, now, bodyRows = 100, cols = 80) {
|
|
|
304
311
|
const trans = t();
|
|
305
312
|
switch (state.mode) {
|
|
306
313
|
case 'loading':
|
|
307
|
-
return
|
|
314
|
+
return loadingStateLines(trans.common.loading, cols, bodyRows);
|
|
308
315
|
case 'public':
|
|
309
316
|
return renderPublicBody(state, now, bodyRows, cols);
|
|
310
317
|
case 'records':
|
|
@@ -3,7 +3,7 @@ import { createNbtTimetableClient, createTimetableSchedule, timetableToIcs, } fr
|
|
|
3
3
|
import { captureFooterHint, digitTabHint, fitFooterHint, passiveFooterHint } from '../chrome.js';
|
|
4
4
|
import { ListField, computeMaxVisible } from '../fields/list-field.js';
|
|
5
5
|
import { TextField } from '../fields/text-field.js';
|
|
6
|
-
import { renderSchedule, hubShortcuts } from './schedule-render.js';
|
|
6
|
+
import { renderSchedule, hubShortcuts, termProgress, } from './schedule-render.js';
|
|
7
7
|
import { handleGridKey, todayGridCursor } from './schedule-grid-cursor.js';
|
|
8
8
|
import { setVimKeysActive } from '../../core/vim-keys.js';
|
|
9
9
|
import { t } from '../../i18n/index.js';
|
|
@@ -328,7 +328,7 @@ async function openStudentRecords(ctx, kind, generation = ++lifecycleGeneration)
|
|
|
328
328
|
term.semester === previousTerm.semester) ?? resolveTerm(catalog);
|
|
329
329
|
pendingRecordsKind = null;
|
|
330
330
|
const panel = new StudentRecordsPanel(kind, selected, relevantTerms(catalog), session.timetableTransport, () => isLifecycleActive(ctx, generation) && recordsPanel === panel, () => {
|
|
331
|
-
pendingRecordsKind = kind;
|
|
331
|
+
pendingRecordsKind = panel.kind;
|
|
332
332
|
createSessionStore().clear();
|
|
333
333
|
recordsPanel?.dispose();
|
|
334
334
|
recordsPanel = null;
|
|
@@ -406,6 +406,12 @@ export const scheduleView = {
|
|
|
406
406
|
state.termField?.setMaxVisible(computeMaxVisible(ctx.bodyRows));
|
|
407
407
|
return renderSchedule(state, new Date(), ctx.bodyRows, ctx.size.cols);
|
|
408
408
|
},
|
|
409
|
+
ambient() {
|
|
410
|
+
if (state.mode !== 'public' && state.mode !== 'hub')
|
|
411
|
+
return undefined;
|
|
412
|
+
const term = termProgress(state.publicWindow);
|
|
413
|
+
return term === undefined ? undefined : { kind: 'mountain', ...term };
|
|
414
|
+
},
|
|
409
415
|
isBusy() {
|
|
410
416
|
if (state.mode === 'records')
|
|
411
417
|
return recordsPanel?.isBusy() ?? false;
|
|
@@ -414,6 +420,9 @@ export const scheduleView = {
|
|
|
414
420
|
scrollsBody() {
|
|
415
421
|
return state.mode === 'records' && !recordsPanel?.capturesPageKeys();
|
|
416
422
|
},
|
|
423
|
+
contextPath() {
|
|
424
|
+
return state.mode === 'records' ? recordsPanel?.contextPath() : undefined;
|
|
425
|
+
},
|
|
417
426
|
shortcuts() {
|
|
418
427
|
if (state.mode === 'records')
|
|
419
428
|
return recordsPanel?.shortcuts() ?? [];
|
|
@@ -431,6 +440,8 @@ export const scheduleView = {
|
|
|
431
440
|
return [...grid, ...hubShortcuts(state.timetable).map(({ key, label }) => ({ key, label }))];
|
|
432
441
|
},
|
|
433
442
|
capturesInput() {
|
|
443
|
+
if (state.mode === 'records')
|
|
444
|
+
return recordsPanel?.capturesInput() ?? false;
|
|
434
445
|
return (state.mode === 'needsLoginId' ||
|
|
435
446
|
state.mode === 'needsLoginPassword' ||
|
|
436
447
|
state.mode === 'needsWeekOne');
|
|
@@ -442,7 +453,7 @@ export const scheduleView = {
|
|
|
442
453
|
},
|
|
443
454
|
footerHint(tabCount, cols = Number.POSITIVE_INFINITY) {
|
|
444
455
|
if (state.mode === 'records')
|
|
445
|
-
return passiveFooterHint(tabCount, cols);
|
|
456
|
+
return recordsPanel?.footerHint(tabCount, cols) ?? passiveFooterHint(tabCount, cols);
|
|
446
457
|
const capturing = state.mode === 'needsLoginId' ||
|
|
447
458
|
state.mode === 'needsLoginPassword' ||
|
|
448
459
|
state.mode === 'needsWeekOne';
|
|
@@ -515,7 +526,7 @@ export const scheduleView = {
|
|
|
515
526
|
return;
|
|
516
527
|
}
|
|
517
528
|
case 'records':
|
|
518
|
-
if (key === 'x' &&
|
|
529
|
+
if (key === 'x' && recordsPanel?.acceptsActions())
|
|
519
530
|
logout(ctx);
|
|
520
531
|
else
|
|
521
532
|
recordsPanel?.handleKey(key, ctx);
|
|
@@ -636,7 +647,7 @@ export const scheduleView = {
|
|
|
636
647
|
const shortcut = hubShortcuts(tt).find((sc) => sc.key === key);
|
|
637
648
|
if (!shortcut)
|
|
638
649
|
return;
|
|
639
|
-
if (shortcut.key === 'a' || shortcut.key === '
|
|
650
|
+
if (shortcut.key === 'a' || shortcut.key === 'c') {
|
|
640
651
|
void openStudentRecords(ctx, shortcut.key === 'a' ? 'exams' : 'grades');
|
|
641
652
|
return;
|
|
642
653
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { space, type } from '../../core/theme.js';
|
|
2
2
|
import { wrapAnsiWithIndent } from '../../core/text.js';
|
|
3
|
+
import { pictureBeside } from '../../core/components/picture.js';
|
|
4
|
+
import { gasGiantLines } from '../../art/planet.js';
|
|
3
5
|
import { renderListFieldWithContext } from '../fields/list-field.js';
|
|
6
|
+
const ABOUT_PLANET_COLS = 28;
|
|
4
7
|
function wrappedIndentedLines(label, cols, style) {
|
|
5
8
|
return wrapAnsiWithIndent(style(label), cols, space.indent);
|
|
6
9
|
}
|
|
@@ -19,13 +22,21 @@ export function renderSettings(state, bodyRows = Number.POSITIVE_INFINITY, cols
|
|
|
19
22
|
case 'language':
|
|
20
23
|
case 'icon':
|
|
21
24
|
case 'color':
|
|
25
|
+
case 'picture':
|
|
22
26
|
case 'reset':
|
|
23
27
|
return state.subField?.render(bodyRows, cols) ?? [];
|
|
24
28
|
case 'about': {
|
|
25
|
-
const
|
|
26
|
-
|
|
29
|
+
const aboutLines = state.aboutLines ?? [];
|
|
30
|
+
const plain = [
|
|
31
|
+
...aboutLines.flatMap((line) => line ? wrappedIndentedLines(line, cols, (value) => value) : ['']),
|
|
27
32
|
'',
|
|
28
33
|
];
|
|
34
|
+
const picture = gasGiantLines(ABOUT_PLANET_COLS) ?? [];
|
|
35
|
+
const fieldRows = state.backField?.render(Number.POSITIVE_INFINITY, cols).length ?? 0;
|
|
36
|
+
const fits = (lines) => !Number.isFinite(bodyRows) || lines.length + fieldRows <= bodyRows;
|
|
37
|
+
const beside = pictureBeside(picture, aboutLines, cols, 52);
|
|
38
|
+
const stacked = [...picture.map((line) => space.indent + line), '', ...plain];
|
|
39
|
+
const context = beside && fits([...beside, '']) ? [...beside, ''] : fits(stacked) ? stacked : plain;
|
|
29
40
|
if (!state.backField)
|
|
30
41
|
return context;
|
|
31
42
|
const fieldLines = state.backField.render(Number.POSITIVE_INFINITY, cols);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ListField } from '../fields/list-field.js';
|
|
2
2
|
import { renderSettings } from './settings-render.js';
|
|
3
|
-
import { applyColorModePreference, loadPreferences, resetPreferences, setColorMode, setIconMode, } from '../../config/preferences.js';
|
|
3
|
+
import { applyColorModePreference, loadPreferences, resetPreferences, setColorMode, setPictureDetail, setIconMode, } from '../../config/preferences.js';
|
|
4
4
|
import { resetIconCache } from '../../core/icons.js';
|
|
5
5
|
import { APP_INFO, URLS } from '../../config/data.js';
|
|
6
6
|
import { t, getCurrentLanguage, saveLanguagePreference, clearTranslationCache, } from '../../i18n/index.js';
|
|
@@ -19,6 +19,7 @@ function modeLabel(mode) {
|
|
|
19
19
|
unicode: theme.modeUnicode,
|
|
20
20
|
on: theme.modeOn,
|
|
21
21
|
off: theme.modeOff,
|
|
22
|
+
fine: theme.modeFine,
|
|
22
23
|
}[mode];
|
|
23
24
|
}
|
|
24
25
|
function modeOptions(modes, current) {
|
|
@@ -40,6 +41,7 @@ function buildMenuField(statusMessage, focus) {
|
|
|
40
41
|
},
|
|
41
42
|
{ value: 'icon', label: trans.theme.iconMode, hint: modeLabel(prefs.iconMode) },
|
|
42
43
|
{ value: 'color', label: trans.theme.colorMode, hint: modeLabel(prefs.colorMode) },
|
|
44
|
+
{ value: 'picture', label: trans.theme.pictureDetail, hint: modeLabel(prefs.pictureDetail) },
|
|
43
45
|
{ value: 'reset', label: trans.theme.resetLabel },
|
|
44
46
|
{ value: 'about', label: trans.about.title },
|
|
45
47
|
];
|
|
@@ -65,6 +67,9 @@ export const settingsView = {
|
|
|
65
67
|
render(ctx) {
|
|
66
68
|
return renderSettings(state, ctx.bodyRows, ctx.size.cols);
|
|
67
69
|
},
|
|
70
|
+
ambient() {
|
|
71
|
+
return state.mode === 'menu' ? { kind: 'emblem' } : undefined;
|
|
72
|
+
},
|
|
68
73
|
capturesInput() {
|
|
69
74
|
return false;
|
|
70
75
|
},
|
|
@@ -137,6 +142,19 @@ export const settingsView = {
|
|
|
137
142
|
};
|
|
138
143
|
return;
|
|
139
144
|
}
|
|
145
|
+
if (result.selected === 'picture') {
|
|
146
|
+
const prefs = loadPreferences();
|
|
147
|
+
const options = modeOptions(['ascii', 'fine'], prefs.pictureDetail);
|
|
148
|
+
state = {
|
|
149
|
+
mode: 'picture',
|
|
150
|
+
subField: new ListField({
|
|
151
|
+
title: trans.theme.pictureDetail,
|
|
152
|
+
options,
|
|
153
|
+
initialIndex: Math.max(0, options.findIndex((o) => o.value === prefs.pictureDetail)),
|
|
154
|
+
}),
|
|
155
|
+
};
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
140
158
|
if (result.selected === 'reset') {
|
|
141
159
|
state = {
|
|
142
160
|
mode: 'reset',
|
|
@@ -213,6 +231,14 @@ export const settingsView = {
|
|
|
213
231
|
goToMenu(saved ? trans.theme.colorUpdated : trans.theme.colorUpdatedSessionOnly);
|
|
214
232
|
return;
|
|
215
233
|
}
|
|
234
|
+
case 'picture': {
|
|
235
|
+
const result = state.subField?.handleKey(key);
|
|
236
|
+
if (!result?.selected)
|
|
237
|
+
return;
|
|
238
|
+
const saved = setPictureDetail(result.selected);
|
|
239
|
+
goToMenu(saved ? trans.theme.pictureUpdated : trans.theme.pictureUpdatedSessionOnly);
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
216
242
|
case 'reset': {
|
|
217
243
|
const result = state.subField?.handleKey(key);
|
|
218
244
|
if (!result?.selected)
|