@yanzc/claude-pro 0.5.7 → 0.5.8
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/package.json +1 -1
- package/src/api.js +591 -591
- package/src/ui/repl.js +2327 -2327
- package/src/ui/screen.js +21 -5
package/src/ui/screen.js
CHANGED
|
@@ -47,6 +47,12 @@ const MULTI_CLICK_MS = 450;
|
|
|
47
47
|
const FIND_MATCH = '\x1b[30;43m';
|
|
48
48
|
const FIND_CURRENT = '\x1b[30;48;5;208m';
|
|
49
49
|
const FIND_MAX = 10_000;
|
|
50
|
+
// A row that fills the rest of its width with its background (the user's messages, see renderUserMessage) ends in an
|
|
51
|
+
// erase to the end of the line made while that background is on. Nothing may erase after it: an erase does not move
|
|
52
|
+
// the cursor, so a second one, made after the colours are reset, would wipe the band out again from the same column.
|
|
53
|
+
const FILL = '\x1b[K';
|
|
54
|
+
const LEAD = /^(?:\x1b\[[0-9;]*m)+/; // the colours a row starts in
|
|
55
|
+
const endRow = (row) => row + (row.includes(FILL) ? '\x1b[0m' : '\x1b[0m\x1b[K');
|
|
50
56
|
|
|
51
57
|
// The part of `plain` (no escape codes) between columns `from` (included) and `to` (not).
|
|
52
58
|
function sliceCols(plain, from, to) {
|
|
@@ -229,7 +235,14 @@ export class Screen {
|
|
|
229
235
|
|
|
230
236
|
wrappedAt(i, cols) {
|
|
231
237
|
if (this.wrapCols !== cols) { this.wrapped = []; this.wrapCols = cols; this.selection = null; } // its rows are other rows now
|
|
232
|
-
|
|
238
|
+
if (this.wrapped[i]) return this.wrapped[i];
|
|
239
|
+
let rows = wrapLine(this.history[i], Math.max(1, cols - 1));
|
|
240
|
+
// a band now wider than the window: each of its rows starts in its colours and fills the rest of the row
|
|
241
|
+
if (rows.length > 1 && this.history[i].includes(FILL)) {
|
|
242
|
+
const lead = LEAD.exec(this.history[i])?.[0] || '';
|
|
243
|
+
rows = rows.map((r, k) => (k ? lead : '') + r.replaceAll(FILL, '') + lead + FILL);
|
|
244
|
+
}
|
|
245
|
+
return (this.wrapped[i] = rows);
|
|
233
246
|
}
|
|
234
247
|
|
|
235
248
|
// Rows of the whole conversation at this width (for the scrolling to stop at its top).
|
|
@@ -277,15 +290,17 @@ export class Screen {
|
|
|
277
290
|
}
|
|
278
291
|
|
|
279
292
|
// A row of the conversation as drawn: the selection in reverse video, the matches of a search highlighted (the
|
|
280
|
-
// current one apart). Such a row loses its own colours.
|
|
293
|
+
// current one apart). Such a row loses its own colours, except the band of a row that fills its width.
|
|
281
294
|
paintRow(e) {
|
|
282
295
|
const sel = this.selectedCols(e);
|
|
283
296
|
const hits = this.finding?.byRow.get(`${e.line}:${e.sub}`);
|
|
284
297
|
if (!sel && !hits) return e.text;
|
|
298
|
+
const fill = e.text.includes(FILL);
|
|
299
|
+
const base = fill ? LEAD.exec(e.text)?.[0] || '' : '';
|
|
285
300
|
const style = (col) => {
|
|
286
301
|
if (sel && col >= sel[0] && col < sel[1]) return '\x1b[7m';
|
|
287
302
|
const hit = hits?.find((h) => col >= h.from && col < h.to);
|
|
288
|
-
return !hit ?
|
|
303
|
+
return !hit ? base : hit.match === this.finding.matches[this.finding.index] ? FIND_CURRENT : FIND_MATCH;
|
|
289
304
|
};
|
|
290
305
|
let out = '';
|
|
291
306
|
let open = '';
|
|
@@ -296,6 +311,7 @@ export class Screen {
|
|
|
296
311
|
out += g;
|
|
297
312
|
col += graphemeWidth(g);
|
|
298
313
|
}
|
|
314
|
+
if (fill) return out + '\x1b[0m' + base + FILL;
|
|
299
315
|
return out + (open ? '\x1b[0m' : '');
|
|
300
316
|
}
|
|
301
317
|
|
|
@@ -575,7 +591,7 @@ export class Screen {
|
|
|
575
591
|
let buf = SYNC_START + ESC.hideCursor + this.titleUpdate();
|
|
576
592
|
if (full) { buf += '\x1b[2J'; this.frame = []; }
|
|
577
593
|
frame.forEach((row, i) => {
|
|
578
|
-
if (this.frame[i] !== row) buf += `\x1b[${i + 1};1H` + row
|
|
594
|
+
if (this.frame[i] !== row) buf += `\x1b[${i + 1};1H` + endRow(row);
|
|
579
595
|
});
|
|
580
596
|
if (frame.length < this.frame.length) buf += `\x1b[${frame.length + 1};1H` + ESC.clearDown;
|
|
581
597
|
this.frame = frame;
|
|
@@ -745,7 +761,7 @@ export class Screen {
|
|
|
745
761
|
}
|
|
746
762
|
const all = [...tail, ...layout.rows];
|
|
747
763
|
let buf = SYNC_START + ESC.hideCursor + this.titleUpdate() + '\x1b[H';
|
|
748
|
-
buf += all.map(
|
|
764
|
+
buf += all.map(endRow).join('\r\n');
|
|
749
765
|
buf += ESC.clearDown;
|
|
750
766
|
buf += this.settleCursor(layout);
|
|
751
767
|
buf += SYNC_END;
|