zames_pro 2.4.0 → 2.4.1
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/input.js +11 -1
- package/package.json +1 -1
package/dist/input.js
CHANGED
|
@@ -38,6 +38,14 @@ function safeJson(v) {
|
|
|
38
38
|
return String(v);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
+
// Сколько визуальных строк занимает текст при данной ширине терминала
|
|
42
|
+
// (с учётом переноса). Нужно, чтобы курсор/стирание блока не сбивались,
|
|
43
|
+
// когда статус длиннее ширины терминала и переносится на 2+ строки.
|
|
44
|
+
export function visRows(s, cols) {
|
|
45
|
+
const width = Math.max(1, Number(cols) || 80);
|
|
46
|
+
const len = visLen(s);
|
|
47
|
+
return Math.max(1, Math.ceil(len / width));
|
|
48
|
+
}
|
|
41
49
|
// Видимая длина строки без ANSI-последовательностей.
|
|
42
50
|
export function visLen(s) {
|
|
43
51
|
s = String(s);
|
|
@@ -251,7 +259,9 @@ export class LineEditor {
|
|
|
251
259
|
let top = 0;
|
|
252
260
|
if (this.statusText) {
|
|
253
261
|
out += this.statusText + NL;
|
|
254
|
-
|
|
262
|
+
// Статус может переноситься на несколько строк — учитываем это,
|
|
263
|
+
// иначе стирание блока промахивается и статусы «стопкой» копятся.
|
|
264
|
+
top = visRows(this.statusText, cols);
|
|
255
265
|
}
|
|
256
266
|
const lay = layoutInput(this.promptStr, this.buf, this.cursor, cols);
|
|
257
267
|
out += lay.rows.map((r) => r.prefix + r.text).join(NL);
|