@nbtca/prompt 1.5.6 → 1.5.7
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 +6 -4
- package/dist/core/theme.js +2 -0
- package/package.json +1 -1
package/dist/app/chrome.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type, space, glyph, brandMark } from '../core/theme.js';
|
|
1
|
+
import { type, space, glyph, brandMark, MAX_FRAME_COLS } 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 } from '../core/text.js';
|
|
@@ -19,7 +19,8 @@ export function resolveChromeLayout(rows) {
|
|
|
19
19
|
return { headerLines: 0, footerLines: 0 };
|
|
20
20
|
}
|
|
21
21
|
function renderRule(cols) {
|
|
22
|
-
const
|
|
22
|
+
const terminal = Number.isFinite(cols) ? Math.max(1, Math.floor(cols)) : 80;
|
|
23
|
+
const width = Math.min(terminal, MAX_FRAME_COLS);
|
|
23
24
|
const indent = visualWidth(space.indent) < width ? space.indent : '';
|
|
24
25
|
const ruleWidth = Math.max(1, width - visualWidth(indent) * 2);
|
|
25
26
|
return indent + type.hint(glyph.rule().repeat(ruleWidth));
|
|
@@ -146,8 +147,9 @@ export function renderFooter(_active, cols, tabCount, overrideHint, lineCount =
|
|
|
146
147
|
function withPosition(hint, hintText, indent, position, cols) {
|
|
147
148
|
if (position === undefined)
|
|
148
149
|
return hint;
|
|
149
|
-
const
|
|
150
|
-
const
|
|
150
|
+
const frame = Math.min(cols, MAX_FRAME_COLS);
|
|
151
|
+
const margin = visualWidth(space.indent) < frame ? space.indent : '';
|
|
152
|
+
const gap = frame - visualWidth(indent + hintText) - visualWidth(position) - visualWidth(margin);
|
|
151
153
|
if (gap < 2)
|
|
152
154
|
return hint;
|
|
153
155
|
return hint + ' '.repeat(gap) + type.hint(position) + margin;
|
package/dist/core/theme.js
CHANGED
|
@@ -42,6 +42,8 @@ export const glyph = {
|
|
|
42
42
|
barFilled: () => pickIcon('█', '#'),
|
|
43
43
|
barEmpty: () => pickIcon('░', '-'),
|
|
44
44
|
};
|
|
45
|
+
/** Beyond this the app stops stretching; a terminal wider than this keeps the slack. */
|
|
46
|
+
export const MAX_FRAME_COLS = 100;
|
|
45
47
|
export const space = {
|
|
46
48
|
indent: ' ',
|
|
47
49
|
};
|