@opentui/core 0.5.9 → 0.5.11
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/README.md +2 -0
- package/audio.d.ts +6 -1
- package/{chunk-bun-b0662dgp.js → chunk-bun-37s3zwb6.js} +1216 -1038
- package/{chunk-bun-b0662dgp.js.map → chunk-bun-37s3zwb6.js.map} +7 -7
- package/{chunk-bun-jxfx3h5k.js → chunk-bun-bwjmgnxw.js} +773 -621
- package/chunk-bun-bwjmgnxw.js.map +32 -0
- package/{chunk-node-dcyj0dm5.js → chunk-node-54dhb2fr.js} +773 -621
- package/chunk-node-54dhb2fr.js.map +32 -0
- package/{chunk-node-zcz10bhr.js → chunk-node-70eg2nhg.js} +1223 -1042
- package/chunk-node-70eg2nhg.js.map +63 -0
- package/image.d.ts +25 -1
- package/index.bun.js +1642 -1374
- package/index.bun.js.map +8 -8
- package/index.node.js +1642 -1374
- package/index.node.js.map +8 -8
- package/lib/detect-links.d.ts +5 -0
- package/lib/tree-sitter/update-assets.js +4 -4
- package/lib/tree-sitter/update-assets.js.map +2 -2
- package/lib/tree-sitter-styled-text.d.ts +4 -0
- package/package.json +13 -9
- package/parser.worker.js +7 -10
- package/parser.worker.js.map +2 -2
- package/renderables/Code.d.ts +6 -0
- package/renderables/Diff.d.ts +1 -2
- package/renderables/Markdown.d.ts +6 -0
- package/renderables/TextBufferRenderable.d.ts +2 -0
- package/renderer.d.ts +23 -2
- package/testing.bun.js +23 -23
- package/testing.bun.js.map +2 -2
- package/testing.js +23 -23
- package/testing.js.map +2 -2
- package/text-buffer-view.d.ts +1 -0
- package/types.d.ts +1 -0
- package/yoga.bun.js +187 -187
- package/yoga.bun.js.map +1 -1
- package/yoga.js +187 -187
- package/yoga.js.map +1 -1
- package/zig-structs.d.ts +8 -1
- package/zig.d.ts +15 -1
- package/chunk-bun-jxfx3h5k.js.map +0 -32
- package/chunk-node-dcyj0dm5.js.map +0 -32
- package/chunk-node-zcz10bhr.js.map +0 -63
|
@@ -1,47 +1,243 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
InternalKeyHandler,
|
|
5
|
-
KeyHandler,
|
|
6
|
-
NativeMeasureTargetKind,
|
|
7
|
-
OptimizedBuffer,
|
|
8
|
-
RGBA,
|
|
9
|
-
Selection,
|
|
10
|
-
SpanInfoStruct,
|
|
11
|
-
StdinParser,
|
|
12
|
-
StyledText,
|
|
13
|
-
SystemClock,
|
|
14
|
-
TextBuffer,
|
|
15
|
-
borderCharsToArray,
|
|
16
|
-
buildTerminalPaletteSignature,
|
|
17
|
-
convertGlobalToLocalSelection,
|
|
18
|
-
createExtmarksController,
|
|
19
|
-
createTerminalPalette,
|
|
20
|
-
createTextAttributes,
|
|
21
|
-
destroyTreeSitterClient,
|
|
22
|
-
env,
|
|
23
|
-
getBorderSides,
|
|
24
|
-
getTreeSitterClient,
|
|
25
|
-
isStyledText,
|
|
26
|
-
normalizeTerminalPalette,
|
|
27
|
-
parseAlign,
|
|
28
|
-
parseAlignItems,
|
|
29
|
-
parseBorderStyle,
|
|
30
|
-
parseColor,
|
|
31
|
-
parseFlexDirection,
|
|
32
|
-
parseJustify,
|
|
33
|
-
parseOverflow,
|
|
34
|
-
parsePositionType,
|
|
35
|
-
parseWrap,
|
|
36
|
-
registerEnvVar,
|
|
37
|
-
resolveRenderLib,
|
|
3
|
+
toArrayBuffer,
|
|
38
4
|
singleton,
|
|
5
|
+
registerEnvVar2,
|
|
6
|
+
env2,
|
|
39
7
|
sleep,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
8
|
+
RGBA2,
|
|
9
|
+
parseColor2,
|
|
10
|
+
parseBorderStyle2,
|
|
11
|
+
getBorderSides2,
|
|
12
|
+
borderCharsToArray2,
|
|
13
|
+
KeyHandler2,
|
|
14
|
+
InternalKeyHandler2,
|
|
15
|
+
createTextAttributes2,
|
|
16
|
+
getLinkId2,
|
|
17
|
+
isStyledText2,
|
|
18
|
+
StyledText2,
|
|
19
|
+
stringToStyledText2,
|
|
20
|
+
SystemClock2,
|
|
21
|
+
parseAlign2,
|
|
22
|
+
parseAlignItems2,
|
|
23
|
+
parseFlexDirection2,
|
|
24
|
+
parseJustify2,
|
|
25
|
+
parseOverflow2,
|
|
26
|
+
parsePositionType2,
|
|
27
|
+
parseWrap2,
|
|
28
|
+
Selection2,
|
|
29
|
+
convertGlobalToLocalSelection2,
|
|
30
|
+
StdinParser2,
|
|
31
|
+
treeSitterToTextChunks2,
|
|
32
|
+
getTreeSitterClient2,
|
|
33
|
+
destroyTreeSitterClient2,
|
|
34
|
+
createExtmarksController2,
|
|
35
|
+
createTerminalPalette2,
|
|
36
|
+
normalizeTerminalPalette2,
|
|
37
|
+
buildTerminalPaletteSignature2,
|
|
38
|
+
Clipboard2,
|
|
39
|
+
OptimizedBuffer2,
|
|
40
|
+
TextBuffer2,
|
|
41
|
+
SpanInfoStruct,
|
|
42
|
+
NativeMeasureTargetKind2,
|
|
43
|
+
resolveRenderLib2,
|
|
43
44
|
yoga_default
|
|
44
|
-
} from "./chunk-bun-
|
|
45
|
+
} from "./chunk-bun-37s3zwb6.js";
|
|
46
|
+
|
|
47
|
+
// src/syntax-style.ts
|
|
48
|
+
function convertThemeToStyles2(theme) {
|
|
49
|
+
const flatStyles = {};
|
|
50
|
+
for (const tokenStyle of theme) {
|
|
51
|
+
const styleDefinition = {};
|
|
52
|
+
if (tokenStyle.style.foreground) {
|
|
53
|
+
styleDefinition.fg = parseColor2(tokenStyle.style.foreground);
|
|
54
|
+
}
|
|
55
|
+
if (tokenStyle.style.background) {
|
|
56
|
+
styleDefinition.bg = parseColor2(tokenStyle.style.background);
|
|
57
|
+
}
|
|
58
|
+
if (tokenStyle.style.bold !== undefined) {
|
|
59
|
+
styleDefinition.bold = tokenStyle.style.bold;
|
|
60
|
+
}
|
|
61
|
+
if (tokenStyle.style.italic !== undefined) {
|
|
62
|
+
styleDefinition.italic = tokenStyle.style.italic;
|
|
63
|
+
}
|
|
64
|
+
if (tokenStyle.style.underline !== undefined) {
|
|
65
|
+
styleDefinition.underline = tokenStyle.style.underline;
|
|
66
|
+
}
|
|
67
|
+
if (tokenStyle.style.dim !== undefined) {
|
|
68
|
+
styleDefinition.dim = tokenStyle.style.dim;
|
|
69
|
+
}
|
|
70
|
+
for (const scope of tokenStyle.scope) {
|
|
71
|
+
flatStyles[scope] = styleDefinition;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return flatStyles;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
class SyntaxStyle2 {
|
|
78
|
+
lib;
|
|
79
|
+
stylePtr;
|
|
80
|
+
_destroyed = false;
|
|
81
|
+
nameCache = new Map;
|
|
82
|
+
styleDefs = new Map;
|
|
83
|
+
mergedCache = new Map;
|
|
84
|
+
constructor(lib, ptr) {
|
|
85
|
+
this.lib = lib;
|
|
86
|
+
this.stylePtr = ptr;
|
|
87
|
+
}
|
|
88
|
+
static create() {
|
|
89
|
+
const lib = resolveRenderLib2();
|
|
90
|
+
const ptr = lib.createSyntaxStyle();
|
|
91
|
+
return new SyntaxStyle2(lib, ptr);
|
|
92
|
+
}
|
|
93
|
+
static fromTheme(theme) {
|
|
94
|
+
const style = SyntaxStyle2.create();
|
|
95
|
+
const flatStyles = convertThemeToStyles2(theme);
|
|
96
|
+
for (const [name, styleDef] of Object.entries(flatStyles)) {
|
|
97
|
+
style.registerStyle(name, styleDef);
|
|
98
|
+
}
|
|
99
|
+
return style;
|
|
100
|
+
}
|
|
101
|
+
static fromStyles(styles) {
|
|
102
|
+
const style = SyntaxStyle2.create();
|
|
103
|
+
for (const [name, styleDef] of Object.entries(styles)) {
|
|
104
|
+
style.registerStyle(name, styleDef);
|
|
105
|
+
}
|
|
106
|
+
return style;
|
|
107
|
+
}
|
|
108
|
+
guard() {
|
|
109
|
+
if (this._destroyed)
|
|
110
|
+
throw new Error("NativeSyntaxStyle is destroyed");
|
|
111
|
+
}
|
|
112
|
+
registerStyle(name, style) {
|
|
113
|
+
this.guard();
|
|
114
|
+
const attributes = createTextAttributes2({
|
|
115
|
+
bold: style.bold,
|
|
116
|
+
italic: style.italic,
|
|
117
|
+
underline: style.underline,
|
|
118
|
+
dim: style.dim
|
|
119
|
+
});
|
|
120
|
+
const fg = style.fg ? parseColor2(style.fg) : null;
|
|
121
|
+
const bg = style.bg ? parseColor2(style.bg) : null;
|
|
122
|
+
const id = this.lib.syntaxStyleRegister(this.stylePtr, name, fg, bg, attributes);
|
|
123
|
+
this.nameCache.set(name, id);
|
|
124
|
+
this.styleDefs.set(name, { ...style, fg: fg ?? undefined, bg: bg ?? undefined });
|
|
125
|
+
return id;
|
|
126
|
+
}
|
|
127
|
+
resolveStyleId(name) {
|
|
128
|
+
this.guard();
|
|
129
|
+
const cached = this.nameCache.get(name);
|
|
130
|
+
if (cached !== undefined)
|
|
131
|
+
return cached;
|
|
132
|
+
const id = this.lib.syntaxStyleResolveByName(this.stylePtr, name);
|
|
133
|
+
if (id !== null) {
|
|
134
|
+
this.nameCache.set(name, id);
|
|
135
|
+
}
|
|
136
|
+
return id;
|
|
137
|
+
}
|
|
138
|
+
getStyleId(name) {
|
|
139
|
+
this.guard();
|
|
140
|
+
const id = this.resolveStyleId(name);
|
|
141
|
+
if (id !== null)
|
|
142
|
+
return id;
|
|
143
|
+
if (name.includes(".")) {
|
|
144
|
+
const baseName = name.split(".")[0];
|
|
145
|
+
return this.resolveStyleId(baseName);
|
|
146
|
+
}
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
get ptr() {
|
|
150
|
+
this.guard();
|
|
151
|
+
return this.stylePtr;
|
|
152
|
+
}
|
|
153
|
+
getStyleCount() {
|
|
154
|
+
this.guard();
|
|
155
|
+
return this.lib.syntaxStyleGetStyleCount(this.stylePtr);
|
|
156
|
+
}
|
|
157
|
+
clearNameCache() {
|
|
158
|
+
this.nameCache.clear();
|
|
159
|
+
}
|
|
160
|
+
getStyle(name) {
|
|
161
|
+
this.guard();
|
|
162
|
+
if (Object.prototype.hasOwnProperty.call(this.styleDefs, name)) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const style = this.styleDefs.get(name);
|
|
166
|
+
if (style)
|
|
167
|
+
return style;
|
|
168
|
+
if (name.includes(".")) {
|
|
169
|
+
const baseName = name.split(".")[0];
|
|
170
|
+
if (Object.prototype.hasOwnProperty.call(this.styleDefs, baseName)) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
return this.styleDefs.get(baseName);
|
|
174
|
+
}
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
mergeStyles(...styleNames) {
|
|
178
|
+
this.guard();
|
|
179
|
+
const cacheKey = styleNames.join(":");
|
|
180
|
+
const cached = this.mergedCache.get(cacheKey);
|
|
181
|
+
if (cached)
|
|
182
|
+
return cached;
|
|
183
|
+
const styleDefinition = {};
|
|
184
|
+
for (const name of styleNames) {
|
|
185
|
+
const style = this.getStyle(name);
|
|
186
|
+
if (!style)
|
|
187
|
+
continue;
|
|
188
|
+
if (style.fg)
|
|
189
|
+
styleDefinition.fg = style.fg;
|
|
190
|
+
if (style.bg)
|
|
191
|
+
styleDefinition.bg = style.bg;
|
|
192
|
+
if (style.bold !== undefined)
|
|
193
|
+
styleDefinition.bold = style.bold;
|
|
194
|
+
if (style.italic !== undefined)
|
|
195
|
+
styleDefinition.italic = style.italic;
|
|
196
|
+
if (style.underline !== undefined)
|
|
197
|
+
styleDefinition.underline = style.underline;
|
|
198
|
+
if (style.dim !== undefined)
|
|
199
|
+
styleDefinition.dim = style.dim;
|
|
200
|
+
}
|
|
201
|
+
const attributes = createTextAttributes2({
|
|
202
|
+
bold: styleDefinition.bold,
|
|
203
|
+
italic: styleDefinition.italic,
|
|
204
|
+
underline: styleDefinition.underline,
|
|
205
|
+
dim: styleDefinition.dim
|
|
206
|
+
});
|
|
207
|
+
const merged = {
|
|
208
|
+
fg: styleDefinition.fg,
|
|
209
|
+
bg: styleDefinition.bg,
|
|
210
|
+
attributes
|
|
211
|
+
};
|
|
212
|
+
this.mergedCache.set(cacheKey, merged);
|
|
213
|
+
return merged;
|
|
214
|
+
}
|
|
215
|
+
clearCache() {
|
|
216
|
+
this.guard();
|
|
217
|
+
this.mergedCache.clear();
|
|
218
|
+
}
|
|
219
|
+
getCacheSize() {
|
|
220
|
+
this.guard();
|
|
221
|
+
return this.mergedCache.size;
|
|
222
|
+
}
|
|
223
|
+
getAllStyles() {
|
|
224
|
+
this.guard();
|
|
225
|
+
return new Map(this.styleDefs);
|
|
226
|
+
}
|
|
227
|
+
getRegisteredNames() {
|
|
228
|
+
this.guard();
|
|
229
|
+
return Array.from(this.styleDefs.keys());
|
|
230
|
+
}
|
|
231
|
+
destroy() {
|
|
232
|
+
if (this._destroyed)
|
|
233
|
+
return;
|
|
234
|
+
this._destroyed = true;
|
|
235
|
+
this.nameCache.clear();
|
|
236
|
+
this.styleDefs.clear();
|
|
237
|
+
this.mergedCache.clear();
|
|
238
|
+
this.lib.destroySyntaxStyle(this.stylePtr);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
45
241
|
|
|
46
242
|
// src/Renderable.ts
|
|
47
243
|
import { EventEmitter } from "events";
|
|
@@ -121,22 +317,22 @@ function isSizeType(value) {
|
|
|
121
317
|
|
|
122
318
|
// src/Renderable.ts
|
|
123
319
|
var BrandedRenderable = Symbol.for("@opentui/core/Renderable");
|
|
124
|
-
var
|
|
125
|
-
((
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
})(
|
|
129
|
-
var
|
|
130
|
-
((
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
})(
|
|
135
|
-
function
|
|
320
|
+
var LayoutEvents2;
|
|
321
|
+
((LayoutEvents) => {
|
|
322
|
+
LayoutEvents["LAYOUT_CHANGED"] = "layout-changed";
|
|
323
|
+
LayoutEvents["RESIZED"] = "resized";
|
|
324
|
+
})(LayoutEvents2 ||= {});
|
|
325
|
+
var RenderableEvents2;
|
|
326
|
+
((RenderableEvents) => {
|
|
327
|
+
RenderableEvents["FOCUSED"] = "focused";
|
|
328
|
+
RenderableEvents["BLURRED"] = "blurred";
|
|
329
|
+
RenderableEvents["DESTROYED"] = "destroyed";
|
|
330
|
+
})(RenderableEvents2 ||= {});
|
|
331
|
+
function isRenderable2(obj) {
|
|
136
332
|
return !!obj?.[BrandedRenderable];
|
|
137
333
|
}
|
|
138
334
|
|
|
139
|
-
class
|
|
335
|
+
class BaseRenderable2 extends EventEmitter {
|
|
140
336
|
[BrandedRenderable] = true;
|
|
141
337
|
static renderableNumber = 1;
|
|
142
338
|
_id;
|
|
@@ -146,7 +342,7 @@ class BaseRenderable extends EventEmitter {
|
|
|
146
342
|
_visible = true;
|
|
147
343
|
constructor(options) {
|
|
148
344
|
super();
|
|
149
|
-
this.num =
|
|
345
|
+
this.num = BaseRenderable2.renderableNumber++;
|
|
150
346
|
this._id = options.id ?? `renderable-${this.num}`;
|
|
151
347
|
}
|
|
152
348
|
get id() {
|
|
@@ -190,7 +386,7 @@ function bumpRenderListRevision(ctx) {
|
|
|
190
386
|
generationContext.__otuiRenderListRevision = getRenderListRevision(ctx) + 1;
|
|
191
387
|
}
|
|
192
388
|
|
|
193
|
-
class
|
|
389
|
+
class Renderable2 extends BaseRenderable2 {
|
|
194
390
|
static renderablesByNumber = new Map;
|
|
195
391
|
_isDestroyed = false;
|
|
196
392
|
_ctx;
|
|
@@ -240,7 +436,7 @@ class Renderable extends BaseRenderable {
|
|
|
240
436
|
constructor(ctx, options) {
|
|
241
437
|
super(options);
|
|
242
438
|
this._ctx = ctx;
|
|
243
|
-
|
|
439
|
+
Renderable2.renderablesByNumber.set(this.num, this);
|
|
244
440
|
validateOptions(this.id, options);
|
|
245
441
|
this.renderBefore = options.renderBefore;
|
|
246
442
|
this.renderAfter = options.renderAfter;
|
|
@@ -412,7 +608,7 @@ class Renderable extends BaseRenderable {
|
|
|
412
608
|
for (const child of this._childrenInLayoutOrder) {
|
|
413
609
|
if (child.id === id)
|
|
414
610
|
return child;
|
|
415
|
-
if (
|
|
611
|
+
if (isRenderable2(child)) {
|
|
416
612
|
const found = child.findDescendantById(id);
|
|
417
613
|
if (found)
|
|
418
614
|
return found;
|
|
@@ -601,11 +797,11 @@ class Renderable extends BaseRenderable {
|
|
|
601
797
|
this._flexShrink = hasExplicitWidth || hasExplicitHeight ? 0 : 1;
|
|
602
798
|
node.setFlexShrink(this._flexShrink);
|
|
603
799
|
}
|
|
604
|
-
node.setFlexDirection(
|
|
605
|
-
node.setFlexWrap(
|
|
606
|
-
node.setAlignItems(
|
|
607
|
-
node.setJustifyContent(
|
|
608
|
-
node.setAlignSelf(
|
|
800
|
+
node.setFlexDirection(parseFlexDirection2(options.flexDirection));
|
|
801
|
+
node.setFlexWrap(parseWrap2(options.flexWrap));
|
|
802
|
+
node.setAlignItems(parseAlignItems2(options.alignItems));
|
|
803
|
+
node.setJustifyContent(parseJustify2(options.justifyContent));
|
|
804
|
+
node.setAlignSelf(parseAlign2(options.alignSelf));
|
|
609
805
|
if (isDimensionType(options.width)) {
|
|
610
806
|
this._width = options.width;
|
|
611
807
|
this.yogaNode.setWidth(options.width);
|
|
@@ -616,11 +812,11 @@ class Renderable extends BaseRenderable {
|
|
|
616
812
|
}
|
|
617
813
|
this._positionType = options.position === "absolute" ? "absolute" : "relative";
|
|
618
814
|
if (this._positionType !== "relative") {
|
|
619
|
-
node.setPositionType(
|
|
815
|
+
node.setPositionType(parsePositionType2(this._positionType));
|
|
620
816
|
}
|
|
621
817
|
this._overflow = options.overflow === "hidden" ? "hidden" : options.overflow === "scroll" ? "scroll" : "visible";
|
|
622
818
|
if (this._overflow !== "visible") {
|
|
623
|
-
node.setOverflow(
|
|
819
|
+
node.setOverflow(parseOverflow2(this._overflow));
|
|
624
820
|
}
|
|
625
821
|
const hasPositionProps = options.top !== undefined || options.right !== undefined || options.bottom !== undefined || options.left !== undefined;
|
|
626
822
|
if (hasPositionProps) {
|
|
@@ -689,7 +885,7 @@ class Renderable extends BaseRenderable {
|
|
|
689
885
|
if (!isPositionTypeType(positionType) || this._positionType === positionType)
|
|
690
886
|
return;
|
|
691
887
|
this._positionType = positionType;
|
|
692
|
-
this.yogaNode.setPositionType(
|
|
888
|
+
this.yogaNode.setPositionType(parsePositionType2(positionType));
|
|
693
889
|
this.requestRender();
|
|
694
890
|
}
|
|
695
891
|
get overflow() {
|
|
@@ -699,7 +895,7 @@ class Renderable extends BaseRenderable {
|
|
|
699
895
|
if (!isOverflowType(overflow) || this._overflow === overflow)
|
|
700
896
|
return;
|
|
701
897
|
this._overflow = overflow;
|
|
702
|
-
this.yogaNode.setOverflow(
|
|
898
|
+
this.yogaNode.setOverflow(parseOverflow2(overflow));
|
|
703
899
|
bumpRenderListRevision(this._ctx);
|
|
704
900
|
this.requestRender();
|
|
705
901
|
}
|
|
@@ -755,23 +951,23 @@ class Renderable extends BaseRenderable {
|
|
|
755
951
|
this.requestRender();
|
|
756
952
|
}
|
|
757
953
|
set flexDirection(direction) {
|
|
758
|
-
this.yogaNode.setFlexDirection(
|
|
954
|
+
this.yogaNode.setFlexDirection(parseFlexDirection2(direction));
|
|
759
955
|
this.requestRender();
|
|
760
956
|
}
|
|
761
957
|
set flexWrap(wrap) {
|
|
762
|
-
this.yogaNode.setFlexWrap(
|
|
958
|
+
this.yogaNode.setFlexWrap(parseWrap2(wrap));
|
|
763
959
|
this.requestRender();
|
|
764
960
|
}
|
|
765
961
|
set alignItems(alignItems) {
|
|
766
|
-
this.yogaNode.setAlignItems(
|
|
962
|
+
this.yogaNode.setAlignItems(parseAlignItems2(alignItems));
|
|
767
963
|
this.requestRender();
|
|
768
964
|
}
|
|
769
965
|
set justifyContent(justifyContent) {
|
|
770
|
-
this.yogaNode.setJustifyContent(
|
|
966
|
+
this.yogaNode.setJustifyContent(parseJustify2(justifyContent));
|
|
771
967
|
this.requestRender();
|
|
772
968
|
}
|
|
773
969
|
set alignSelf(alignSelf) {
|
|
774
|
-
this.yogaNode.setAlignSelf(
|
|
970
|
+
this.yogaNode.setAlignSelf(parseAlign2(alignSelf));
|
|
775
971
|
this.requestRender();
|
|
776
972
|
}
|
|
777
973
|
set flexBasis(basis) {
|
|
@@ -956,7 +1152,7 @@ class Renderable extends BaseRenderable {
|
|
|
956
1152
|
}
|
|
957
1153
|
try {
|
|
958
1154
|
const widthMethod = this._ctx.widthMethod;
|
|
959
|
-
this.frameBuffer =
|
|
1155
|
+
this.frameBuffer = OptimizedBuffer2.create(w, h, widthMethod, {
|
|
960
1156
|
respectAlpha: true,
|
|
961
1157
|
id: `framebuffer-${this.id}`
|
|
962
1158
|
});
|
|
@@ -979,7 +1175,7 @@ class Renderable extends BaseRenderable {
|
|
|
979
1175
|
if (!obj) {
|
|
980
1176
|
return -1;
|
|
981
1177
|
}
|
|
982
|
-
const renderable =
|
|
1178
|
+
const renderable = maybeMakeRenderable2(this._ctx, obj);
|
|
983
1179
|
if (!renderable) {
|
|
984
1180
|
return -1;
|
|
985
1181
|
}
|
|
@@ -1024,7 +1220,7 @@ class Renderable extends BaseRenderable {
|
|
|
1024
1220
|
if (!obj) {
|
|
1025
1221
|
return -1;
|
|
1026
1222
|
}
|
|
1027
|
-
const renderable =
|
|
1223
|
+
const renderable = maybeMakeRenderable2(this._ctx, obj);
|
|
1028
1224
|
if (!renderable) {
|
|
1029
1225
|
return -1;
|
|
1030
1226
|
}
|
|
@@ -1034,7 +1230,7 @@ class Renderable extends BaseRenderable {
|
|
|
1034
1230
|
}
|
|
1035
1231
|
return -1;
|
|
1036
1232
|
}
|
|
1037
|
-
if (!
|
|
1233
|
+
if (!isRenderable2(anchor)) {
|
|
1038
1234
|
throw new Error("Anchor must be a Renderable");
|
|
1039
1235
|
}
|
|
1040
1236
|
if (anchor.isDestroyed) {
|
|
@@ -1083,7 +1279,7 @@ class Renderable extends BaseRenderable {
|
|
|
1083
1279
|
return this._childrenInLayoutOrder.find((child) => child.id === id);
|
|
1084
1280
|
}
|
|
1085
1281
|
remove(child) {
|
|
1086
|
-
if (!(child instanceof
|
|
1282
|
+
if (!(child instanceof BaseRenderable2)) {
|
|
1087
1283
|
throw new Error("remove expects a renderable child object");
|
|
1088
1284
|
}
|
|
1089
1285
|
const index = this._childrenInLayoutOrder.indexOf(child);
|
|
@@ -1200,13 +1396,13 @@ class Renderable extends BaseRenderable {
|
|
|
1200
1396
|
}
|
|
1201
1397
|
}
|
|
1202
1398
|
_hasVisibleChildFilter() {
|
|
1203
|
-
return this._getVisibleChildren !==
|
|
1399
|
+
return this._getVisibleChildren !== Renderable2.prototype._getVisibleChildren;
|
|
1204
1400
|
}
|
|
1205
1401
|
_getVisibleChildren() {
|
|
1206
1402
|
return this._childrenInZIndexOrder.map((child) => child.num);
|
|
1207
1403
|
}
|
|
1208
1404
|
canReuseRenderCommandList() {
|
|
1209
|
-
return this.onUpdate ===
|
|
1405
|
+
return this.onUpdate === Renderable2.prototype.onUpdate && (this._overflow === "visible" || this.getScissorRect === Renderable2.prototype.getScissorRect) && !this._hasVisibleChildFilter();
|
|
1210
1406
|
}
|
|
1211
1407
|
onUpdate(deltaTime) {}
|
|
1212
1408
|
getScissorRect() {
|
|
@@ -1240,7 +1436,7 @@ class Renderable extends BaseRenderable {
|
|
|
1240
1436
|
this._childrenInLayoutOrder = [];
|
|
1241
1437
|
this._childrenInZIndexOrder = [];
|
|
1242
1438
|
this._shouldUpdateBefore.clear();
|
|
1243
|
-
|
|
1439
|
+
Renderable2.renderablesByNumber.delete(this.num);
|
|
1244
1440
|
this.blur();
|
|
1245
1441
|
this.removeAllListeners();
|
|
1246
1442
|
this.destroySelf();
|
|
@@ -1364,7 +1560,7 @@ class Renderable extends BaseRenderable {
|
|
|
1364
1560
|
}
|
|
1365
1561
|
}
|
|
1366
1562
|
|
|
1367
|
-
class
|
|
1563
|
+
class RootRenderable2 extends Renderable2 {
|
|
1368
1564
|
renderList = [];
|
|
1369
1565
|
_currentRenderable;
|
|
1370
1566
|
appliedLayoutGeneration = -1;
|
|
@@ -1491,7 +1687,7 @@ class RootRenderable extends Renderable {
|
|
|
1491
1687
|
import util from "util";
|
|
1492
1688
|
var BrandedVNode = Symbol.for("@opentui/core/VNode");
|
|
1493
1689
|
function isRenderableConstructor(value) {
|
|
1494
|
-
return typeof value === "function" && value.prototype &&
|
|
1690
|
+
return typeof value === "function" && value.prototype && Renderable2.prototype.isPrototypeOf(value.prototype);
|
|
1495
1691
|
}
|
|
1496
1692
|
function flattenChildren(children) {
|
|
1497
1693
|
const result = [];
|
|
@@ -1504,7 +1700,7 @@ function flattenChildren(children) {
|
|
|
1504
1700
|
}
|
|
1505
1701
|
return result;
|
|
1506
1702
|
}
|
|
1507
|
-
function
|
|
1703
|
+
function h2(type, props, ...children) {
|
|
1508
1704
|
if (typeof type !== "function") {
|
|
1509
1705
|
throw new TypeError("h() received an invalid vnode type");
|
|
1510
1706
|
}
|
|
@@ -1550,20 +1746,20 @@ function h(type, props, ...children) {
|
|
|
1550
1746
|
}
|
|
1551
1747
|
return vnode;
|
|
1552
1748
|
}
|
|
1553
|
-
function
|
|
1749
|
+
function isVNode2(node) {
|
|
1554
1750
|
return node && node[BrandedVNode];
|
|
1555
1751
|
}
|
|
1556
|
-
function
|
|
1557
|
-
if (
|
|
1752
|
+
function maybeMakeRenderable2(ctx, node) {
|
|
1753
|
+
if (isRenderable2(node))
|
|
1558
1754
|
return node;
|
|
1559
|
-
if (
|
|
1560
|
-
return
|
|
1755
|
+
if (isVNode2(node))
|
|
1756
|
+
return instantiate2(ctx, node);
|
|
1561
1757
|
if (true) {
|
|
1562
1758
|
console.warn("maybeMakeRenderable received an invalid node", util.inspect(node, { depth: 2 }));
|
|
1563
1759
|
}
|
|
1564
1760
|
return null;
|
|
1565
1761
|
}
|
|
1566
|
-
function
|
|
1762
|
+
function wrapWithDelegates2(instance, delegateMap) {
|
|
1567
1763
|
if (!delegateMap || Object.keys(delegateMap).length === 0)
|
|
1568
1764
|
return instance;
|
|
1569
1765
|
const getDescendant = (id) => {
|
|
@@ -1595,8 +1791,8 @@ function wrapWithDelegates(instance, delegateMap) {
|
|
|
1595
1791
|
});
|
|
1596
1792
|
return proxy;
|
|
1597
1793
|
}
|
|
1598
|
-
function
|
|
1599
|
-
if (
|
|
1794
|
+
function instantiate2(ctx, node) {
|
|
1795
|
+
if (isRenderable2(node))
|
|
1600
1796
|
return node;
|
|
1601
1797
|
if (!node || typeof node !== "object") {
|
|
1602
1798
|
throw new TypeError("mount() received an invalid vnode");
|
|
@@ -1608,14 +1804,14 @@ function instantiate(ctx, node) {
|
|
|
1608
1804
|
if (isRenderableConstructor(type)) {
|
|
1609
1805
|
const instance = new type(ctx, props || {});
|
|
1610
1806
|
for (const child of children) {
|
|
1611
|
-
if (
|
|
1807
|
+
if (isRenderable2(child)) {
|
|
1612
1808
|
instance.add(child);
|
|
1613
1809
|
} else {
|
|
1614
|
-
const mounted =
|
|
1810
|
+
const mounted = instantiate2(ctx, child);
|
|
1615
1811
|
instance.add(mounted);
|
|
1616
1812
|
}
|
|
1617
1813
|
}
|
|
1618
|
-
const delegatedInstance =
|
|
1814
|
+
const delegatedInstance = wrapWithDelegates2(instance, delegateMap);
|
|
1619
1815
|
const pendingCalls = vnode.__pendingCalls;
|
|
1620
1816
|
if (pendingCalls) {
|
|
1621
1817
|
for (const call of pendingCalls) {
|
|
@@ -1629,12 +1825,12 @@ function instantiate(ctx, node) {
|
|
|
1629
1825
|
return delegatedInstance;
|
|
1630
1826
|
}
|
|
1631
1827
|
const resolved = type(props || {}, children);
|
|
1632
|
-
const inst =
|
|
1633
|
-
return
|
|
1828
|
+
const inst = instantiate2(ctx, resolved);
|
|
1829
|
+
return wrapWithDelegates2(inst, delegateMap);
|
|
1634
1830
|
}
|
|
1635
|
-
function
|
|
1636
|
-
if (
|
|
1637
|
-
return
|
|
1831
|
+
function delegate2(mapping, vnode) {
|
|
1832
|
+
if (isRenderable2(vnode)) {
|
|
1833
|
+
return wrapWithDelegates2(vnode, mapping);
|
|
1638
1834
|
}
|
|
1639
1835
|
if (!vnode || typeof vnode !== "object")
|
|
1640
1836
|
return vnode;
|
|
@@ -1643,7 +1839,7 @@ function delegate(mapping, vnode) {
|
|
|
1643
1839
|
}
|
|
1644
1840
|
|
|
1645
1841
|
// src/text-buffer-view.ts
|
|
1646
|
-
class
|
|
1842
|
+
class TextBufferView2 {
|
|
1647
1843
|
lib;
|
|
1648
1844
|
viewPtr;
|
|
1649
1845
|
textBuffer;
|
|
@@ -1654,9 +1850,9 @@ class TextBufferView {
|
|
|
1654
1850
|
this.textBuffer = textBuffer;
|
|
1655
1851
|
}
|
|
1656
1852
|
static create(textBuffer) {
|
|
1657
|
-
const lib =
|
|
1853
|
+
const lib = resolveRenderLib2();
|
|
1658
1854
|
const viewPtr = lib.createTextBufferView(textBuffer.ptr);
|
|
1659
|
-
return new
|
|
1855
|
+
return new TextBufferView2(lib, viewPtr, textBuffer);
|
|
1660
1856
|
}
|
|
1661
1857
|
guard() {
|
|
1662
1858
|
if (this._destroyed)
|
|
@@ -1734,6 +1930,10 @@ class TextBufferView {
|
|
|
1734
1930
|
this.guard();
|
|
1735
1931
|
return this.lib.textBufferViewGetLogicalLineInfo(this.viewPtr);
|
|
1736
1932
|
}
|
|
1933
|
+
getLineSources(startLine, lineCount) {
|
|
1934
|
+
this.guard();
|
|
1935
|
+
return this.lib.textBufferViewGetLineSources(this.viewPtr, startLine, lineCount);
|
|
1936
|
+
}
|
|
1737
1937
|
getSelectedText() {
|
|
1738
1938
|
this.guard();
|
|
1739
1939
|
const byteSize = this.textBuffer.byteSize;
|
|
@@ -1786,7 +1986,7 @@ class TextBufferView {
|
|
|
1786
1986
|
// src/edit-buffer.ts
|
|
1787
1987
|
import { EventEmitter as EventEmitter2 } from "events";
|
|
1788
1988
|
|
|
1789
|
-
class
|
|
1989
|
+
class EditBuffer2 extends EventEmitter2 {
|
|
1790
1990
|
static registry = new Map;
|
|
1791
1991
|
static nativeEventsSubscribed = false;
|
|
1792
1992
|
lib;
|
|
@@ -1804,23 +2004,23 @@ class EditBuffer extends EventEmitter2 {
|
|
|
1804
2004
|
this.bufferPtr = ptr;
|
|
1805
2005
|
this.textBufferPtr = lib.editBufferGetTextBuffer(ptr);
|
|
1806
2006
|
this.id = lib.editBufferGetId(ptr);
|
|
1807
|
-
|
|
1808
|
-
|
|
2007
|
+
EditBuffer2.registry.set(this.id, this);
|
|
2008
|
+
EditBuffer2.subscribeToNativeEvents(lib);
|
|
1809
2009
|
}
|
|
1810
2010
|
static create(widthMethod) {
|
|
1811
|
-
const lib =
|
|
2011
|
+
const lib = resolveRenderLib2();
|
|
1812
2012
|
const ptr = lib.createEditBuffer(widthMethod);
|
|
1813
|
-
return new
|
|
2013
|
+
return new EditBuffer2(lib, ptr);
|
|
1814
2014
|
}
|
|
1815
2015
|
static subscribeToNativeEvents(lib) {
|
|
1816
|
-
if (
|
|
2016
|
+
if (EditBuffer2.nativeEventsSubscribed)
|
|
1817
2017
|
return;
|
|
1818
|
-
|
|
2018
|
+
EditBuffer2.nativeEventsSubscribed = true;
|
|
1819
2019
|
lib.onAnyNativeEvent((name, data) => {
|
|
1820
2020
|
const buffer = new Uint16Array(data);
|
|
1821
2021
|
if (name.startsWith("eb_") && buffer.length >= 1) {
|
|
1822
2022
|
const id = buffer[0];
|
|
1823
|
-
const instance =
|
|
2023
|
+
const instance = EditBuffer2.registry.get(id);
|
|
1824
2024
|
if (instance) {
|
|
1825
2025
|
const eventName = name.slice(3);
|
|
1826
2026
|
const eventData = data.slice(2);
|
|
@@ -2099,13 +2299,13 @@ class EditBuffer extends EventEmitter2 {
|
|
|
2099
2299
|
if (this._destroyed)
|
|
2100
2300
|
return;
|
|
2101
2301
|
this._destroyed = true;
|
|
2102
|
-
|
|
2302
|
+
EditBuffer2.registry.delete(this.id);
|
|
2103
2303
|
this.lib.destroyEditBuffer(this.bufferPtr);
|
|
2104
2304
|
}
|
|
2105
2305
|
}
|
|
2106
2306
|
|
|
2107
2307
|
// src/editor-view.ts
|
|
2108
|
-
class
|
|
2308
|
+
class EditorView2 {
|
|
2109
2309
|
lib;
|
|
2110
2310
|
viewPtr;
|
|
2111
2311
|
editBuffer;
|
|
@@ -2118,9 +2318,9 @@ class EditorView {
|
|
|
2118
2318
|
this.editBuffer = editBuffer;
|
|
2119
2319
|
}
|
|
2120
2320
|
static create(editBuffer, viewportWidth, viewportHeight) {
|
|
2121
|
-
const lib =
|
|
2321
|
+
const lib = resolveRenderLib2();
|
|
2122
2322
|
const viewPtr = lib.createEditorView(editBuffer.ptr, viewportWidth, viewportHeight);
|
|
2123
|
-
return new
|
|
2323
|
+
return new EditorView2(lib, viewPtr, editBuffer);
|
|
2124
2324
|
}
|
|
2125
2325
|
guard() {
|
|
2126
2326
|
if (this._destroyed)
|
|
@@ -2285,7 +2485,7 @@ class EditorView {
|
|
|
2285
2485
|
}
|
|
2286
2486
|
get extmarks() {
|
|
2287
2487
|
if (!this._extmarksController) {
|
|
2288
|
-
this._extmarksController =
|
|
2488
|
+
this._extmarksController = createExtmarksController2(this.editBuffer, this);
|
|
2289
2489
|
}
|
|
2290
2490
|
return this._extmarksController;
|
|
2291
2491
|
}
|
|
@@ -2319,201 +2519,6 @@ class EditorView {
|
|
|
2319
2519
|
}
|
|
2320
2520
|
}
|
|
2321
2521
|
|
|
2322
|
-
// src/syntax-style.ts
|
|
2323
|
-
function convertThemeToStyles(theme) {
|
|
2324
|
-
const flatStyles = {};
|
|
2325
|
-
for (const tokenStyle of theme) {
|
|
2326
|
-
const styleDefinition = {};
|
|
2327
|
-
if (tokenStyle.style.foreground) {
|
|
2328
|
-
styleDefinition.fg = parseColor(tokenStyle.style.foreground);
|
|
2329
|
-
}
|
|
2330
|
-
if (tokenStyle.style.background) {
|
|
2331
|
-
styleDefinition.bg = parseColor(tokenStyle.style.background);
|
|
2332
|
-
}
|
|
2333
|
-
if (tokenStyle.style.bold !== undefined) {
|
|
2334
|
-
styleDefinition.bold = tokenStyle.style.bold;
|
|
2335
|
-
}
|
|
2336
|
-
if (tokenStyle.style.italic !== undefined) {
|
|
2337
|
-
styleDefinition.italic = tokenStyle.style.italic;
|
|
2338
|
-
}
|
|
2339
|
-
if (tokenStyle.style.underline !== undefined) {
|
|
2340
|
-
styleDefinition.underline = tokenStyle.style.underline;
|
|
2341
|
-
}
|
|
2342
|
-
if (tokenStyle.style.dim !== undefined) {
|
|
2343
|
-
styleDefinition.dim = tokenStyle.style.dim;
|
|
2344
|
-
}
|
|
2345
|
-
for (const scope of tokenStyle.scope) {
|
|
2346
|
-
flatStyles[scope] = styleDefinition;
|
|
2347
|
-
}
|
|
2348
|
-
}
|
|
2349
|
-
return flatStyles;
|
|
2350
|
-
}
|
|
2351
|
-
|
|
2352
|
-
class SyntaxStyle {
|
|
2353
|
-
lib;
|
|
2354
|
-
stylePtr;
|
|
2355
|
-
_destroyed = false;
|
|
2356
|
-
nameCache = new Map;
|
|
2357
|
-
styleDefs = new Map;
|
|
2358
|
-
mergedCache = new Map;
|
|
2359
|
-
constructor(lib, ptr) {
|
|
2360
|
-
this.lib = lib;
|
|
2361
|
-
this.stylePtr = ptr;
|
|
2362
|
-
}
|
|
2363
|
-
static create() {
|
|
2364
|
-
const lib = resolveRenderLib();
|
|
2365
|
-
const ptr = lib.createSyntaxStyle();
|
|
2366
|
-
return new SyntaxStyle(lib, ptr);
|
|
2367
|
-
}
|
|
2368
|
-
static fromTheme(theme) {
|
|
2369
|
-
const style = SyntaxStyle.create();
|
|
2370
|
-
const flatStyles = convertThemeToStyles(theme);
|
|
2371
|
-
for (const [name, styleDef] of Object.entries(flatStyles)) {
|
|
2372
|
-
style.registerStyle(name, styleDef);
|
|
2373
|
-
}
|
|
2374
|
-
return style;
|
|
2375
|
-
}
|
|
2376
|
-
static fromStyles(styles) {
|
|
2377
|
-
const style = SyntaxStyle.create();
|
|
2378
|
-
for (const [name, styleDef] of Object.entries(styles)) {
|
|
2379
|
-
style.registerStyle(name, styleDef);
|
|
2380
|
-
}
|
|
2381
|
-
return style;
|
|
2382
|
-
}
|
|
2383
|
-
guard() {
|
|
2384
|
-
if (this._destroyed)
|
|
2385
|
-
throw new Error("NativeSyntaxStyle is destroyed");
|
|
2386
|
-
}
|
|
2387
|
-
registerStyle(name, style) {
|
|
2388
|
-
this.guard();
|
|
2389
|
-
const attributes = createTextAttributes({
|
|
2390
|
-
bold: style.bold,
|
|
2391
|
-
italic: style.italic,
|
|
2392
|
-
underline: style.underline,
|
|
2393
|
-
dim: style.dim
|
|
2394
|
-
});
|
|
2395
|
-
const fg = style.fg ? parseColor(style.fg) : null;
|
|
2396
|
-
const bg = style.bg ? parseColor(style.bg) : null;
|
|
2397
|
-
const id = this.lib.syntaxStyleRegister(this.stylePtr, name, fg, bg, attributes);
|
|
2398
|
-
this.nameCache.set(name, id);
|
|
2399
|
-
this.styleDefs.set(name, { ...style, fg: fg ?? undefined, bg: bg ?? undefined });
|
|
2400
|
-
return id;
|
|
2401
|
-
}
|
|
2402
|
-
resolveStyleId(name) {
|
|
2403
|
-
this.guard();
|
|
2404
|
-
const cached = this.nameCache.get(name);
|
|
2405
|
-
if (cached !== undefined)
|
|
2406
|
-
return cached;
|
|
2407
|
-
const id = this.lib.syntaxStyleResolveByName(this.stylePtr, name);
|
|
2408
|
-
if (id !== null) {
|
|
2409
|
-
this.nameCache.set(name, id);
|
|
2410
|
-
}
|
|
2411
|
-
return id;
|
|
2412
|
-
}
|
|
2413
|
-
getStyleId(name) {
|
|
2414
|
-
this.guard();
|
|
2415
|
-
const id = this.resolveStyleId(name);
|
|
2416
|
-
if (id !== null)
|
|
2417
|
-
return id;
|
|
2418
|
-
if (name.includes(".")) {
|
|
2419
|
-
const baseName = name.split(".")[0];
|
|
2420
|
-
return this.resolveStyleId(baseName);
|
|
2421
|
-
}
|
|
2422
|
-
return null;
|
|
2423
|
-
}
|
|
2424
|
-
get ptr() {
|
|
2425
|
-
this.guard();
|
|
2426
|
-
return this.stylePtr;
|
|
2427
|
-
}
|
|
2428
|
-
getStyleCount() {
|
|
2429
|
-
this.guard();
|
|
2430
|
-
return this.lib.syntaxStyleGetStyleCount(this.stylePtr);
|
|
2431
|
-
}
|
|
2432
|
-
clearNameCache() {
|
|
2433
|
-
this.nameCache.clear();
|
|
2434
|
-
}
|
|
2435
|
-
getStyle(name) {
|
|
2436
|
-
this.guard();
|
|
2437
|
-
if (Object.prototype.hasOwnProperty.call(this.styleDefs, name)) {
|
|
2438
|
-
return;
|
|
2439
|
-
}
|
|
2440
|
-
const style = this.styleDefs.get(name);
|
|
2441
|
-
if (style)
|
|
2442
|
-
return style;
|
|
2443
|
-
if (name.includes(".")) {
|
|
2444
|
-
const baseName = name.split(".")[0];
|
|
2445
|
-
if (Object.prototype.hasOwnProperty.call(this.styleDefs, baseName)) {
|
|
2446
|
-
return;
|
|
2447
|
-
}
|
|
2448
|
-
return this.styleDefs.get(baseName);
|
|
2449
|
-
}
|
|
2450
|
-
return;
|
|
2451
|
-
}
|
|
2452
|
-
mergeStyles(...styleNames) {
|
|
2453
|
-
this.guard();
|
|
2454
|
-
const cacheKey = styleNames.join(":");
|
|
2455
|
-
const cached = this.mergedCache.get(cacheKey);
|
|
2456
|
-
if (cached)
|
|
2457
|
-
return cached;
|
|
2458
|
-
const styleDefinition = {};
|
|
2459
|
-
for (const name of styleNames) {
|
|
2460
|
-
const style = this.getStyle(name);
|
|
2461
|
-
if (!style)
|
|
2462
|
-
continue;
|
|
2463
|
-
if (style.fg)
|
|
2464
|
-
styleDefinition.fg = style.fg;
|
|
2465
|
-
if (style.bg)
|
|
2466
|
-
styleDefinition.bg = style.bg;
|
|
2467
|
-
if (style.bold !== undefined)
|
|
2468
|
-
styleDefinition.bold = style.bold;
|
|
2469
|
-
if (style.italic !== undefined)
|
|
2470
|
-
styleDefinition.italic = style.italic;
|
|
2471
|
-
if (style.underline !== undefined)
|
|
2472
|
-
styleDefinition.underline = style.underline;
|
|
2473
|
-
if (style.dim !== undefined)
|
|
2474
|
-
styleDefinition.dim = style.dim;
|
|
2475
|
-
}
|
|
2476
|
-
const attributes = createTextAttributes({
|
|
2477
|
-
bold: styleDefinition.bold,
|
|
2478
|
-
italic: styleDefinition.italic,
|
|
2479
|
-
underline: styleDefinition.underline,
|
|
2480
|
-
dim: styleDefinition.dim
|
|
2481
|
-
});
|
|
2482
|
-
const merged = {
|
|
2483
|
-
fg: styleDefinition.fg,
|
|
2484
|
-
bg: styleDefinition.bg,
|
|
2485
|
-
attributes
|
|
2486
|
-
};
|
|
2487
|
-
this.mergedCache.set(cacheKey, merged);
|
|
2488
|
-
return merged;
|
|
2489
|
-
}
|
|
2490
|
-
clearCache() {
|
|
2491
|
-
this.guard();
|
|
2492
|
-
this.mergedCache.clear();
|
|
2493
|
-
}
|
|
2494
|
-
getCacheSize() {
|
|
2495
|
-
this.guard();
|
|
2496
|
-
return this.mergedCache.size;
|
|
2497
|
-
}
|
|
2498
|
-
getAllStyles() {
|
|
2499
|
-
this.guard();
|
|
2500
|
-
return new Map(this.styleDefs);
|
|
2501
|
-
}
|
|
2502
|
-
getRegisteredNames() {
|
|
2503
|
-
this.guard();
|
|
2504
|
-
return Array.from(this.styleDefs.keys());
|
|
2505
|
-
}
|
|
2506
|
-
destroy() {
|
|
2507
|
-
if (this._destroyed)
|
|
2508
|
-
return;
|
|
2509
|
-
this._destroyed = true;
|
|
2510
|
-
this.nameCache.clear();
|
|
2511
|
-
this.styleDefs.clear();
|
|
2512
|
-
this.mergedCache.clear();
|
|
2513
|
-
this.lib.destroySyntaxStyle(this.stylePtr);
|
|
2514
|
-
}
|
|
2515
|
-
}
|
|
2516
|
-
|
|
2517
2522
|
// src/renderables/Box.ts
|
|
2518
2523
|
function isGapType(value) {
|
|
2519
2524
|
if (value === undefined) {
|
|
@@ -2525,7 +2530,7 @@ function isGapType(value) {
|
|
|
2525
2530
|
return isValidPercentage(value);
|
|
2526
2531
|
}
|
|
2527
2532
|
|
|
2528
|
-
class
|
|
2533
|
+
class BoxRenderable2 extends Renderable2 {
|
|
2529
2534
|
_backgroundColor;
|
|
2530
2535
|
_border;
|
|
2531
2536
|
_borderStyle;
|
|
@@ -2555,20 +2560,20 @@ class BoxRenderable extends Renderable {
|
|
|
2555
2560
|
if (options.focusable === true) {
|
|
2556
2561
|
this._focusable = true;
|
|
2557
2562
|
}
|
|
2558
|
-
this._backgroundColor =
|
|
2563
|
+
this._backgroundColor = parseColor2(options.backgroundColor || this._defaultOptions.backgroundColor);
|
|
2559
2564
|
this._border = options.border ?? this._defaultOptions.border;
|
|
2560
2565
|
if (!options.border && (options.borderStyle || options.borderColor || options.focusedBorderColor || options.customBorderChars)) {
|
|
2561
2566
|
this._border = true;
|
|
2562
2567
|
}
|
|
2563
|
-
this._borderStyle =
|
|
2564
|
-
this._borderColor =
|
|
2565
|
-
this._focusedBorderColor =
|
|
2568
|
+
this._borderStyle = parseBorderStyle2(options.borderStyle, this._defaultOptions.borderStyle);
|
|
2569
|
+
this._borderColor = parseColor2(options.borderColor || this._defaultOptions.borderColor);
|
|
2570
|
+
this._focusedBorderColor = parseColor2(options.focusedBorderColor || this._defaultOptions.focusedBorderColor);
|
|
2566
2571
|
this._customBorderCharsObj = options.customBorderChars;
|
|
2567
|
-
this._customBorderChars = this._customBorderCharsObj ?
|
|
2568
|
-
this.borderSides =
|
|
2572
|
+
this._customBorderChars = this._customBorderCharsObj ? borderCharsToArray2(this._customBorderCharsObj) : undefined;
|
|
2573
|
+
this.borderSides = getBorderSides2(this._border);
|
|
2569
2574
|
this.shouldFill = options.shouldFill ?? this._defaultOptions.shouldFill;
|
|
2570
2575
|
this._title = options.title;
|
|
2571
|
-
this._titleColor = options.titleColor ?
|
|
2576
|
+
this._titleColor = options.titleColor ? parseColor2(options.titleColor) : undefined;
|
|
2572
2577
|
this._titleAlignment = options.titleAlignment || this._defaultOptions.titleAlignment;
|
|
2573
2578
|
this._bottomTitle = options.bottomTitle;
|
|
2574
2579
|
this._bottomTitleAlignment = options.bottomTitleAlignment || this._defaultOptions.bottomTitleAlignment;
|
|
@@ -2581,7 +2586,7 @@ class BoxRenderable extends Renderable {
|
|
|
2581
2586
|
initializeBorder() {
|
|
2582
2587
|
if (this._border === false) {
|
|
2583
2588
|
this._border = true;
|
|
2584
|
-
this.borderSides =
|
|
2589
|
+
this.borderSides = getBorderSides2(this._border);
|
|
2585
2590
|
this.applyYogaBorders();
|
|
2586
2591
|
}
|
|
2587
2592
|
}
|
|
@@ -2590,14 +2595,14 @@ class BoxRenderable extends Renderable {
|
|
|
2590
2595
|
}
|
|
2591
2596
|
set customBorderChars(value) {
|
|
2592
2597
|
this._customBorderCharsObj = value;
|
|
2593
|
-
this._customBorderChars = value ?
|
|
2598
|
+
this._customBorderChars = value ? borderCharsToArray2(value) : undefined;
|
|
2594
2599
|
this.requestRender();
|
|
2595
2600
|
}
|
|
2596
2601
|
get backgroundColor() {
|
|
2597
2602
|
return this._backgroundColor;
|
|
2598
2603
|
}
|
|
2599
2604
|
set backgroundColor(value) {
|
|
2600
|
-
const newColor =
|
|
2605
|
+
const newColor = parseColor2(value ?? this._defaultOptions.backgroundColor);
|
|
2601
2606
|
if (this._backgroundColor !== newColor) {
|
|
2602
2607
|
this._backgroundColor = newColor;
|
|
2603
2608
|
this.requestRender();
|
|
@@ -2609,7 +2614,7 @@ class BoxRenderable extends Renderable {
|
|
|
2609
2614
|
set border(value) {
|
|
2610
2615
|
if (this._border !== value) {
|
|
2611
2616
|
this._border = value;
|
|
2612
|
-
this.borderSides =
|
|
2617
|
+
this.borderSides = getBorderSides2(value);
|
|
2613
2618
|
this.applyYogaBorders();
|
|
2614
2619
|
this.requestRender();
|
|
2615
2620
|
}
|
|
@@ -2618,7 +2623,7 @@ class BoxRenderable extends Renderable {
|
|
|
2618
2623
|
return this._borderStyle;
|
|
2619
2624
|
}
|
|
2620
2625
|
set borderStyle(value) {
|
|
2621
|
-
const _value =
|
|
2626
|
+
const _value = parseBorderStyle2(value, this._defaultOptions.borderStyle);
|
|
2622
2627
|
if (this._borderStyle !== _value || !this._border) {
|
|
2623
2628
|
this._borderStyle = _value;
|
|
2624
2629
|
this._customBorderChars = undefined;
|
|
@@ -2630,7 +2635,7 @@ class BoxRenderable extends Renderable {
|
|
|
2630
2635
|
return this._borderColor;
|
|
2631
2636
|
}
|
|
2632
2637
|
set borderColor(value) {
|
|
2633
|
-
const newColor =
|
|
2638
|
+
const newColor = parseColor2(value ?? this._defaultOptions.borderColor);
|
|
2634
2639
|
if (this._borderColor !== newColor) {
|
|
2635
2640
|
this._borderColor = newColor;
|
|
2636
2641
|
this.initializeBorder();
|
|
@@ -2641,7 +2646,7 @@ class BoxRenderable extends Renderable {
|
|
|
2641
2646
|
return this._focusedBorderColor;
|
|
2642
2647
|
}
|
|
2643
2648
|
set focusedBorderColor(value) {
|
|
2644
|
-
const newColor =
|
|
2649
|
+
const newColor = parseColor2(value ?? this._defaultOptions.focusedBorderColor);
|
|
2645
2650
|
if (this._focusedBorderColor !== newColor) {
|
|
2646
2651
|
this._focusedBorderColor = newColor;
|
|
2647
2652
|
this.initializeBorder();
|
|
@@ -2663,7 +2668,7 @@ class BoxRenderable extends Renderable {
|
|
|
2663
2668
|
return this._titleColor;
|
|
2664
2669
|
}
|
|
2665
2670
|
set titleColor(value) {
|
|
2666
|
-
const newColor = value ?
|
|
2671
|
+
const newColor = value ? parseColor2(value) : undefined;
|
|
2667
2672
|
if (this._titleColor !== newColor) {
|
|
2668
2673
|
this._titleColor = newColor;
|
|
2669
2674
|
this.requestRender();
|
|
@@ -2781,7 +2786,7 @@ class BoxRenderable extends Renderable {
|
|
|
2781
2786
|
}
|
|
2782
2787
|
|
|
2783
2788
|
// src/renderables/TextBufferRenderable.ts
|
|
2784
|
-
class
|
|
2789
|
+
class TextBufferRenderable2 extends Renderable2 {
|
|
2785
2790
|
selectable = true;
|
|
2786
2791
|
_defaultFg;
|
|
2787
2792
|
_defaultBg;
|
|
@@ -2801,8 +2806,8 @@ class TextBufferRenderable extends Renderable {
|
|
|
2801
2806
|
_textBufferSyntaxStyle;
|
|
2802
2807
|
nativeRenderable = null;
|
|
2803
2808
|
_defaultOptions = {
|
|
2804
|
-
fg:
|
|
2805
|
-
bg:
|
|
2809
|
+
fg: RGBA2.fromValues(1, 1, 1, 1),
|
|
2810
|
+
bg: RGBA2.fromValues(0, 0, 0, 0),
|
|
2806
2811
|
selectionBg: undefined,
|
|
2807
2812
|
selectionFg: undefined,
|
|
2808
2813
|
selectable: true,
|
|
@@ -2814,20 +2819,20 @@ class TextBufferRenderable extends Renderable {
|
|
|
2814
2819
|
};
|
|
2815
2820
|
constructor(ctx, options) {
|
|
2816
2821
|
super(ctx, options);
|
|
2817
|
-
this._defaultFg =
|
|
2818
|
-
this._defaultBg =
|
|
2822
|
+
this._defaultFg = parseColor2(options.fg ?? this._defaultOptions.fg);
|
|
2823
|
+
this._defaultBg = parseColor2(options.bg ?? this._defaultOptions.bg);
|
|
2819
2824
|
this._defaultAttributes = options.attributes ?? this._defaultOptions.attributes;
|
|
2820
|
-
this._selectionBg = options.selectionBg ?
|
|
2821
|
-
this._selectionFg = options.selectionFg ?
|
|
2825
|
+
this._selectionBg = options.selectionBg ? parseColor2(options.selectionBg) : this._defaultOptions.selectionBg;
|
|
2826
|
+
this._selectionFg = options.selectionFg ? parseColor2(options.selectionFg) : this._defaultOptions.selectionFg;
|
|
2822
2827
|
this.selectable = options.selectable ?? this._defaultOptions.selectable;
|
|
2823
2828
|
this._wrapMode = options.wrapMode ?? this._defaultOptions.wrapMode;
|
|
2824
2829
|
this._tabIndicator = options.tabIndicator ?? this._defaultOptions.tabIndicator;
|
|
2825
|
-
this._tabIndicatorColor = options.tabIndicatorColor ?
|
|
2830
|
+
this._tabIndicatorColor = options.tabIndicatorColor ? parseColor2(options.tabIndicatorColor) : this._defaultOptions.tabIndicatorColor;
|
|
2826
2831
|
this._truncate = options.truncate ?? this._defaultOptions.truncate;
|
|
2827
|
-
this.textBuffer =
|
|
2828
|
-
this.textBufferView =
|
|
2832
|
+
this.textBuffer = TextBuffer2.create(this._ctx.widthMethod);
|
|
2833
|
+
this.textBufferView = TextBufferView2.create(this.textBuffer);
|
|
2829
2834
|
this._firstLineOffset = ctx.claimFirstLineOffset?.(this) ?? 0;
|
|
2830
|
-
this._textBufferSyntaxStyle =
|
|
2835
|
+
this._textBufferSyntaxStyle = SyntaxStyle2.create();
|
|
2831
2836
|
this.textBuffer.setSyntaxStyle(this._textBufferSyntaxStyle);
|
|
2832
2837
|
this.textBufferView.setWrapMode(this._wrapMode);
|
|
2833
2838
|
this.textBufferView.setFirstLineOffset(this._firstLineOffset);
|
|
@@ -2875,6 +2880,23 @@ class TextBufferRenderable extends Renderable {
|
|
|
2875
2880
|
get lineInfo() {
|
|
2876
2881
|
return this.textBufferView.logicalLineInfo;
|
|
2877
2882
|
}
|
|
2883
|
+
getLineSources(startLine, lineCount) {
|
|
2884
|
+
if (this.needsLineInfoFallback(TextBufferRenderable2.prototype)) {
|
|
2885
|
+
return this.lineInfo.lineSources.slice(startLine, startLine + lineCount);
|
|
2886
|
+
}
|
|
2887
|
+
return this.textBufferView.getLineSources(startLine, lineCount);
|
|
2888
|
+
}
|
|
2889
|
+
needsLineInfoFallback(owner) {
|
|
2890
|
+
let prototype = this;
|
|
2891
|
+
while (prototype && prototype !== owner) {
|
|
2892
|
+
if (Object.hasOwn(prototype, "getLineSources"))
|
|
2893
|
+
return false;
|
|
2894
|
+
if (Object.hasOwn(prototype, "lineInfo"))
|
|
2895
|
+
return true;
|
|
2896
|
+
prototype = Object.getPrototypeOf(prototype);
|
|
2897
|
+
}
|
|
2898
|
+
return false;
|
|
2899
|
+
}
|
|
2878
2900
|
get lineCount() {
|
|
2879
2901
|
return this.textBuffer.getLineCount();
|
|
2880
2902
|
}
|
|
@@ -2909,7 +2931,7 @@ class TextBufferRenderable extends Renderable {
|
|
|
2909
2931
|
return this.lineInfo.lineWidthColsMax;
|
|
2910
2932
|
}
|
|
2911
2933
|
get scrollHeight() {
|
|
2912
|
-
return this.
|
|
2934
|
+
return this.virtualLineCount;
|
|
2913
2935
|
}
|
|
2914
2936
|
get maxScrollY() {
|
|
2915
2937
|
return Math.max(0, this.scrollHeight - this.height);
|
|
@@ -2932,7 +2954,7 @@ class TextBufferRenderable extends Renderable {
|
|
|
2932
2954
|
return this._defaultFg;
|
|
2933
2955
|
}
|
|
2934
2956
|
set fg(value) {
|
|
2935
|
-
const newColor =
|
|
2957
|
+
const newColor = parseColor2(value ?? this._defaultOptions.fg);
|
|
2936
2958
|
if (this._defaultFg !== newColor) {
|
|
2937
2959
|
this._defaultFg = newColor;
|
|
2938
2960
|
this.textBuffer.setDefaultFg(this._defaultFg);
|
|
@@ -2944,7 +2966,7 @@ class TextBufferRenderable extends Renderable {
|
|
|
2944
2966
|
return this._selectionBg;
|
|
2945
2967
|
}
|
|
2946
2968
|
set selectionBg(value) {
|
|
2947
|
-
const newColor = value ?
|
|
2969
|
+
const newColor = value ? parseColor2(value) : this._defaultOptions.selectionBg;
|
|
2948
2970
|
if (this._selectionBg !== newColor) {
|
|
2949
2971
|
this._selectionBg = newColor;
|
|
2950
2972
|
if (this.lastLocalSelection) {
|
|
@@ -2957,7 +2979,7 @@ class TextBufferRenderable extends Renderable {
|
|
|
2957
2979
|
return this._selectionFg;
|
|
2958
2980
|
}
|
|
2959
2981
|
set selectionFg(value) {
|
|
2960
|
-
const newColor = value ?
|
|
2982
|
+
const newColor = value ? parseColor2(value) : this._defaultOptions.selectionFg;
|
|
2961
2983
|
if (this._selectionFg !== newColor) {
|
|
2962
2984
|
this._selectionFg = newColor;
|
|
2963
2985
|
if (this.lastLocalSelection) {
|
|
@@ -2970,7 +2992,7 @@ class TextBufferRenderable extends Renderable {
|
|
|
2970
2992
|
return this._defaultBg;
|
|
2971
2993
|
}
|
|
2972
2994
|
set bg(value) {
|
|
2973
|
-
const newColor =
|
|
2995
|
+
const newColor = parseColor2(value ?? this._defaultOptions.bg);
|
|
2974
2996
|
if (this._defaultBg !== newColor) {
|
|
2975
2997
|
this._defaultBg = newColor;
|
|
2976
2998
|
this.textBuffer.setDefaultBg(this._defaultBg);
|
|
@@ -3019,7 +3041,7 @@ class TextBufferRenderable extends Renderable {
|
|
|
3019
3041
|
return this._tabIndicatorColor;
|
|
3020
3042
|
}
|
|
3021
3043
|
set tabIndicatorColor(value) {
|
|
3022
|
-
const newColor = value ?
|
|
3044
|
+
const newColor = value ? parseColor2(value) : undefined;
|
|
3023
3045
|
if (this._tabIndicatorColor !== newColor) {
|
|
3024
3046
|
this._tabIndicatorColor = newColor;
|
|
3025
3047
|
if (newColor !== undefined) {
|
|
@@ -3066,13 +3088,13 @@ class TextBufferRenderable extends Renderable {
|
|
|
3066
3088
|
this.emit("line-info-change");
|
|
3067
3089
|
}
|
|
3068
3090
|
setupNativeRenderable() {
|
|
3069
|
-
const lib =
|
|
3091
|
+
const lib = resolveRenderLib2();
|
|
3070
3092
|
const nativeRenderable = lib.createNativeRenderable();
|
|
3071
3093
|
if (!lib.nativeRenderableAttachYogaNode(nativeRenderable, this.yogaNode.ptr)) {
|
|
3072
3094
|
lib.destroyNativeRenderable(nativeRenderable);
|
|
3073
3095
|
throw new Error("Failed to attach native renderable Yoga node");
|
|
3074
3096
|
}
|
|
3075
|
-
if (!lib.nativeRenderableSetMeasureTarget(nativeRenderable,
|
|
3097
|
+
if (!lib.nativeRenderableSetMeasureTarget(nativeRenderable, NativeMeasureTargetKind2.TextBufferView, this.textBufferView.ptr)) {
|
|
3076
3098
|
lib.destroyNativeRenderable(nativeRenderable);
|
|
3077
3099
|
throw new Error("Failed to attach text buffer native measure target");
|
|
3078
3100
|
}
|
|
@@ -3086,7 +3108,7 @@ class TextBufferRenderable extends Renderable {
|
|
|
3086
3108
|
return localX >= 0 && localX < this.width && localY >= 0 && localY < this.height;
|
|
3087
3109
|
}
|
|
3088
3110
|
onSelectionChanged(selection) {
|
|
3089
|
-
const localSelection =
|
|
3111
|
+
const localSelection = convertGlobalToLocalSelection2(selection, this.x, this.y);
|
|
3090
3112
|
this.lastLocalSelection = localSelection;
|
|
3091
3113
|
let changed;
|
|
3092
3114
|
if (!localSelection?.isActive) {
|
|
@@ -3132,7 +3154,7 @@ class TextBufferRenderable extends Renderable {
|
|
|
3132
3154
|
if (this.isDestroyed)
|
|
3133
3155
|
return;
|
|
3134
3156
|
if (this.nativeRenderable) {
|
|
3135
|
-
|
|
3157
|
+
resolveRenderLib2().destroyNativeRenderable(this.nativeRenderable);
|
|
3136
3158
|
this.nativeRenderable = null;
|
|
3137
3159
|
}
|
|
3138
3160
|
this.textBuffer.setSyntaxStyle(null);
|
|
@@ -3147,7 +3169,7 @@ class TextBufferRenderable extends Renderable {
|
|
|
3147
3169
|
}
|
|
3148
3170
|
|
|
3149
3171
|
// src/renderables/Code.ts
|
|
3150
|
-
class
|
|
3172
|
+
class CodeRenderable2 extends TextBufferRenderable2 {
|
|
3151
3173
|
_content;
|
|
3152
3174
|
_filetype;
|
|
3153
3175
|
_syntaxStyle;
|
|
@@ -3182,7 +3204,7 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
3182
3204
|
this._content = options.content ?? this._contentDefaultOptions.content;
|
|
3183
3205
|
this._filetype = options.filetype;
|
|
3184
3206
|
this._syntaxStyle = options.syntaxStyle;
|
|
3185
|
-
this._treeSitterClient = options.treeSitterClient ??
|
|
3207
|
+
this._treeSitterClient = options.treeSitterClient ?? getTreeSitterClient2();
|
|
3186
3208
|
this._conceal = options.conceal ?? this._contentDefaultOptions.conceal;
|
|
3187
3209
|
this._drawUnstyledText = options.drawUnstyledText ?? this._contentDefaultOptions.drawUnstyledText;
|
|
3188
3210
|
this._streaming = options.streaming ?? this._contentDefaultOptions.streaming;
|
|
@@ -3216,7 +3238,7 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
3216
3238
|
this.requestRender();
|
|
3217
3239
|
return;
|
|
3218
3240
|
}
|
|
3219
|
-
if (this._initialStyledText && this._drawUnstyledText) {
|
|
3241
|
+
if (value && this._initialStyledText && this._drawUnstyledText) {
|
|
3220
3242
|
this.textBuffer.setStyledText(this._initialStyledText);
|
|
3221
3243
|
} else {
|
|
3222
3244
|
this.textBuffer.setText(value);
|
|
@@ -3225,6 +3247,14 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
3225
3247
|
this.updateTextInfo();
|
|
3226
3248
|
}
|
|
3227
3249
|
}
|
|
3250
|
+
updateStreamingPreview(content, initialStyledText) {
|
|
3251
|
+
this._content = content;
|
|
3252
|
+
this._initialStyledText = initialStyledText;
|
|
3253
|
+
this.invalidateHighlights();
|
|
3254
|
+
this.textBuffer.setStyledText(initialStyledText);
|
|
3255
|
+
this.setRenderedLineSources(undefined);
|
|
3256
|
+
this.updateTextInfo();
|
|
3257
|
+
}
|
|
3228
3258
|
get lineInfo() {
|
|
3229
3259
|
if (!this._renderedLineSources)
|
|
3230
3260
|
return super.lineInfo;
|
|
@@ -3238,6 +3268,14 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
3238
3268
|
};
|
|
3239
3269
|
return this._mappedLineInfo;
|
|
3240
3270
|
}
|
|
3271
|
+
getLineSources(startLine, lineCount) {
|
|
3272
|
+
if (this.needsLineInfoFallback(CodeRenderable2.prototype)) {
|
|
3273
|
+
return this.lineInfo.lineSources.slice(startLine, startLine + lineCount);
|
|
3274
|
+
}
|
|
3275
|
+
const sources = this.textBufferView.getLineSources(startLine, lineCount);
|
|
3276
|
+
const renderedLineSources = this._renderedLineSources;
|
|
3277
|
+
return renderedLineSources ? sources.map((line) => renderedLineSources[line] ?? line) : sources;
|
|
3278
|
+
}
|
|
3241
3279
|
get wrapMode() {
|
|
3242
3280
|
return super.wrapMode;
|
|
3243
3281
|
}
|
|
@@ -3296,6 +3334,10 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
3296
3334
|
}
|
|
3297
3335
|
set initialStyledText(value) {
|
|
3298
3336
|
if (this._initialStyledText !== value) {
|
|
3337
|
+
if (value && this._streaming && this._drawUnstyledText && this._isHighlighting) {
|
|
3338
|
+
this.updateStreamingPreview(this._content, value);
|
|
3339
|
+
return;
|
|
3340
|
+
}
|
|
3299
3341
|
this._initialStyledText = value;
|
|
3300
3342
|
this.invalidateHighlights();
|
|
3301
3343
|
}
|
|
@@ -3423,15 +3465,18 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
3423
3465
|
}
|
|
3424
3466
|
}
|
|
3425
3467
|
if (highlights.length > 0 || this._onChunks || this._baseHighlight) {
|
|
3468
|
+
const sourceRanges = this._onChunks ? [] : undefined;
|
|
3426
3469
|
const context = {
|
|
3427
3470
|
content,
|
|
3428
3471
|
filetype,
|
|
3429
3472
|
syntaxStyle: this._syntaxStyle,
|
|
3430
|
-
highlights
|
|
3473
|
+
highlights,
|
|
3474
|
+
sourceRanges
|
|
3431
3475
|
};
|
|
3432
|
-
let chunks =
|
|
3476
|
+
let chunks = treeSitterToTextChunks2(content, highlights, this._syntaxStyle, {
|
|
3433
3477
|
enabled: this._conceal,
|
|
3434
|
-
baseHighlight: this._baseHighlight
|
|
3478
|
+
baseHighlight: this._baseHighlight,
|
|
3479
|
+
ranges: sourceRanges
|
|
3435
3480
|
});
|
|
3436
3481
|
const renderedLineSources = this._onChunks ? undefined : this.getConcealLinesSourceMap(content, highlights);
|
|
3437
3482
|
chunks = await this.transformChunks(chunks, context);
|
|
@@ -3441,7 +3486,7 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
3441
3486
|
}
|
|
3442
3487
|
if (this.isDestroyed)
|
|
3443
3488
|
return;
|
|
3444
|
-
const styledText = new
|
|
3489
|
+
const styledText = new StyledText2(chunks);
|
|
3445
3490
|
this.textBuffer.setStyledText(styledText);
|
|
3446
3491
|
this.setRenderedLineSources(renderedLineSources);
|
|
3447
3492
|
} else {
|
|
@@ -3530,7 +3575,7 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
3530
3575
|
getConcealLinesSourceMap(content, highlights) {
|
|
3531
3576
|
if (!this._conceal || content.length === 0)
|
|
3532
3577
|
return;
|
|
3533
|
-
const concealLineRanges =
|
|
3578
|
+
const concealLineRanges = CodeRenderable2.getMergedConcealLineRanges(highlights);
|
|
3534
3579
|
if (concealLineRanges.length === 0)
|
|
3535
3580
|
return;
|
|
3536
3581
|
const lineSources = [];
|
|
@@ -3572,7 +3617,7 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
3572
3617
|
break;
|
|
3573
3618
|
lineStart = newlineOffset + 1;
|
|
3574
3619
|
}
|
|
3575
|
-
if (lineSources.length === 0 ||
|
|
3620
|
+
if (lineSources.length === 0 || CodeRenderable2.isIdentityLineSources(lineSources))
|
|
3576
3621
|
return;
|
|
3577
3622
|
return lineSources;
|
|
3578
3623
|
}
|
|
@@ -3634,12 +3679,12 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
3634
3679
|
|
|
3635
3680
|
// src/renderables/TextNode.ts
|
|
3636
3681
|
var BrandedTextNodeRenderable = Symbol.for("@opentui/core/TextNodeRenderable");
|
|
3637
|
-
function
|
|
3682
|
+
function isTextNodeRenderable2(obj) {
|
|
3638
3683
|
return !!obj?.[BrandedTextNodeRenderable];
|
|
3639
3684
|
}
|
|
3640
3685
|
function styledTextToTextNodes(styledText) {
|
|
3641
3686
|
return styledText.chunks.map((chunk) => {
|
|
3642
|
-
const node = new
|
|
3687
|
+
const node = new TextNodeRenderable2({
|
|
3643
3688
|
fg: chunk.fg,
|
|
3644
3689
|
bg: chunk.bg,
|
|
3645
3690
|
attributes: chunk.attributes,
|
|
@@ -3650,7 +3695,7 @@ function styledTextToTextNodes(styledText) {
|
|
|
3650
3695
|
});
|
|
3651
3696
|
}
|
|
3652
3697
|
|
|
3653
|
-
class
|
|
3698
|
+
class TextNodeRenderable2 extends BaseRenderable2 {
|
|
3654
3699
|
[BrandedTextNodeRenderable] = true;
|
|
3655
3700
|
_fg;
|
|
3656
3701
|
_bg;
|
|
@@ -3660,8 +3705,8 @@ class TextNodeRenderable extends BaseRenderable {
|
|
|
3660
3705
|
parent = null;
|
|
3661
3706
|
constructor(options) {
|
|
3662
3707
|
super(options);
|
|
3663
|
-
this._fg = options.fg ?
|
|
3664
|
-
this._bg = options.bg ?
|
|
3708
|
+
this._fg = options.fg ? parseColor2(options.fg) : undefined;
|
|
3709
|
+
this._bg = options.bg ? parseColor2(options.bg) : undefined;
|
|
3665
3710
|
this._attributes = options.attributes ?? 0;
|
|
3666
3711
|
this._link = options.link;
|
|
3667
3712
|
}
|
|
@@ -3670,12 +3715,12 @@ class TextNodeRenderable extends BaseRenderable {
|
|
|
3670
3715
|
}
|
|
3671
3716
|
set children(children) {
|
|
3672
3717
|
for (const child of this._children) {
|
|
3673
|
-
if (
|
|
3718
|
+
if (isTextNodeRenderable2(child) && child.parent === this) {
|
|
3674
3719
|
child.parent = null;
|
|
3675
3720
|
}
|
|
3676
3721
|
}
|
|
3677
3722
|
for (const child of children) {
|
|
3678
|
-
if (
|
|
3723
|
+
if (isTextNodeRenderable2(child)) {
|
|
3679
3724
|
if (child.parent && child.parent !== this) {
|
|
3680
3725
|
child.parent.remove(child);
|
|
3681
3726
|
}
|
|
@@ -3701,14 +3746,14 @@ class TextNodeRenderable extends BaseRenderable {
|
|
|
3701
3746
|
this.requestRender();
|
|
3702
3747
|
return insertIndex;
|
|
3703
3748
|
}
|
|
3704
|
-
if (
|
|
3749
|
+
if (isTextNodeRenderable2(obj)) {
|
|
3705
3750
|
const insertIndex = this.prepareChildInsert(obj, index);
|
|
3706
3751
|
this._children.splice(insertIndex, 0, obj);
|
|
3707
3752
|
obj.parent = this;
|
|
3708
3753
|
this.requestRender();
|
|
3709
3754
|
return insertIndex;
|
|
3710
3755
|
}
|
|
3711
|
-
if (
|
|
3756
|
+
if (isStyledText2(obj)) {
|
|
3712
3757
|
const textNodes = styledTextToTextNodes(obj);
|
|
3713
3758
|
if (index !== undefined) {
|
|
3714
3759
|
this._children.splice(index, 0, ...textNodes);
|
|
@@ -3740,10 +3785,10 @@ class TextNodeRenderable extends BaseRenderable {
|
|
|
3740
3785
|
}
|
|
3741
3786
|
replace(obj, index) {
|
|
3742
3787
|
const existing = this._children[index];
|
|
3743
|
-
if (
|
|
3788
|
+
if (isTextNodeRenderable2(existing) && existing.parent === this) {
|
|
3744
3789
|
existing.parent = null;
|
|
3745
3790
|
}
|
|
3746
|
-
if (
|
|
3791
|
+
if (isTextNodeRenderable2(obj)) {
|
|
3747
3792
|
if (obj.parent && obj.parent !== this) {
|
|
3748
3793
|
obj.parent.remove(obj);
|
|
3749
3794
|
} else if (obj.parent === this) {
|
|
@@ -3760,7 +3805,7 @@ class TextNodeRenderable extends BaseRenderable {
|
|
|
3760
3805
|
this.requestRender();
|
|
3761
3806
|
}
|
|
3762
3807
|
insertBefore(child, anchorNode) {
|
|
3763
|
-
if (!anchorNode || !
|
|
3808
|
+
if (!anchorNode || !isTextNodeRenderable2(anchorNode)) {
|
|
3764
3809
|
throw new Error("Anchor must be a TextNodeRenderable");
|
|
3765
3810
|
}
|
|
3766
3811
|
const anchorIndex = this._children.indexOf(anchorNode);
|
|
@@ -3770,13 +3815,13 @@ class TextNodeRenderable extends BaseRenderable {
|
|
|
3770
3815
|
if (child === anchorNode) {
|
|
3771
3816
|
return this;
|
|
3772
3817
|
}
|
|
3773
|
-
if (
|
|
3818
|
+
if (isTextNodeRenderable2(child)) {
|
|
3774
3819
|
this.add(child, anchorIndex);
|
|
3775
3820
|
return this;
|
|
3776
3821
|
}
|
|
3777
3822
|
if (typeof child === "string") {
|
|
3778
3823
|
this._children.splice(anchorIndex, 0, child);
|
|
3779
|
-
} else if (
|
|
3824
|
+
} else if (isStyledText2(child)) {
|
|
3780
3825
|
const textNodes = styledTextToTextNodes(child);
|
|
3781
3826
|
this._children.splice(anchorIndex, 0, ...textNodes);
|
|
3782
3827
|
textNodes.forEach((node) => node.parent = this);
|
|
@@ -3787,7 +3832,7 @@ class TextNodeRenderable extends BaseRenderable {
|
|
|
3787
3832
|
return this;
|
|
3788
3833
|
}
|
|
3789
3834
|
remove(child) {
|
|
3790
|
-
if (!
|
|
3835
|
+
if (!isTextNodeRenderable2(child)) {
|
|
3791
3836
|
throw new Error("remove expects a TextNodeRenderable child object");
|
|
3792
3837
|
}
|
|
3793
3838
|
const childIndex = this._children.indexOf(child);
|
|
@@ -3803,7 +3848,7 @@ class TextNodeRenderable extends BaseRenderable {
|
|
|
3803
3848
|
}
|
|
3804
3849
|
clear() {
|
|
3805
3850
|
for (const child of this._children) {
|
|
3806
|
-
if (
|
|
3851
|
+
if (isTextNodeRenderable2(child) && child.parent === this) {
|
|
3807
3852
|
child.parent = null;
|
|
3808
3853
|
}
|
|
3809
3854
|
}
|
|
@@ -3844,12 +3889,12 @@ class TextNodeRenderable extends BaseRenderable {
|
|
|
3844
3889
|
return chunks;
|
|
3845
3890
|
}
|
|
3846
3891
|
static fromString(text, options = {}) {
|
|
3847
|
-
const node = new
|
|
3892
|
+
const node = new TextNodeRenderable2(options);
|
|
3848
3893
|
node.add(text);
|
|
3849
3894
|
return node;
|
|
3850
3895
|
}
|
|
3851
3896
|
static fromNodes(nodes, options = {}) {
|
|
3852
|
-
const node = new
|
|
3897
|
+
const node = new TextNodeRenderable2(options);
|
|
3853
3898
|
for (const childNode of nodes) {
|
|
3854
3899
|
node.add(childNode);
|
|
3855
3900
|
}
|
|
@@ -3872,7 +3917,7 @@ class TextNodeRenderable extends BaseRenderable {
|
|
|
3872
3917
|
return this._children.find((child) => typeof child !== "string" && child.id === id);
|
|
3873
3918
|
}
|
|
3874
3919
|
getRenderableIndex(id) {
|
|
3875
|
-
return this._children.findIndex((child) =>
|
|
3920
|
+
return this._children.findIndex((child) => isTextNodeRenderable2(child) && child.id === id);
|
|
3876
3921
|
}
|
|
3877
3922
|
get fg() {
|
|
3878
3923
|
return this._fg;
|
|
@@ -3883,7 +3928,7 @@ class TextNodeRenderable extends BaseRenderable {
|
|
|
3883
3928
|
this.requestRender();
|
|
3884
3929
|
return;
|
|
3885
3930
|
}
|
|
3886
|
-
this._fg =
|
|
3931
|
+
this._fg = parseColor2(fg);
|
|
3887
3932
|
this.requestRender();
|
|
3888
3933
|
}
|
|
3889
3934
|
set bg(bg) {
|
|
@@ -3892,7 +3937,7 @@ class TextNodeRenderable extends BaseRenderable {
|
|
|
3892
3937
|
this.requestRender();
|
|
3893
3938
|
return;
|
|
3894
3939
|
}
|
|
3895
|
-
this._bg =
|
|
3940
|
+
this._bg = parseColor2(bg);
|
|
3896
3941
|
this.requestRender();
|
|
3897
3942
|
}
|
|
3898
3943
|
get bg() {
|
|
@@ -3917,7 +3962,7 @@ class TextNodeRenderable extends BaseRenderable {
|
|
|
3917
3962
|
}
|
|
3918
3963
|
}
|
|
3919
3964
|
|
|
3920
|
-
class
|
|
3965
|
+
class RootTextNodeRenderable2 extends TextNodeRenderable2 {
|
|
3921
3966
|
ctx;
|
|
3922
3967
|
textParent;
|
|
3923
3968
|
constructor(ctx, options, textParent) {
|
|
@@ -3932,7 +3977,7 @@ class RootTextNodeRenderable extends TextNodeRenderable {
|
|
|
3932
3977
|
}
|
|
3933
3978
|
|
|
3934
3979
|
// src/renderables/Text.ts
|
|
3935
|
-
class
|
|
3980
|
+
class TextRenderable2 extends TextBufferRenderable2 {
|
|
3936
3981
|
_text;
|
|
3937
3982
|
_hasManualStyledText = false;
|
|
3938
3983
|
rootTextNode;
|
|
@@ -3942,10 +3987,10 @@ class TextRenderable extends TextBufferRenderable {
|
|
|
3942
3987
|
constructor(ctx, options) {
|
|
3943
3988
|
super(ctx, options);
|
|
3944
3989
|
const content = options.content ?? this._contentDefaultOptions.content;
|
|
3945
|
-
const styledText = typeof content === "string" ?
|
|
3990
|
+
const styledText = typeof content === "string" ? stringToStyledText2(content) : content;
|
|
3946
3991
|
this._text = styledText;
|
|
3947
3992
|
this._hasManualStyledText = options.content !== undefined && content !== "";
|
|
3948
|
-
this.rootTextNode = new
|
|
3993
|
+
this.rootTextNode = new RootTextNodeRenderable2(ctx, {
|
|
3949
3994
|
id: `${this.id}-root`,
|
|
3950
3995
|
fg: this._defaultFg,
|
|
3951
3996
|
bg: this._defaultBg,
|
|
@@ -3969,7 +4014,7 @@ class TextRenderable extends TextBufferRenderable {
|
|
|
3969
4014
|
}
|
|
3970
4015
|
set content(value) {
|
|
3971
4016
|
this._hasManualStyledText = true;
|
|
3972
|
-
const styledText = typeof value === "string" ?
|
|
4017
|
+
const styledText = typeof value === "string" ? stringToStyledText2(value) : value;
|
|
3973
4018
|
if (this._text !== styledText) {
|
|
3974
4019
|
this._text = styledText;
|
|
3975
4020
|
this.updateTextBuffer(styledText);
|
|
@@ -3984,7 +4029,7 @@ class TextRenderable extends TextBufferRenderable {
|
|
|
3984
4029
|
attributes: this._defaultAttributes,
|
|
3985
4030
|
link: undefined
|
|
3986
4031
|
});
|
|
3987
|
-
this.textBuffer.setStyledText(new
|
|
4032
|
+
this.textBuffer.setStyledText(new StyledText2(chunks));
|
|
3988
4033
|
this.refreshLocalSelection();
|
|
3989
4034
|
this.yogaNode.markDirty();
|
|
3990
4035
|
}
|
|
@@ -4004,7 +4049,7 @@ class TextRenderable extends TextBufferRenderable {
|
|
|
4004
4049
|
}
|
|
4005
4050
|
clear() {
|
|
4006
4051
|
this.rootTextNode.clear();
|
|
4007
|
-
const emptyStyledText =
|
|
4052
|
+
const emptyStyledText = stringToStyledText2("");
|
|
4008
4053
|
this._text = emptyStyledText;
|
|
4009
4054
|
this.updateTextBuffer(emptyStyledText);
|
|
4010
4055
|
this.updateTextInfo();
|
|
@@ -4034,11 +4079,11 @@ function toNumber(value) {
|
|
|
4034
4079
|
}
|
|
4035
4080
|
var canThrowAcrossNativeCallback = typeof process !== "undefined" && typeof process.versions === "object" && process.versions !== null && typeof process.versions.bun === "string";
|
|
4036
4081
|
|
|
4037
|
-
class
|
|
4082
|
+
class NativeSpanFeed2 {
|
|
4038
4083
|
static create(options) {
|
|
4039
|
-
const lib =
|
|
4084
|
+
const lib = resolveRenderLib2();
|
|
4040
4085
|
const streamPtr = lib.createNativeSpanFeed(options);
|
|
4041
|
-
const stream = new
|
|
4086
|
+
const stream = new NativeSpanFeed2(streamPtr);
|
|
4042
4087
|
lib.registerNativeSpanFeedStream(streamPtr, stream.eventHandler);
|
|
4043
4088
|
const status = lib.attachNativeSpanFeed(streamPtr);
|
|
4044
4089
|
if (status !== 0) {
|
|
@@ -4049,8 +4094,8 @@ class NativeSpanFeed {
|
|
|
4049
4094
|
return stream;
|
|
4050
4095
|
}
|
|
4051
4096
|
static attach(streamPtr, _options) {
|
|
4052
|
-
const lib =
|
|
4053
|
-
const stream = new
|
|
4097
|
+
const lib = resolveRenderLib2();
|
|
4098
|
+
const stream = new NativeSpanFeed2(streamPtr);
|
|
4054
4099
|
lib.registerNativeSpanFeedStream(streamPtr, stream.eventHandler);
|
|
4055
4100
|
const status = lib.attachNativeSpanFeed(streamPtr);
|
|
4056
4101
|
if (status !== 0) {
|
|
@@ -4060,7 +4105,7 @@ class NativeSpanFeed {
|
|
|
4060
4105
|
return stream;
|
|
4061
4106
|
}
|
|
4062
4107
|
streamPtr;
|
|
4063
|
-
lib =
|
|
4108
|
+
lib = resolveRenderLib2();
|
|
4064
4109
|
eventHandler;
|
|
4065
4110
|
chunkMap = new Map;
|
|
4066
4111
|
chunkSizes = new Map;
|
|
@@ -4534,14 +4579,14 @@ function getCallerInfo() {
|
|
|
4534
4579
|
const columnNumber = parseInt(match[4], 10) || 0;
|
|
4535
4580
|
return { functionName, fullPath, fileName, lineNumber, columnNumber };
|
|
4536
4581
|
}
|
|
4537
|
-
var
|
|
4538
|
-
|
|
4582
|
+
var capture2 = singleton("ConsoleCapture", () => new Capture);
|
|
4583
|
+
registerEnvVar2({
|
|
4539
4584
|
name: "OTUI_USE_CONSOLE",
|
|
4540
4585
|
description: "Whether to use the console. Will not capture console output if set to false.",
|
|
4541
4586
|
type: "boolean",
|
|
4542
4587
|
default: true
|
|
4543
4588
|
});
|
|
4544
|
-
|
|
4589
|
+
registerEnvVar2({
|
|
4545
4590
|
name: "SHOW_CONSOLE",
|
|
4546
4591
|
description: "Show the console at startup if set to true.",
|
|
4547
4592
|
type: "boolean",
|
|
@@ -4561,7 +4606,7 @@ class TerminalConsoleCache extends EventEmitter4 {
|
|
|
4561
4606
|
super();
|
|
4562
4607
|
}
|
|
4563
4608
|
activate() {
|
|
4564
|
-
if (!
|
|
4609
|
+
if (!env2.OTUI_USE_CONSOLE)
|
|
4565
4610
|
return;
|
|
4566
4611
|
if (!this._originalConsole) {
|
|
4567
4612
|
this._originalConsole = global.console;
|
|
@@ -4570,10 +4615,10 @@ class TerminalConsoleCache extends EventEmitter4 {
|
|
|
4570
4615
|
this.overrideConsoleMethods();
|
|
4571
4616
|
}
|
|
4572
4617
|
setupConsoleCapture() {
|
|
4573
|
-
if (!
|
|
4618
|
+
if (!env2.OTUI_USE_CONSOLE)
|
|
4574
4619
|
return;
|
|
4575
|
-
const mockStdout = new CapturedWritableStream("stdout",
|
|
4576
|
-
const mockStderr = new CapturedWritableStream("stderr",
|
|
4620
|
+
const mockStdout = new CapturedWritableStream("stdout", capture2);
|
|
4621
|
+
const mockStderr = new CapturedWritableStream("stderr", capture2);
|
|
4577
4622
|
global.console = new Console({
|
|
4578
4623
|
stdout: mockStdout,
|
|
4579
4624
|
stderr: mockStderr,
|
|
@@ -4645,19 +4690,19 @@ class TerminalConsoleCache extends EventEmitter4 {
|
|
|
4645
4690
|
}
|
|
4646
4691
|
}
|
|
4647
4692
|
var terminalConsoleCache = singleton("TerminalConsoleCache", () => {
|
|
4648
|
-
const
|
|
4693
|
+
const terminalConsoleCache = new TerminalConsoleCache;
|
|
4649
4694
|
process.on("exit", () => {
|
|
4650
|
-
|
|
4695
|
+
terminalConsoleCache.destroy();
|
|
4651
4696
|
});
|
|
4652
|
-
return
|
|
4697
|
+
return terminalConsoleCache;
|
|
4653
4698
|
});
|
|
4654
|
-
var
|
|
4655
|
-
((
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
})(
|
|
4699
|
+
var ConsolePosition2;
|
|
4700
|
+
((ConsolePosition) => {
|
|
4701
|
+
ConsolePosition["TOP"] = "top";
|
|
4702
|
+
ConsolePosition["BOTTOM"] = "bottom";
|
|
4703
|
+
ConsolePosition["LEFT"] = "left";
|
|
4704
|
+
ConsolePosition["RIGHT"] = "right";
|
|
4705
|
+
})(ConsolePosition2 ||= {});
|
|
4661
4706
|
var defaultConsoleKeybindings = [
|
|
4662
4707
|
{ name: "up", action: "scroll-up" },
|
|
4663
4708
|
{ name: "down", action: "scroll-down" },
|
|
@@ -4680,10 +4725,10 @@ var DEFAULT_CONSOLE_OPTIONS = {
|
|
|
4680
4725
|
colorError: "#FF0000",
|
|
4681
4726
|
colorDebug: "#808080",
|
|
4682
4727
|
colorDefault: "#FFFFFF",
|
|
4683
|
-
backgroundColor:
|
|
4728
|
+
backgroundColor: RGBA2.fromValues(0.1, 0.1, 0.1, 0.7),
|
|
4684
4729
|
startInDebugMode: false,
|
|
4685
4730
|
title: "Console",
|
|
4686
|
-
titleBarColor:
|
|
4731
|
+
titleBarColor: RGBA2.fromValues(0.05, 0.05, 0.05, 0.7),
|
|
4687
4732
|
titleBarTextColor: "#FFFFFF",
|
|
4688
4733
|
cursorColor: "#00A0FF",
|
|
4689
4734
|
maxStoredLogs: 2000,
|
|
@@ -4691,12 +4736,12 @@ var DEFAULT_CONSOLE_OPTIONS = {
|
|
|
4691
4736
|
onCopySelection: undefined,
|
|
4692
4737
|
keyBindings: undefined,
|
|
4693
4738
|
keyAliasMap: undefined,
|
|
4694
|
-
selectionColor:
|
|
4739
|
+
selectionColor: RGBA2.fromValues(0.3, 0.5, 0.8, 0.5),
|
|
4695
4740
|
copyButtonColor: "#00A0FF"
|
|
4696
4741
|
};
|
|
4697
4742
|
var INDENT_WIDTH = 2;
|
|
4698
4743
|
|
|
4699
|
-
class
|
|
4744
|
+
class TerminalConsole2 extends EventEmitter4 {
|
|
4700
4745
|
isVisible = false;
|
|
4701
4746
|
isFocused = false;
|
|
4702
4747
|
renderer;
|
|
@@ -4765,23 +4810,23 @@ class TerminalConsole extends EventEmitter4 {
|
|
|
4765
4810
|
constructor(renderer, options = {}) {
|
|
4766
4811
|
super();
|
|
4767
4812
|
this.renderer = renderer;
|
|
4768
|
-
this.clock = options.clock ?? new
|
|
4813
|
+
this.clock = options.clock ?? new SystemClock2;
|
|
4769
4814
|
this.options = { ...DEFAULT_CONSOLE_OPTIONS, ...options };
|
|
4770
4815
|
this.keyHandler = this.handleKeyPress.bind(this);
|
|
4771
4816
|
this._debugModeEnabled = this.options.startInDebugMode;
|
|
4772
4817
|
terminalConsoleCache.setCollectCallerInfo(this._debugModeEnabled);
|
|
4773
|
-
this._rgbaInfo =
|
|
4774
|
-
this._rgbaWarn =
|
|
4775
|
-
this._rgbaError =
|
|
4776
|
-
this._rgbaDebug =
|
|
4777
|
-
this._rgbaDefault =
|
|
4778
|
-
this.backgroundColor =
|
|
4779
|
-
this._rgbaTitleBar =
|
|
4780
|
-
this._rgbaTitleBarText =
|
|
4818
|
+
this._rgbaInfo = parseColor2(this.options.colorInfo);
|
|
4819
|
+
this._rgbaWarn = parseColor2(this.options.colorWarn);
|
|
4820
|
+
this._rgbaError = parseColor2(this.options.colorError);
|
|
4821
|
+
this._rgbaDebug = parseColor2(this.options.colorDebug);
|
|
4822
|
+
this._rgbaDefault = parseColor2(this.options.colorDefault);
|
|
4823
|
+
this.backgroundColor = parseColor2(this.options.backgroundColor);
|
|
4824
|
+
this._rgbaTitleBar = parseColor2(this.options.titleBarColor);
|
|
4825
|
+
this._rgbaTitleBarText = parseColor2(this.options.titleBarTextColor || this.options.colorDefault);
|
|
4781
4826
|
this._title = this.options.title;
|
|
4782
|
-
this._rgbaCursor =
|
|
4783
|
-
this._rgbaSelection =
|
|
4784
|
-
this._rgbaCopyButton =
|
|
4827
|
+
this._rgbaCursor = parseColor2(this.options.cursorColor);
|
|
4828
|
+
this._rgbaSelection = parseColor2(this.options.selectionColor);
|
|
4829
|
+
this._rgbaCopyButton = parseColor2(this.options.copyButtonColor);
|
|
4785
4830
|
this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, options.keyAliasMap || {});
|
|
4786
4831
|
this._keyBindings = options.keyBindings || [];
|
|
4787
4832
|
this._mergedKeyBindings = mergeKeyBindings(defaultConsoleKeybindings, this._keyBindings);
|
|
@@ -4793,7 +4838,7 @@ class TerminalConsole extends EventEmitter4 {
|
|
|
4793
4838
|
this._handleNewLog(logEntry);
|
|
4794
4839
|
};
|
|
4795
4840
|
terminalConsoleCache.on("entry", this._entryListener);
|
|
4796
|
-
if (
|
|
4841
|
+
if (env2.SHOW_CONSOLE) {
|
|
4797
4842
|
this.show();
|
|
4798
4843
|
}
|
|
4799
4844
|
}
|
|
@@ -5052,7 +5097,7 @@ class TerminalConsole extends EventEmitter4 {
|
|
|
5052
5097
|
this._processCachedLogs();
|
|
5053
5098
|
terminalConsoleCache.setCachingEnabled(false);
|
|
5054
5099
|
if (!this.frameBuffer) {
|
|
5055
|
-
this.frameBuffer =
|
|
5100
|
+
this.frameBuffer = OptimizedBuffer2.create(this.consoleWidth, this.consoleHeight, this.renderer.widthMethod, {
|
|
5056
5101
|
respectAlpha: this.backgroundColor.a < 1,
|
|
5057
5102
|
id: "console framebuffer"
|
|
5058
5103
|
});
|
|
@@ -5099,7 +5144,7 @@ class TerminalConsole extends EventEmitter4 {
|
|
|
5099
5144
|
const copyButtonX = this.consoleWidth - copyLabel.length - 1;
|
|
5100
5145
|
if (copyButtonX >= 0) {
|
|
5101
5146
|
const copyButtonEnabled = this.hasSelection();
|
|
5102
|
-
const disabledColor =
|
|
5147
|
+
const disabledColor = RGBA2.fromInts(100, 100, 100, 255);
|
|
5103
5148
|
const copyColor = copyButtonEnabled ? this._rgbaCopyButton : disabledColor;
|
|
5104
5149
|
this.frameBuffer.drawText(copyLabel, copyButtonX, 0, copyColor, this._rgbaTitleBar);
|
|
5105
5150
|
this._copyButtonBounds = { x: copyButtonX, y: 0, width: copyLabel.length, height: 1 };
|
|
@@ -5488,10 +5533,10 @@ class TerminalConsole extends EventEmitter4 {
|
|
|
5488
5533
|
|
|
5489
5534
|
// src/renderables/EditBufferRenderable.ts
|
|
5490
5535
|
var BrandedEditBufferRenderable = Symbol.for("@opentui/core/EditBufferRenderable");
|
|
5491
|
-
var
|
|
5492
|
-
((
|
|
5493
|
-
|
|
5494
|
-
})(
|
|
5536
|
+
var EditBufferRenderableEvents2;
|
|
5537
|
+
((EditBufferRenderableEvents) => {
|
|
5538
|
+
EditBufferRenderableEvents["TRAITS_CHANGED"] = "traits-changed";
|
|
5539
|
+
})(EditBufferRenderableEvents2 ||= {});
|
|
5495
5540
|
function sameCapture(a, b) {
|
|
5496
5541
|
if (a === b)
|
|
5497
5542
|
return true;
|
|
@@ -5504,11 +5549,11 @@ function sameCapture(a, b) {
|
|
|
5504
5549
|
function sameTraits(a, b) {
|
|
5505
5550
|
return a.suspend === b.suspend && a.status === b.status && sameCapture(a.capture, b.capture);
|
|
5506
5551
|
}
|
|
5507
|
-
function
|
|
5552
|
+
function isEditBufferRenderable2(obj) {
|
|
5508
5553
|
return !!(obj && typeof obj === "object" && (BrandedEditBufferRenderable in obj));
|
|
5509
5554
|
}
|
|
5510
5555
|
|
|
5511
|
-
class
|
|
5556
|
+
class EditBufferRenderable2 extends Renderable2 {
|
|
5512
5557
|
[BrandedEditBufferRenderable] = true;
|
|
5513
5558
|
_focusable = true;
|
|
5514
5559
|
selectable = true;
|
|
@@ -5536,7 +5581,7 @@ class EditBufferRenderable extends Renderable {
|
|
|
5536
5581
|
editorView;
|
|
5537
5582
|
nativeRenderable = null;
|
|
5538
5583
|
_defaultOptions = {
|
|
5539
|
-
textColor:
|
|
5584
|
+
textColor: RGBA2.fromValues(1, 1, 1, 1),
|
|
5540
5585
|
backgroundColor: "transparent",
|
|
5541
5586
|
selectionBg: undefined,
|
|
5542
5587
|
selectionFg: undefined,
|
|
@@ -5546,7 +5591,7 @@ class EditBufferRenderable extends Renderable {
|
|
|
5546
5591
|
scrollMargin: 0.2,
|
|
5547
5592
|
scrollSpeed: 16,
|
|
5548
5593
|
showCursor: true,
|
|
5549
|
-
cursorColor:
|
|
5594
|
+
cursorColor: RGBA2.fromValues(1, 1, 1, 1),
|
|
5550
5595
|
cursorStyle: {
|
|
5551
5596
|
style: "block",
|
|
5552
5597
|
blinking: true
|
|
@@ -5556,22 +5601,22 @@ class EditBufferRenderable extends Renderable {
|
|
|
5556
5601
|
};
|
|
5557
5602
|
constructor(ctx, options) {
|
|
5558
5603
|
super(ctx, options);
|
|
5559
|
-
this._textColor =
|
|
5560
|
-
this._backgroundColor =
|
|
5604
|
+
this._textColor = parseColor2(options.textColor ?? this._defaultOptions.textColor);
|
|
5605
|
+
this._backgroundColor = parseColor2(options.backgroundColor ?? this._defaultOptions.backgroundColor);
|
|
5561
5606
|
this._defaultAttributes = options.attributes ?? this._defaultOptions.attributes;
|
|
5562
|
-
this._selectionBg = options.selectionBg ?
|
|
5563
|
-
this._selectionFg = options.selectionFg ?
|
|
5607
|
+
this._selectionBg = options.selectionBg ? parseColor2(options.selectionBg) : this._defaultOptions.selectionBg;
|
|
5608
|
+
this._selectionFg = options.selectionFg ? parseColor2(options.selectionFg) : this._defaultOptions.selectionFg;
|
|
5564
5609
|
this.selectable = options.selectable ?? this._defaultOptions.selectable;
|
|
5565
5610
|
this._wrapMode = options.wrapMode ?? this._defaultOptions.wrapMode;
|
|
5566
5611
|
this._scrollMargin = options.scrollMargin ?? this._defaultOptions.scrollMargin;
|
|
5567
5612
|
this._scrollSpeed = options.scrollSpeed ?? this._defaultOptions.scrollSpeed;
|
|
5568
5613
|
this._showCursor = options.showCursor ?? this._defaultOptions.showCursor;
|
|
5569
|
-
this._cursorColor =
|
|
5614
|
+
this._cursorColor = parseColor2(options.cursorColor ?? this._defaultOptions.cursorColor);
|
|
5570
5615
|
this._cursorStyle = options.cursorStyle ?? this._defaultOptions.cursorStyle;
|
|
5571
5616
|
this._tabIndicator = options.tabIndicator ?? this._defaultOptions.tabIndicator;
|
|
5572
|
-
this._tabIndicatorColor = options.tabIndicatorColor ?
|
|
5573
|
-
this.editBuffer =
|
|
5574
|
-
this.editorView =
|
|
5617
|
+
this._tabIndicatorColor = options.tabIndicatorColor ? parseColor2(options.tabIndicatorColor) : this._defaultOptions.tabIndicatorColor;
|
|
5618
|
+
this.editBuffer = EditBuffer2.create(this._ctx.widthMethod);
|
|
5619
|
+
this.editorView = EditorView2.create(this.editBuffer, this.width || 80, this.height || 24);
|
|
5575
5620
|
this.editorView.setWrapMode(this._wrapMode);
|
|
5576
5621
|
this.editorView.setScrollMargin(this._scrollMargin);
|
|
5577
5622
|
if (options.selectionOccupancy === "boundary") {
|
|
@@ -5663,7 +5708,7 @@ class EditBufferRenderable extends Renderable {
|
|
|
5663
5708
|
return this._textColor;
|
|
5664
5709
|
}
|
|
5665
5710
|
set textColor(value) {
|
|
5666
|
-
const newColor =
|
|
5711
|
+
const newColor = parseColor2(value ?? this._defaultOptions.textColor);
|
|
5667
5712
|
if (this._textColor !== newColor) {
|
|
5668
5713
|
this._textColor = newColor;
|
|
5669
5714
|
this.editBuffer.setDefaultFg(newColor);
|
|
@@ -5684,7 +5729,7 @@ class EditBufferRenderable extends Renderable {
|
|
|
5684
5729
|
this.emit("traits-changed" /* TRAITS_CHANGED */, value, prev);
|
|
5685
5730
|
}
|
|
5686
5731
|
set selectionBg(value) {
|
|
5687
|
-
const newColor = value ?
|
|
5732
|
+
const newColor = value ? parseColor2(value) : this._defaultOptions.selectionBg;
|
|
5688
5733
|
if (this._selectionBg !== newColor) {
|
|
5689
5734
|
this._selectionBg = newColor;
|
|
5690
5735
|
this.refreshSelectionStyle();
|
|
@@ -5695,7 +5740,7 @@ class EditBufferRenderable extends Renderable {
|
|
|
5695
5740
|
return this._selectionFg;
|
|
5696
5741
|
}
|
|
5697
5742
|
set selectionFg(value) {
|
|
5698
|
-
const newColor = value ?
|
|
5743
|
+
const newColor = value ? parseColor2(value) : this._defaultOptions.selectionFg;
|
|
5699
5744
|
if (this._selectionFg !== newColor) {
|
|
5700
5745
|
this._selectionFg = newColor;
|
|
5701
5746
|
this.refreshSelectionStyle();
|
|
@@ -5706,7 +5751,7 @@ class EditBufferRenderable extends Renderable {
|
|
|
5706
5751
|
return this._backgroundColor;
|
|
5707
5752
|
}
|
|
5708
5753
|
set backgroundColor(value) {
|
|
5709
|
-
const newColor =
|
|
5754
|
+
const newColor = parseColor2(value ?? this._defaultOptions.backgroundColor);
|
|
5710
5755
|
if (this._backgroundColor !== newColor) {
|
|
5711
5756
|
this._backgroundColor = newColor;
|
|
5712
5757
|
this.editBuffer.setDefaultBg(newColor);
|
|
@@ -5750,7 +5795,7 @@ class EditBufferRenderable extends Renderable {
|
|
|
5750
5795
|
return this._cursorColor;
|
|
5751
5796
|
}
|
|
5752
5797
|
set cursorColor(value) {
|
|
5753
|
-
const newColor =
|
|
5798
|
+
const newColor = parseColor2(value);
|
|
5754
5799
|
if (this._cursorColor !== newColor) {
|
|
5755
5800
|
this._cursorColor = newColor;
|
|
5756
5801
|
if (this._focused) {
|
|
@@ -5796,7 +5841,7 @@ class EditBufferRenderable extends Renderable {
|
|
|
5796
5841
|
return this._tabIndicatorColor;
|
|
5797
5842
|
}
|
|
5798
5843
|
set tabIndicatorColor(value) {
|
|
5799
|
-
const newColor = value ?
|
|
5844
|
+
const newColor = value ? parseColor2(value) : undefined;
|
|
5800
5845
|
if (this._tabIndicatorColor !== newColor) {
|
|
5801
5846
|
this._tabIndicatorColor = newColor;
|
|
5802
5847
|
if (newColor !== undefined) {
|
|
@@ -5868,7 +5913,7 @@ class EditBufferRenderable extends Renderable {
|
|
|
5868
5913
|
return localX >= 0 && localX < this.width && localY >= 0 && localY < this.height;
|
|
5869
5914
|
}
|
|
5870
5915
|
onSelectionChanged(selection) {
|
|
5871
|
-
const localSelection =
|
|
5916
|
+
const localSelection = convertGlobalToLocalSelection2(selection, this.x, this.y);
|
|
5872
5917
|
this.lastLocalSelection = localSelection;
|
|
5873
5918
|
const updateCursor = true;
|
|
5874
5919
|
const followCursor = this._keyboardSelectionActive;
|
|
@@ -6240,13 +6285,13 @@ class EditBufferRenderable extends Renderable {
|
|
|
6240
6285
|
return true;
|
|
6241
6286
|
}
|
|
6242
6287
|
setupNativeRenderable() {
|
|
6243
|
-
const lib =
|
|
6288
|
+
const lib = resolveRenderLib2();
|
|
6244
6289
|
const nativeRenderable = lib.createNativeRenderable();
|
|
6245
6290
|
if (!lib.nativeRenderableAttachYogaNode(nativeRenderable, this.yogaNode.ptr)) {
|
|
6246
6291
|
lib.destroyNativeRenderable(nativeRenderable);
|
|
6247
6292
|
throw new Error("Failed to attach native renderable Yoga node");
|
|
6248
6293
|
}
|
|
6249
|
-
if (!lib.nativeRenderableSetMeasureTarget(nativeRenderable,
|
|
6294
|
+
if (!lib.nativeRenderableSetMeasureTarget(nativeRenderable, NativeMeasureTargetKind2.EditorView, this.editorView.ptr)) {
|
|
6250
6295
|
lib.destroyNativeRenderable(nativeRenderable);
|
|
6251
6296
|
throw new Error("Failed to attach editor native measure target");
|
|
6252
6297
|
}
|
|
@@ -6302,7 +6347,7 @@ class EditBufferRenderable extends Renderable {
|
|
|
6302
6347
|
this.blur();
|
|
6303
6348
|
}
|
|
6304
6349
|
if (this.nativeRenderable) {
|
|
6305
|
-
|
|
6350
|
+
resolveRenderLib2().destroyNativeRenderable(this.nativeRenderable);
|
|
6306
6351
|
this.nativeRenderable = null;
|
|
6307
6352
|
}
|
|
6308
6353
|
this.editorView.destroy();
|
|
@@ -6612,7 +6657,7 @@ function oscThemeColorToHex(r, g, b, hex6) {
|
|
|
6612
6657
|
return "#000000";
|
|
6613
6658
|
}
|
|
6614
6659
|
function inferThemeModeFromBackgroundColor(color) {
|
|
6615
|
-
const [r, g, b] =
|
|
6660
|
+
const [r, g, b] = parseColor2(color).toInts();
|
|
6616
6661
|
const brightness = (r * 299 + g * 587 + b * 114) / 1000;
|
|
6617
6662
|
return brightness > 128 ? "light" : "dark";
|
|
6618
6663
|
}
|
|
@@ -6744,51 +6789,52 @@ class RendererThemeMode {
|
|
|
6744
6789
|
}
|
|
6745
6790
|
|
|
6746
6791
|
// src/renderer.ts
|
|
6747
|
-
|
|
6792
|
+
registerEnvVar2({
|
|
6748
6793
|
name: "OTUI_DUMP_CAPTURES",
|
|
6749
6794
|
description: "Dump captured stdout and console caches when the renderer exit handler runs.",
|
|
6750
6795
|
type: "boolean",
|
|
6751
6796
|
default: false
|
|
6752
6797
|
});
|
|
6753
|
-
|
|
6798
|
+
registerEnvVar2({
|
|
6754
6799
|
name: "OTUI_NO_NATIVE_RENDER",
|
|
6755
6800
|
description: "Skip the Zig/native frame renderer. Useful for debugging the render loop; split-footer stdout flushing may still write ANSI.",
|
|
6756
6801
|
type: "boolean",
|
|
6757
6802
|
default: false
|
|
6758
6803
|
});
|
|
6759
|
-
|
|
6804
|
+
registerEnvVar2({
|
|
6760
6805
|
name: "OTUI_USE_ALTERNATE_SCREEN",
|
|
6761
6806
|
description: "When explicitly set, force screen mode selection: true=alternate-screen, false=main-screen.",
|
|
6762
6807
|
type: "boolean",
|
|
6763
6808
|
default: true
|
|
6764
6809
|
});
|
|
6765
|
-
|
|
6810
|
+
registerEnvVar2({
|
|
6766
6811
|
name: "OTUI_OVERRIDE_STDOUT",
|
|
6767
6812
|
description: "When explicitly set, force stdout routing: false=passthrough, true=capture in split-footer mode.",
|
|
6768
6813
|
type: "boolean",
|
|
6769
6814
|
default: true
|
|
6770
6815
|
});
|
|
6771
|
-
|
|
6816
|
+
registerEnvVar2({
|
|
6772
6817
|
name: "OTUI_DEBUG",
|
|
6773
6818
|
description: "Enable debug mode to capture all raw input for debugging purposes.",
|
|
6774
6819
|
type: "boolean",
|
|
6775
6820
|
default: false
|
|
6776
6821
|
});
|
|
6777
|
-
|
|
6822
|
+
registerEnvVar2({
|
|
6778
6823
|
name: "OTUI_STDIN_LOG",
|
|
6779
6824
|
description: "Write the raw stdin byte stream to this file for debugging.",
|
|
6780
6825
|
type: "string",
|
|
6781
6826
|
default: ""
|
|
6782
6827
|
});
|
|
6783
|
-
|
|
6828
|
+
registerEnvVar2({
|
|
6784
6829
|
name: "OTUI_SHOW_STATS",
|
|
6785
6830
|
description: "Show the debug overlay at startup.",
|
|
6786
6831
|
type: "boolean",
|
|
6787
6832
|
default: false
|
|
6788
6833
|
});
|
|
6834
|
+
var KITTY_IMAGE_TRANSPORTS = ["raw", "zlib", "file"];
|
|
6789
6835
|
var DEFAULT_FOOTER_HEIGHT = 12;
|
|
6790
6836
|
var MAX_SCROLLBACK_SURFACE_HEIGHT_PASSES = 4;
|
|
6791
|
-
var TRANSPARENT_RGBA =
|
|
6837
|
+
var TRANSPARENT_RGBA = RGBA2.fromValues(0, 0, 0, 0);
|
|
6792
6838
|
var scrollbackSurfaceCounter = 0;
|
|
6793
6839
|
function normalizeFooterHeight(footerHeight) {
|
|
6794
6840
|
if (footerHeight === undefined) {
|
|
@@ -6806,12 +6852,12 @@ function normalizeFooterHeight(footerHeight) {
|
|
|
6806
6852
|
function resolveModes(config) {
|
|
6807
6853
|
let screenMode = config.screenMode ?? "alternate-screen";
|
|
6808
6854
|
if (process.env.OTUI_USE_ALTERNATE_SCREEN !== undefined) {
|
|
6809
|
-
screenMode =
|
|
6855
|
+
screenMode = env2.OTUI_USE_ALTERNATE_SCREEN ? "alternate-screen" : "main-screen";
|
|
6810
6856
|
}
|
|
6811
6857
|
const footerHeight = screenMode === "split-footer" ? normalizeFooterHeight(config.footerHeight) : DEFAULT_FOOTER_HEIGHT;
|
|
6812
6858
|
let externalOutputMode = config.externalOutputMode ?? (screenMode === "split-footer" ? "capture-stdout" : "passthrough");
|
|
6813
6859
|
if (process.env.OTUI_OVERRIDE_STDOUT !== undefined) {
|
|
6814
|
-
externalOutputMode =
|
|
6860
|
+
externalOutputMode = env2.OTUI_OVERRIDE_STDOUT && screenMode === "split-footer" ? "capture-stdout" : "passthrough";
|
|
6815
6861
|
}
|
|
6816
6862
|
if (externalOutputMode === "capture-stdout" && screenMode !== "split-footer") {
|
|
6817
6863
|
throw new Error('externalOutputMode "capture-stdout" requires screenMode "split-footer"');
|
|
@@ -6841,9 +6887,9 @@ class ExternalOutputQueue {
|
|
|
6841
6887
|
}
|
|
6842
6888
|
const clampedLimit = Number.isFinite(limit) ? Math.max(1, Math.trunc(limit)) : this.commits.length;
|
|
6843
6889
|
if (clampedLimit >= this.commits.length) {
|
|
6844
|
-
const
|
|
6890
|
+
const output = this.commits;
|
|
6845
6891
|
this.commits = [];
|
|
6846
|
-
return
|
|
6892
|
+
return output;
|
|
6847
6893
|
}
|
|
6848
6894
|
const output = this.commits.slice(0, clampedLimit);
|
|
6849
6895
|
this.commits = this.commits.slice(clampedLimit);
|
|
@@ -6884,8 +6930,8 @@ class ScrollbackSnapshotRenderContext extends EventEmitter5 {
|
|
|
6884
6930
|
this.resolution = resolution;
|
|
6885
6931
|
this.capabilities = capabilities;
|
|
6886
6932
|
this.widthMethod = widthMethod;
|
|
6887
|
-
this.keyInput = new
|
|
6888
|
-
this._internalKeyInput = new
|
|
6933
|
+
this.keyInput = new KeyHandler2;
|
|
6934
|
+
this._internalKeyInput = new InternalKeyHandler2;
|
|
6889
6935
|
}
|
|
6890
6936
|
addToHitGrid(_x, _y, _width, _height, _id) {}
|
|
6891
6937
|
pushHitGridScissorRect(_x, _y, _width, _height) {}
|
|
@@ -6904,7 +6950,7 @@ class ScrollbackSnapshotRenderContext extends EventEmitter5 {
|
|
|
6904
6950
|
get currentFocusedEditor() {
|
|
6905
6951
|
if (!this.currentFocusedRenderable)
|
|
6906
6952
|
return null;
|
|
6907
|
-
if (!
|
|
6953
|
+
if (!isEditBufferRenderable2(this.currentFocusedRenderable))
|
|
6908
6954
|
return null;
|
|
6909
6955
|
return this.currentFocusedRenderable;
|
|
6910
6956
|
}
|
|
@@ -6931,6 +6977,7 @@ class ScrollbackSnapshotRenderContext extends EventEmitter5 {
|
|
|
6931
6977
|
updateSelection(_currentRenderable, _x, _y, _options) {}
|
|
6932
6978
|
}
|
|
6933
6979
|
var DEFAULT_FORWARDED_ENV_KEYS = [
|
|
6980
|
+
"TMPDIR",
|
|
6934
6981
|
"SSH_CONNECTION",
|
|
6935
6982
|
"SSH_CLIENT",
|
|
6936
6983
|
"SSH_TTY",
|
|
@@ -6970,7 +7017,7 @@ var KITTY_FLAG_ALL_KEYS_AS_ESCAPES = 8;
|
|
|
6970
7017
|
var KITTY_FLAG_REPORT_TEXT = 16;
|
|
6971
7018
|
var DEFAULT_STDIN_PARSER_MAX_BUFFER_BYTES = 64 * 1024 * 1024;
|
|
6972
7019
|
var NATIVE_PALETTE_QUERY_SIZE = 16;
|
|
6973
|
-
function
|
|
7020
|
+
function buildKittyKeyboardFlags2(config) {
|
|
6974
7021
|
if (!config) {
|
|
6975
7022
|
return 0;
|
|
6976
7023
|
}
|
|
@@ -6993,7 +7040,7 @@ function buildKittyKeyboardFlags(config) {
|
|
|
6993
7040
|
return flags;
|
|
6994
7041
|
}
|
|
6995
7042
|
|
|
6996
|
-
class
|
|
7043
|
+
class MouseEvent2 {
|
|
6997
7044
|
type;
|
|
6998
7045
|
button;
|
|
6999
7046
|
x;
|
|
@@ -7030,19 +7077,19 @@ class MouseEvent {
|
|
|
7030
7077
|
this._defaultPrevented = true;
|
|
7031
7078
|
}
|
|
7032
7079
|
}
|
|
7033
|
-
var
|
|
7034
|
-
((
|
|
7035
|
-
|
|
7036
|
-
|
|
7037
|
-
|
|
7038
|
-
|
|
7039
|
-
|
|
7040
|
-
})(
|
|
7080
|
+
var MouseButton2;
|
|
7081
|
+
((MouseButton) => {
|
|
7082
|
+
MouseButton[MouseButton["LEFT"] = 0] = "LEFT";
|
|
7083
|
+
MouseButton[MouseButton["MIDDLE"] = 1] = "MIDDLE";
|
|
7084
|
+
MouseButton[MouseButton["RIGHT"] = 2] = "RIGHT";
|
|
7085
|
+
MouseButton[MouseButton["WHEEL_UP"] = 4] = "WHEEL_UP";
|
|
7086
|
+
MouseButton[MouseButton["WHEEL_DOWN"] = 5] = "WHEEL_DOWN";
|
|
7087
|
+
})(MouseButton2 ||= {});
|
|
7041
7088
|
var rendererTracker = singleton("RendererTracker", () => ({
|
|
7042
7089
|
renderers: new Set,
|
|
7043
7090
|
streamOwners: new WeakMap
|
|
7044
7091
|
}));
|
|
7045
|
-
async function
|
|
7092
|
+
async function createCliRenderer2(config = {}) {
|
|
7046
7093
|
if (process.argv.includes("--delay-start")) {
|
|
7047
7094
|
await new Promise((resolve) => setTimeout(resolve, 5000));
|
|
7048
7095
|
}
|
|
@@ -7050,7 +7097,7 @@ async function createCliRenderer(config = {}) {
|
|
|
7050
7097
|
const stdout = config.stdout ?? process.stdout;
|
|
7051
7098
|
const width = stdout.columns || config.width || 80;
|
|
7052
7099
|
const height = stdout.rows || config.height || 24;
|
|
7053
|
-
const renderer = new
|
|
7100
|
+
const renderer = new CliRenderer2(stdin, stdout, width, height, config);
|
|
7054
7101
|
try {
|
|
7055
7102
|
await renderer.setupTerminal();
|
|
7056
7103
|
return renderer;
|
|
@@ -7063,37 +7110,37 @@ async function createCliRenderer(config = {}) {
|
|
|
7063
7110
|
throw error;
|
|
7064
7111
|
}
|
|
7065
7112
|
}
|
|
7066
|
-
var
|
|
7067
|
-
((
|
|
7068
|
-
|
|
7069
|
-
|
|
7070
|
-
|
|
7071
|
-
|
|
7072
|
-
|
|
7073
|
-
|
|
7074
|
-
|
|
7075
|
-
|
|
7076
|
-
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
|
|
7084
|
-
})(
|
|
7085
|
-
var
|
|
7086
|
-
((
|
|
7087
|
-
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
7091
|
-
|
|
7092
|
-
|
|
7093
|
-
})(
|
|
7113
|
+
var CliRenderEvents2;
|
|
7114
|
+
((CliRenderEvents) => {
|
|
7115
|
+
CliRenderEvents["RESIZE"] = "resize";
|
|
7116
|
+
CliRenderEvents["FRAME"] = "frame";
|
|
7117
|
+
CliRenderEvents["RENDER_ERROR"] = "render:error";
|
|
7118
|
+
CliRenderEvents["HANDLER_ERROR"] = "handler:error";
|
|
7119
|
+
CliRenderEvents["EXTERNAL_OUTPUT"] = "external_output";
|
|
7120
|
+
CliRenderEvents["FOCUS"] = "focus";
|
|
7121
|
+
CliRenderEvents["BLUR"] = "blur";
|
|
7122
|
+
CliRenderEvents["FOCUSED_RENDERABLE"] = "focused_renderable";
|
|
7123
|
+
CliRenderEvents["FOCUSED_EDITOR"] = "focused_editor";
|
|
7124
|
+
CliRenderEvents["THEME_MODE"] = "theme_mode";
|
|
7125
|
+
CliRenderEvents["PALETTE"] = "palette";
|
|
7126
|
+
CliRenderEvents["CAPABILITIES"] = "capabilities";
|
|
7127
|
+
CliRenderEvents["SELECTION"] = "selection";
|
|
7128
|
+
CliRenderEvents["DEBUG_OVERLAY_TOGGLE"] = "debugOverlay:toggle";
|
|
7129
|
+
CliRenderEvents["DESTROY"] = "destroy";
|
|
7130
|
+
CliRenderEvents["MEMORY_SNAPSHOT"] = "memory:snapshot";
|
|
7131
|
+
})(CliRenderEvents2 ||= {});
|
|
7132
|
+
var RendererControlState2;
|
|
7133
|
+
((RendererControlState) => {
|
|
7134
|
+
RendererControlState["IDLE"] = "idle";
|
|
7135
|
+
RendererControlState["AUTO_STARTED"] = "auto_started";
|
|
7136
|
+
RendererControlState["EXPLICIT_STARTED"] = "explicit_started";
|
|
7137
|
+
RendererControlState["EXPLICIT_PAUSED"] = "explicit_paused";
|
|
7138
|
+
RendererControlState["EXPLICIT_SUSPENDED"] = "explicit_suspended";
|
|
7139
|
+
RendererControlState["EXPLICIT_STOPPED"] = "explicit_stopped";
|
|
7140
|
+
})(RendererControlState2 ||= {});
|
|
7094
7141
|
var CLICK_REPEAT_INTERVAL_MS = 500;
|
|
7095
7142
|
|
|
7096
|
-
class
|
|
7143
|
+
class CliRenderer2 extends EventEmitter5 {
|
|
7097
7144
|
static animationFrameId = 0;
|
|
7098
7145
|
lib;
|
|
7099
7146
|
rendererPtr;
|
|
@@ -7128,7 +7175,7 @@ class CliRenderer extends EventEmitter5 {
|
|
|
7128
7175
|
frameTimes = [];
|
|
7129
7176
|
maxStatSamples = 300;
|
|
7130
7177
|
postProcessFns = [];
|
|
7131
|
-
backgroundColor =
|
|
7178
|
+
backgroundColor = RGBA2.fromInts(0, 0, 0, 0);
|
|
7132
7179
|
waitingForPixelResolution = false;
|
|
7133
7180
|
pixelResolutionRequeryPending = false;
|
|
7134
7181
|
clock;
|
|
@@ -7144,6 +7191,7 @@ class CliRenderer extends EventEmitter5 {
|
|
|
7144
7191
|
minTargetFrameTime = 1000 / this._maxFps;
|
|
7145
7192
|
immediateRerenderRequested = false;
|
|
7146
7193
|
updateScheduled = false;
|
|
7194
|
+
updateGeneration = 0;
|
|
7147
7195
|
liveRequestCounter = 0;
|
|
7148
7196
|
_controlState = "idle" /* IDLE */;
|
|
7149
7197
|
frameCallbacks = [];
|
|
@@ -7154,7 +7202,7 @@ class CliRenderer extends EventEmitter5 {
|
|
|
7154
7202
|
frameCallbackTime: 0
|
|
7155
7203
|
};
|
|
7156
7204
|
debugOverlay = {
|
|
7157
|
-
enabled:
|
|
7205
|
+
enabled: env2.OTUI_SHOW_STATS,
|
|
7158
7206
|
corner: 3 /* bottomRight */
|
|
7159
7207
|
};
|
|
7160
7208
|
_console;
|
|
@@ -7166,6 +7214,8 @@ class CliRenderer extends EventEmitter5 {
|
|
|
7166
7214
|
animationRequest = new Map;
|
|
7167
7215
|
resizeTimeoutId = null;
|
|
7168
7216
|
capabilityTimeoutId = null;
|
|
7217
|
+
kittyTransportTimer = null;
|
|
7218
|
+
kittyTransportMode;
|
|
7169
7219
|
terminalKeepAliveTimer = null;
|
|
7170
7220
|
xtVersionWaiters = new Set;
|
|
7171
7221
|
splitStartupSeedTimeoutId = null;
|
|
@@ -7237,8 +7287,8 @@ class CliRenderer extends EventEmitter5 {
|
|
|
7237
7287
|
themeModeHandler;
|
|
7238
7288
|
idleResolvers = [];
|
|
7239
7289
|
_debugInputs = [];
|
|
7240
|
-
_debugModeEnabled =
|
|
7241
|
-
stdinLogPath =
|
|
7290
|
+
_debugModeEnabled = env2.OTUI_DEBUG;
|
|
7291
|
+
stdinLogPath = env2.OTUI_STDIN_LOG;
|
|
7242
7292
|
handleError = ((error) => {
|
|
7243
7293
|
console.error(error);
|
|
7244
7294
|
if (this._openConsoleOnError) {
|
|
@@ -7247,7 +7297,7 @@ class CliRenderer extends EventEmitter5 {
|
|
|
7247
7297
|
}).bind(this);
|
|
7248
7298
|
dumpOutputCache(optionalMessage = "") {
|
|
7249
7299
|
const cachedLogs = this.console.getCachedLogs();
|
|
7250
|
-
const capturedConsoleOutput =
|
|
7300
|
+
const capturedConsoleOutput = capture2.claimOutput();
|
|
7251
7301
|
const capturedExternalOutputCommits = this.externalOutputQueue.claim();
|
|
7252
7302
|
let capturedExternalOutput = "";
|
|
7253
7303
|
for (const commit of capturedExternalOutputCommits) {
|
|
@@ -7281,7 +7331,7 @@ Captured external output:
|
|
|
7281
7331
|
}
|
|
7282
7332
|
exitHandler = (() => {
|
|
7283
7333
|
this.destroy();
|
|
7284
|
-
if (
|
|
7334
|
+
if (env2.OTUI_DUMP_CAPTURES) {
|
|
7285
7335
|
sleep(100).then(() => {
|
|
7286
7336
|
this.dumpOutputCache(`=== CAPTURED OUTPUT ===
|
|
7287
7337
|
`);
|
|
@@ -7296,8 +7346,7 @@ Captured external output:
|
|
|
7296
7346
|
_detachFeed = null;
|
|
7297
7347
|
_detachFeedError = null;
|
|
7298
7348
|
feedIdleRenderScheduled = false;
|
|
7299
|
-
|
|
7300
|
-
ordinaryFrameWaitControlState = null;
|
|
7349
|
+
feedIdleWaitPending = false;
|
|
7301
7350
|
get controlState() {
|
|
7302
7351
|
return this._controlState;
|
|
7303
7352
|
}
|
|
@@ -7307,12 +7356,16 @@ Captured external output:
|
|
|
7307
7356
|
this.stdout = stdout;
|
|
7308
7357
|
this._usesProcessStdout = stdout === process.stdout;
|
|
7309
7358
|
this.realStdoutWrite = stdout.write;
|
|
7310
|
-
const lib =
|
|
7359
|
+
const lib = resolveRenderLib2();
|
|
7311
7360
|
const useMemoryBufferedOutput = config.bufferedOutput === "memory";
|
|
7312
7361
|
const useFeedOutput = !this._usesProcessStdout && !useMemoryBufferedOutput;
|
|
7313
7362
|
const { screenMode, footerHeight, externalOutputMode } = resolveModes(config);
|
|
7314
7363
|
const initialGeometry = calculateRenderGeometry(screenMode, width, height, footerHeight);
|
|
7315
7364
|
const remoteMode = config.remote ?? (useFeedOutput ? true : undefined);
|
|
7365
|
+
this.kittyTransportMode = config.kittyImageTransport ?? "raw";
|
|
7366
|
+
const transportCode = KITTY_IMAGE_TRANSPORTS.indexOf(this.kittyTransportMode);
|
|
7367
|
+
if (transportCode < 0)
|
|
7368
|
+
throw new TypeError("Invalid kittyImageTransport");
|
|
7316
7369
|
if (rendererTracker.streamOwners.get(stdin)) {
|
|
7317
7370
|
throw new Error("Cannot create CliRenderer: stdin is already used by another CliRenderer");
|
|
7318
7371
|
}
|
|
@@ -7322,7 +7375,7 @@ Captured external output:
|
|
|
7322
7375
|
let feed = null;
|
|
7323
7376
|
if (useFeedOutput) {
|
|
7324
7377
|
try {
|
|
7325
|
-
feed =
|
|
7378
|
+
feed = NativeSpanFeed2.create();
|
|
7326
7379
|
} catch (error) {
|
|
7327
7380
|
throw new Error(`Failed to allocate NativeSpanFeed for custom stdout: ${error instanceof Error ? error.message : String(error)}`);
|
|
7328
7381
|
}
|
|
@@ -7342,13 +7395,14 @@ Captured external output:
|
|
|
7342
7395
|
feed?.close();
|
|
7343
7396
|
throw new Error("Failed to create renderer");
|
|
7344
7397
|
}
|
|
7398
|
+
lib.setKittyImageTransport(rendererPtr, transportCode);
|
|
7345
7399
|
if (config.useThread === undefined)
|
|
7346
7400
|
config.useThread = true;
|
|
7347
7401
|
if (process.platform === "linux")
|
|
7348
7402
|
config.useThread = false;
|
|
7349
7403
|
lib.setUseThread(rendererPtr, config.useThread);
|
|
7350
7404
|
const kittyConfig = config.useKittyKeyboard ?? {};
|
|
7351
|
-
const kittyFlags =
|
|
7405
|
+
const kittyFlags = buildKittyKeyboardFlags2(kittyConfig);
|
|
7352
7406
|
lib.setKittyKeyboardFlags(rendererPtr, kittyFlags);
|
|
7353
7407
|
this._feed = feed;
|
|
7354
7408
|
if (feed) {
|
|
@@ -7358,6 +7412,8 @@ Captured external output:
|
|
|
7358
7412
|
});
|
|
7359
7413
|
});
|
|
7360
7414
|
this._detachFeedError = feed.onError((code) => {
|
|
7415
|
+
if (this.kittyTransportTimer !== null)
|
|
7416
|
+
this.kittyOutputErrorHandler();
|
|
7361
7417
|
console.error(`[CliRenderer] NativeSpanFeed error: code=${code}`);
|
|
7362
7418
|
});
|
|
7363
7419
|
}
|
|
@@ -7392,11 +7448,11 @@ Captured external output:
|
|
|
7392
7448
|
"SIGBREAK",
|
|
7393
7449
|
"SIGBUS"
|
|
7394
7450
|
];
|
|
7395
|
-
this.clipboard = new
|
|
7451
|
+
this.clipboard = new Clipboard2(this.lib, this.rendererPtr);
|
|
7396
7452
|
this.resizeDebounceDelay = config.debounceDelay || 100;
|
|
7397
7453
|
this.targetFps = config.targetFps || 30;
|
|
7398
7454
|
this.maxFps = config.maxFps || 60;
|
|
7399
|
-
this.clock = config.clock ?? new
|
|
7455
|
+
this.clock = config.clock ?? new SystemClock2;
|
|
7400
7456
|
this.themeModeState = new RendererThemeMode({
|
|
7401
7457
|
queryThemeColors: () => {
|
|
7402
7458
|
this.lib.queryThemeColors(this.rendererPtr);
|
|
@@ -7423,7 +7479,7 @@ Captured external output:
|
|
|
7423
7479
|
this.currentRenderBuffer = this.lib.getCurrentBuffer(this.rendererPtr);
|
|
7424
7480
|
this.postProcessFns = config.postProcessFns || [];
|
|
7425
7481
|
this.prependedInputHandlers = config.prependInputHandlers || [];
|
|
7426
|
-
this.root = new
|
|
7482
|
+
this.root = new RootRenderable2(this);
|
|
7427
7483
|
if (this.memorySnapshotInterval > 0) {
|
|
7428
7484
|
this.startMemorySnapshotTimer();
|
|
7429
7485
|
}
|
|
@@ -7434,7 +7490,7 @@ Captured external output:
|
|
|
7434
7490
|
process.on("uncaughtException", this.handleError);
|
|
7435
7491
|
process.on("unhandledRejection", this.handleError);
|
|
7436
7492
|
const useKittyForParsing = kittyConfig !== null;
|
|
7437
|
-
this._keyHandler = new
|
|
7493
|
+
this._keyHandler = new InternalKeyHandler2;
|
|
7438
7494
|
this._keyHandler.on("keypress", (event) => {
|
|
7439
7495
|
if (this.exitOnCtrlC && matchesKeyBinding(event, { name: "c", ctrl: true })) {
|
|
7440
7496
|
process.nextTick(() => {
|
|
@@ -7445,7 +7501,7 @@ Captured external output:
|
|
|
7445
7501
|
});
|
|
7446
7502
|
this.addExitListeners();
|
|
7447
7503
|
const stdinParserMaxBufferBytes = config.stdinParserMaxBufferBytes ?? DEFAULT_STDIN_PARSER_MAX_BUFFER_BYTES;
|
|
7448
|
-
this.stdinParser = new
|
|
7504
|
+
this.stdinParser = new StdinParser2({
|
|
7449
7505
|
timeoutMs: 20,
|
|
7450
7506
|
maxPendingBytes: stdinParserMaxBufferBytes,
|
|
7451
7507
|
armTimeouts: true,
|
|
@@ -7462,7 +7518,7 @@ Captured external output:
|
|
|
7462
7518
|
},
|
|
7463
7519
|
clock: this.clock
|
|
7464
7520
|
});
|
|
7465
|
-
this._console = new
|
|
7521
|
+
this._console = new TerminalConsole2(this, {
|
|
7466
7522
|
...config.consoleOptions ?? {},
|
|
7467
7523
|
clock: this.clock
|
|
7468
7524
|
});
|
|
@@ -7476,20 +7532,21 @@ Captured external output:
|
|
|
7476
7532
|
this._openConsoleOnError = config.openConsoleOnError ?? true;
|
|
7477
7533
|
this._onDestroy = config.onDestroy;
|
|
7478
7534
|
global.requestAnimationFrame = (callback) => {
|
|
7479
|
-
const id =
|
|
7535
|
+
const id = CliRenderer2.animationFrameId++;
|
|
7480
7536
|
this.animationRequest.set(id, callback);
|
|
7481
7537
|
this.requestLive();
|
|
7482
7538
|
return id;
|
|
7483
7539
|
};
|
|
7484
7540
|
global.cancelAnimationFrame = (handle) => {
|
|
7485
|
-
this.animationRequest.delete(handle)
|
|
7541
|
+
if (this.animationRequest.delete(handle))
|
|
7542
|
+
this.dropLive();
|
|
7486
7543
|
};
|
|
7487
7544
|
const window = global.window;
|
|
7488
7545
|
if (!window) {
|
|
7489
7546
|
global.window = {};
|
|
7490
7547
|
}
|
|
7491
7548
|
global.window.requestAnimationFrame = requestAnimationFrame;
|
|
7492
|
-
if (
|
|
7549
|
+
if (env2.OTUI_NO_NATIVE_RENDER) {
|
|
7493
7550
|
this.renderNative = () => {
|
|
7494
7551
|
if (this._splitHeight > 0) {
|
|
7495
7552
|
this.flushStdoutCache(this._splitHeight);
|
|
@@ -7530,8 +7587,9 @@ Captured external output:
|
|
|
7530
7587
|
removeExitListeners() {
|
|
7531
7588
|
if (!this._exitListenersAdded || this.exitSignals.length === 0)
|
|
7532
7589
|
return;
|
|
7590
|
+
const processEvents = process;
|
|
7533
7591
|
this.exitSignals.forEach((signal) => {
|
|
7534
|
-
|
|
7592
|
+
processEvents.removeListener(signal, this.exitHandler);
|
|
7535
7593
|
});
|
|
7536
7594
|
this._exitListenersAdded = false;
|
|
7537
7595
|
}
|
|
@@ -7553,7 +7611,7 @@ Captured external output:
|
|
|
7553
7611
|
get currentFocusedEditor() {
|
|
7554
7612
|
if (!this._currentFocusedRenderable)
|
|
7555
7613
|
return null;
|
|
7556
|
-
if (!
|
|
7614
|
+
if (!isEditBufferRenderable2(this._currentFocusedRenderable))
|
|
7557
7615
|
return null;
|
|
7558
7616
|
return this._currentFocusedRenderable;
|
|
7559
7617
|
}
|
|
@@ -7635,27 +7693,33 @@ Captured external output:
|
|
|
7635
7693
|
}
|
|
7636
7694
|
scheduleRenderAfterFeedIdle() {
|
|
7637
7695
|
const feed = this._feed;
|
|
7638
|
-
if (!feed || this.
|
|
7696
|
+
if (!feed || this._isDestroyed || this._controlState === "explicit_suspended" /* EXPLICIT_SUSPENDED */)
|
|
7639
7697
|
return;
|
|
7640
7698
|
this.feedIdleRenderScheduled = true;
|
|
7699
|
+
if (this.feedIdleWaitPending)
|
|
7700
|
+
return;
|
|
7701
|
+
this.feedIdleWaitPending = true;
|
|
7641
7702
|
feed.idle().then(() => {
|
|
7642
|
-
this.
|
|
7643
|
-
|
|
7644
|
-
|
|
7645
|
-
|
|
7646
|
-
|
|
7647
|
-
if (this._isDestroyed || ordinaryFrameWasWaiting && this._controlState !== ordinaryFrameWaitControlState && (this._controlState === "explicit_paused" /* EXPLICIT_PAUSED */ || this._controlState === "explicit_stopped" /* EXPLICIT_STOPPED */ || this._controlState === "explicit_suspended" /* EXPLICIT_SUSPENDED */)) {
|
|
7648
|
-
this.resolveIdleIfNeeded();
|
|
7703
|
+
this.feedIdleWaitPending = false;
|
|
7704
|
+
if (!this.feedIdleRenderScheduled)
|
|
7705
|
+
return;
|
|
7706
|
+
if (feed.isBackpressured()) {
|
|
7707
|
+
this.scheduleRenderAfterFeedIdle();
|
|
7649
7708
|
return;
|
|
7650
7709
|
}
|
|
7710
|
+
this.feedIdleRenderScheduled = false;
|
|
7651
7711
|
this.scheduleRenderTimer();
|
|
7652
7712
|
this.resolveIdleIfNeeded();
|
|
7653
7713
|
});
|
|
7654
7714
|
}
|
|
7715
|
+
cancelRenderAfterFeedIdle() {
|
|
7716
|
+
if (!this.feedIdleRenderScheduled)
|
|
7717
|
+
return;
|
|
7718
|
+
this.feedIdleRenderScheduled = false;
|
|
7719
|
+
this.immediateRerenderRequested = false;
|
|
7720
|
+
}
|
|
7655
7721
|
handleNativeRenderRejection(status) {
|
|
7656
7722
|
if (status === NATIVE_RENDER_STATUS_SKIPPED && this._feed) {
|
|
7657
|
-
this.ordinaryFrameWaitingForFeed = true;
|
|
7658
|
-
this.ordinaryFrameWaitControlState = this._controlState;
|
|
7659
7723
|
this.scheduleRenderAfterFeedIdle();
|
|
7660
7724
|
return "retryable-skip";
|
|
7661
7725
|
}
|
|
@@ -7697,39 +7761,38 @@ Captured external output:
|
|
|
7697
7761
|
return;
|
|
7698
7762
|
}
|
|
7699
7763
|
if (this._isRunning) {
|
|
7700
|
-
if (!this.rendering && !this.renderTimeout
|
|
7764
|
+
if (!this.rendering && !this.renderTimeout) {
|
|
7701
7765
|
this.scheduleRenderTimer();
|
|
7702
7766
|
}
|
|
7703
7767
|
return;
|
|
7704
7768
|
}
|
|
7705
|
-
if (this.ordinaryFrameWaitingForFeed) {
|
|
7706
|
-
return;
|
|
7707
|
-
}
|
|
7708
7769
|
if (this.rendering) {
|
|
7709
7770
|
this.immediateRerenderRequested = true;
|
|
7710
7771
|
return;
|
|
7711
7772
|
}
|
|
7712
7773
|
if (!this.updateScheduled && !this.renderTimeout) {
|
|
7713
7774
|
this.updateScheduled = true;
|
|
7775
|
+
const generation = ++this.updateGeneration;
|
|
7714
7776
|
const now = this.normalizeClockTime(this.clock.now(), this.lastTime);
|
|
7715
7777
|
const elapsed = this.getElapsedMs(now, this.lastTime);
|
|
7716
7778
|
const delay = Math.max(this.minTargetFrameTime - elapsed, 0);
|
|
7717
7779
|
if (delay === 0) {
|
|
7718
|
-
process.nextTick(() => this.activateFrame());
|
|
7780
|
+
process.nextTick(() => this.activateFrame(generation));
|
|
7719
7781
|
return;
|
|
7720
7782
|
}
|
|
7721
|
-
this.clock.setTimeout(() => this.activateFrame(), delay);
|
|
7783
|
+
this.clock.setTimeout(() => this.activateFrame(generation), delay);
|
|
7722
7784
|
}
|
|
7723
7785
|
}
|
|
7724
|
-
async activateFrame() {
|
|
7725
|
-
if (!this.updateScheduled) {
|
|
7786
|
+
async activateFrame(generation) {
|
|
7787
|
+
if (generation !== this.updateGeneration || !this.updateScheduled) {
|
|
7726
7788
|
this.resolveIdleIfNeeded();
|
|
7727
7789
|
return;
|
|
7728
7790
|
}
|
|
7729
7791
|
try {
|
|
7730
7792
|
await this.loop();
|
|
7731
7793
|
} finally {
|
|
7732
|
-
this.
|
|
7794
|
+
if (generation === this.updateGeneration)
|
|
7795
|
+
this.updateScheduled = false;
|
|
7733
7796
|
this.resolveIdleIfNeeded();
|
|
7734
7797
|
}
|
|
7735
7798
|
}
|
|
@@ -7948,6 +8011,50 @@ Captured external output:
|
|
|
7948
8011
|
get capabilities() {
|
|
7949
8012
|
return this._capabilities;
|
|
7950
8013
|
}
|
|
8014
|
+
get kittyImageTransport() {
|
|
8015
|
+
return this.kittyTransportMode;
|
|
8016
|
+
}
|
|
8017
|
+
set kittyImageTransport(mode) {
|
|
8018
|
+
const code = KITTY_IMAGE_TRANSPORTS.indexOf(mode);
|
|
8019
|
+
if (code < 0)
|
|
8020
|
+
throw new TypeError("Invalid kittyImageTransport");
|
|
8021
|
+
if (this._isDestroyed || mode === this.kittyTransportMode)
|
|
8022
|
+
return;
|
|
8023
|
+
this.kittyTransportMode = mode;
|
|
8024
|
+
this.startKittyTransportPolling();
|
|
8025
|
+
this.lib.setKittyImageTransport(this.rendererPtr, code);
|
|
8026
|
+
this.requestRender();
|
|
8027
|
+
}
|
|
8028
|
+
startKittyTransportPolling() {
|
|
8029
|
+
if (!this._terminalIsSetup || this.kittyTransportMode !== "file" || this.kittyTransportTimer !== null)
|
|
8030
|
+
return;
|
|
8031
|
+
this.stdout.on("error", this.kittyOutputErrorHandler);
|
|
8032
|
+
this.kittyTransportTimer = this.clock.setInterval(() => {
|
|
8033
|
+
if (!this._isDestroyed && this.lib.pollKittyImageTransport(this.rendererPtr))
|
|
8034
|
+
this.requestRender();
|
|
8035
|
+
}, 1000);
|
|
8036
|
+
}
|
|
8037
|
+
get kittyImageTransportStatus() {
|
|
8038
|
+
const [mode, effective, fileState, fallback, pendingFiles, pendingBytes] = this.lib.getKittyImageTransport(this.rendererPtr);
|
|
8039
|
+
return {
|
|
8040
|
+
requested: KITTY_IMAGE_TRANSPORTS[mode],
|
|
8041
|
+
effective: ["raw", "zlib", "png", "file"][effective],
|
|
8042
|
+
fileState: ["disabled", "probing", "ready", "unsupported", "timeout", "io-error", "cancelled"][fileState],
|
|
8043
|
+
fallback: ["none", "not-ready", "unavailable", "budget", "busy", "preparation", "compression"][fallback],
|
|
8044
|
+
pendingFiles,
|
|
8045
|
+
pendingBytes
|
|
8046
|
+
};
|
|
8047
|
+
}
|
|
8048
|
+
cancelKittyImageTransport() {
|
|
8049
|
+
if (this._isDestroyed)
|
|
8050
|
+
return;
|
|
8051
|
+
this.lib.cancelKittyImageTransport(this.rendererPtr, false);
|
|
8052
|
+
this.requestRender();
|
|
8053
|
+
}
|
|
8054
|
+
kittyOutputErrorHandler = () => {
|
|
8055
|
+
if (!this._isDestroyed)
|
|
8056
|
+
this.lib.cancelKittyImageTransport(this.rendererPtr, true);
|
|
8057
|
+
};
|
|
7951
8058
|
triggerNotification(message, title) {
|
|
7952
8059
|
if (this._isDestroyed)
|
|
7953
8060
|
return false;
|
|
@@ -7998,8 +8105,8 @@ Captured external output:
|
|
|
7998
8105
|
enumerable: true,
|
|
7999
8106
|
configurable: true
|
|
8000
8107
|
});
|
|
8001
|
-
const internalRoot = new
|
|
8002
|
-
const publicRoot = new
|
|
8108
|
+
const internalRoot = new RootRenderable2(renderContext);
|
|
8109
|
+
const publicRoot = new BoxRenderable2(renderContext, {
|
|
8003
8110
|
id: `scrollback-surface-root-${surfaceId}`,
|
|
8004
8111
|
position: "absolute",
|
|
8005
8112
|
left: 0,
|
|
@@ -8022,12 +8129,16 @@ Captured external output:
|
|
|
8022
8129
|
let surfaceDestroyed = false;
|
|
8023
8130
|
let hasRendered = false;
|
|
8024
8131
|
let nextCommitStartOnNewLine = startOnNewLine;
|
|
8025
|
-
let backingBuffer =
|
|
8132
|
+
let backingBuffer = OptimizedBuffer2.create(surfaceWidth, surfaceHeight, surfaceWidthMethod, {
|
|
8026
8133
|
id: `scrollback-surface-buffer-${surfaceId}`
|
|
8027
8134
|
});
|
|
8028
8135
|
const destroyListener = () => {
|
|
8029
8136
|
destroySurface();
|
|
8030
8137
|
};
|
|
8138
|
+
const capabilitiesListener = (capabilities) => {
|
|
8139
|
+
snapshotContext.capabilities = capabilities;
|
|
8140
|
+
renderContext.emit("capabilities" /* CAPABILITIES */, capabilities);
|
|
8141
|
+
};
|
|
8031
8142
|
const assertNotDestroyed = () => {
|
|
8032
8143
|
if (surfaceDestroyed) {
|
|
8033
8144
|
throw new Error("ScrollbackSurface is destroyed");
|
|
@@ -8059,7 +8170,7 @@ Captured external output:
|
|
|
8059
8170
|
};
|
|
8060
8171
|
const collectPendingCodeRenderables = (node) => {
|
|
8061
8172
|
const pending = [];
|
|
8062
|
-
if (node instanceof
|
|
8173
|
+
if (node instanceof CodeRenderable2 && node.isHighlighting) {
|
|
8063
8174
|
pending.push(node);
|
|
8064
8175
|
}
|
|
8065
8176
|
for (const child of node.getChildren()) {
|
|
@@ -8116,7 +8227,7 @@ Captured external output:
|
|
|
8116
8227
|
let targetHeight = Math.max(1, surfaceHeight);
|
|
8117
8228
|
if (surfaceWidthMethod !== widthMethod) {
|
|
8118
8229
|
backingBuffer.destroy();
|
|
8119
|
-
backingBuffer =
|
|
8230
|
+
backingBuffer = OptimizedBuffer2.create(width, targetHeight, widthMethod, {
|
|
8120
8231
|
id: `scrollback-surface-buffer-${surfaceId}`
|
|
8121
8232
|
});
|
|
8122
8233
|
} else {
|
|
@@ -8176,7 +8287,7 @@ Captured external output:
|
|
|
8176
8287
|
return;
|
|
8177
8288
|
}
|
|
8178
8289
|
const rowCount = endRowExclusive - startRow;
|
|
8179
|
-
const commitBuffer =
|
|
8290
|
+
const commitBuffer = OptimizedBuffer2.create(surfaceWidth, rowCount, surfaceWidthMethod, {
|
|
8180
8291
|
id: `scrollback-surface-commit-${surfaceId}`
|
|
8181
8292
|
});
|
|
8182
8293
|
try {
|
|
@@ -8199,6 +8310,7 @@ Captured external output:
|
|
|
8199
8310
|
}
|
|
8200
8311
|
surfaceDestroyed = true;
|
|
8201
8312
|
renderer.off("destroy" /* DESTROY */, destroyListener);
|
|
8313
|
+
renderer.off("capabilities" /* CAPABILITIES */, capabilitiesListener);
|
|
8202
8314
|
let destroyError = null;
|
|
8203
8315
|
try {
|
|
8204
8316
|
internalRoot.destroyRecursively();
|
|
@@ -8219,6 +8331,7 @@ Captured external output:
|
|
|
8219
8331
|
}
|
|
8220
8332
|
};
|
|
8221
8333
|
renderer.on("destroy" /* DESTROY */, destroyListener);
|
|
8334
|
+
renderer.on("capabilities" /* CAPABILITIES */, capabilitiesListener);
|
|
8222
8335
|
return {
|
|
8223
8336
|
get renderContext() {
|
|
8224
8337
|
return renderContext;
|
|
@@ -8265,8 +8378,8 @@ Captured external output:
|
|
|
8265
8378
|
snapshotContext.width = snapshotWidth;
|
|
8266
8379
|
snapshotContext.height = snapshotHeight;
|
|
8267
8380
|
snapshotContext.widthMethod = this.widthMethod;
|
|
8268
|
-
snapshotRoot = new
|
|
8269
|
-
snapshotBuffer =
|
|
8381
|
+
snapshotRoot = new RootRenderable2(snapshotContext);
|
|
8382
|
+
snapshotBuffer = OptimizedBuffer2.create(snapshotWidth, snapshotHeight, this.widthMethod, {
|
|
8270
8383
|
id: "scrollback-snapshot-commit"
|
|
8271
8384
|
});
|
|
8272
8385
|
snapshotRoot.add(rootRenderable);
|
|
@@ -8425,8 +8538,8 @@ Captured external output:
|
|
|
8425
8538
|
const lineCells = [...line];
|
|
8426
8539
|
const rowColumns = Math.min(lineCells.length, maxWidth);
|
|
8427
8540
|
const renderedLine = lineCells.slice(0, maxWidth).join("");
|
|
8428
|
-
const snapshotRoot = new
|
|
8429
|
-
const snapshotRenderable = new
|
|
8541
|
+
const snapshotRoot = new RootRenderable2(snapshotContext);
|
|
8542
|
+
const snapshotRenderable = new TextRenderable2(snapshotContext, {
|
|
8430
8543
|
id: "captured-stdout-snapshot",
|
|
8431
8544
|
position: "absolute",
|
|
8432
8545
|
left: 0,
|
|
@@ -8435,7 +8548,7 @@ Captured external output:
|
|
|
8435
8548
|
height: 1,
|
|
8436
8549
|
content: renderedLine
|
|
8437
8550
|
});
|
|
8438
|
-
const snapshotBuffer =
|
|
8551
|
+
const snapshotBuffer = OptimizedBuffer2.create(Math.max(1, rowColumns), 1, this.widthMethod, {
|
|
8439
8552
|
id: "captured-stdout-snapshot"
|
|
8440
8553
|
});
|
|
8441
8554
|
try {
|
|
@@ -8509,7 +8622,7 @@ Captured external output:
|
|
|
8509
8622
|
const forceCommit = forceFooterRepaint && index === lastCommitIndex;
|
|
8510
8623
|
const beginFrame = index === 0;
|
|
8511
8624
|
const finalizeFrame = index === lastCommitIndex;
|
|
8512
|
-
const nativeResult = this.lib.commitSplitFooterSnapshot(this.rendererPtr, commit.snapshot, commit.rowColumns, commit.startOnNewLine, commit.trailingNewline, this.getSplitPinnedRenderOffset(), forceCommit, beginFrame, finalizeFrame);
|
|
8625
|
+
const nativeResult = this.lib.commitSplitFooterSnapshot(this.rendererPtr, commit.snapshot, commit.rowColumns, commit.startOnNewLine, commit.trailingNewline, this.getSplitPinnedRenderOffset(), forceCommit, beginFrame, finalizeFrame, drainAll);
|
|
8513
8626
|
if (nativeResult.status === NATIVE_RENDER_STATUS_SKIPPED) {
|
|
8514
8627
|
nativeBackpressured = true;
|
|
8515
8628
|
break;
|
|
@@ -8850,6 +8963,7 @@ Captured external output:
|
|
|
8850
8963
|
explicitWidthCprActive: true,
|
|
8851
8964
|
startupCursorCprActive
|
|
8852
8965
|
});
|
|
8966
|
+
this.startKittyTransportPolling();
|
|
8853
8967
|
this.lib.setupTerminal(this.rendererPtr, this._screenMode === "alternate-screen");
|
|
8854
8968
|
this._capabilities = this.lib.getTerminalCapabilities(this.rendererPtr);
|
|
8855
8969
|
if (this.debugOverlay.enabled) {
|
|
@@ -9015,6 +9129,14 @@ Captured external output:
|
|
|
9015
9129
|
});
|
|
9016
9130
|
}
|
|
9017
9131
|
handleStdinEvent(event) {
|
|
9132
|
+
if (event.type === "response" && event.sequence.startsWith("\x1B_G")) {
|
|
9133
|
+
const result = this.lib.processKittyImageReply(this.rendererPtr, event.sequence);
|
|
9134
|
+
if (result !== 0) {
|
|
9135
|
+
if (result === 2)
|
|
9136
|
+
this.requestRender();
|
|
9137
|
+
return;
|
|
9138
|
+
}
|
|
9139
|
+
}
|
|
9018
9140
|
if (this._controlState === "explicit_suspended" /* EXPLICIT_SUSPENDED */) {
|
|
9019
9141
|
if (event.type === "response" && isPixelResolutionResponse(event.sequence)) {
|
|
9020
9142
|
this.dispatchSequenceHandlers(event.sequence);
|
|
@@ -9099,7 +9221,7 @@ Captured external output:
|
|
|
9099
9221
|
this.startTerminalKeepAlive();
|
|
9100
9222
|
}
|
|
9101
9223
|
dispatchMouseEvent(target, attributes) {
|
|
9102
|
-
const event = new
|
|
9224
|
+
const event = new MouseEvent2(target, attributes);
|
|
9103
9225
|
this.sendMouseEvent(target, event);
|
|
9104
9226
|
if (this.autoFocus && event.type === "down" && event.button === 0 /* LEFT */ && !event.defaultPrevented) {
|
|
9105
9227
|
let current = target;
|
|
@@ -9136,27 +9258,27 @@ Captured external output:
|
|
|
9136
9258
|
if (this._console.visible) {
|
|
9137
9259
|
const consoleBounds = this._console.bounds;
|
|
9138
9260
|
if (mouseEvent.x >= consoleBounds.x && mouseEvent.x < consoleBounds.x + consoleBounds.width && mouseEvent.y >= consoleBounds.y && mouseEvent.y < consoleBounds.y + consoleBounds.height) {
|
|
9139
|
-
const
|
|
9140
|
-
const handled = this._console.handleMouse(
|
|
9261
|
+
const event = new MouseEvent2(null, mouseEvent);
|
|
9262
|
+
const handled = this._console.handleMouse(event);
|
|
9141
9263
|
if (handled)
|
|
9142
9264
|
return true;
|
|
9143
9265
|
}
|
|
9144
9266
|
}
|
|
9145
9267
|
if (mouseEvent.type === "scroll") {
|
|
9146
|
-
const
|
|
9147
|
-
const
|
|
9268
|
+
const maybeRenderableId = this.hitTest(mouseEvent.x, mouseEvent.y);
|
|
9269
|
+
const maybeRenderable = Renderable2.renderablesByNumber.get(maybeRenderableId);
|
|
9148
9270
|
const fallbackTarget = this._currentFocusedRenderable && !this._currentFocusedRenderable.isDestroyed && this._currentFocusedRenderable.focused ? this._currentFocusedRenderable : null;
|
|
9149
|
-
const scrollTarget =
|
|
9271
|
+
const scrollTarget = maybeRenderable ?? fallbackTarget;
|
|
9150
9272
|
if (scrollTarget) {
|
|
9151
|
-
const
|
|
9152
|
-
this.sendMouseEvent(scrollTarget,
|
|
9273
|
+
const event = new MouseEvent2(scrollTarget, mouseEvent);
|
|
9274
|
+
this.sendMouseEvent(scrollTarget, event);
|
|
9153
9275
|
}
|
|
9154
9276
|
return true;
|
|
9155
9277
|
}
|
|
9156
9278
|
const maybeRenderableId = this.hitTest(mouseEvent.x, mouseEvent.y);
|
|
9157
9279
|
const sameElement = maybeRenderableId === this.lastOverRenderableNum;
|
|
9158
9280
|
this.lastOverRenderableNum = maybeRenderableId;
|
|
9159
|
-
const maybeRenderable =
|
|
9281
|
+
const maybeRenderable = Renderable2.renderablesByNumber.get(maybeRenderableId);
|
|
9160
9282
|
if (mouseEvent.type === "down" && mouseEvent.button === 0 /* LEFT */ && !this.currentSelection?.isDragging && !mouseEvent.modifiers.ctrl) {
|
|
9161
9283
|
const canStartSelection = Boolean(maybeRenderable && maybeRenderable.selectable && !maybeRenderable.isDestroyed && maybeRenderable.shouldStartSelection(mouseEvent.x, mouseEvent.y));
|
|
9162
9284
|
if (canStartSelection && maybeRenderable) {
|
|
@@ -9168,21 +9290,21 @@ Captured external output:
|
|
|
9168
9290
|
if (mouseEvent.type === "drag" && this.currentSelection?.isDragging) {
|
|
9169
9291
|
this.updateSelection(maybeRenderable, mouseEvent.x, mouseEvent.y);
|
|
9170
9292
|
if (maybeRenderable) {
|
|
9171
|
-
const
|
|
9293
|
+
const event = new MouseEvent2(maybeRenderable, {
|
|
9172
9294
|
...mouseEvent,
|
|
9173
9295
|
isDragging: true
|
|
9174
9296
|
});
|
|
9175
|
-
this.sendMouseEvent(maybeRenderable,
|
|
9297
|
+
this.sendMouseEvent(maybeRenderable, event);
|
|
9176
9298
|
}
|
|
9177
9299
|
return true;
|
|
9178
9300
|
}
|
|
9179
9301
|
if (mouseEvent.type === "up" && mouseEvent.button === 0 /* LEFT */ && this.currentSelection?.isDragging) {
|
|
9180
9302
|
if (maybeRenderable) {
|
|
9181
|
-
const
|
|
9303
|
+
const event = new MouseEvent2(maybeRenderable, {
|
|
9182
9304
|
...mouseEvent,
|
|
9183
9305
|
isDragging: true
|
|
9184
9306
|
});
|
|
9185
|
-
this.sendMouseEvent(maybeRenderable,
|
|
9307
|
+
this.sendMouseEvent(maybeRenderable, event);
|
|
9186
9308
|
}
|
|
9187
9309
|
this.finishSelection();
|
|
9188
9310
|
return true;
|
|
@@ -9196,41 +9318,41 @@ Captured external output:
|
|
|
9196
9318
|
}
|
|
9197
9319
|
if (!sameElement && (mouseEvent.type === "drag" || mouseEvent.type === "move")) {
|
|
9198
9320
|
if (this.lastOverRenderable && this.lastOverRenderable !== this.capturedRenderable && !this.lastOverRenderable.isDestroyed) {
|
|
9199
|
-
const
|
|
9321
|
+
const event = new MouseEvent2(this.lastOverRenderable, {
|
|
9200
9322
|
...mouseEvent,
|
|
9201
9323
|
type: "out"
|
|
9202
9324
|
});
|
|
9203
|
-
this.sendMouseEvent(this.lastOverRenderable,
|
|
9325
|
+
this.sendMouseEvent(this.lastOverRenderable, event);
|
|
9204
9326
|
}
|
|
9205
9327
|
this.lastOverRenderable = maybeRenderable;
|
|
9206
9328
|
if (maybeRenderable) {
|
|
9207
|
-
const
|
|
9329
|
+
const event = new MouseEvent2(maybeRenderable, {
|
|
9208
9330
|
...mouseEvent,
|
|
9209
9331
|
type: "over",
|
|
9210
9332
|
source: this.capturedRenderable
|
|
9211
9333
|
});
|
|
9212
|
-
this.sendMouseEvent(maybeRenderable,
|
|
9334
|
+
this.sendMouseEvent(maybeRenderable, event);
|
|
9213
9335
|
}
|
|
9214
9336
|
}
|
|
9215
9337
|
if (this.capturedRenderable && mouseEvent.type !== "up") {
|
|
9216
|
-
const
|
|
9217
|
-
this.sendMouseEvent(this.capturedRenderable,
|
|
9338
|
+
const event = new MouseEvent2(this.capturedRenderable, mouseEvent);
|
|
9339
|
+
this.sendMouseEvent(this.capturedRenderable, event);
|
|
9218
9340
|
return true;
|
|
9219
9341
|
}
|
|
9220
9342
|
if (this.capturedRenderable && mouseEvent.type === "up") {
|
|
9221
|
-
const
|
|
9343
|
+
const event = new MouseEvent2(this.capturedRenderable, {
|
|
9222
9344
|
...mouseEvent,
|
|
9223
9345
|
type: "drag-end"
|
|
9224
9346
|
});
|
|
9225
|
-
this.sendMouseEvent(this.capturedRenderable,
|
|
9226
|
-
this.sendMouseEvent(this.capturedRenderable, new
|
|
9347
|
+
this.sendMouseEvent(this.capturedRenderable, event);
|
|
9348
|
+
this.sendMouseEvent(this.capturedRenderable, new MouseEvent2(this.capturedRenderable, mouseEvent));
|
|
9227
9349
|
if (maybeRenderable) {
|
|
9228
|
-
const
|
|
9350
|
+
const event = new MouseEvent2(maybeRenderable, {
|
|
9229
9351
|
...mouseEvent,
|
|
9230
9352
|
type: "drop",
|
|
9231
9353
|
source: this.capturedRenderable
|
|
9232
9354
|
});
|
|
9233
|
-
this.sendMouseEvent(maybeRenderable,
|
|
9355
|
+
this.sendMouseEvent(maybeRenderable, event);
|
|
9234
9356
|
}
|
|
9235
9357
|
this.lastOverRenderable = this.capturedRenderable;
|
|
9236
9358
|
this.lastOverRenderableNum = this.capturedRenderable.num;
|
|
@@ -9260,7 +9382,7 @@ Captured external output:
|
|
|
9260
9382
|
if (this.capturedRenderable)
|
|
9261
9383
|
return;
|
|
9262
9384
|
const hitId = this.hitTest(this._latestPointer.x, this._latestPointer.y);
|
|
9263
|
-
const hitRenderable =
|
|
9385
|
+
const hitRenderable = Renderable2.renderablesByNumber.get(hitId);
|
|
9264
9386
|
const lastOver = this.lastOverRenderable;
|
|
9265
9387
|
if (lastOver?.num === hitId) {
|
|
9266
9388
|
this.lastOverRenderableNum = hitId;
|
|
@@ -9274,13 +9396,13 @@ Captured external output:
|
|
|
9274
9396
|
modifiers: this._lastPointerModifiers
|
|
9275
9397
|
};
|
|
9276
9398
|
if (lastOver && !lastOver.isDestroyed) {
|
|
9277
|
-
const event = new
|
|
9399
|
+
const event = new MouseEvent2(lastOver, { ...baseEvent, type: "out" });
|
|
9278
9400
|
this.sendMouseEvent(lastOver, event);
|
|
9279
9401
|
}
|
|
9280
9402
|
this.lastOverRenderable = hitRenderable;
|
|
9281
9403
|
this.lastOverRenderableNum = hitId;
|
|
9282
9404
|
if (hitRenderable) {
|
|
9283
|
-
const event = new
|
|
9405
|
+
const event = new MouseEvent2(hitRenderable, {
|
|
9284
9406
|
...baseEvent,
|
|
9285
9407
|
type: "over"
|
|
9286
9408
|
});
|
|
@@ -9294,6 +9416,18 @@ Captured external output:
|
|
|
9294
9416
|
hitTest(x, y) {
|
|
9295
9417
|
return this.lib.checkHit(this.rendererPtr, x, y);
|
|
9296
9418
|
}
|
|
9419
|
+
getLinkIdAt(x, y) {
|
|
9420
|
+
if (this._isDestroyed || !Number.isInteger(x) || !Number.isInteger(y))
|
|
9421
|
+
return 0;
|
|
9422
|
+
const buffer = this.currentRenderBuffer;
|
|
9423
|
+
if (x < 0 || y < 0 || x >= buffer.width || y >= buffer.height)
|
|
9424
|
+
return 0;
|
|
9425
|
+
return getLinkId2(buffer.buffers.attributes[y * buffer.width + x]);
|
|
9426
|
+
}
|
|
9427
|
+
getLinkAt(x, y) {
|
|
9428
|
+
const linkId = this.getLinkIdAt(x, y);
|
|
9429
|
+
return linkId === 0 ? null : this.currentRenderBuffer.lib.linkGetUrl(linkId) || null;
|
|
9430
|
+
}
|
|
9297
9431
|
takeMemorySnapshot() {
|
|
9298
9432
|
if (this._isDestroyed)
|
|
9299
9433
|
return;
|
|
@@ -9408,7 +9542,7 @@ Captured external output:
|
|
|
9408
9542
|
this.processResize(width, height);
|
|
9409
9543
|
}
|
|
9410
9544
|
setBackgroundColor(color) {
|
|
9411
|
-
const parsedColor =
|
|
9545
|
+
const parsedColor = parseColor2(color);
|
|
9412
9546
|
this.lib.setBackgroundColor(this.rendererPtr, parsedColor);
|
|
9413
9547
|
this.backgroundColor = parsedColor;
|
|
9414
9548
|
this.nextRenderBuffer.clear(parsedColor);
|
|
@@ -9461,18 +9595,18 @@ Captured external output:
|
|
|
9461
9595
|
this.lib.dumpOutputBuffer(this.rendererPtr, timestamp);
|
|
9462
9596
|
}
|
|
9463
9597
|
static setCursorPosition(renderer, x, y, visible = true) {
|
|
9464
|
-
const lib =
|
|
9598
|
+
const lib = resolveRenderLib2();
|
|
9465
9599
|
lib.setCursorPosition(renderer.rendererPtr, x, y, visible);
|
|
9466
9600
|
}
|
|
9467
9601
|
static setCursorStyle(renderer, options) {
|
|
9468
|
-
const lib =
|
|
9602
|
+
const lib = resolveRenderLib2();
|
|
9469
9603
|
lib.setCursorStyleOptions(renderer.rendererPtr, options);
|
|
9470
9604
|
if (options.cursor !== undefined) {
|
|
9471
9605
|
renderer._currentMousePointerStyle = options.cursor;
|
|
9472
9606
|
}
|
|
9473
9607
|
}
|
|
9474
9608
|
static setCursorColor(renderer, color) {
|
|
9475
|
-
const lib =
|
|
9609
|
+
const lib = resolveRenderLib2();
|
|
9476
9610
|
lib.setCursorColor(renderer.rendererPtr, color);
|
|
9477
9611
|
}
|
|
9478
9612
|
setCursorPosition(x, y, visible = true) {
|
|
@@ -9513,13 +9647,21 @@ Captured external output:
|
|
|
9513
9647
|
if (this._controlState === "idle" /* IDLE */ && this.liveRequestCounter > 0) {
|
|
9514
9648
|
this._controlState = "auto_started" /* AUTO_STARTED */;
|
|
9515
9649
|
this.internalStart();
|
|
9650
|
+
} else if (this._controlState === "explicit_suspended" /* EXPLICIT_SUSPENDED */ && this._previousControlState === "idle" /* IDLE */) {
|
|
9651
|
+
this._previousControlState = "auto_started" /* AUTO_STARTED */;
|
|
9516
9652
|
}
|
|
9517
9653
|
}
|
|
9518
9654
|
dropLive() {
|
|
9519
|
-
|
|
9655
|
+
if (this.liveRequestCounter === 0)
|
|
9656
|
+
return;
|
|
9657
|
+
this.liveRequestCounter--;
|
|
9658
|
+
if (this.liveRequestCounter === 0 && this._controlState === "explicit_suspended" /* EXPLICIT_SUSPENDED */ && this._previousControlState === "auto_started" /* AUTO_STARTED */) {
|
|
9659
|
+
this._previousControlState = "idle" /* IDLE */;
|
|
9660
|
+
}
|
|
9520
9661
|
if (this._controlState === "auto_started" /* AUTO_STARTED */ && this.liveRequestCounter === 0) {
|
|
9521
9662
|
this._controlState = "idle" /* IDLE */;
|
|
9522
|
-
this.
|
|
9663
|
+
this._isRunning = false;
|
|
9664
|
+
this.resolveIdleIfNeeded();
|
|
9523
9665
|
}
|
|
9524
9666
|
}
|
|
9525
9667
|
start() {
|
|
@@ -9533,6 +9675,7 @@ Captured external output:
|
|
|
9533
9675
|
if (!this._isRunning && !this._isDestroyed) {
|
|
9534
9676
|
this._isRunning = true;
|
|
9535
9677
|
this.updateScheduled = false;
|
|
9678
|
+
this.updateGeneration++;
|
|
9536
9679
|
if (this.memorySnapshotInterval > 0) {
|
|
9537
9680
|
this.startMemorySnapshotTimer();
|
|
9538
9681
|
}
|
|
@@ -9547,6 +9690,7 @@ Captured external output:
|
|
|
9547
9690
|
this._previousControlState = this._controlState;
|
|
9548
9691
|
this._controlState = "explicit_suspended" /* EXPLICIT_SUSPENDED */;
|
|
9549
9692
|
this.updateScheduled = false;
|
|
9693
|
+
this.updateGeneration++;
|
|
9550
9694
|
this.internalPause();
|
|
9551
9695
|
if (this._terminalIsSetup) {
|
|
9552
9696
|
this.clearSplitStartupCursorSeed();
|
|
@@ -9624,6 +9768,7 @@ Captured external output:
|
|
|
9624
9768
|
}
|
|
9625
9769
|
internalPause() {
|
|
9626
9770
|
this._isRunning = false;
|
|
9771
|
+
this.cancelRenderAfterFeedIdle();
|
|
9627
9772
|
if (this.renderTimeout) {
|
|
9628
9773
|
this.clock.clearTimeout(this.renderTimeout);
|
|
9629
9774
|
this.renderTimeout = null;
|
|
@@ -9637,20 +9782,14 @@ Captured external output:
|
|
|
9637
9782
|
this.internalStop();
|
|
9638
9783
|
}
|
|
9639
9784
|
internalStop() {
|
|
9640
|
-
|
|
9641
|
-
|
|
9642
|
-
|
|
9643
|
-
|
|
9644
|
-
|
|
9645
|
-
|
|
9646
|
-
if (this.renderTimeout) {
|
|
9647
|
-
this.clock.clearTimeout(this.renderTimeout);
|
|
9648
|
-
this.renderTimeout = null;
|
|
9649
|
-
}
|
|
9650
|
-
if (!this.rendering) {
|
|
9651
|
-
this.resolveIdleIfNeeded();
|
|
9652
|
-
}
|
|
9785
|
+
this.updateScheduled = false;
|
|
9786
|
+
this.updateGeneration++;
|
|
9787
|
+
this.immediateRerenderRequested = false;
|
|
9788
|
+
if (this.memorySnapshotTimer) {
|
|
9789
|
+
this.clock.clearInterval(this.memorySnapshotTimer);
|
|
9790
|
+
this.memorySnapshotTimer = null;
|
|
9653
9791
|
}
|
|
9792
|
+
this.internalPause();
|
|
9654
9793
|
}
|
|
9655
9794
|
destroy() {
|
|
9656
9795
|
if (this._isDestroyed)
|
|
@@ -9668,12 +9807,20 @@ Captured external output:
|
|
|
9668
9807
|
if (this._destroyCleanupPrepared)
|
|
9669
9808
|
return;
|
|
9670
9809
|
this._destroyCleanupPrepared = true;
|
|
9810
|
+
this.cancelRenderAfterFeedIdle();
|
|
9811
|
+
if (this.kittyTransportTimer !== null) {
|
|
9812
|
+
this.clock.clearInterval(this.kittyTransportTimer);
|
|
9813
|
+
this.kittyTransportTimer = null;
|
|
9814
|
+
this.stdout.off("error", this.kittyOutputErrorHandler);
|
|
9815
|
+
this.lib.cancelKittyImageTransport(this.rendererPtr, false);
|
|
9816
|
+
}
|
|
9817
|
+
const processEvents = process;
|
|
9671
9818
|
if (this._usesProcessStdout) {
|
|
9672
|
-
|
|
9819
|
+
processEvents.removeListener("SIGWINCH", this.sigwinchHandler);
|
|
9673
9820
|
}
|
|
9674
|
-
|
|
9675
|
-
|
|
9676
|
-
|
|
9821
|
+
processEvents.removeListener("uncaughtException", this.handleError);
|
|
9822
|
+
processEvents.removeListener("unhandledRejection", this.handleError);
|
|
9823
|
+
processEvents.removeListener("warning", this.warningHandler);
|
|
9677
9824
|
this.removeExitListeners();
|
|
9678
9825
|
if (this.resizeTimeoutId !== null) {
|
|
9679
9826
|
this.clock.clearTimeout(this.resizeTimeoutId);
|
|
@@ -9791,7 +9938,7 @@ Captured external output:
|
|
|
9791
9938
|
}
|
|
9792
9939
|
rendererTracker.renderers.delete(this);
|
|
9793
9940
|
if (rendererTracker.renderers.size === 0) {
|
|
9794
|
-
|
|
9941
|
+
destroyTreeSitterClient2().catch((error) => {
|
|
9795
9942
|
console.error("Failed to destroy tree-sitter client:", error);
|
|
9796
9943
|
});
|
|
9797
9944
|
}
|
|
@@ -9847,6 +9994,11 @@ Captured external output:
|
|
|
9847
9994
|
this.rendering = true;
|
|
9848
9995
|
let renderFailed = false;
|
|
9849
9996
|
try {
|
|
9997
|
+
if (this._feed?.isBackpressured()) {
|
|
9998
|
+
this.handleNativeRenderRejection(NATIVE_RENDER_STATUS_SKIPPED);
|
|
9999
|
+
this.immediateRerenderRequested = false;
|
|
10000
|
+
return;
|
|
10001
|
+
}
|
|
9850
10002
|
this._frameId++;
|
|
9851
10003
|
const now = this.normalizeClockTime(this.clock.now(), this.lastTime);
|
|
9852
10004
|
const elapsed = this.getElapsedMs(now, this.lastTime);
|
|
@@ -9929,7 +10081,7 @@ Captured external output:
|
|
|
9929
10081
|
this.renderTimeout = null;
|
|
9930
10082
|
}
|
|
9931
10083
|
} else if (nativeStatus === "backpressured") {
|
|
9932
|
-
if (!startedWhileRunning || this._isRunning || this.immediateRerenderRequested) {
|
|
10084
|
+
if (!startedWhileRunning || this._isRunning || this.immediateRerenderRequested || this._controlState === "idle" /* IDLE */) {
|
|
9933
10085
|
this.scheduleRenderAfterBackpressure();
|
|
9934
10086
|
}
|
|
9935
10087
|
} else if (nativeStatus === "retryable-skip") {
|
|
@@ -10064,7 +10216,7 @@ Captured external output:
|
|
|
10064
10216
|
return;
|
|
10065
10217
|
this.clearSelectionState();
|
|
10066
10218
|
this.selectionContainers.push(renderable.parent || this.root);
|
|
10067
|
-
this.currentSelection = new
|
|
10219
|
+
this.currentSelection = new Selection2(renderable, { x, y }, { x, y }, behavior);
|
|
10068
10220
|
this.currentSelection.isStart = true;
|
|
10069
10221
|
this.notifySelectablesOfSelectionChange();
|
|
10070
10222
|
}
|
|
@@ -10106,7 +10258,7 @@ Captured external output:
|
|
|
10106
10258
|
if (this.currentSelection?.isDragging) {
|
|
10107
10259
|
const pointer = this._latestPointer;
|
|
10108
10260
|
const maybeRenderableId = this.hitTest(pointer.x, pointer.y);
|
|
10109
|
-
const maybeRenderable =
|
|
10261
|
+
const maybeRenderable = Renderable2.renderablesByNumber.get(maybeRenderableId);
|
|
10110
10262
|
this.updateSelection(maybeRenderable, pointer.x, pointer.y);
|
|
10111
10263
|
}
|
|
10112
10264
|
}
|
|
@@ -10187,7 +10339,7 @@ Captured external output:
|
|
|
10187
10339
|
if (!this._paletteDetector) {
|
|
10188
10340
|
const isTmux = Boolean(this.capabilities?.multiplexer === "tmux" || this.capabilities?.terminal?.name?.toLowerCase()?.includes("tmux"));
|
|
10189
10341
|
const isLegacyTmux = this.capabilities?.terminal?.name?.toLowerCase()?.includes("tmux") && this.capabilities?.terminal?.version?.localeCompare("3.6") < 0;
|
|
10190
|
-
this._paletteDetector =
|
|
10342
|
+
this._paletteDetector = createTerminalPalette2({
|
|
10191
10343
|
stdin: this.stdin,
|
|
10192
10344
|
stdout: this.stdout,
|
|
10193
10345
|
writeFn: (data) => this._isDestroyed ? false : this.writeOut(data),
|
|
@@ -10202,18 +10354,18 @@ Captured external output:
|
|
|
10202
10354
|
return this._paletteDetector;
|
|
10203
10355
|
}
|
|
10204
10356
|
syncNativePaletteState(colors) {
|
|
10205
|
-
const signature =
|
|
10357
|
+
const signature = buildTerminalPaletteSignature2(colors);
|
|
10206
10358
|
if (this._nativePaletteSignature !== signature) {
|
|
10207
10359
|
this._paletteEpoch = this._paletteEpoch + 1 >>> 0;
|
|
10208
10360
|
}
|
|
10209
10361
|
this._nativePaletteSignature = signature;
|
|
10210
|
-
const normalized =
|
|
10362
|
+
const normalized = normalizeTerminalPalette2(colors);
|
|
10211
10363
|
this.lib.rendererSetPaletteState(this.rendererPtr, normalized.palette, normalized.defaultForeground, normalized.defaultBackground, this._paletteEpoch);
|
|
10212
10364
|
}
|
|
10213
10365
|
emitPaletteChange(colors) {
|
|
10214
10366
|
if (this.listenerCount("palette" /* PALETTE */) === 0)
|
|
10215
10367
|
return;
|
|
10216
|
-
const signature =
|
|
10368
|
+
const signature = buildTerminalPaletteSignature2(colors);
|
|
10217
10369
|
if (this._emittedPaletteSignature === signature)
|
|
10218
10370
|
return;
|
|
10219
10371
|
this._emittedPaletteSignature = signature;
|
|
@@ -10319,7 +10471,7 @@ Captured external output:
|
|
|
10319
10471
|
}
|
|
10320
10472
|
}
|
|
10321
10473
|
|
|
10322
|
-
export {
|
|
10474
|
+
export { convertThemeToStyles2, SyntaxStyle2, h2, isVNode2, maybeMakeRenderable2, wrapWithDelegates2, instantiate2, delegate2, LayoutEvents2, RenderableEvents2, isRenderable2, BaseRenderable2, Renderable2, RootRenderable2, TextBufferView2, EditBuffer2, EditorView2, ANSI, BoxRenderable2, TextBufferRenderable2, CodeRenderable2, isTextNodeRenderable2, TextNodeRenderable2, RootTextNodeRenderable2, TextRenderable2, NativeSpanFeed2, defaultKeyAliases, mergeKeyAliases, mergeKeyBindings, getKeyBindingAction, buildKeyBindingsMap, capture2, ConsolePosition2, TerminalConsole2, getObjectsInViewport, EditBufferRenderableEvents2, isEditBufferRenderable2, EditBufferRenderable2, buildKittyKeyboardFlags2, MouseEvent2, MouseButton2, createCliRenderer2, CliRenderEvents2, RendererControlState2, CliRenderer2 };
|
|
10323
10475
|
|
|
10324
|
-
//# debugId=
|
|
10325
|
-
//# sourceMappingURL=chunk-bun-
|
|
10476
|
+
//# debugId=D9293021961B480764756E2164756E21
|
|
10477
|
+
//# sourceMappingURL=chunk-bun-bwjmgnxw.js.map
|