@oh-my-pi/pi-tui 12.11.0 → 12.11.2

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/tui.ts +27 -31
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oh-my-pi/pi-tui",
3
- "version": "12.11.0",
3
+ "version": "12.11.2",
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",
@@ -52,8 +52,8 @@
52
52
  "bun": ">=1.3.7"
53
53
  },
54
54
  "dependencies": {
55
- "@oh-my-pi/pi-natives": "12.11.0",
56
- "@oh-my-pi/pi-utils": "12.11.0",
55
+ "@oh-my-pi/pi-natives": "12.11.2",
56
+ "@oh-my-pi/pi-utils": "12.11.2",
57
57
  "@types/mime-types": "^3.0.1",
58
58
  "chalk": "^5.6.2",
59
59
  "marked": "^17.0.2",
package/src/tui.ts CHANGED
@@ -968,37 +968,33 @@ export class TUI extends Container {
968
968
  // All changes are in deleted lines (nothing to render, just clear)
969
969
  if (firstChanged >= newLines.length) {
970
970
  const targetRow = Math.max(0, newLines.length - 1);
971
- if (this.#previousLines.length > newLines.length) {
972
- let buffer = "\x1b[?2026h";
973
- const lineDiff = computeLineDiff(targetRow);
974
- if (lineDiff > 0) buffer += `\x1b[${lineDiff}B`;
975
- else if (lineDiff < 0) buffer += `\x1b[${-lineDiff}A`;
976
- buffer += "\r";
977
- // Clear extra lines without scrolling
978
- const extraLines = this.#previousLines.length - newLines.length;
979
- if (extraLines > height) {
980
- logRedraw(`extraLines > height (${extraLines} > ${height})`);
981
- fullRender(true);
982
- return;
983
- }
984
- if (extraLines > 0) {
985
- buffer += "\x1b[1B";
986
- }
987
- for (let i = 0; i < extraLines; i++) {
988
- buffer += "\r\x1b[2K";
989
- if (i < extraLines - 1) buffer += "\x1b[1B";
990
- }
991
- if (extraLines > 0) {
992
- buffer += `\x1b[${extraLines}A`;
993
- }
994
- const cursorUpdate = this.#buildHardwareCursorSequence(cursorPos, newLines.length, targetRow);
995
- buffer += cursorUpdate.sequence;
996
- buffer += "\x1b[?2026l";
997
- this.terminal.write(buffer);
998
- this.#hardwareCursorRow = cursorUpdate.row;
999
- } else {
1000
- this.#positionHardwareCursor(cursorPos, newLines.length);
971
+ let buffer = "\x1b[?2026h";
972
+ const lineDiff = computeLineDiff(targetRow);
973
+ if (lineDiff > 0) buffer += `\x1b[${lineDiff}B`;
974
+ else if (lineDiff < 0) buffer += `\x1b[${-lineDiff}A`;
975
+ buffer += "\r";
976
+ // Clear extra lines without scrolling
977
+ const extraLines = this.#previousLines.length - newLines.length;
978
+ if (extraLines > height) {
979
+ logRedraw(`extraLines > height (${extraLines} > ${height})`);
980
+ fullRender(true);
981
+ return;
982
+ }
983
+ if (extraLines > 0) {
984
+ buffer += "\x1b[1B";
985
+ }
986
+ for (let i = 0; i < extraLines; i++) {
987
+ buffer += "\r\x1b[2K";
988
+ if (i < extraLines - 1) buffer += "\x1b[1B";
989
+ }
990
+ if (extraLines > 0) {
991
+ buffer += `\x1b[${extraLines}A`;
1001
992
  }
993
+ const cursorUpdate = this.#buildHardwareCursorSequence(cursorPos, newLines.length, targetRow);
994
+ buffer += cursorUpdate.sequence;
995
+ buffer += "\x1b[?2026l";
996
+ this.terminal.write(buffer);
997
+ this.#hardwareCursorRow = cursorUpdate.row;
1002
998
  this.#cursorRow = targetRow;
1003
999
  this.#previousLines = newLines;
1004
1000
  this.#previousWidth = width;
@@ -1148,7 +1144,7 @@ export class TUI extends Container {
1148
1144
 
1149
1145
  /**
1150
1146
  * Build cursor movement and visibility escape sequence and return resulting row.
1151
- * Used by differential rendering so cursor placement stays inside synchronized output.
1147
+ * Used by differential and direct cursor updates to keep movement logic consistent.
1152
1148
  */
1153
1149
  #buildHardwareCursorSequence(
1154
1150
  cursorPos: { row: number; col: number } | null,