hedgequantx 2.9.246 → 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 +23 -33
package/package.json
CHANGED
package/src/pages/algo/ui.js
CHANGED
|
@@ -77,47 +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 characters
|
|
80
|
+
* Ensures output is EXACTLY width visible characters
|
|
81
81
|
*/
|
|
82
82
|
const fitToWidth = (text, width) => {
|
|
83
83
|
const plain = stripAnsi(text);
|
|
84
84
|
|
|
85
|
-
if (plain.length
|
|
86
|
-
//
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
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++;
|
|
102
101
|
}
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
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);
|
|
102
|
+
i++; // skip 'm'
|
|
103
|
+
} else {
|
|
104
|
+
visibleCount++;
|
|
105
|
+
i++;
|
|
115
106
|
}
|
|
116
|
-
|
|
107
|
+
cutIndex = i;
|
|
117
108
|
}
|
|
118
109
|
|
|
119
|
-
|
|
120
|
-
return text + ' '.repeat(width - plain.length);
|
|
110
|
+
return text.substring(0, cutIndex) + '..';
|
|
121
111
|
};
|
|
122
112
|
|
|
123
113
|
/**
|