@vincemakes/kiso-tui-cells 0.15.6 → 0.15.7
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/dist/components.js +35 -1
- package/package.json +1 -1
package/dist/components.js
CHANGED
|
@@ -182,6 +182,15 @@ export function cellComponent(cell) {
|
|
|
182
182
|
* colours, so dimmed text would invert into a dimmed block with no
|
|
183
183
|
* contrast.
|
|
184
184
|
*/
|
|
185
|
+
/**
|
|
186
|
+
* REL-0152-D13 — how much of a turn the chip shows.
|
|
187
|
+
*
|
|
188
|
+
* Twelve rows is enough to recognise what you sent and short enough
|
|
189
|
+
* that sending it does not scroll away what you were looking at. The
|
|
190
|
+
* bound is on ROWS, after folding, so one enormous line is caught by
|
|
191
|
+
* the same rule as three thousand short ones.
|
|
192
|
+
*/
|
|
193
|
+
const USER_CHIP_ROWS = 12;
|
|
185
194
|
class UserMessage {
|
|
186
195
|
cell;
|
|
187
196
|
constructor(cell) {
|
|
@@ -191,14 +200,39 @@ class UserMessage {
|
|
|
191
200
|
const p = palette();
|
|
192
201
|
const chipW = Math.max(1, W - 2);
|
|
193
202
|
const rows = [];
|
|
194
|
-
|
|
203
|
+
// REL-0152-D13: fold only as far as the bound needs. A pasted file
|
|
204
|
+
// has thousands of lines and folding all of them to show twelve is
|
|
205
|
+
// work with no reader — the measurement that opened this finding
|
|
206
|
+
// was a 3000-line turn writing 260,298 bytes in one frame.
|
|
207
|
+
const paras = this.cell.text.split("\n");
|
|
208
|
+
let truncated = false;
|
|
209
|
+
for (const para of paras) {
|
|
210
|
+
if (rows.length >= USER_CHIP_ROWS) {
|
|
211
|
+
truncated = true;
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
195
214
|
const folded = foldLine(escapeTerminal(para), chipW);
|
|
196
215
|
const inner = Math.max(...folded.map((r) => displayWidth(r)));
|
|
197
216
|
for (const row of folded) {
|
|
217
|
+
if (rows.length >= USER_CHIP_ROWS) {
|
|
218
|
+
truncated = true;
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
198
221
|
const pad = inner - displayWidth(row);
|
|
199
222
|
rows.push(`${p.rv} ${row}${" ".repeat(pad)} ${p.rvEnd}`);
|
|
200
223
|
}
|
|
201
224
|
}
|
|
225
|
+
if (!truncated)
|
|
226
|
+
return rows;
|
|
227
|
+
// The notice is OUTSIDE the chip's reverse video, in the cut-row
|
|
228
|
+
// vocabulary the rest of the product uses, and it says the thing
|
|
229
|
+
// that matters: the model got all of it. A bounded display of a
|
|
230
|
+
// complete message is not a truncated message, and the row has to
|
|
231
|
+
// make that difference visible or it reads as data loss.
|
|
232
|
+
const shown = rows.length;
|
|
233
|
+
const total = paras.length;
|
|
234
|
+
const more = Math.max(0, total - shown);
|
|
235
|
+
rows.push(`${p.dim}\u2514 ${more > 0 ? `+${more} more line${more === 1 ? "" : "s"}` : "cut here"} \u00b7 sent in full${p.reset}`);
|
|
202
236
|
return rows;
|
|
203
237
|
}
|
|
204
238
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vincemakes/kiso-tui-cells",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.7",
|
|
4
4
|
"description": "kiso tui-cells \u2014 the components cell renderer (components, diff, width, the render slice). Zero runtime dependencies: input is data, output is bytes.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|