@oh-my-pi/pi-tui 3.9.1337 → 3.13.1337

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oh-my-pi/pi-tui",
3
- "version": "3.9.1337",
3
+ "version": "3.13.1337",
4
4
  "description": "Terminal User Interface library with differential rendering for efficient text-based applications",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -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 4 for borders (2 left + 2 right)
191
- const contentAreaWidth = width - 4;
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 - 4 (for prefix and suffix borders)
218
- const lineContentWidth = width - 4;
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 lineVisibleWidth = visibleWidth(layoutLine.text);
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
- // lineVisibleWidth stays the same - we're replacing, not adding
236
+ // displayWidth stays the same - we're replacing, not adding
237
237
  } else {
238
- // Cursor is at the end - check if we have room for the cursor
239
- if (lineVisibleWidth < lineContentWidth) {
240
- // We have room - add thin bar cursor (▏) with blink
241
- // \x1b[5m = slow blink, no reverse video so it's a thin line
242
- const cursor = "\x1b[5m▏\x1b[0m";
243
- displayText = before + cursor;
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 get 1 char padding on each side for consistent alignment
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 - lineVisibleWidth - 2));
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("│ ");