hedgequantx 2.9.245 → 2.9.246
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 +34 -5
package/package.json
CHANGED
package/src/pages/algo/ui.js
CHANGED
|
@@ -77,17 +77,46 @@ const center = (text, width) => {
|
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
79
|
* Fit text to exact width (truncate or pad)
|
|
80
|
+
* Ensures output is EXACTLY width characters (visible)
|
|
80
81
|
*/
|
|
81
82
|
const fitToWidth = (text, width) => {
|
|
82
83
|
const plain = stripAnsi(text);
|
|
84
|
+
|
|
83
85
|
if (plain.length > width) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
// Need to truncate - find cut point accounting for ANSI codes
|
|
87
|
+
let visibleCount = 0;
|
|
88
|
+
let cutIndex = 0;
|
|
89
|
+
let inAnsi = false;
|
|
90
|
+
|
|
91
|
+
for (let i = 0; i < text.length; i++) {
|
|
92
|
+
if (text[i] === '\x1B') {
|
|
93
|
+
inAnsi = true;
|
|
94
|
+
} else if (inAnsi && text[i] === 'm') {
|
|
95
|
+
inAnsi = false;
|
|
96
|
+
} else if (!inAnsi) {
|
|
97
|
+
visibleCount++;
|
|
98
|
+
if (visibleCount >= width - 2) {
|
|
99
|
+
cutIndex = i + 1;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
cutIndex = i + 1;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Truncate and add ".." (2 chars to stay within width)
|
|
107
|
+
const truncated = text.substring(0, cutIndex);
|
|
108
|
+
const truncatedPlain = stripAnsi(truncated);
|
|
109
|
+
const remaining = width - truncatedPlain.length;
|
|
110
|
+
|
|
111
|
+
if (remaining >= 2) {
|
|
112
|
+
return truncated + '..' + ' '.repeat(remaining - 2);
|
|
113
|
+
} else if (remaining > 0) {
|
|
114
|
+
return truncated + ' '.repeat(remaining);
|
|
88
115
|
}
|
|
89
|
-
return
|
|
116
|
+
return truncated;
|
|
90
117
|
}
|
|
118
|
+
|
|
119
|
+
// Pad to exact width
|
|
91
120
|
return text + ' '.repeat(width - plain.length);
|
|
92
121
|
};
|
|
93
122
|
|