@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.
- package/package.json +3 -3
- 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.
|
|
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.
|
|
56
|
-
"@oh-my-pi/pi-utils": "12.11.
|
|
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
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
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
|
|
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,
|