@oh-my-pi/pi-tui 3.9.1337 → 3.14.0
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/components/editor.ts +16 -18
package/package.json
CHANGED
package/src/components/editor.ts
CHANGED
|
@@ -187,8 +187,8 @@ export class Editor implements Component {
|
|
|
187
187
|
const bottomRight = this.borderColor("─╯");
|
|
188
188
|
const horizontal = this.borderColor("─");
|
|
189
189
|
|
|
190
|
-
// Layout the text - content area is width minus
|
|
191
|
-
const contentAreaWidth = width -
|
|
190
|
+
// Layout the text - content area is width minus 6 for borders (3 left + 3 right)
|
|
191
|
+
const contentAreaWidth = width - 6;
|
|
192
192
|
const layoutLines = this.layoutText(contentAreaWidth);
|
|
193
193
|
|
|
194
194
|
const result: string[] = [];
|
|
@@ -214,11 +214,11 @@ export class Editor implements Component {
|
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
// Render each layout line
|
|
217
|
-
// Content area is width -
|
|
218
|
-
const lineContentWidth = width -
|
|
217
|
+
// Content area is width - 6 (for "│ " prefix and " │" suffix borders)
|
|
218
|
+
const lineContentWidth = width - 6;
|
|
219
219
|
for (const layoutLine of layoutLines) {
|
|
220
220
|
let displayText = layoutLine.text;
|
|
221
|
-
let
|
|
221
|
+
let displayWidth = visibleWidth(layoutLine.text);
|
|
222
222
|
|
|
223
223
|
// Add cursor if this line has it
|
|
224
224
|
if (layoutLine.hasCursor && layoutLine.cursorPos !== undefined) {
|
|
@@ -233,17 +233,14 @@ export class Editor implements Component {
|
|
|
233
233
|
const restAfter = after.slice(firstGrapheme.length);
|
|
234
234
|
const cursor = `\x1b[7m${firstGrapheme}\x1b[0m`;
|
|
235
235
|
displayText = before + cursor + restAfter;
|
|
236
|
-
//
|
|
236
|
+
// displayWidth stays the same - we're replacing, not adding
|
|
237
237
|
} else {
|
|
238
|
-
// Cursor is at the end -
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
// lineVisibleWidth increases by 1 - we're adding a space
|
|
245
|
-
lineVisibleWidth = lineVisibleWidth + 1;
|
|
246
|
-
} else {
|
|
238
|
+
// Cursor is at the end - add thin blinking bar cursor
|
|
239
|
+
// The ▏ character has width 1
|
|
240
|
+
const cursor = "\x1b[5m▏\x1b[0m";
|
|
241
|
+
displayText = before + cursor;
|
|
242
|
+
displayWidth += 1; // Account for cursor width
|
|
243
|
+
if (displayWidth > lineContentWidth) {
|
|
247
244
|
// Line is at full width - use reverse video on last grapheme if possible
|
|
248
245
|
// or just show cursor at the end without adding space
|
|
249
246
|
const beforeGraphemes = [...segmenter.segment(before)];
|
|
@@ -256,17 +253,18 @@ export class Editor implements Component {
|
|
|
256
253
|
.map((g) => g.segment)
|
|
257
254
|
.join("");
|
|
258
255
|
displayText = beforeWithoutLast + cursor;
|
|
256
|
+
displayWidth -= 1; // Back to original width (reverse video replaces, doesn't add)
|
|
259
257
|
}
|
|
260
|
-
// lineVisibleWidth stays the same
|
|
261
258
|
}
|
|
262
259
|
}
|
|
263
260
|
}
|
|
264
261
|
|
|
265
|
-
// All lines
|
|
262
|
+
// All lines have consistent 6-char borders (3 left + 3 right)
|
|
266
263
|
const isLastLine = layoutLine === layoutLines[layoutLines.length - 1];
|
|
267
|
-
const padding = " ".repeat(Math.max(0, lineContentWidth -
|
|
264
|
+
const padding = " ".repeat(Math.max(0, lineContentWidth - displayWidth));
|
|
268
265
|
|
|
269
266
|
if (isLastLine) {
|
|
267
|
+
// Last line: "╰─ " (3) + content + padding + " ─╯" (3) = 6 chars border
|
|
270
268
|
result.push(`${bottomLeft} ${displayText}${padding} ${bottomRight}`);
|
|
271
269
|
} else {
|
|
272
270
|
const leftBorder = this.borderColor("│ ");
|