hedgequantx 2.9.245 → 2.9.247
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/pages/algo/ui.js +26 -7
package/package.json
CHANGED
package/src/pages/algo/ui.js
CHANGED
|
@@ -77,18 +77,37 @@ const center = (text, width) => {
|
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
79
|
* Fit text to exact width (truncate or pad)
|
|
80
|
+
* Ensures output is EXACTLY width visible characters
|
|
80
81
|
*/
|
|
81
82
|
const fitToWidth = (text, width) => {
|
|
82
83
|
const plain = stripAnsi(text);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
|
|
85
|
+
if (plain.length <= width) {
|
|
86
|
+
// Pad to exact width
|
|
87
|
+
return text + ' '.repeat(width - plain.length);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Need to truncate to (width - 2) visible chars, then add ".."
|
|
91
|
+
const targetLen = width - 2;
|
|
92
|
+
let visibleCount = 0;
|
|
93
|
+
let cutIndex = 0;
|
|
94
|
+
let i = 0;
|
|
95
|
+
|
|
96
|
+
while (i < text.length && visibleCount < targetLen) {
|
|
97
|
+
if (text[i] === '\x1B') {
|
|
98
|
+
// Skip entire ANSI sequence
|
|
99
|
+
while (i < text.length && text[i] !== 'm') {
|
|
100
|
+
i++;
|
|
101
|
+
}
|
|
102
|
+
i++; // skip 'm'
|
|
103
|
+
} else {
|
|
104
|
+
visibleCount++;
|
|
105
|
+
i++;
|
|
88
106
|
}
|
|
89
|
-
|
|
107
|
+
cutIndex = i;
|
|
90
108
|
}
|
|
91
|
-
|
|
109
|
+
|
|
110
|
+
return text.substring(0, cutIndex) + '..';
|
|
92
111
|
};
|
|
93
112
|
|
|
94
113
|
/**
|