@next_term/core 0.0.1-next.0
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/buffer.d.ts +46 -0
- package/dist/buffer.d.ts.map +1 -0
- package/dist/buffer.js +146 -0
- package/dist/buffer.js.map +1 -0
- package/dist/cell-grid.d.ts +102 -0
- package/dist/cell-grid.d.ts.map +1 -0
- package/dist/cell-grid.js +294 -0
- package/dist/cell-grid.js.map +1 -0
- package/dist/gesture-handler.d.ts +65 -0
- package/dist/gesture-handler.d.ts.map +1 -0
- package/dist/gesture-handler.js +186 -0
- package/dist/gesture-handler.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/parser/index.d.ts +196 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +1952 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/states.d.ts +39 -0
- package/dist/parser/states.d.ts.map +1 -0
- package/dist/parser/states.js +240 -0
- package/dist/parser/states.js.map +1 -0
- package/dist/types.d.ts +54 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +30 -0
- package/dist/types.js.map +1 -0
- package/package.json +28 -0
package/dist/buffer.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { CellGrid } from "./cell-grid.js";
|
|
2
|
+
import type { CursorState } from "./types.js";
|
|
3
|
+
export declare class Buffer {
|
|
4
|
+
readonly cols: number;
|
|
5
|
+
readonly rows: number;
|
|
6
|
+
readonly grid: CellGrid;
|
|
7
|
+
cursor: CursorState;
|
|
8
|
+
scrollTop: number;
|
|
9
|
+
scrollBottom: number;
|
|
10
|
+
/** Default tab-stop interval. */
|
|
11
|
+
private readonly tabWidth;
|
|
12
|
+
/** Custom tab stops (column indices). */
|
|
13
|
+
tabStops: Set<number>;
|
|
14
|
+
private savedCursor;
|
|
15
|
+
constructor(cols: number, rows: number);
|
|
16
|
+
private resetTabStops;
|
|
17
|
+
nextTabStop(col: number): number;
|
|
18
|
+
prevTabStop(col: number): number;
|
|
19
|
+
saveCursor(): void;
|
|
20
|
+
restoreCursor(): void;
|
|
21
|
+
/** Scroll the scroll region up by one line. */
|
|
22
|
+
scrollUp(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Scroll the scroll region down by one line.
|
|
25
|
+
*/
|
|
26
|
+
scrollDown(): void;
|
|
27
|
+
}
|
|
28
|
+
export declare class BufferSet {
|
|
29
|
+
readonly cols: number;
|
|
30
|
+
readonly rows: number;
|
|
31
|
+
normal: Buffer;
|
|
32
|
+
alternate: Buffer;
|
|
33
|
+
active: Buffer;
|
|
34
|
+
/** Scrollback lines for the normal buffer (array of Uint32Array). */
|
|
35
|
+
scrollback: Uint32Array[];
|
|
36
|
+
readonly maxScrollback: number;
|
|
37
|
+
constructor(cols: number, rows: number, maxScrollback?: number);
|
|
38
|
+
get isAlternate(): boolean;
|
|
39
|
+
activateAlternate(): void;
|
|
40
|
+
activateNormal(): void;
|
|
41
|
+
/** Push a line into scrollback (for the normal buffer). */
|
|
42
|
+
pushScrollback(line: Uint32Array): void;
|
|
43
|
+
/** Scroll the active buffer up, pushing the top line into scrollback if normal buffer. */
|
|
44
|
+
scrollUpWithHistory(): void;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=buffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../src/buffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,qBAAa,MAAM;aAcC,IAAI,EAAE,MAAM;aACZ,IAAI,EAAE,MAAM;IAd9B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,MAAM,EAAE,WAAW,CAAC;IACpB,SAAS,EAAE,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scrollTop;
|
|
8
|
+
scrollBottom;
|
|
9
|
+
/** Default tab-stop interval. */
|
|
10
|
+
tabWidth = 8;
|
|
11
|
+
/** Custom tab stops (column indices). */
|
|
12
|
+
tabStops;
|
|
13
|
+
// Saved cursor for DECSC / DECRC
|
|
14
|
+
savedCursor = null;
|
|
15
|
+
constructor(cols, rows) {
|
|
16
|
+
this.cols = cols;
|
|
17
|
+
this.rows = rows;
|
|
18
|
+
this.grid = new CellGrid(cols, rows);
|
|
19
|
+
this.cursor = { row: 0, col: 0, visible: true, style: "block", wrapPending: false };
|
|
20
|
+
this.scrollTop = 0;
|
|
21
|
+
this.scrollBottom = rows - 1;
|
|
22
|
+
this.tabStops = new Set();
|
|
23
|
+
this.resetTabStops();
|
|
24
|
+
}
|
|
25
|
+
resetTabStops() {
|
|
26
|
+
this.tabStops.clear();
|
|
27
|
+
for (let c = this.tabWidth; c < this.cols; c += this.tabWidth) {
|
|
28
|
+
this.tabStops.add(c);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
nextTabStop(col) {
|
|
32
|
+
for (let c = col + 1; c < this.cols; c++) {
|
|
33
|
+
if (this.tabStops.has(c))
|
|
34
|
+
return c;
|
|
35
|
+
}
|
|
36
|
+
return this.cols - 1;
|
|
37
|
+
}
|
|
38
|
+
prevTabStop(col) {
|
|
39
|
+
for (let c = col - 1; c >= 0; c--) {
|
|
40
|
+
if (this.tabStops.has(c))
|
|
41
|
+
return c;
|
|
42
|
+
}
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
45
|
+
saveCursor() {
|
|
46
|
+
this.savedCursor = { ...this.cursor };
|
|
47
|
+
}
|
|
48
|
+
restoreCursor() {
|
|
49
|
+
if (this.savedCursor) {
|
|
50
|
+
this.cursor = { ...this.savedCursor };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** Scroll the scroll region up by one line. */
|
|
54
|
+
scrollUp() {
|
|
55
|
+
if (this.scrollTop === 0 && this.scrollBottom === this.rows - 1) {
|
|
56
|
+
// Full-screen scroll: O(1) rotation instead of O(rows×cols) copy
|
|
57
|
+
this.grid.rotateUp();
|
|
58
|
+
this.grid.clearRowRaw(this.scrollBottom);
|
|
59
|
+
this.grid.markDirtyRange(this.scrollTop, this.scrollBottom);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
// Partial scroll region: shift rows up using copyWithin on physical offsets
|
|
63
|
+
const rowSize = this.cols * CELL_SIZE;
|
|
64
|
+
for (let r = this.scrollTop; r < this.scrollBottom; r++) {
|
|
65
|
+
const dst = this.grid.rowStart(r);
|
|
66
|
+
const src = this.grid.rowStart(r + 1);
|
|
67
|
+
this.grid.data.copyWithin(dst, src, src + rowSize);
|
|
68
|
+
}
|
|
69
|
+
this.grid.clearRowRaw(this.scrollBottom);
|
|
70
|
+
this.grid.markDirtyRange(this.scrollTop, this.scrollBottom);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Scroll the scroll region down by one line.
|
|
75
|
+
*/
|
|
76
|
+
scrollDown() {
|
|
77
|
+
if (this.scrollTop === 0 && this.scrollBottom === this.rows - 1) {
|
|
78
|
+
// Full-screen scroll: O(1) rotation
|
|
79
|
+
this.grid.rotateDown();
|
|
80
|
+
this.grid.clearRowRaw(this.scrollTop);
|
|
81
|
+
this.grid.markDirtyRange(this.scrollTop, this.scrollBottom);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
// Partial scroll region: shift rows down using copyWithin on physical offsets
|
|
85
|
+
const rowSize = this.cols * CELL_SIZE;
|
|
86
|
+
for (let r = this.scrollBottom; r > this.scrollTop; r--) {
|
|
87
|
+
const dst = this.grid.rowStart(r);
|
|
88
|
+
const src = this.grid.rowStart(r - 1);
|
|
89
|
+
this.grid.data.copyWithin(dst, src, src + rowSize);
|
|
90
|
+
}
|
|
91
|
+
this.grid.clearRowRaw(this.scrollTop);
|
|
92
|
+
this.grid.markDirtyRange(this.scrollTop, this.scrollBottom);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
export class BufferSet {
|
|
97
|
+
cols;
|
|
98
|
+
rows;
|
|
99
|
+
normal;
|
|
100
|
+
alternate;
|
|
101
|
+
active;
|
|
102
|
+
/** Scrollback lines for the normal buffer (array of Uint32Array). */
|
|
103
|
+
scrollback;
|
|
104
|
+
maxScrollback;
|
|
105
|
+
constructor(cols, rows, maxScrollback = 5000) {
|
|
106
|
+
this.cols = cols;
|
|
107
|
+
this.rows = rows;
|
|
108
|
+
this.normal = new Buffer(cols, rows);
|
|
109
|
+
this.alternate = new Buffer(cols, rows);
|
|
110
|
+
this.active = this.normal;
|
|
111
|
+
this.scrollback = [];
|
|
112
|
+
this.maxScrollback = maxScrollback;
|
|
113
|
+
}
|
|
114
|
+
get isAlternate() {
|
|
115
|
+
return this.active === this.alternate;
|
|
116
|
+
}
|
|
117
|
+
activateAlternate() {
|
|
118
|
+
if (this.active === this.alternate)
|
|
119
|
+
return;
|
|
120
|
+
this.active = this.alternate;
|
|
121
|
+
this.alternate.grid.clear();
|
|
122
|
+
this.alternate.cursor = { row: 0, col: 0, visible: true, style: "block", wrapPending: false };
|
|
123
|
+
this.alternate.scrollTop = 0;
|
|
124
|
+
this.alternate.scrollBottom = this.rows - 1;
|
|
125
|
+
}
|
|
126
|
+
activateNormal() {
|
|
127
|
+
if (this.active === this.normal)
|
|
128
|
+
return;
|
|
129
|
+
this.active = this.normal;
|
|
130
|
+
}
|
|
131
|
+
/** Push a line into scrollback (for the normal buffer). */
|
|
132
|
+
pushScrollback(line) {
|
|
133
|
+
this.scrollback.push(line);
|
|
134
|
+
while (this.scrollback.length > this.maxScrollback) {
|
|
135
|
+
this.scrollback.shift();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/** Scroll the active buffer up, pushing the top line into scrollback if normal buffer. */
|
|
139
|
+
scrollUpWithHistory() {
|
|
140
|
+
if (this.maxScrollback > 0 && this.active === this.normal && this.active.scrollTop === 0) {
|
|
141
|
+
this.pushScrollback(this.active.grid.copyRow(0));
|
|
142
|
+
}
|
|
143
|
+
this.active.scrollUp();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=buffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer.js","sourceRoot":"","sources":["../src/buffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAGrD,MAAM,OAAO,MAAM;IAcC;IACA;IAdT,IAAI,CAAW;IACxB,MAAM,CAAc;IACpB,SAAS,CAAS;IAClB,YAAY,CAAS;IACrB,iCAAiC;IAChB,QAAQ,GAAG,CAAC,CAAC;IAC9B,yCAAyC;IACzC,QAAQ,CAAc;IAEtB,iCAAiC;IACzB,WAAW,GAAuB,IAAI,CAAC;IAE/C,YACkB,IAAY,EACZ,IAAY;QADZ,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAAQ;QAE5B,IAAI,CAAC,IAAI,GAAG,IAAI,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;QACpF,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;QACnB,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;QAClC,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;IAEO,aAAa;QACnB,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE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D,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export declare const CELL_SIZE = 2;
|
|
2
|
+
/** Default blank cell word0: space (0x20) + default fg index 7. */
|
|
3
|
+
export declare const DEFAULT_CELL_W0: number;
|
|
4
|
+
/** Default blank cell word1: bg index 0, no attrs. */
|
|
5
|
+
export declare const DEFAULT_CELL_W1 = 0;
|
|
6
|
+
/** Safe modulo that always returns a non-negative result (JS % preserves sign). */
|
|
7
|
+
export declare function modPositive(value: number, modulo: number): number;
|
|
8
|
+
export declare class CellGrid {
|
|
9
|
+
readonly cols: number;
|
|
10
|
+
readonly rows: number;
|
|
11
|
+
readonly data: Uint32Array;
|
|
12
|
+
readonly dirtyRows: Int32Array;
|
|
13
|
+
readonly rgbColors: Uint32Array;
|
|
14
|
+
private readonly buffer;
|
|
15
|
+
readonly isShared: boolean;
|
|
16
|
+
private readonly _templateRow;
|
|
17
|
+
/**
|
|
18
|
+
* Cursor data stored in the SAB for cross-worker access.
|
|
19
|
+
* Layout: [cursorRow, cursorCol, cursorVisible, cursorStyle]
|
|
20
|
+
* cursorStyle: 0 = block, 1 = underline, 2 = bar
|
|
21
|
+
*/
|
|
22
|
+
readonly cursorData: Int32Array;
|
|
23
|
+
/**
|
|
24
|
+
* Circular row buffer offset. Logical row r maps to physical row
|
|
25
|
+
* (r + rowOffsetData[0]) % rows. Scrolling rotates this offset
|
|
26
|
+
* instead of copying cell data, making full-screen scroll O(1).
|
|
27
|
+
*/
|
|
28
|
+
readonly rowOffsetData: Int32Array;
|
|
29
|
+
constructor(cols: number, rows: number);
|
|
30
|
+
/** Map logical row to physical row in the circular buffer. */
|
|
31
|
+
physicalRow(row: number): number;
|
|
32
|
+
/** Get the data array offset for the start of a logical row. */
|
|
33
|
+
rowStart(row: number): number;
|
|
34
|
+
/** Rotate the circular buffer up by n rows (for scroll-up). */
|
|
35
|
+
rotateUp(n?: number): void;
|
|
36
|
+
/** Rotate the circular buffer down by n rows (for scroll-down). */
|
|
37
|
+
rotateDown(n?: number): void;
|
|
38
|
+
getCodepoint(row: number, col: number): number;
|
|
39
|
+
getFgIndex(row: number, col: number): number;
|
|
40
|
+
getBgIndex(row: number, col: number): number;
|
|
41
|
+
getAttrs(row: number, col: number): number;
|
|
42
|
+
isFgRGB(row: number, col: number): boolean;
|
|
43
|
+
isBgRGB(row: number, col: number): boolean;
|
|
44
|
+
isBold(row: number, col: number): boolean;
|
|
45
|
+
isItalic(row: number, col: number): boolean;
|
|
46
|
+
isUnderline(row: number, col: number): boolean;
|
|
47
|
+
isStrikethrough(row: number, col: number): boolean;
|
|
48
|
+
isInverse(row: number, col: number): boolean;
|
|
49
|
+
isWide(row: number, col: number): boolean;
|
|
50
|
+
setCell(row: number, col: number, codepoint: number, fgIndex: number, bgIndex: number, attrs: number, fgIsRGB?: boolean, bgIsRGB?: boolean): void;
|
|
51
|
+
markDirty(row: number): void;
|
|
52
|
+
/** Mark a contiguous range of rows [from..to] dirty. */
|
|
53
|
+
markDirtyRange(from: number, to: number): void;
|
|
54
|
+
isDirty(row: number): boolean;
|
|
55
|
+
clearDirty(row: number): void;
|
|
56
|
+
markAllDirty(): void;
|
|
57
|
+
clear(): void;
|
|
58
|
+
/** Copy a logical row of cell data into a new Uint32Array. */
|
|
59
|
+
copyRow(row: number): Uint32Array;
|
|
60
|
+
/** Overwrite a logical row from a previously copied Uint32Array. */
|
|
61
|
+
pasteRow(row: number, src: Uint32Array): void;
|
|
62
|
+
/** Fill a logical row with spaces and default attributes. */
|
|
63
|
+
clearRow(row: number): void;
|
|
64
|
+
/** Fill a logical row with defaults without marking dirty (caller will batch-mark). */
|
|
65
|
+
clearRowRaw(row: number): void;
|
|
66
|
+
/** Style string to Int32 encoding for cursorData[3]. */
|
|
67
|
+
private static readonly CURSOR_STYLE_MAP;
|
|
68
|
+
private static readonly CURSOR_STYLE_REVERSE;
|
|
69
|
+
/**
|
|
70
|
+
* Write cursor state into the SAB so render workers can read it atomically.
|
|
71
|
+
*/
|
|
72
|
+
setCursor(row: number, col: number, visible: boolean, style: string): void;
|
|
73
|
+
/**
|
|
74
|
+
* Read cursor state from the SAB.
|
|
75
|
+
*/
|
|
76
|
+
getCursor(): {
|
|
77
|
+
row: number;
|
|
78
|
+
col: number;
|
|
79
|
+
visible: boolean;
|
|
80
|
+
style: string;
|
|
81
|
+
};
|
|
82
|
+
getBuffer(): SharedArrayBuffer | ArrayBuffer;
|
|
83
|
+
}
|
|
84
|
+
export interface SelectionRange {
|
|
85
|
+
startRow: number;
|
|
86
|
+
startCol: number;
|
|
87
|
+
endRow: number;
|
|
88
|
+
endCol: number;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Normalize a selection so that start is before end.
|
|
92
|
+
*/
|
|
93
|
+
export declare function normalizeSelection(sel: SelectionRange): SelectionRange;
|
|
94
|
+
/**
|
|
95
|
+
* Extract text from a CellGrid for the given selection range.
|
|
96
|
+
*
|
|
97
|
+
* - Normalizes the selection (handles backwards selections).
|
|
98
|
+
* - Trims trailing spaces from each line.
|
|
99
|
+
* - Joins lines with `\n`.
|
|
100
|
+
*/
|
|
101
|
+
export declare function extractText(grid: CellGrid, startRow: number, startCol: number, endRow: number, endCol: number): string;
|
|
102
|
+
//# sourceMappingURL=cell-grid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cell-grid.d.ts","sourceRoot":"","sources":["../src/cell-grid.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,SAAS,IAAI,CAAC;AAE3B,mEAAmE;AACnE,eAAO,MAAM,eAAe,QAAmB,CAAC;AAChD,sDAAsD;AACtD,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC,mFAAmF;AACnF,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED,qBAAa,QAAQ;IACnB,QAAQ,CA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,gBAAgB,CAItC;IACF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAA0C;IAEtF;;OAEG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAc1E;;OAEG;IACH,SAAS,IAAI;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;IAiB1E,SAAS,IAAI,iBAAiB,GAAG,WAAW;CAG7C;AAMD,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,cAAc,GAAG,cAAc,CAWtE;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,QAAQ,EACd,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,MAAM,CAwBR"}
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
// Feature detection for SharedArrayBuffer
|
|
2
|
+
const SAB_AVAILABLE = typeof SharedArrayBuffer !== "undefined" &&
|
|
3
|
+
(typeof crossOriginIsolated !== "undefined" ? crossOriginIsolated : true);
|
|
4
|
+
// Cell packing: 2 x Uint32 per cell
|
|
5
|
+
// Word 0: [0-20] codepoint, [21] fg-is-rgb, [22] bg-is-rgb, [23-30] fg-index, [31] dirty
|
|
6
|
+
// Word 1: [0-7] bg-index, [8] bold, [9] italic, [10] underline, [11] strikethrough,
|
|
7
|
+
// [12-13] underline-style, [14] inverse, [15] wide, [16-31] reserved
|
|
8
|
+
export const CELL_SIZE = 2; // 2 x uint32 per cell
|
|
9
|
+
/** Default blank cell word0: space (0x20) + default fg index 7. */
|
|
10
|
+
export const DEFAULT_CELL_W0 = 0x20 | (7 << 23);
|
|
11
|
+
/** Default blank cell word1: bg index 0, no attrs. */
|
|
12
|
+
export const DEFAULT_CELL_W1 = 0;
|
|
13
|
+
/** Safe modulo that always returns a non-negative result (JS % preserves sign). */
|
|
14
|
+
export function modPositive(value, modulo) {
|
|
15
|
+
return ((value % modulo) + modulo) % modulo;
|
|
16
|
+
}
|
|
17
|
+
export class CellGrid {
|
|
18
|
+
cols;
|
|
19
|
+
rows;
|
|
20
|
+
data;
|
|
21
|
+
dirtyRows;
|
|
22
|
+
rgbColors;
|
|
23
|
+
buffer;
|
|
24
|
+
isShared;
|
|
25
|
+
_templateRow;
|
|
26
|
+
/**
|
|
27
|
+
* Cursor data stored in the SAB for cross-worker access.
|
|
28
|
+
* Layout: [cursorRow, cursorCol, cursorVisible, cursorStyle]
|
|
29
|
+
* cursorStyle: 0 = block, 1 = underline, 2 = bar
|
|
30
|
+
*/
|
|
31
|
+
cursorData;
|
|
32
|
+
/**
|
|
33
|
+
* Circular row buffer offset. Logical row r maps to physical row
|
|
34
|
+
* (r + rowOffsetData[0]) % rows. Scrolling rotates this offset
|
|
35
|
+
* instead of copying cell data, making full-screen scroll O(1).
|
|
36
|
+
*/
|
|
37
|
+
rowOffsetData;
|
|
38
|
+
constructor(cols, rows) {
|
|
39
|
+
this.cols = cols;
|
|
40
|
+
this.rows = rows;
|
|
41
|
+
this.isShared = SAB_AVAILABLE;
|
|
42
|
+
const cellBytes = cols * rows * CELL_SIZE * 4;
|
|
43
|
+
const dirtyBytes = rows * 4; // Int32Array: 4 bytes per element
|
|
44
|
+
const rgbBytes = 512 * 4;
|
|
45
|
+
const cursorBytes = 4 * 4; // 4 x Int32: row, col, visible, style
|
|
46
|
+
const offsetBytes = 1 * 4; // 1 x Int32: row offset for circular buffer
|
|
47
|
+
const totalBytes = cellBytes + dirtyBytes + rgbBytes + cursorBytes + offsetBytes;
|
|
48
|
+
const BufferType = SAB_AVAILABLE ? SharedArrayBuffer : ArrayBuffer;
|
|
49
|
+
this.buffer = new BufferType(totalBytes);
|
|
50
|
+
this.data = new Uint32Array(this.buffer, 0, cols * rows * CELL_SIZE);
|
|
51
|
+
this.dirtyRows = new Int32Array(this.buffer, cellBytes, rows);
|
|
52
|
+
this.rgbColors = new Uint32Array(this.buffer, cellBytes + dirtyBytes, 512);
|
|
53
|
+
this.cursorData = new Int32Array(this.buffer, cellBytes + dirtyBytes + rgbBytes, 4);
|
|
54
|
+
this.rowOffsetData = new Int32Array(this.buffer, cellBytes + dirtyBytes + rgbBytes + cursorBytes, 1);
|
|
55
|
+
// Build a template row: each cell is a space with default fg=7
|
|
56
|
+
this._templateRow = new Uint32Array(cols * CELL_SIZE);
|
|
57
|
+
for (let c = 0; c < cols; c++) {
|
|
58
|
+
this._templateRow[c * CELL_SIZE] = DEFAULT_CELL_W0;
|
|
59
|
+
// [c * CELL_SIZE + 1] is already DEFAULT_CELL_W1 (0)
|
|
60
|
+
}
|
|
61
|
+
this.clear();
|
|
62
|
+
}
|
|
63
|
+
/** Map logical row to physical row in the circular buffer. */
|
|
64
|
+
physicalRow(row) {
|
|
65
|
+
// row is in [0, rows) and rowOffsetData[0] is in [0, rows),
|
|
66
|
+
// so sum is in [0, 2*rows) — branch is cheaper than modulo.
|
|
67
|
+
const sum = row + this.rowOffsetData[0];
|
|
68
|
+
return sum >= this.rows ? sum - this.rows : sum;
|
|
69
|
+
}
|
|
70
|
+
/** Get the data array offset for the start of a logical row. */
|
|
71
|
+
rowStart(row) {
|
|
72
|
+
return this.physicalRow(row) * this.cols * CELL_SIZE;
|
|
73
|
+
}
|
|
74
|
+
/** Rotate the circular buffer up by n rows (for scroll-up). */
|
|
75
|
+
rotateUp(n = 1) {
|
|
76
|
+
const v = this.rowOffsetData[0] + (n % this.rows);
|
|
77
|
+
this.rowOffsetData[0] = v >= this.rows ? v - this.rows : v;
|
|
78
|
+
}
|
|
79
|
+
/** Rotate the circular buffer down by n rows (for scroll-down). */
|
|
80
|
+
rotateDown(n = 1) {
|
|
81
|
+
const v = this.rowOffsetData[0] - (n % this.rows);
|
|
82
|
+
this.rowOffsetData[0] = v < 0 ? v + this.rows : v;
|
|
83
|
+
}
|
|
84
|
+
getCodepoint(row, col) {
|
|
85
|
+
return this.data[this.rowStart(row) + col * CELL_SIZE] & 0x1fffff;
|
|
86
|
+
}
|
|
87
|
+
getFgIndex(row, col) {
|
|
88
|
+
return (this.data[this.rowStart(row) + col * CELL_SIZE] >>> 23) & 0xff;
|
|
89
|
+
}
|
|
90
|
+
getBgIndex(row, col) {
|
|
91
|
+
return this.data[this.rowStart(row) + col * CELL_SIZE + 1] & 0xff;
|
|
92
|
+
}
|
|
93
|
+
getAttrs(row, col) {
|
|
94
|
+
return (this.data[this.rowStart(row) + col * CELL_SIZE + 1] >>> 8) & 0xff;
|
|
95
|
+
}
|
|
96
|
+
isFgRGB(row, col) {
|
|
97
|
+
return (this.data[this.rowStart(row) + col * CELL_SIZE] & (1 << 21)) !== 0;
|
|
98
|
+
}
|
|
99
|
+
isBgRGB(row, col) {
|
|
100
|
+
return (this.data[this.rowStart(row) + col * CELL_SIZE] & (1 << 22)) !== 0;
|
|
101
|
+
}
|
|
102
|
+
isBold(row, col) {
|
|
103
|
+
return (this.data[this.rowStart(row) + col * CELL_SIZE + 1] & (1 << 8)) !== 0;
|
|
104
|
+
}
|
|
105
|
+
isItalic(row, col) {
|
|
106
|
+
return (this.data[this.rowStart(row) + col * CELL_SIZE + 1] & (1 << 9)) !== 0;
|
|
107
|
+
}
|
|
108
|
+
isUnderline(row, col) {
|
|
109
|
+
return (this.data[this.rowStart(row) + col * CELL_SIZE + 1] & (1 << 10)) !== 0;
|
|
110
|
+
}
|
|
111
|
+
isStrikethrough(row, col) {
|
|
112
|
+
return (this.data[this.rowStart(row) + col * CELL_SIZE + 1] & (1 << 11)) !== 0;
|
|
113
|
+
}
|
|
114
|
+
isInverse(row, col) {
|
|
115
|
+
return (this.data[this.rowStart(row) + col * CELL_SIZE + 1] & (1 << 14)) !== 0;
|
|
116
|
+
}
|
|
117
|
+
isWide(row, col) {
|
|
118
|
+
return (this.data[this.rowStart(row) + col * CELL_SIZE + 1] & (1 << 15)) !== 0;
|
|
119
|
+
}
|
|
120
|
+
setCell(row, col, codepoint, fgIndex, bgIndex, attrs, fgIsRGB = false, bgIsRGB = false) {
|
|
121
|
+
const idx = this.rowStart(row) + col * CELL_SIZE;
|
|
122
|
+
this.data[idx] =
|
|
123
|
+
(codepoint & 0x1fffff) |
|
|
124
|
+
(fgIsRGB ? 1 << 21 : 0) |
|
|
125
|
+
(bgIsRGB ? 1 << 22 : 0) |
|
|
126
|
+
((fgIndex & 0xff) << 23);
|
|
127
|
+
this.data[idx + 1] = (bgIndex & 0xff) | ((attrs & 0xff) << 8);
|
|
128
|
+
this.markDirty(row);
|
|
129
|
+
}
|
|
130
|
+
markDirty(row) {
|
|
131
|
+
if (this.isShared) {
|
|
132
|
+
Atomics.store(this.dirtyRows, row, 1);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
this.dirtyRows[row] = 1;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/** Mark a contiguous range of rows [from..to] dirty. */
|
|
139
|
+
markDirtyRange(from, to) {
|
|
140
|
+
// fill() is not atomic, but the trailing Atomics.store acts as a release
|
|
141
|
+
// fence. Render workers that miss a flag will catch it on the next frame.
|
|
142
|
+
this.dirtyRows.fill(1, from, to + 1);
|
|
143
|
+
if (this.isShared) {
|
|
144
|
+
Atomics.store(this.dirtyRows, to, 1);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
isDirty(row) {
|
|
148
|
+
if (this.isShared) {
|
|
149
|
+
return Atomics.load(this.dirtyRows, row) !== 0;
|
|
150
|
+
}
|
|
151
|
+
return this.dirtyRows[row] !== 0;
|
|
152
|
+
}
|
|
153
|
+
clearDirty(row) {
|
|
154
|
+
if (this.isShared) {
|
|
155
|
+
Atomics.store(this.dirtyRows, row, 0);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
this.dirtyRows[row] = 0;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
markAllDirty() {
|
|
162
|
+
this.dirtyRows.fill(1);
|
|
163
|
+
if (this.isShared) {
|
|
164
|
+
Atomics.store(this.dirtyRows, this.rows - 1, 1);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
clear() {
|
|
168
|
+
this.rowOffsetData[0] = 0;
|
|
169
|
+
for (let r = 0; r < this.rows; r++) {
|
|
170
|
+
this.data.set(this._templateRow, r * this.cols * CELL_SIZE);
|
|
171
|
+
}
|
|
172
|
+
this.markAllDirty();
|
|
173
|
+
}
|
|
174
|
+
/** Copy a logical row of cell data into a new Uint32Array. */
|
|
175
|
+
copyRow(row) {
|
|
176
|
+
const start = this.rowStart(row);
|
|
177
|
+
return new Uint32Array(this.data.slice(start, start + this.cols * CELL_SIZE));
|
|
178
|
+
}
|
|
179
|
+
/** Overwrite a logical row from a previously copied Uint32Array. */
|
|
180
|
+
pasteRow(row, src) {
|
|
181
|
+
const start = this.rowStart(row);
|
|
182
|
+
const rowLen = this.cols * CELL_SIZE;
|
|
183
|
+
if (src.length <= rowLen) {
|
|
184
|
+
this.data.set(src, start);
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
// Source row is wider than this grid — only copy what fits
|
|
188
|
+
this.data.set(src.subarray(0, rowLen), start);
|
|
189
|
+
}
|
|
190
|
+
this.markDirty(row);
|
|
191
|
+
}
|
|
192
|
+
/** Fill a logical row with spaces and default attributes. */
|
|
193
|
+
clearRow(row) {
|
|
194
|
+
const start = this.rowStart(row);
|
|
195
|
+
this.data.set(this._templateRow, start);
|
|
196
|
+
this.markDirty(row);
|
|
197
|
+
}
|
|
198
|
+
/** Fill a logical row with defaults without marking dirty (caller will batch-mark). */
|
|
199
|
+
clearRowRaw(row) {
|
|
200
|
+
this.data.set(this._templateRow, this.rowStart(row));
|
|
201
|
+
}
|
|
202
|
+
// ---- Cursor in SAB -------------------------------------------------------
|
|
203
|
+
/** Style string to Int32 encoding for cursorData[3]. */
|
|
204
|
+
static CURSOR_STYLE_MAP = {
|
|
205
|
+
block: 0,
|
|
206
|
+
underline: 1,
|
|
207
|
+
bar: 2,
|
|
208
|
+
};
|
|
209
|
+
static CURSOR_STYLE_REVERSE = ["block", "underline", "bar"];
|
|
210
|
+
/**
|
|
211
|
+
* Write cursor state into the SAB so render workers can read it atomically.
|
|
212
|
+
*/
|
|
213
|
+
setCursor(row, col, visible, style) {
|
|
214
|
+
if (this.isShared) {
|
|
215
|
+
Atomics.store(this.cursorData, 0, row);
|
|
216
|
+
Atomics.store(this.cursorData, 1, col);
|
|
217
|
+
Atomics.store(this.cursorData, 2, visible ? 1 : 0);
|
|
218
|
+
Atomics.store(this.cursorData, 3, CellGrid.CURSOR_STYLE_MAP[style] ?? 0);
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
this.cursorData[0] = row;
|
|
222
|
+
this.cursorData[1] = col;
|
|
223
|
+
this.cursorData[2] = visible ? 1 : 0;
|
|
224
|
+
this.cursorData[3] = CellGrid.CURSOR_STYLE_MAP[style] ?? 0;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Read cursor state from the SAB.
|
|
229
|
+
*/
|
|
230
|
+
getCursor() {
|
|
231
|
+
if (this.isShared) {
|
|
232
|
+
return {
|
|
233
|
+
row: Atomics.load(this.cursorData, 0),
|
|
234
|
+
col: Atomics.load(this.cursorData, 1),
|
|
235
|
+
visible: Atomics.load(this.cursorData, 2) !== 0,
|
|
236
|
+
style: CellGrid.CURSOR_STYLE_REVERSE[Atomics.load(this.cursorData, 3)] ?? "block",
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
return {
|
|
240
|
+
row: this.cursorData[0],
|
|
241
|
+
col: this.cursorData[1],
|
|
242
|
+
visible: this.cursorData[2] !== 0,
|
|
243
|
+
style: CellGrid.CURSOR_STYLE_REVERSE[this.cursorData[3]] ?? "block",
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
getBuffer() {
|
|
247
|
+
return this.buffer;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Normalize a selection so that start is before end.
|
|
252
|
+
*/
|
|
253
|
+
export function normalizeSelection(sel) {
|
|
254
|
+
let { startRow, startCol, endRow, endCol } = sel;
|
|
255
|
+
if (startRow > endRow || (startRow === endRow && startCol > endCol)) {
|
|
256
|
+
const tmpR = startRow;
|
|
257
|
+
const tmpC = startCol;
|
|
258
|
+
startRow = endRow;
|
|
259
|
+
startCol = endCol;
|
|
260
|
+
endRow = tmpR;
|
|
261
|
+
endCol = tmpC;
|
|
262
|
+
}
|
|
263
|
+
return { startRow, startCol, endRow, endCol };
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Extract text from a CellGrid for the given selection range.
|
|
267
|
+
*
|
|
268
|
+
* - Normalizes the selection (handles backwards selections).
|
|
269
|
+
* - Trims trailing spaces from each line.
|
|
270
|
+
* - Joins lines with `\n`.
|
|
271
|
+
*/
|
|
272
|
+
export function extractText(grid, startRow, startCol, endRow, endCol) {
|
|
273
|
+
const sel = normalizeSelection({ startRow, startCol, endRow, endCol });
|
|
274
|
+
const sr = Math.max(0, sel.startRow);
|
|
275
|
+
const er = Math.min(grid.rows - 1, sel.endRow);
|
|
276
|
+
const lines = [];
|
|
277
|
+
for (let row = sr; row <= er; row++) {
|
|
278
|
+
let colStart = 0;
|
|
279
|
+
let colEnd = grid.cols - 1;
|
|
280
|
+
if (row === sr)
|
|
281
|
+
colStart = Math.max(0, sel.startCol);
|
|
282
|
+
if (row === er)
|
|
283
|
+
colEnd = Math.min(grid.cols - 1, sel.endCol);
|
|
284
|
+
let line = "";
|
|
285
|
+
for (let col = colStart; col <= colEnd; col++) {
|
|
286
|
+
const cp = grid.getCodepoint(row, col);
|
|
287
|
+
line += cp > 0x20 ? String.fromCodePoint(cp) : " ";
|
|
288
|
+
}
|
|
289
|
+
// Trim trailing spaces
|
|
290
|
+
lines.push(line.replace(/\s+$/, ""));
|
|
291
|
+
}
|
|
292
|
+
return lines.join("\n");
|
|
293
|
+
}
|
|
294
|
+
//# sourceMappingURL=cell-grid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cell-grid.js","sourceRoot":"","sources":["../src/cell-grid.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,MAAM,aAAa,GACjB,OAAO,iBAAiB,KAAK,WAAW;IACxC,CAAC,OAAO,mBAAmB,KAAK,WAAW,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAE5E,oCAAoC;AACpC,yFAAyF;AACzF,oFAAoF;AACpF,6EAA6E;AAE7E,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,CAAC,sBAAsB;AAElD,mEAAmE;AACnE,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AAChD,sDAAsD;AACtD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC;AAEjC,mFAAmF;AACnF,MAAM,UAAU,WAAW,CAAC,KAAa,EAAE,MAAc;IACvD,OAAO,CAAC,CAAC,KAAK,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC;AAC9C,CAAC;AAED,MAAM,OAAO,QAAQ;IACV,IAAI,CAAS;IACb,IAAI,CAAS;IACb,IAAI,CAAc;IAClB,SAAS,CAAa;IACtB,SAAS,CAAc;IACf,MAAM,CAAkC;IAChD,QAAQ,CAAU;IACV,YAAY,CAAc;IAE3C;;;;OAIG;IACM,UAAU,CAAa;IAEhC;;;;OAIG;IACM,aAAa,CAAa;IAEnC,YAAY,IAAY,EAAE,IAAY;QACp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