@opentui/core 0.1.19-snapshot4-010c3be8 → 0.1.19
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/3d.js +1 -1
- package/Renderable.d.ts +20 -8
- package/{index-grak7z0n.js → index-0h2r5adk.js} +170 -107
- package/{index-grak7z0n.js.map → index-0h2r5adk.js.map} +8 -8
- package/index.js +298 -11
- package/index.js.map +6 -5
- package/lib/styled-text.d.ts +13 -8
- package/package.json +7 -7
- package/renderables/Text.d.ts +17 -2
- package/renderables/TextNode.d.ts +57 -0
- package/renderables/composition/constructs.d.ts +30 -9
- package/renderables/index.d.ts +1 -0
- package/text-buffer.d.ts +8 -2
- package/zig.d.ts +7 -0
package/3d.js
CHANGED
package/Renderable.d.ts
CHANGED
|
@@ -25,7 +25,10 @@ export interface Position {
|
|
|
25
25
|
bottom?: number | "auto" | `${number}%`;
|
|
26
26
|
left?: number | "auto" | `${number}%`;
|
|
27
27
|
}
|
|
28
|
-
export interface
|
|
28
|
+
export interface BaseRenderableOptions {
|
|
29
|
+
id?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface LayoutOptions extends BaseRenderableOptions {
|
|
29
32
|
flexGrow?: number;
|
|
30
33
|
flexShrink?: number;
|
|
31
34
|
flexDirection?: FlexDirectionString;
|
|
@@ -56,8 +59,7 @@ export interface LayoutOptions {
|
|
|
56
59
|
paddingLeft?: number | `${number}%`;
|
|
57
60
|
enableLayout?: boolean;
|
|
58
61
|
}
|
|
59
|
-
export interface RenderableOptions<T extends
|
|
60
|
-
id?: string;
|
|
62
|
+
export interface RenderableOptions<T extends BaseRenderable = BaseRenderable> extends Partial<LayoutOptions> {
|
|
61
63
|
width?: number | "auto" | `${number}%`;
|
|
62
64
|
height?: number | "auto" | `${number}%`;
|
|
63
65
|
zIndex?: number;
|
|
@@ -89,12 +91,25 @@ export declare function isDimensionType(value: any): value is number | "auto" |
|
|
|
89
91
|
export declare function isFlexBasisType(value: any): value is number | "auto" | undefined;
|
|
90
92
|
export declare function isSizeType(value: any): value is number | `${number}%` | undefined;
|
|
91
93
|
export declare function isRenderable(obj: any): obj is Renderable;
|
|
92
|
-
export declare abstract class
|
|
94
|
+
export declare abstract class BaseRenderable extends EventEmitter {
|
|
93
95
|
[BrandedRenderable]: boolean;
|
|
94
96
|
private static renderableNumber;
|
|
95
|
-
static renderablesByNumber: Map<number, Renderable>;
|
|
96
97
|
readonly id: string;
|
|
97
98
|
readonly num: number;
|
|
99
|
+
protected _dirty: boolean;
|
|
100
|
+
constructor(options: BaseRenderableOptions);
|
|
101
|
+
abstract add(obj: BaseRenderable | unknown, index?: number): number;
|
|
102
|
+
abstract remove(id: string): void;
|
|
103
|
+
abstract getChildren(): BaseRenderable[];
|
|
104
|
+
abstract getChildrenCount(): number;
|
|
105
|
+
abstract getRenderable(id: string): BaseRenderable | undefined;
|
|
106
|
+
abstract requestRender(): void;
|
|
107
|
+
get isDirty(): boolean;
|
|
108
|
+
protected markClean(): void;
|
|
109
|
+
protected markDirty(): void;
|
|
110
|
+
}
|
|
111
|
+
export declare abstract class Renderable extends BaseRenderable {
|
|
112
|
+
static renderablesByNumber: Map<number, Renderable>;
|
|
98
113
|
private _isDestroyed;
|
|
99
114
|
protected _ctx: RenderContext;
|
|
100
115
|
protected _translateX: number;
|
|
@@ -110,7 +125,6 @@ export declare abstract class Renderable extends EventEmitter {
|
|
|
110
125
|
selectable: boolean;
|
|
111
126
|
protected buffered: boolean;
|
|
112
127
|
protected frameBuffer: OptimizedBuffer | null;
|
|
113
|
-
private _dirty;
|
|
114
128
|
protected focusable: boolean;
|
|
115
129
|
protected _focused: boolean;
|
|
116
130
|
protected keyHandler: KeyHandler;
|
|
@@ -149,9 +163,7 @@ export declare abstract class Renderable extends EventEmitter {
|
|
|
149
163
|
set live(value: boolean);
|
|
150
164
|
protected propagateLiveCount(delta: number): void;
|
|
151
165
|
handleKeyPress?(key: ParsedKey | string): boolean;
|
|
152
|
-
protected get isDirty(): boolean;
|
|
153
166
|
findDescendantById(id: string): Renderable | undefined;
|
|
154
|
-
private markClean;
|
|
155
167
|
requestRender(): void;
|
|
156
168
|
get translateX(): number;
|
|
157
169
|
set translateX(value: number);
|
|
@@ -3938,64 +3938,70 @@ function createTextAttributes({
|
|
|
3938
3938
|
}
|
|
3939
3939
|
|
|
3940
3940
|
// src/lib/styled-text.ts
|
|
3941
|
-
var textEncoder = new TextEncoder;
|
|
3942
|
-
|
|
3943
3941
|
class StyledText {
|
|
3944
3942
|
chunks;
|
|
3943
|
+
textRenderable;
|
|
3945
3944
|
constructor(chunks) {
|
|
3946
3945
|
this.chunks = chunks;
|
|
3947
3946
|
}
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
newInstance.chunks = chunks;
|
|
3951
|
-
return newInstance;
|
|
3947
|
+
mount(textRenderable) {
|
|
3948
|
+
this.textRenderable = textRenderable;
|
|
3952
3949
|
}
|
|
3953
3950
|
insert(chunk, index) {
|
|
3954
3951
|
const originalLength = this.chunks.length;
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
newChunks
|
|
3958
|
-
|
|
3959
|
-
|
|
3952
|
+
if (this.textRenderable) {
|
|
3953
|
+
this.textRenderable.insertChunk(chunk, index ?? originalLength);
|
|
3954
|
+
let newChunks;
|
|
3955
|
+
if (index === undefined || index === originalLength) {
|
|
3956
|
+
newChunks = [...this.chunks, chunk];
|
|
3957
|
+
} else {
|
|
3958
|
+
newChunks = [...this.chunks.slice(0, index), chunk, ...this.chunks.slice(index)];
|
|
3959
|
+
}
|
|
3960
|
+
this.chunks = newChunks;
|
|
3960
3961
|
}
|
|
3961
|
-
return
|
|
3962
|
+
return this;
|
|
3962
3963
|
}
|
|
3963
3964
|
remove(chunk) {
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
newChunks
|
|
3971
|
-
|
|
3972
|
-
|
|
3965
|
+
if (this.textRenderable) {
|
|
3966
|
+
this.textRenderable.removeChunk(chunk);
|
|
3967
|
+
const originalLength = this.chunks.length;
|
|
3968
|
+
const index = this.chunks.indexOf(chunk);
|
|
3969
|
+
if (index === -1)
|
|
3970
|
+
return this;
|
|
3971
|
+
let newChunks;
|
|
3972
|
+
if (index === originalLength - 1) {
|
|
3973
|
+
newChunks = this.chunks.slice(0, -1);
|
|
3974
|
+
} else {
|
|
3975
|
+
newChunks = [...this.chunks.slice(0, index), ...this.chunks.slice(index + 1)];
|
|
3976
|
+
}
|
|
3977
|
+
this.chunks = newChunks;
|
|
3973
3978
|
}
|
|
3974
|
-
return
|
|
3979
|
+
return this;
|
|
3975
3980
|
}
|
|
3976
3981
|
replace(chunk, oldChunk) {
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
newChunks
|
|
3983
|
-
|
|
3984
|
-
|
|
3982
|
+
if (this.textRenderable) {
|
|
3983
|
+
this.textRenderable.replaceChunk(chunk, oldChunk);
|
|
3984
|
+
const index = this.chunks.indexOf(oldChunk);
|
|
3985
|
+
if (index === -1)
|
|
3986
|
+
return this;
|
|
3987
|
+
let newChunks;
|
|
3988
|
+
if (index === this.chunks.length - 1) {
|
|
3989
|
+
newChunks = [...this.chunks.slice(0, -1), chunk];
|
|
3990
|
+
} else {
|
|
3991
|
+
newChunks = [...this.chunks.slice(0, index), chunk, ...this.chunks.slice(index + 1)];
|
|
3992
|
+
}
|
|
3993
|
+
this.chunks = newChunks;
|
|
3985
3994
|
}
|
|
3986
|
-
return
|
|
3995
|
+
return this;
|
|
3987
3996
|
}
|
|
3988
3997
|
}
|
|
3989
3998
|
function stringToStyledText(content) {
|
|
3990
|
-
const textEncoder2 = new TextEncoder;
|
|
3991
3999
|
const chunk = {
|
|
3992
4000
|
__isChunk: true,
|
|
3993
|
-
text:
|
|
3994
|
-
plainText: content
|
|
4001
|
+
text: content
|
|
3995
4002
|
};
|
|
3996
4003
|
return new StyledText([chunk]);
|
|
3997
4004
|
}
|
|
3998
|
-
var templateCache = new WeakMap;
|
|
3999
4005
|
function applyStyle(input, style) {
|
|
4000
4006
|
if (typeof input === "object" && "__isChunk" in input) {
|
|
4001
4007
|
const existingChunk = input;
|
|
@@ -4006,21 +4012,18 @@ function applyStyle(input, style) {
|
|
|
4006
4012
|
return {
|
|
4007
4013
|
__isChunk: true,
|
|
4008
4014
|
text: existingChunk.text,
|
|
4009
|
-
plainText: existingChunk.plainText,
|
|
4010
4015
|
fg,
|
|
4011
4016
|
bg,
|
|
4012
4017
|
attributes: mergedAttrs
|
|
4013
4018
|
};
|
|
4014
4019
|
} else {
|
|
4015
4020
|
const plainTextStr = String(input);
|
|
4016
|
-
const text = textEncoder.encode(plainTextStr);
|
|
4017
4021
|
const fg = style.fg ? parseColor(style.fg) : undefined;
|
|
4018
4022
|
const bg = style.bg ? parseColor(style.bg) : undefined;
|
|
4019
4023
|
const attributes = createTextAttributes(style);
|
|
4020
4024
|
return {
|
|
4021
4025
|
__isChunk: true,
|
|
4022
|
-
text,
|
|
4023
|
-
plainText: plainTextStr,
|
|
4026
|
+
text: plainTextStr,
|
|
4024
4027
|
fg,
|
|
4025
4028
|
bg,
|
|
4026
4029
|
attributes
|
|
@@ -4060,15 +4063,14 @@ var reverse = (input) => applyStyle(input, { reverse: true });
|
|
|
4060
4063
|
var blink = (input) => applyStyle(input, { blink: true });
|
|
4061
4064
|
var fg = (color) => (input) => applyStyle(input, { fg: color });
|
|
4062
4065
|
var bg = (color) => (input) => applyStyle(input, { bg: color });
|
|
4063
|
-
function
|
|
4066
|
+
function t(strings, ...values) {
|
|
4064
4067
|
const chunks = [];
|
|
4065
4068
|
for (let i = 0;i < strings.length; i++) {
|
|
4066
4069
|
const raw = strings[i];
|
|
4067
4070
|
if (raw) {
|
|
4068
4071
|
chunks.push({
|
|
4069
4072
|
__isChunk: true,
|
|
4070
|
-
text:
|
|
4071
|
-
plainText: raw,
|
|
4073
|
+
text: raw,
|
|
4072
4074
|
attributes: 0
|
|
4073
4075
|
});
|
|
4074
4076
|
}
|
|
@@ -4079,48 +4081,7 @@ function tn(strings, ...values) {
|
|
|
4079
4081
|
const plainTextStr = String(val);
|
|
4080
4082
|
chunks.push({
|
|
4081
4083
|
__isChunk: true,
|
|
4082
|
-
text:
|
|
4083
|
-
plainText: plainTextStr,
|
|
4084
|
-
attributes: 0
|
|
4085
|
-
});
|
|
4086
|
-
}
|
|
4087
|
-
}
|
|
4088
|
-
return new StyledText(chunks);
|
|
4089
|
-
}
|
|
4090
|
-
function t(strings, ...values) {
|
|
4091
|
-
let cachedStringChunks = templateCache.get(strings);
|
|
4092
|
-
if (!cachedStringChunks) {
|
|
4093
|
-
cachedStringChunks = [];
|
|
4094
|
-
for (let i = 0;i < strings.length; i++) {
|
|
4095
|
-
const raw = strings[i];
|
|
4096
|
-
if (raw) {
|
|
4097
|
-
cachedStringChunks.push({
|
|
4098
|
-
__isChunk: true,
|
|
4099
|
-
text: textEncoder.encode(raw),
|
|
4100
|
-
plainText: raw,
|
|
4101
|
-
attributes: 0
|
|
4102
|
-
});
|
|
4103
|
-
} else {
|
|
4104
|
-
cachedStringChunks.push(null);
|
|
4105
|
-
}
|
|
4106
|
-
}
|
|
4107
|
-
templateCache.set(strings, cachedStringChunks);
|
|
4108
|
-
}
|
|
4109
|
-
const chunks = [];
|
|
4110
|
-
for (let i = 0;i < strings.length; i++) {
|
|
4111
|
-
const stringChunk = cachedStringChunks[i];
|
|
4112
|
-
if (stringChunk) {
|
|
4113
|
-
chunks.push(stringChunk);
|
|
4114
|
-
}
|
|
4115
|
-
const val = values[i];
|
|
4116
|
-
if (typeof val === "object" && "__isChunk" in val) {
|
|
4117
|
-
chunks.push(val);
|
|
4118
|
-
} else if (val !== undefined) {
|
|
4119
|
-
const plainTextStr = String(val);
|
|
4120
|
-
chunks.push({
|
|
4121
|
-
__isChunk: true,
|
|
4122
|
-
text: textEncoder.encode(plainTextStr),
|
|
4123
|
-
plainText: plainTextStr,
|
|
4084
|
+
text: plainTextStr,
|
|
4124
4085
|
attributes: 0
|
|
4125
4086
|
});
|
|
4126
4087
|
}
|
|
@@ -4180,7 +4141,6 @@ class SyntaxStyle {
|
|
|
4180
4141
|
return this.mergedStyleCache.size;
|
|
4181
4142
|
}
|
|
4182
4143
|
}
|
|
4183
|
-
var textEncoder2 = new TextEncoder;
|
|
4184
4144
|
function hastToTextChunks(node, syntaxStyle, parentStyles = []) {
|
|
4185
4145
|
const chunks = [];
|
|
4186
4146
|
if (node.type === "text") {
|
|
@@ -4188,8 +4148,7 @@ function hastToTextChunks(node, syntaxStyle, parentStyles = []) {
|
|
|
4188
4148
|
const mergedStyle = syntaxStyle.mergeStyles(...stylesToMerge);
|
|
4189
4149
|
chunks.push({
|
|
4190
4150
|
__isChunk: true,
|
|
4191
|
-
text:
|
|
4192
|
-
plainText: node.value,
|
|
4151
|
+
text: node.value,
|
|
4193
4152
|
fg: mergedStyle.fg,
|
|
4194
4153
|
bg: mergedStyle.bg,
|
|
4195
4154
|
attributes: mergedStyle.attributes
|
|
@@ -5171,6 +5130,10 @@ function getOpenTUILib(libPath) {
|
|
|
5171
5130
|
args: ["ptr", "ptr", "usize"],
|
|
5172
5131
|
returns: "usize"
|
|
5173
5132
|
},
|
|
5133
|
+
textBufferGetPlainText: {
|
|
5134
|
+
args: ["ptr", "ptr", "usize"],
|
|
5135
|
+
returns: "usize"
|
|
5136
|
+
},
|
|
5174
5137
|
textBufferSetLocalSelection: {
|
|
5175
5138
|
args: ["ptr", "i32", "i32", "i32", "i32", "ptr", "ptr"],
|
|
5176
5139
|
returns: "bool"
|
|
@@ -5179,6 +5142,26 @@ function getOpenTUILib(libPath) {
|
|
|
5179
5142
|
args: ["ptr"],
|
|
5180
5143
|
returns: "void"
|
|
5181
5144
|
},
|
|
5145
|
+
textBufferInsertChunkGroup: {
|
|
5146
|
+
args: ["ptr", "usize", "ptr", "u32", "ptr", "ptr", "u8"],
|
|
5147
|
+
returns: "u32"
|
|
5148
|
+
},
|
|
5149
|
+
textBufferRemoveChunkGroup: {
|
|
5150
|
+
args: ["ptr", "usize"],
|
|
5151
|
+
returns: "u32"
|
|
5152
|
+
},
|
|
5153
|
+
textBufferReplaceChunkGroup: {
|
|
5154
|
+
args: ["ptr", "usize", "ptr", "u32", "ptr", "ptr", "u8"],
|
|
5155
|
+
returns: "u32"
|
|
5156
|
+
},
|
|
5157
|
+
textBufferGetChunkGroupCount: {
|
|
5158
|
+
args: ["ptr"],
|
|
5159
|
+
returns: "usize"
|
|
5160
|
+
},
|
|
5161
|
+
getArenaAllocatedBytes: {
|
|
5162
|
+
args: [],
|
|
5163
|
+
returns: "usize"
|
|
5164
|
+
},
|
|
5182
5165
|
bufferDrawTextBuffer: {
|
|
5183
5166
|
args: ["ptr", "ptr", "i32", "i32", "i32", "i32", "u32", "u32", "bool"],
|
|
5184
5167
|
returns: "void"
|
|
@@ -5546,6 +5529,10 @@ class FFIRenderLib {
|
|
|
5546
5529
|
const result = this.opentui.symbols.textBufferGetSelectedText(buffer, outPtr, maxLen);
|
|
5547
5530
|
return typeof result === "bigint" ? Number(result) : result;
|
|
5548
5531
|
}
|
|
5532
|
+
textBufferGetPlainText(buffer, outPtr, maxLen) {
|
|
5533
|
+
const result = this.opentui.symbols.textBufferGetPlainText(buffer, outPtr, maxLen);
|
|
5534
|
+
return typeof result === "bigint" ? Number(result) : result;
|
|
5535
|
+
}
|
|
5549
5536
|
getSelectedTextBytes(buffer, maxLength) {
|
|
5550
5537
|
const outBuffer = new Uint8Array(maxLength);
|
|
5551
5538
|
const actualLen = this.textBufferGetSelectedText(buffer, ptr(outBuffer), maxLength);
|
|
@@ -5554,6 +5541,14 @@ class FFIRenderLib {
|
|
|
5554
5541
|
}
|
|
5555
5542
|
return outBuffer.slice(0, actualLen);
|
|
5556
5543
|
}
|
|
5544
|
+
getPlainTextBytes(buffer, maxLength) {
|
|
5545
|
+
const outBuffer = new Uint8Array(maxLength);
|
|
5546
|
+
const actualLen = this.textBufferGetPlainText(buffer, ptr(outBuffer), maxLength);
|
|
5547
|
+
if (actualLen === 0) {
|
|
5548
|
+
return null;
|
|
5549
|
+
}
|
|
5550
|
+
return outBuffer.slice(0, actualLen);
|
|
5551
|
+
}
|
|
5557
5552
|
textBufferSetLocalSelection(buffer, anchorX, anchorY, focusX, focusY, bgColor, fgColor) {
|
|
5558
5553
|
const bg2 = bgColor ? bgColor.buffer : null;
|
|
5559
5554
|
const fg2 = fgColor ? fgColor.buffer : null;
|
|
@@ -5562,6 +5557,29 @@ class FFIRenderLib {
|
|
|
5562
5557
|
textBufferResetLocalSelection(buffer) {
|
|
5563
5558
|
this.opentui.symbols.textBufferResetLocalSelection(buffer);
|
|
5564
5559
|
}
|
|
5560
|
+
textBufferInsertChunkGroup(buffer, index, textBytes, fg2, bg2, attributes) {
|
|
5561
|
+
const fgPtr = fg2 ? fg2.buffer : null;
|
|
5562
|
+
const bgPtr = bg2 ? bg2.buffer : null;
|
|
5563
|
+
const attr = attributes ?? 255;
|
|
5564
|
+
return this.opentui.symbols.textBufferInsertChunkGroup(buffer, index, textBytes, textBytes.length, fgPtr, bgPtr, attr);
|
|
5565
|
+
}
|
|
5566
|
+
textBufferRemoveChunkGroup(buffer, index) {
|
|
5567
|
+
return this.opentui.symbols.textBufferRemoveChunkGroup(buffer, index);
|
|
5568
|
+
}
|
|
5569
|
+
textBufferReplaceChunkGroup(buffer, index, textBytes, fg2, bg2, attributes) {
|
|
5570
|
+
const fgPtr = fg2 ? fg2.buffer : null;
|
|
5571
|
+
const bgPtr = bg2 ? bg2.buffer : null;
|
|
5572
|
+
const attr = attributes ?? 255;
|
|
5573
|
+
return this.opentui.symbols.textBufferReplaceChunkGroup(buffer, index, textBytes, textBytes.length, fgPtr, bgPtr, attr);
|
|
5574
|
+
}
|
|
5575
|
+
textBufferGetChunkGroupCount(buffer) {
|
|
5576
|
+
const result = this.opentui.symbols.textBufferGetChunkGroupCount(buffer);
|
|
5577
|
+
return typeof result === "bigint" ? Number(result) : result;
|
|
5578
|
+
}
|
|
5579
|
+
getArenaAllocatedBytes() {
|
|
5580
|
+
const result = this.opentui.symbols.getArenaAllocatedBytes();
|
|
5581
|
+
return typeof result === "bigint" ? Number(result) : result;
|
|
5582
|
+
}
|
|
5565
5583
|
textBufferGetLineInfo(buffer) {
|
|
5566
5584
|
const lineCount = this.textBufferGetLineCount(buffer);
|
|
5567
5585
|
if (lineCount === 0) {
|
|
@@ -5661,7 +5679,8 @@ class TextBuffer {
|
|
|
5661
5679
|
this._length = 0;
|
|
5662
5680
|
this._lineInfo = undefined;
|
|
5663
5681
|
for (const chunk of text.chunks) {
|
|
5664
|
-
const
|
|
5682
|
+
const textBytes = this.lib.encoder.encode(chunk.text);
|
|
5683
|
+
const result = this.lib.textBufferWriteChunk(this.bufferPtr, textBytes, chunk.fg || null, chunk.bg || null, chunk.attributes ?? null);
|
|
5665
5684
|
if (result & 1) {
|
|
5666
5685
|
this._capacity = this.lib.textBufferGetCapacity(this.bufferPtr);
|
|
5667
5686
|
}
|
|
@@ -5693,11 +5712,19 @@ class TextBuffer {
|
|
|
5693
5712
|
getSelectedText() {
|
|
5694
5713
|
if (this._length === 0)
|
|
5695
5714
|
return "";
|
|
5696
|
-
const selectedBytes = this.lib.getSelectedTextBytes(this.bufferPtr, this.
|
|
5715
|
+
const selectedBytes = this.lib.getSelectedTextBytes(this.bufferPtr, this.length * 4);
|
|
5697
5716
|
if (!selectedBytes)
|
|
5698
5717
|
return "";
|
|
5699
5718
|
return this.lib.decoder.decode(selectedBytes);
|
|
5700
5719
|
}
|
|
5720
|
+
getPlainText() {
|
|
5721
|
+
if (this._length === 0)
|
|
5722
|
+
return "";
|
|
5723
|
+
const plainBytes = this.lib.getPlainTextBytes(this.bufferPtr, this.length * 4);
|
|
5724
|
+
if (!plainBytes)
|
|
5725
|
+
return "";
|
|
5726
|
+
return this.lib.decoder.decode(plainBytes);
|
|
5727
|
+
}
|
|
5701
5728
|
get lineInfo() {
|
|
5702
5729
|
if (!this._lineInfo) {
|
|
5703
5730
|
this._lineInfo = this.lib.textBufferGetLineInfo(this.bufferPtr);
|
|
@@ -5722,6 +5749,29 @@ class TextBuffer {
|
|
|
5722
5749
|
hasSelection() {
|
|
5723
5750
|
return this.getSelection() !== null;
|
|
5724
5751
|
}
|
|
5752
|
+
insertChunkGroup(index, text, fg2, bg2, attributes) {
|
|
5753
|
+
const textBytes = this.lib.encoder.encode(text);
|
|
5754
|
+
this.insertEncodedChunkGroup(index, textBytes, fg2, bg2, attributes);
|
|
5755
|
+
}
|
|
5756
|
+
insertEncodedChunkGroup(index, textBytes, fg2, bg2, attributes) {
|
|
5757
|
+
this._length = this.lib.textBufferInsertChunkGroup(this.bufferPtr, index, textBytes, fg2 || null, bg2 || null, attributes ?? null);
|
|
5758
|
+
this._lineInfo = undefined;
|
|
5759
|
+
}
|
|
5760
|
+
removeChunkGroup(index) {
|
|
5761
|
+
this._length = this.lib.textBufferRemoveChunkGroup(this.bufferPtr, index);
|
|
5762
|
+
this._lineInfo = undefined;
|
|
5763
|
+
}
|
|
5764
|
+
replaceChunkGroup(index, text, fg2, bg2, attributes) {
|
|
5765
|
+
const textBytes = this.lib.encoder.encode(text);
|
|
5766
|
+
this.replaceEncodedChunkGroup(index, textBytes, fg2, bg2, attributes);
|
|
5767
|
+
}
|
|
5768
|
+
replaceEncodedChunkGroup(index, textBytes, fg2, bg2, attributes) {
|
|
5769
|
+
this._length = this.lib.textBufferReplaceChunkGroup(this.bufferPtr, index, textBytes, fg2 || null, bg2 || null, attributes ?? null);
|
|
5770
|
+
this._lineInfo = undefined;
|
|
5771
|
+
}
|
|
5772
|
+
get chunkGroupCount() {
|
|
5773
|
+
return this.lib.textBufferGetChunkGroupCount(this.bufferPtr);
|
|
5774
|
+
}
|
|
5725
5775
|
destroy() {
|
|
5726
5776
|
this.lib.destroyTextBuffer(this.bufferPtr);
|
|
5727
5777
|
}
|
|
@@ -5817,12 +5867,30 @@ function isRenderable(obj) {
|
|
|
5817
5867
|
return !!obj?.[BrandedRenderable];
|
|
5818
5868
|
}
|
|
5819
5869
|
|
|
5820
|
-
class
|
|
5870
|
+
class BaseRenderable extends EventEmitter3 {
|
|
5821
5871
|
[BrandedRenderable] = true;
|
|
5822
5872
|
static renderableNumber = 1;
|
|
5823
|
-
static renderablesByNumber = new Map;
|
|
5824
5873
|
id;
|
|
5825
5874
|
num;
|
|
5875
|
+
_dirty = false;
|
|
5876
|
+
constructor(options) {
|
|
5877
|
+
super();
|
|
5878
|
+
this.num = BaseRenderable.renderableNumber++;
|
|
5879
|
+
this.id = options.id ?? `renderable-${this.num}`;
|
|
5880
|
+
}
|
|
5881
|
+
get isDirty() {
|
|
5882
|
+
return this._dirty;
|
|
5883
|
+
}
|
|
5884
|
+
markClean() {
|
|
5885
|
+
this._dirty = false;
|
|
5886
|
+
}
|
|
5887
|
+
markDirty() {
|
|
5888
|
+
this._dirty = true;
|
|
5889
|
+
}
|
|
5890
|
+
}
|
|
5891
|
+
|
|
5892
|
+
class Renderable extends BaseRenderable {
|
|
5893
|
+
static renderablesByNumber = new Map;
|
|
5826
5894
|
_isDestroyed = false;
|
|
5827
5895
|
_ctx;
|
|
5828
5896
|
_translateX = 0;
|
|
@@ -5838,7 +5906,6 @@ class Renderable extends EventEmitter3 {
|
|
|
5838
5906
|
selectable = false;
|
|
5839
5907
|
buffered;
|
|
5840
5908
|
frameBuffer = null;
|
|
5841
|
-
_dirty = false;
|
|
5842
5909
|
focusable = false;
|
|
5843
5910
|
_focused = false;
|
|
5844
5911
|
keyHandler = getKeyHandler();
|
|
@@ -5862,9 +5929,7 @@ class Renderable extends EventEmitter3 {
|
|
|
5862
5929
|
renderBefore;
|
|
5863
5930
|
renderAfter;
|
|
5864
5931
|
constructor(ctx, options) {
|
|
5865
|
-
super();
|
|
5866
|
-
this.num = Renderable.renderableNumber++;
|
|
5867
|
-
this.id = options.id ?? `renderable-${this.num}`;
|
|
5932
|
+
super(options);
|
|
5868
5933
|
this._ctx = ctx;
|
|
5869
5934
|
Renderable.renderablesByNumber.set(this.num, this);
|
|
5870
5935
|
validateOptions(this.id, options);
|
|
@@ -5974,9 +6039,6 @@ class Renderable extends EventEmitter3 {
|
|
|
5974
6039
|
this._liveCount += delta;
|
|
5975
6040
|
this.parent?.propagateLiveCount(delta);
|
|
5976
6041
|
}
|
|
5977
|
-
get isDirty() {
|
|
5978
|
-
return this._dirty;
|
|
5979
|
-
}
|
|
5980
6042
|
findDescendantById(id) {
|
|
5981
6043
|
for (const child of this.renderableArray) {
|
|
5982
6044
|
if (child.id === id)
|
|
@@ -5987,11 +6049,8 @@ class Renderable extends EventEmitter3 {
|
|
|
5987
6049
|
}
|
|
5988
6050
|
return;
|
|
5989
6051
|
}
|
|
5990
|
-
markClean() {
|
|
5991
|
-
this._dirty = false;
|
|
5992
|
-
}
|
|
5993
6052
|
requestRender() {
|
|
5994
|
-
this.
|
|
6053
|
+
this.markDirty();
|
|
5995
6054
|
this._ctx.requestRender();
|
|
5996
6055
|
}
|
|
5997
6056
|
get translateX() {
|
|
@@ -6714,10 +6773,10 @@ class Renderable extends EventEmitter3 {
|
|
|
6714
6773
|
this.layoutNode.destroy();
|
|
6715
6774
|
}
|
|
6716
6775
|
destroyRecursively() {
|
|
6717
|
-
this.destroy();
|
|
6718
6776
|
for (const child of this.renderableArray) {
|
|
6719
6777
|
child.destroyRecursively();
|
|
6720
6778
|
}
|
|
6779
|
+
this.destroy();
|
|
6721
6780
|
}
|
|
6722
6781
|
destroySelf() {}
|
|
6723
6782
|
processMouseEvent(event) {
|
|
@@ -7976,6 +8035,7 @@ Error details:
|
|
|
7976
8035
|
global.requestAnimationFrame = (callback) => {
|
|
7977
8036
|
const id = CliRenderer.animationFrameId++;
|
|
7978
8037
|
this.animationRequest.set(id, callback);
|
|
8038
|
+
this.requestLive();
|
|
7979
8039
|
return id;
|
|
7980
8040
|
};
|
|
7981
8041
|
global.cancelAnimationFrame = (handle) => {
|
|
@@ -8586,7 +8646,10 @@ Error details:
|
|
|
8586
8646
|
const frameRequests = Array.from(this.animationRequest.values());
|
|
8587
8647
|
this.animationRequest.clear();
|
|
8588
8648
|
const animationRequestStart = performance.now();
|
|
8589
|
-
frameRequests.forEach((callback) =>
|
|
8649
|
+
frameRequests.forEach((callback) => {
|
|
8650
|
+
callback(deltaTime);
|
|
8651
|
+
this.dropLive();
|
|
8652
|
+
});
|
|
8590
8653
|
const animationRequestEnd = performance.now();
|
|
8591
8654
|
const animationRequestTime = animationRequestEnd - animationRequestStart;
|
|
8592
8655
|
const start = performance.now();
|
|
@@ -8771,7 +8834,7 @@ Error details:
|
|
|
8771
8834
|
}
|
|
8772
8835
|
}
|
|
8773
8836
|
|
|
8774
|
-
export { __toESM, __commonJS, __export, __require, Edge, Gutter, MeasureMode, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, TrackedNode, createTrackedNode, nonAlphanumericKeys, parseKeypress, KeyHandler, getKeyHandler, RGBA, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, DebugOverlayCorner, createTextAttributes, StyledText, stringToStyledText, black, red, green, yellow, blue, magenta, cyan, white, brightBlack, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bold, italic, underline, strikethrough, dim, reverse, blink, fg, bg,
|
|
8837
|
+
export { __toESM, __commonJS, __export, __require, Edge, Gutter, MeasureMode, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, TrackedNode, createTrackedNode, nonAlphanumericKeys, parseKeypress, KeyHandler, getKeyHandler, RGBA, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, DebugOverlayCorner, createTextAttributes, StyledText, stringToStyledText, black, red, green, yellow, blue, magenta, cyan, white, brightBlack, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bold, italic, underline, strikethrough, dim, reverse, blink, fg, bg, t, SyntaxStyle, hastToStyledText, parseAlign, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, convertGlobalToLocalSelection, ASCIIFontSelectionHelper, TextBuffer, LogLevel2 as LogLevel, setRenderLibPath, resolveRenderLib, OptimizedBuffer, h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, LayoutEvents, RenderableEvents, isValidPercentage, isMarginType, isPaddingType, isPositionType, isPositionTypeType, isOverflowType, isDimensionType, isFlexBasisType, isSizeType, isRenderable, BaseRenderable, Renderable, RootRenderable, capture, ConsolePosition, TerminalConsole, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, CliRenderer };
|
|
8775
8838
|
|
|
8776
|
-
//# debugId=
|
|
8777
|
-
//# sourceMappingURL=index-
|
|
8839
|
+
//# debugId=C116B02488BF34D464756E2164756E21
|
|
8840
|
+
//# sourceMappingURL=index-0h2r5adk.js.map
|