@tooee/renderers 0.2.4 → 0.3.1
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/code-blocks.d.ts +6 -6
- package/dist/code-blocks.d.ts.map +1 -1
- package/dist/code-blocks.js +52 -42
- package/dist/code-blocks.js.map +1 -1
- package/dist/{CodeView.d.ts → code-view.d.ts} +3 -3
- package/dist/code-view.d.ts.map +1 -0
- package/dist/{CodeView.js → code-view.js} +5 -5
- package/dist/code-view.js.map +1 -0
- package/dist/{CommandPalette.d.ts → command-palette.d.ts} +2 -2
- package/dist/command-palette.d.ts.map +1 -0
- package/dist/{CommandPalette.js → command-palette.js} +27 -24
- package/dist/command-palette.js.map +1 -0
- package/dist/{ContextMenu.d.ts → context-menu.d.ts} +2 -2
- package/dist/context-menu.d.ts.map +1 -0
- package/dist/{ContextMenu.js → context-menu.js} +24 -14
- package/dist/context-menu.js.map +1 -0
- package/dist/{DecorationLayer.d.ts → decoration-layer.d.ts} +2 -2
- package/dist/decoration-layer.d.ts.map +1 -0
- package/dist/decoration-layer.js +2 -0
- package/dist/decoration-layer.js.map +1 -0
- package/dist/{DocumentBindings.d.ts → document-bindings.d.ts} +4 -4
- package/dist/document-bindings.d.ts.map +1 -0
- package/dist/document-bindings.js +2 -0
- package/dist/document-bindings.js.map +1 -0
- package/dist/index.d.ts +16 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/dist/markdown-blocks.d.ts +9 -13
- package/dist/markdown-blocks.d.ts.map +1 -1
- package/dist/markdown-blocks.js +98 -79
- package/dist/markdown-blocks.js.map +1 -1
- package/dist/{MarkdownView.d.ts → markdown-view.d.ts} +13 -13
- package/dist/markdown-view.d.ts.map +1 -0
- package/dist/markdown-view.js +455 -0
- package/dist/markdown-view.js.map +1 -0
- package/dist/mermaid.d.ts +6 -6
- package/dist/mermaid.d.ts.map +1 -1
- package/dist/mermaid.js +56 -26
- package/dist/mermaid.js.map +1 -1
- package/dist/parsers.d.ts +5 -5
- package/dist/parsers.d.ts.map +1 -1
- package/dist/parsers.js +64 -44
- package/dist/parsers.js.map +1 -1
- package/dist/{RowDocumentRenderable.d.ts → row-document-renderable.d.ts} +15 -11
- package/dist/row-document-renderable.d.ts.map +1 -0
- package/dist/{RowDocumentRenderable.js → row-document-renderable.js} +110 -62
- package/dist/row-document-renderable.js.map +1 -0
- package/dist/row-document.d.ts +1 -1
- package/dist/row-document.d.ts.map +1 -1
- package/dist/row-document.js +1 -1
- package/dist/row-document.js.map +1 -1
- package/dist/source.d.ts +6 -6
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +35 -26
- package/dist/source.js.map +1 -1
- package/dist/table-types.d.ts.map +1 -1
- package/dist/{Table.d.ts → table.d.ts} +6 -6
- package/dist/table.d.ts.map +1 -0
- package/dist/{Table.js → table.js} +65 -35
- package/dist/table.js.map +1 -0
- package/dist/text-table.d.ts.map +1 -1
- package/dist/text-table.js.map +1 -1
- package/dist/use-gutter-palette.d.ts +3 -0
- package/dist/use-gutter-palette.d.ts.map +1 -0
- package/dist/{useGutterPalette.js → use-gutter-palette.js} +4 -4
- package/dist/use-gutter-palette.js.map +1 -0
- package/package.json +5 -5
- package/src/code-blocks.tsx +122 -106
- package/src/{CodeView.tsx → code-view.tsx} +19 -14
- package/src/command-palette.tsx +163 -0
- package/src/context-menu.tsx +157 -0
- package/src/decoration-layer.ts +11 -0
- package/src/document-bindings.ts +16 -0
- package/src/index.ts +24 -23
- package/src/markdown-blocks.ts +178 -138
- package/src/markdown-view.tsx +853 -0
- package/src/mermaid.ts +122 -70
- package/src/parsers.ts +141 -103
- package/src/row-document-renderable.ts +672 -0
- package/src/row-document.ts +4 -4
- package/src/source.ts +92 -72
- package/src/table-types.ts +4 -4
- package/src/table.tsx +346 -0
- package/src/text-table.ts +4 -4
- package/src/use-gutter-palette.ts +15 -0
- package/dist/CodeView.d.ts.map +0 -1
- package/dist/CodeView.js.map +0 -1
- package/dist/CommandPalette.d.ts.map +0 -1
- package/dist/CommandPalette.js.map +0 -1
- package/dist/ContextMenu.d.ts.map +0 -1
- package/dist/ContextMenu.js.map +0 -1
- package/dist/DecorationLayer.d.ts.map +0 -1
- package/dist/DecorationLayer.js +0 -2
- package/dist/DecorationLayer.js.map +0 -1
- package/dist/DocumentBindings.d.ts.map +0 -1
- package/dist/DocumentBindings.js +0 -2
- package/dist/DocumentBindings.js.map +0 -1
- package/dist/MarkdownView.d.ts.map +0 -1
- package/dist/MarkdownView.js +0 -360
- package/dist/MarkdownView.js.map +0 -1
- package/dist/RowDocumentRenderable.d.ts.map +0 -1
- package/dist/RowDocumentRenderable.js.map +0 -1
- package/dist/Table.d.ts.map +0 -1
- package/dist/Table.js.map +0 -1
- package/dist/useGutterPalette.d.ts +0 -3
- package/dist/useGutterPalette.d.ts.map +0 -1
- package/dist/useGutterPalette.js.map +0 -1
- package/src/CommandPalette.tsx +0 -147
- package/src/ContextMenu.tsx +0 -132
- package/src/DecorationLayer.ts +0 -11
- package/src/DocumentBindings.ts +0 -16
- package/src/MarkdownView.tsx +0 -738
- package/src/RowDocumentRenderable.ts +0 -593
- package/src/Table.tsx +0 -300
- package/src/useGutterPalette.ts +0 -15
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ScrollBoxRenderable, RGBA
|
|
1
|
+
import { ScrollBoxRenderable, RGBA } from "@opentui/core";
|
|
2
2
|
// ---------------------------------------------------------------------------
|
|
3
3
|
// Types
|
|
4
4
|
// ---------------------------------------------------------------------------
|
|
@@ -6,33 +6,39 @@ export const DEFAULT_SIGN_COLUMN_WIDTH = 3;
|
|
|
6
6
|
// ---------------------------------------------------------------------------
|
|
7
7
|
// Provider detection
|
|
8
8
|
// ---------------------------------------------------------------------------
|
|
9
|
-
function isRowContentProvider(x) {
|
|
10
|
-
return (
|
|
11
|
-
|
|
9
|
+
const isRowContentProvider = function isRowContentProvider(x) {
|
|
10
|
+
return (x !== null &&
|
|
11
|
+
x !== undefined &&
|
|
12
|
+
typeof x === "object" &&
|
|
13
|
+
"lineInfo" in x &&
|
|
14
|
+
"lineCount" in x &&
|
|
15
|
+
"virtualLineCount" in x);
|
|
16
|
+
};
|
|
12
17
|
// ---------------------------------------------------------------------------
|
|
13
18
|
// Color cache — avoids re-parsing hex strings every frame
|
|
14
19
|
// ---------------------------------------------------------------------------
|
|
15
20
|
const colorCache = new Map();
|
|
16
|
-
function cachedColor(hex) {
|
|
21
|
+
const cachedColor = function cachedColor(hex) {
|
|
17
22
|
let c = colorCache.get(hex);
|
|
18
23
|
if (!c) {
|
|
19
24
|
c = RGBA.fromHex(hex);
|
|
20
25
|
colorCache.set(hex, c);
|
|
21
26
|
}
|
|
22
27
|
return c;
|
|
23
|
-
}
|
|
24
|
-
function normalizePalette(palette = {}) {
|
|
28
|
+
};
|
|
29
|
+
const normalizePalette = function normalizePalette(palette = {}) {
|
|
25
30
|
return {
|
|
26
|
-
gutterFg: palette.gutterFg ?? "#6e7681",
|
|
27
31
|
gutterBg: palette.gutterBg ?? "#0d1117",
|
|
32
|
+
gutterFg: palette.gutterFg ?? "#6e7681",
|
|
28
33
|
};
|
|
29
|
-
}
|
|
30
|
-
function normalizeDecorationLayers(layers) {
|
|
31
|
-
if (!layers || layers.length === 0)
|
|
34
|
+
};
|
|
35
|
+
const normalizeDecorationLayers = function normalizeDecorationLayers(layers) {
|
|
36
|
+
if (!layers || layers.length === 0) {
|
|
32
37
|
return [];
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
}
|
|
39
|
+
return [...layers].toSorted((a, b) => a.priority - b.priority);
|
|
40
|
+
};
|
|
41
|
+
export const computeRowDocumentGutterWidth = function computeRowDocumentGutterWidth(opts) {
|
|
36
42
|
let width = 0;
|
|
37
43
|
if (opts.showLineNumbers) {
|
|
38
44
|
const maxLineNum = (opts.lineNumberStart ?? 1) + opts.rowCount - 1;
|
|
@@ -41,7 +47,7 @@ export function computeRowDocumentGutterWidth(opts) {
|
|
|
41
47
|
width += opts.signColumnWidth ?? 0;
|
|
42
48
|
width += opts.gutterPaddingRight ?? 1;
|
|
43
49
|
return width;
|
|
44
|
-
}
|
|
50
|
+
};
|
|
45
51
|
// ---------------------------------------------------------------------------
|
|
46
52
|
// RowDocumentRenderable
|
|
47
53
|
// ---------------------------------------------------------------------------
|
|
@@ -82,10 +88,16 @@ export class RowDocumentRenderable extends ScrollBoxRenderable {
|
|
|
82
88
|
// -----------------------------------------------------------------------
|
|
83
89
|
// Decorations
|
|
84
90
|
// -----------------------------------------------------------------------
|
|
91
|
+
get decorations() {
|
|
92
|
+
return this._layers;
|
|
93
|
+
}
|
|
85
94
|
set decorations(layers) {
|
|
86
95
|
this._layers = normalizeDecorationLayers(layers);
|
|
87
96
|
this.requestRender();
|
|
88
97
|
}
|
|
98
|
+
get palette() {
|
|
99
|
+
return this._palette;
|
|
100
|
+
}
|
|
89
101
|
set palette(palette) {
|
|
90
102
|
this._palette = normalizePalette(palette);
|
|
91
103
|
this.requestRender();
|
|
@@ -93,6 +105,9 @@ export class RowDocumentRenderable extends ScrollBoxRenderable {
|
|
|
93
105
|
// -----------------------------------------------------------------------
|
|
94
106
|
// Gutter config setters
|
|
95
107
|
// -----------------------------------------------------------------------
|
|
108
|
+
get showGutter() {
|
|
109
|
+
return this._showGutter;
|
|
110
|
+
}
|
|
96
111
|
set showGutter(value) {
|
|
97
112
|
if (this._showGutter !== value) {
|
|
98
113
|
this._showGutter = value;
|
|
@@ -100,6 +115,9 @@ export class RowDocumentRenderable extends ScrollBoxRenderable {
|
|
|
100
115
|
this.requestRender();
|
|
101
116
|
}
|
|
102
117
|
}
|
|
118
|
+
get showLineNumbers() {
|
|
119
|
+
return this._showLineNumbers;
|
|
120
|
+
}
|
|
103
121
|
set showLineNumbers(value) {
|
|
104
122
|
if (this._showLineNumbers !== value) {
|
|
105
123
|
this._showLineNumbers = value;
|
|
@@ -117,24 +135,27 @@ export class RowDocumentRenderable extends ScrollBoxRenderable {
|
|
|
117
135
|
return this._virtualRowToRow.length;
|
|
118
136
|
}
|
|
119
137
|
getRowMetrics(row) {
|
|
120
|
-
if (row < 0 || row >= this._rowCount)
|
|
138
|
+
if (row < 0 || row >= this._rowCount) {
|
|
121
139
|
return null;
|
|
140
|
+
}
|
|
122
141
|
return {
|
|
123
142
|
row,
|
|
124
|
-
virtualTop: this._rowVirtualStarts[row],
|
|
125
143
|
virtualHeight: this._rowVirtualHeights[row],
|
|
144
|
+
virtualTop: this._rowVirtualStarts[row],
|
|
126
145
|
};
|
|
127
146
|
}
|
|
128
147
|
getRowAtVirtualY(y) {
|
|
129
148
|
const clamped = Math.max(0, Math.min(y, this._virtualRowToRow.length - 1));
|
|
130
149
|
const row = this._virtualRowToRow[clamped];
|
|
131
|
-
if (row
|
|
150
|
+
if (row >= 0) {
|
|
132
151
|
return row;
|
|
152
|
+
}
|
|
133
153
|
// Gap row — search backward for nearest valid row
|
|
134
|
-
for (let i = clamped - 1; i >= 0; i
|
|
154
|
+
for (let i = clamped - 1; i >= 0; i -= 1) {
|
|
135
155
|
const r = this._virtualRowToRow[i];
|
|
136
|
-
if (r
|
|
156
|
+
if (r >= 0) {
|
|
137
157
|
return r;
|
|
158
|
+
}
|
|
138
159
|
}
|
|
139
160
|
return 0;
|
|
140
161
|
}
|
|
@@ -152,23 +173,26 @@ export class RowDocumentRenderable extends ScrollBoxRenderable {
|
|
|
152
173
|
*/
|
|
153
174
|
getRowAtScreenY(screenY) {
|
|
154
175
|
const localY = screenY - this.viewport.y;
|
|
155
|
-
if (localY < 0 || localY >= this.viewport.height)
|
|
176
|
+
if (localY < 0 || localY >= this.viewport.height) {
|
|
156
177
|
return null;
|
|
178
|
+
}
|
|
157
179
|
const virtualY = Math.floor(this.scrollTop) + localY;
|
|
158
|
-
if (virtualY < 0 || virtualY >= this._virtualRowToRow.length)
|
|
180
|
+
if (virtualY < 0 || virtualY >= this._virtualRowToRow.length) {
|
|
159
181
|
return null;
|
|
160
|
-
|
|
182
|
+
}
|
|
183
|
+
if (virtualY >= this._contentVirtualEnd) {
|
|
161
184
|
return null;
|
|
185
|
+
}
|
|
162
186
|
return this.getRowAtVirtualY(virtualY);
|
|
163
187
|
}
|
|
164
188
|
getVisibleRange() {
|
|
165
189
|
const top = Math.floor(this.scrollTop);
|
|
166
190
|
const bottom = top + this.viewport.height;
|
|
167
191
|
return {
|
|
168
|
-
virtualTop: top,
|
|
169
|
-
virtualBottom: bottom,
|
|
170
192
|
firstRow: this.getRowAtVirtualY(top),
|
|
171
193
|
lastRow: this.getRowAtVirtualY(bottom - 1),
|
|
194
|
+
virtualBottom: bottom,
|
|
195
|
+
virtualTop: top,
|
|
172
196
|
};
|
|
173
197
|
}
|
|
174
198
|
// -----------------------------------------------------------------------
|
|
@@ -176,21 +200,25 @@ export class RowDocumentRenderable extends ScrollBoxRenderable {
|
|
|
176
200
|
// -----------------------------------------------------------------------
|
|
177
201
|
scrollToRow(row, align = "nearest") {
|
|
178
202
|
const metrics = this.getRowMetrics(row);
|
|
179
|
-
if (!metrics)
|
|
203
|
+
if (!metrics) {
|
|
180
204
|
return;
|
|
205
|
+
}
|
|
181
206
|
const vpHeight = this.viewport.height;
|
|
182
207
|
const { virtualTop, virtualHeight } = metrics;
|
|
183
208
|
let target = this.scrollTop;
|
|
184
209
|
switch (align) {
|
|
185
|
-
case "start":
|
|
210
|
+
case "start": {
|
|
186
211
|
target = virtualTop;
|
|
187
212
|
break;
|
|
188
|
-
|
|
213
|
+
}
|
|
214
|
+
case "center": {
|
|
189
215
|
target = virtualTop - (vpHeight - virtualHeight) / 2;
|
|
190
216
|
break;
|
|
191
|
-
|
|
217
|
+
}
|
|
218
|
+
case "end": {
|
|
192
219
|
target = virtualTop + virtualHeight - vpHeight;
|
|
193
220
|
break;
|
|
221
|
+
}
|
|
194
222
|
case "nearest": {
|
|
195
223
|
if (virtualTop < this.scrollTop) {
|
|
196
224
|
target = virtualTop;
|
|
@@ -200,6 +228,9 @@ export class RowDocumentRenderable extends ScrollBoxRenderable {
|
|
|
200
228
|
}
|
|
201
229
|
break;
|
|
202
230
|
}
|
|
231
|
+
default: {
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
203
234
|
}
|
|
204
235
|
// When scrolling to the first row, include header content (pre-offset children)
|
|
205
236
|
if (row === 0 && this._rowChildOffset > 0) {
|
|
@@ -238,10 +269,12 @@ export class RowDocumentRenderable extends ScrollBoxRenderable {
|
|
|
238
269
|
// Geometry computation
|
|
239
270
|
// -----------------------------------------------------------------------
|
|
240
271
|
_detectMode() {
|
|
241
|
-
if (this._mode === "multi")
|
|
272
|
+
if (this._mode === "multi") {
|
|
242
273
|
return "multi";
|
|
243
|
-
|
|
274
|
+
}
|
|
275
|
+
if (this._mode === "provider") {
|
|
244
276
|
return "provider";
|
|
277
|
+
}
|
|
245
278
|
// Auto-detect: single child with LineInfoProvider → provider mode
|
|
246
279
|
const children = this.getChildren();
|
|
247
280
|
if (children.length === 1 && isRowContentProvider(children[0])) {
|
|
@@ -272,14 +305,14 @@ export class RowDocumentRenderable extends ScrollBoxRenderable {
|
|
|
272
305
|
const rowVirtualHeights = [];
|
|
273
306
|
const virtualRowToRow = Array.from({ length: totalHeight }, () => -1);
|
|
274
307
|
const virtualRowWraps = Array.from({ length: totalHeight }, () => 0);
|
|
275
|
-
for (let i = offset; i < children.length; i
|
|
308
|
+
for (let i = offset; i < children.length; i += 1) {
|
|
276
309
|
const row = i - offset;
|
|
277
310
|
const child = children[i];
|
|
278
311
|
const childStart = child.y - contentY;
|
|
279
312
|
const h = Math.max(1, child.height);
|
|
280
313
|
rowVirtualStarts[row] = childStart;
|
|
281
314
|
rowVirtualHeights[row] = h;
|
|
282
|
-
for (let r = 0; r < h; r
|
|
315
|
+
for (let r = 0; r < h; r += 1) {
|
|
283
316
|
const vRow = childStart + r;
|
|
284
317
|
if (vRow >= 0 && vRow < totalHeight) {
|
|
285
318
|
virtualRowToRow[vRow] = row;
|
|
@@ -291,11 +324,13 @@ export class RowDocumentRenderable extends ScrollBoxRenderable {
|
|
|
291
324
|
}
|
|
292
325
|
_computeFromProvider() {
|
|
293
326
|
const children = this.getChildren();
|
|
294
|
-
if (children.length === 0)
|
|
327
|
+
if (children.length === 0) {
|
|
295
328
|
return;
|
|
296
|
-
|
|
297
|
-
|
|
329
|
+
}
|
|
330
|
+
const [provider] = children;
|
|
331
|
+
if (!isRowContentProvider(provider)) {
|
|
298
332
|
return;
|
|
333
|
+
}
|
|
299
334
|
const info = provider.lineInfo;
|
|
300
335
|
const { lineSources, lineWraps } = info;
|
|
301
336
|
const rowVirtualStarts = [];
|
|
@@ -304,7 +339,7 @@ export class RowDocumentRenderable extends ScrollBoxRenderable {
|
|
|
304
339
|
const virtualRowWraps = [];
|
|
305
340
|
let currentRow = -1;
|
|
306
341
|
let rowCount = 0;
|
|
307
|
-
for (let v = 0; v < lineSources.length; v
|
|
342
|
+
for (let v = 0; v < lineSources.length; v += 1) {
|
|
308
343
|
const row = lineSources[v];
|
|
309
344
|
virtualRowToRow[v] = row;
|
|
310
345
|
virtualRowWraps[v] = lineWraps[v];
|
|
@@ -326,10 +361,11 @@ export class RowDocumentRenderable extends ScrollBoxRenderable {
|
|
|
326
361
|
}
|
|
327
362
|
_finishGeometry(rowVirtualStarts, rowVirtualHeights, virtualRowToRow, virtualRowWraps, rowCount) {
|
|
328
363
|
let contentVirtualEnd = 0;
|
|
329
|
-
for (let row = 0; row < rowCount; row
|
|
364
|
+
for (let row = 0; row < rowCount; row += 1) {
|
|
330
365
|
const end = rowVirtualStarts[row] + rowVirtualHeights[row];
|
|
331
|
-
if (end > contentVirtualEnd)
|
|
366
|
+
if (end > contentVirtualEnd) {
|
|
332
367
|
contentVirtualEnd = end;
|
|
368
|
+
}
|
|
333
369
|
}
|
|
334
370
|
this._contentVirtualEnd = contentVirtualEnd;
|
|
335
371
|
// Change detection via hash
|
|
@@ -348,14 +384,15 @@ export class RowDocumentRenderable extends ScrollBoxRenderable {
|
|
|
348
384
|
// Gutter width calculation and padding
|
|
349
385
|
// -----------------------------------------------------------------------
|
|
350
386
|
_computeGutterWidth() {
|
|
351
|
-
if (!this._showGutter)
|
|
387
|
+
if (!this._showGutter) {
|
|
352
388
|
return 0;
|
|
389
|
+
}
|
|
353
390
|
return computeRowDocumentGutterWidth({
|
|
354
|
-
|
|
355
|
-
rowCount: this._rowCount,
|
|
391
|
+
gutterPaddingRight: this._gutterPaddingRight,
|
|
356
392
|
lineNumberStart: this._lineNumberStart,
|
|
393
|
+
rowCount: this._rowCount,
|
|
394
|
+
showLineNumbers: this._showLineNumbers,
|
|
357
395
|
signColumnWidth: this._signColumnWidth,
|
|
358
|
-
gutterPaddingRight: this._gutterPaddingRight,
|
|
359
396
|
});
|
|
360
397
|
}
|
|
361
398
|
_applyGutterPadding() {
|
|
@@ -368,8 +405,9 @@ export class RowDocumentRenderable extends ScrollBoxRenderable {
|
|
|
368
405
|
_paintDecorations(buffer) {
|
|
369
406
|
this._layerGutterBgs = new Map();
|
|
370
407
|
this._layerSigns = new Map();
|
|
371
|
-
if (this._layers.length === 0)
|
|
408
|
+
if (this._layers.length === 0) {
|
|
372
409
|
return;
|
|
410
|
+
}
|
|
373
411
|
const vpX = this.viewport.x;
|
|
374
412
|
const vpY = this.viewport.y;
|
|
375
413
|
const vpHeight = this.viewport.height;
|
|
@@ -381,24 +419,30 @@ export class RowDocumentRenderable extends ScrollBoxRenderable {
|
|
|
381
419
|
const rowSigns = new Map();
|
|
382
420
|
for (const layer of this._layers) {
|
|
383
421
|
for (const deco of layer.forVisibleRows(firstRow, lastRow)) {
|
|
384
|
-
if (deco.background)
|
|
422
|
+
if (deco.background !== undefined && deco.background !== "") {
|
|
385
423
|
rowBgs.set(deco.row, deco.background);
|
|
386
|
-
|
|
424
|
+
}
|
|
425
|
+
if (deco.gutterBackground !== undefined && deco.gutterBackground !== "") {
|
|
387
426
|
rowGutterBgs.set(deco.row, deco.gutterBackground);
|
|
388
|
-
|
|
427
|
+
}
|
|
428
|
+
if (deco.sign) {
|
|
389
429
|
rowSigns.set(deco.row, deco.sign);
|
|
430
|
+
}
|
|
390
431
|
}
|
|
391
432
|
}
|
|
392
|
-
for (let screenY = 0; screenY < vpHeight; screenY
|
|
433
|
+
for (let screenY = 0; screenY < vpHeight; screenY += 1) {
|
|
393
434
|
const vRow = top + screenY;
|
|
394
|
-
if (vRow >= this._virtualRowToRow.length)
|
|
435
|
+
if (vRow >= this._virtualRowToRow.length) {
|
|
395
436
|
break;
|
|
437
|
+
}
|
|
396
438
|
const row = this._virtualRowToRow[vRow];
|
|
397
|
-
if (row < 0)
|
|
398
|
-
continue;
|
|
439
|
+
if (row < 0) {
|
|
440
|
+
continue;
|
|
441
|
+
}
|
|
399
442
|
const bg = rowBgs.get(row);
|
|
400
|
-
if (
|
|
443
|
+
if (bg === undefined || bg === "") {
|
|
401
444
|
continue;
|
|
445
|
+
}
|
|
402
446
|
buffer.fillRect(vpX, vpY + screenY, vpWidth, 1, cachedColor(bg));
|
|
403
447
|
}
|
|
404
448
|
this._layerGutterBgs = rowGutterBgs;
|
|
@@ -409,8 +453,9 @@ export class RowDocumentRenderable extends ScrollBoxRenderable {
|
|
|
409
453
|
// -----------------------------------------------------------------------
|
|
410
454
|
_paintGutter(buffer) {
|
|
411
455
|
const gutterWidth = this._computeGutterWidth();
|
|
412
|
-
if (gutterWidth === 0)
|
|
456
|
+
if (gutterWidth === 0) {
|
|
413
457
|
return;
|
|
458
|
+
}
|
|
414
459
|
const vpX = this.viewport.x;
|
|
415
460
|
const vpY = this.viewport.y;
|
|
416
461
|
const vpHeight = this.viewport.height;
|
|
@@ -422,21 +467,24 @@ export class RowDocumentRenderable extends ScrollBoxRenderable {
|
|
|
422
467
|
const lineNumWidth = this._showLineNumbers
|
|
423
468
|
? Math.max(String(this._lineNumberStart + this._rowCount - 1).length, 1)
|
|
424
469
|
: 0;
|
|
425
|
-
for (let screenY = 0; screenY < vpHeight; screenY
|
|
470
|
+
for (let screenY = 0; screenY < vpHeight; screenY += 1) {
|
|
426
471
|
const vRow = top + screenY;
|
|
427
|
-
if (vRow >= this._virtualRowToRow.length)
|
|
472
|
+
if (vRow >= this._virtualRowToRow.length) {
|
|
428
473
|
break;
|
|
474
|
+
}
|
|
429
475
|
const row = this._virtualRowToRow[vRow];
|
|
430
|
-
if (row < 0)
|
|
431
|
-
continue;
|
|
476
|
+
if (row < 0) {
|
|
477
|
+
continue;
|
|
478
|
+
}
|
|
432
479
|
const isFirstLine = this._virtualRowWraps[vRow] === 0;
|
|
433
|
-
if (!isFirstLine)
|
|
480
|
+
if (!isFirstLine) {
|
|
434
481
|
continue;
|
|
482
|
+
}
|
|
435
483
|
const drawX = vpX;
|
|
436
484
|
let col = 0;
|
|
437
485
|
const rowGutterHex = this._layerGutterBgs.get(row);
|
|
438
|
-
const effectiveGutterBg = rowGutterHex ? cachedColor(rowGutterHex) : gutterBg;
|
|
439
|
-
if (rowGutterHex) {
|
|
486
|
+
const effectiveGutterBg = rowGutterHex !== undefined && rowGutterHex !== "" ? cachedColor(rowGutterHex) : gutterBg;
|
|
487
|
+
if (rowGutterHex !== undefined && rowGutterHex !== "") {
|
|
440
488
|
buffer.fillRect(drawX, vpY + screenY, gutterWidth, 1, effectiveGutterBg);
|
|
441
489
|
}
|
|
442
490
|
// Line number
|
|
@@ -450,11 +498,11 @@ export class RowDocumentRenderable extends ScrollBoxRenderable {
|
|
|
450
498
|
if (this._signColumnWidth > 0) {
|
|
451
499
|
const sign = this._layerSigns.get(row);
|
|
452
500
|
if (sign) {
|
|
453
|
-
const signFg = sign.fg ? cachedColor(sign.fg) : gutterFg;
|
|
501
|
+
const signFg = sign.fg !== undefined && sign.fg !== "" ? cachedColor(sign.fg) : gutterFg;
|
|
454
502
|
buffer.drawText(sign.text.slice(0, this._signColumnWidth), drawX + col, vpY + screenY, signFg, effectiveGutterBg);
|
|
455
503
|
}
|
|
456
504
|
}
|
|
457
505
|
}
|
|
458
506
|
}
|
|
459
507
|
}
|
|
460
|
-
//# sourceMappingURL=
|
|
508
|
+
//# sourceMappingURL=row-document-renderable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row-document-renderable.js","sourceRoot":"","sources":["../src/row-document-renderable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAS1D,8EAA8E;AAC9E,QAAQ;AACR,8EAA8E;AAE9E,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAyB3C,8EAA8E;AAC9E,qBAAqB;AACrB,8EAA8E;AAE9E,MAAM,oBAAoB,GAAG,SAAS,oBAAoB,CAAC,CAAU;IACnE,OAAO,CACL,CAAC,KAAK,IAAI;QACV,CAAC,KAAK,SAAS;QACf,OAAO,CAAC,KAAK,QAAQ;QACrB,UAAU,IAAI,CAAC;QACf,WAAW,IAAI,CAAC;QAChB,kBAAkB,IAAI,CAAC,CACxB,CAAC;AACJ,CAAC,CAAC;AAEF,8EAA8E;AAC9E,0DAA0D;AAC1D,8EAA8E;AAE9E,MAAM,UAAU,GAAG,IAAI,GAAG,EAAgB,CAAC;AAE3C,MAAM,WAAW,GAAG,SAAS,WAAW,CAAC,GAAW;IAClD,IAAI,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,IAAI,CAAC,CAAC,EAAE,CAAC;QACP,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACtB,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,SAAS,gBAAgB,CAChD,UAA8B,EAAE;IAEhC,OAAO;QACL,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,SAAS;QACvC,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,SAAS;KACxC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,yBAAyB,GA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,CAAC;CACF"}
|
package/dist/row-document.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"row-document.d.ts","sourceRoot":"","sources":["../src/row-document.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"row-document.d.ts","sourceRoot":"","sources":["../src/row-document.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAIrE,OAAO,QAAQ,gBAAgB,CAAC;IAC9B,UAAU,iBAAiB;QACzB,cAAc,EAAE,OAAO,qBAAqB,CAAC;KAC9C;CACF"}
|
package/dist/row-document.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { extend } from "@opentui/react";
|
|
2
|
-
import { RowDocumentRenderable } from "./
|
|
2
|
+
import { RowDocumentRenderable } from "./row-document-renderable.js";
|
|
3
3
|
extend({ "row-document": RowDocumentRenderable });
|
|
4
4
|
//# sourceMappingURL=row-document.js.map
|
package/dist/row-document.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"row-document.js","sourceRoot":"","sources":["../src/row-document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"row-document.js","sourceRoot":"","sources":["../src/row-document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE,MAAM,CAAC,EAAE,cAAc,EAAE,qBAAqB,EAAE,CAAC,CAAC"}
|
package/dist/source.d.ts
CHANGED
|
@@ -44,10 +44,10 @@ export interface DocumentRowAnchor<T> {
|
|
|
44
44
|
* `\r\n` string, so the `\r` counts as a column on the preceding line.
|
|
45
45
|
*/
|
|
46
46
|
export declare class SourceIndex {
|
|
47
|
-
readonly text: string;
|
|
48
|
-
readonly sourceId?: string | undefined;
|
|
49
47
|
readonly lineStarts: number[];
|
|
50
|
-
|
|
48
|
+
readonly text: string;
|
|
49
|
+
readonly sourceId?: string;
|
|
50
|
+
constructor(text: string, sourceId?: string);
|
|
51
51
|
/** The physical line index (0-based) containing `offset`, via binary search. */
|
|
52
52
|
lineAt(offset: number): number;
|
|
53
53
|
point(offset: number): SourcePoint;
|
|
@@ -72,12 +72,12 @@ export interface SourceLineRow {
|
|
|
72
72
|
* its newline delimiter; CRLF is one line break while offsets keep addressing
|
|
73
73
|
* the original `\r\n` string.
|
|
74
74
|
*/
|
|
75
|
-
export declare
|
|
75
|
+
export declare const sourceLines: (source: string, options?: {
|
|
76
76
|
sourceId?: string;
|
|
77
|
-
})
|
|
77
|
+
}) => SourceLineRow[];
|
|
78
78
|
/** Adapter for `sourceLines()` rows: identity mapping in row/line space. */
|
|
79
79
|
export declare const sourceLineAdapter: {
|
|
80
|
-
getText: (row: SourceLineRow) => string;
|
|
81
80
|
getSource: (row: SourceLineRow) => DocumentRowSource;
|
|
81
|
+
getText: (row: SourceLineRow) => string;
|
|
82
82
|
};
|
|
83
83
|
//# sourceMappingURL=source.d.ts.map
|
package/dist/source.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAMjC,wFAAwF;AACxF,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,MAAM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W,GACtB,QAAQ,MAAM,EACd,UAAU;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,KAC9B,aAAa,EAYf,CAAC;AAEF,4EAA4E;AAC5E,eAAO,MAAM,iBAAiB;qBACX,aAAa,KAAG,iBAAiB;mBACnC,aAAa,KAAG,MAAM;CACtC,CAAC"}
|
package/dist/source.js
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
// ---------------------------------------------------------------------------
|
|
2
2
|
// Line index and span construction
|
|
3
3
|
// ---------------------------------------------------------------------------
|
|
4
|
+
const LINE_FEED_CODE = 10;
|
|
5
|
+
const CARRIAGE_RETURN_CODE = 13;
|
|
4
6
|
/** Offsets of the first character of every physical line. */
|
|
5
|
-
function buildLineStarts(text) {
|
|
7
|
+
const buildLineStarts = function buildLineStarts(text) {
|
|
6
8
|
const starts = [0];
|
|
7
|
-
for (let i = 0; i < text.length; i
|
|
8
|
-
if (text.
|
|
9
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
10
|
+
if (text.codePointAt(i) === LINE_FEED_CODE) {
|
|
9
11
|
starts.push(i + 1);
|
|
12
|
+
}
|
|
10
13
|
}
|
|
11
14
|
return starts;
|
|
12
|
-
}
|
|
15
|
+
};
|
|
13
16
|
/**
|
|
14
17
|
* A CRLF-aware line-start index over an original source string. A `\r\n` is one
|
|
15
18
|
* line break (the break lands on the `\n`); offsets still address the original
|
|
16
19
|
* `\r\n` string, so the `\r` counts as a column on the preceding line.
|
|
17
20
|
*/
|
|
18
21
|
export class SourceIndex {
|
|
22
|
+
lineStarts;
|
|
19
23
|
text;
|
|
20
24
|
sourceId;
|
|
21
|
-
lineStarts;
|
|
22
25
|
constructor(text, sourceId) {
|
|
23
26
|
this.text = text;
|
|
24
27
|
this.sourceId = sourceId;
|
|
@@ -30,27 +33,30 @@ export class SourceIndex {
|
|
|
30
33
|
let lo = 0;
|
|
31
34
|
let hi = starts.length - 1;
|
|
32
35
|
while (lo < hi) {
|
|
33
|
-
const mid = (lo + hi + 1)
|
|
34
|
-
if (starts[mid] <= offset)
|
|
36
|
+
const mid = Math.floor((lo + hi + 1) / 2);
|
|
37
|
+
if (starts[mid] <= offset) {
|
|
35
38
|
lo = mid;
|
|
36
|
-
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
37
41
|
hi = mid - 1;
|
|
42
|
+
}
|
|
38
43
|
}
|
|
39
44
|
return lo;
|
|
40
45
|
}
|
|
41
46
|
point(offset) {
|
|
42
47
|
const line = this.lineAt(offset);
|
|
43
|
-
return {
|
|
48
|
+
return { column: offset - this.lineStarts[line], line, offset };
|
|
44
49
|
}
|
|
45
50
|
/** End offset of a line's content, excluding its `\n`/`\r\n` delimiter. */
|
|
46
51
|
lineContentEnd(line) {
|
|
47
52
|
const starts = this.lineStarts;
|
|
48
53
|
const nextStart = line + 1 < starts.length ? starts[line + 1] : this.text.length;
|
|
49
54
|
let end = nextStart;
|
|
50
|
-
if (end > starts[line] && this.text.
|
|
51
|
-
end
|
|
52
|
-
if (end > starts[line] && this.text.
|
|
53
|
-
end
|
|
55
|
+
if (end > starts[line] && this.text.codePointAt(end - 1) === LINE_FEED_CODE) {
|
|
56
|
+
end -= 1;
|
|
57
|
+
if (end > starts[line] && this.text.codePointAt(end - 1) === CARRIAGE_RETURN_CODE) {
|
|
58
|
+
end -= 1;
|
|
59
|
+
}
|
|
54
60
|
}
|
|
55
61
|
return end;
|
|
56
62
|
}
|
|
@@ -63,26 +69,29 @@ export class SourceIndex {
|
|
|
63
69
|
span(rawStart, rawEnd, trimTrailingNewlines = true) {
|
|
64
70
|
let end = rawEnd;
|
|
65
71
|
if (trimTrailingNewlines) {
|
|
66
|
-
while (end > rawStart && this.text.
|
|
67
|
-
end
|
|
68
|
-
if (end > rawStart && this.text.
|
|
69
|
-
end
|
|
72
|
+
while (end > rawStart && this.text.codePointAt(end - 1) === 10) {
|
|
73
|
+
end -= 1;
|
|
74
|
+
if (end > rawStart && this.text.codePointAt(end - 1) === 13) {
|
|
75
|
+
end -= 1;
|
|
76
|
+
}
|
|
70
77
|
}
|
|
71
78
|
}
|
|
72
|
-
if (end < rawStart)
|
|
79
|
+
if (end < rawStart) {
|
|
73
80
|
end = rawStart;
|
|
81
|
+
}
|
|
74
82
|
const start = this.point(rawStart);
|
|
75
83
|
const endPoint = this.point(end);
|
|
76
84
|
const lastLine = end > rawStart ? this.lineAt(end - 1) : start.line;
|
|
77
85
|
const span = {
|
|
78
|
-
start,
|
|
79
86
|
end: endPoint,
|
|
80
87
|
lastLine,
|
|
81
|
-
text: this.text.slice(rawStart, end),
|
|
82
88
|
lineText: this.text.slice(this.lineStarts[start.line], this.lineContentEnd(lastLine)),
|
|
89
|
+
start,
|
|
90
|
+
text: this.text.slice(rawStart, end),
|
|
83
91
|
};
|
|
84
|
-
if (this.sourceId !== undefined)
|
|
92
|
+
if (this.sourceId !== undefined) {
|
|
85
93
|
span.sourceId = this.sourceId;
|
|
94
|
+
}
|
|
86
95
|
return span;
|
|
87
96
|
}
|
|
88
97
|
}
|
|
@@ -93,22 +102,22 @@ export class SourceIndex {
|
|
|
93
102
|
* its newline delimiter; CRLF is one line break while offsets keep addressing
|
|
94
103
|
* the original `\r\n` string.
|
|
95
104
|
*/
|
|
96
|
-
export function sourceLines(source, options) {
|
|
105
|
+
export const sourceLines = function sourceLines(source, options) {
|
|
97
106
|
const index = new SourceIndex(source, options?.sourceId);
|
|
98
107
|
const rows = [];
|
|
99
|
-
for (let line = 0; line < index.lineStarts.length; line
|
|
108
|
+
for (let line = 0; line < index.lineStarts.length; line += 1) {
|
|
100
109
|
const start = index.lineStarts[line];
|
|
101
110
|
const end = index.lineContentEnd(line);
|
|
102
111
|
rows.push({
|
|
103
|
-
text: source.slice(start, end),
|
|
104
112
|
source: { primary: index.span(start, end, false) },
|
|
113
|
+
text: source.slice(start, end),
|
|
105
114
|
});
|
|
106
115
|
}
|
|
107
116
|
return rows;
|
|
108
|
-
}
|
|
117
|
+
};
|
|
109
118
|
/** Adapter for `sourceLines()` rows: identity mapping in row/line space. */
|
|
110
119
|
export const sourceLineAdapter = {
|
|
111
|
-
getText: (row) => row.text,
|
|
112
120
|
getSource: (row) => row.source,
|
|
121
|
+
getText: (row) => row.text,
|
|
113
122
|
};
|
|
114
123
|
//# sourceMappingURL=source.js.map
|