@opentui/core 0.0.0-20251209-015faccd → 0.0.0-20251211-4403a69a
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 +14 -3
- package/buffer.d.ts +4 -0
- package/edit-buffer.d.ts +20 -6
- package/editor-view.d.ts +2 -0
- package/{index-4s3xr47p.js → index-yhfn13z6.js} +124 -13
- package/{index-4s3xr47p.js.map → index-yhfn13z6.js.map} +7 -7
- package/index.js +103 -77
- package/index.js.map +11 -11
- package/lib/extmarks.d.ts +1 -0
- package/package.json +8 -8
- package/renderables/EditBufferRenderable.d.ts +10 -3
- package/renderables/Input.d.ts +1 -1
- package/renderables/ScrollBar.d.ts +1 -1
- package/renderables/ScrollBox.d.ts +1 -1
- package/renderables/Select.d.ts +1 -1
- package/renderables/TabSelect.d.ts +1 -1
- package/renderables/Textarea.d.ts +8 -2
- package/testing.js +13 -5
- package/testing.js.map +3 -3
- package/zig.d.ts +10 -2
package/index.js
CHANGED
|
@@ -138,7 +138,7 @@ import {
|
|
|
138
138
|
white,
|
|
139
139
|
wrapWithDelegates,
|
|
140
140
|
yellow
|
|
141
|
-
} from "./index-
|
|
141
|
+
} from "./index-yhfn13z6.js";
|
|
142
142
|
// src/text-buffer-view.ts
|
|
143
143
|
class TextBufferView {
|
|
144
144
|
lib;
|
|
@@ -309,29 +309,33 @@ class EditBuffer extends EventEmitter {
|
|
|
309
309
|
this.guard();
|
|
310
310
|
return this.bufferPtr;
|
|
311
311
|
}
|
|
312
|
-
setText(text
|
|
312
|
+
setText(text) {
|
|
313
313
|
this.guard();
|
|
314
|
-
const history = opts?.history ?? true;
|
|
315
314
|
const textBytes = this.lib.encoder.encode(text);
|
|
316
|
-
if (
|
|
317
|
-
this.
|
|
318
|
-
const memId = this.lib.textBufferRegisterMemBuffer(this.textBufferPtr, textBytes, false);
|
|
319
|
-
this.lib.editBufferSetTextFromMem(this.bufferPtr, memId, true);
|
|
315
|
+
if (this._singleTextMemId !== null) {
|
|
316
|
+
this.lib.textBufferReplaceMemBuffer(this.textBufferPtr, this._singleTextMemId, textBytes, false);
|
|
320
317
|
} else {
|
|
321
|
-
|
|
322
|
-
this.lib.textBufferReplaceMemBuffer(this.textBufferPtr, this._singleTextMemId, textBytes, false);
|
|
323
|
-
} else {
|
|
324
|
-
this._singleTextMemId = this.lib.textBufferRegisterMemBuffer(this.textBufferPtr, textBytes, false);
|
|
325
|
-
}
|
|
326
|
-
this._singleTextBytes = textBytes;
|
|
327
|
-
this.lib.editBufferSetTextFromMem(this.bufferPtr, this._singleTextMemId, false);
|
|
318
|
+
this._singleTextMemId = this.lib.textBufferRegisterMemBuffer(this.textBufferPtr, textBytes, false);
|
|
328
319
|
}
|
|
320
|
+
this._singleTextBytes = textBytes;
|
|
321
|
+
this.lib.editBufferSetTextFromMem(this.bufferPtr, this._singleTextMemId);
|
|
322
|
+
}
|
|
323
|
+
setTextOwned(text) {
|
|
324
|
+
this.guard();
|
|
325
|
+
const textBytes = this.lib.encoder.encode(text);
|
|
326
|
+
this.lib.editBufferSetText(this.bufferPtr, textBytes);
|
|
327
|
+
}
|
|
328
|
+
replaceText(text) {
|
|
329
|
+
this.guard();
|
|
330
|
+
const textBytes = this.lib.encoder.encode(text);
|
|
331
|
+
this._textBytes.push(textBytes);
|
|
332
|
+
const memId = this.lib.textBufferRegisterMemBuffer(this.textBufferPtr, textBytes, false);
|
|
333
|
+
this.lib.editBufferReplaceTextFromMem(this.bufferPtr, memId);
|
|
329
334
|
}
|
|
330
|
-
|
|
335
|
+
replaceTextOwned(text) {
|
|
331
336
|
this.guard();
|
|
332
|
-
const history = opts?.history ?? true;
|
|
333
337
|
const textBytes = this.lib.encoder.encode(text);
|
|
334
|
-
this.lib.
|
|
338
|
+
this.lib.editBufferReplaceText(this.bufferPtr, textBytes);
|
|
335
339
|
}
|
|
336
340
|
getLineCount() {
|
|
337
341
|
this.guard();
|
|
@@ -688,6 +692,14 @@ class EditorView {
|
|
|
688
692
|
this.guard();
|
|
689
693
|
return this.lib.editorViewGetEOL(this.viewPtr);
|
|
690
694
|
}
|
|
695
|
+
getVisualSOL() {
|
|
696
|
+
this.guard();
|
|
697
|
+
return this.lib.editorViewGetVisualSOL(this.viewPtr);
|
|
698
|
+
}
|
|
699
|
+
getVisualEOL() {
|
|
700
|
+
this.guard();
|
|
701
|
+
return this.lib.editorViewGetVisualEOL(this.viewPtr);
|
|
702
|
+
}
|
|
691
703
|
getLineInfo() {
|
|
692
704
|
this.guard();
|
|
693
705
|
return this.lib.editorViewGetLineInfo(this.viewPtr);
|
|
@@ -5676,19 +5688,12 @@ class InputRenderable extends Renderable {
|
|
|
5676
5688
|
}
|
|
5677
5689
|
}
|
|
5678
5690
|
handleKeyPress(key) {
|
|
5679
|
-
const keyName = typeof key === "string" ? key : key.name;
|
|
5680
|
-
const keySequence = typeof key === "string" ? key : key.sequence;
|
|
5681
|
-
const keyCtrl = typeof key === "string" ? false : key.ctrl;
|
|
5682
|
-
const keyShift = typeof key === "string" ? false : key.shift;
|
|
5683
|
-
const keyMeta = typeof key === "string" ? false : key.meta;
|
|
5684
|
-
const keySuper = typeof key === "string" ? false : key.super;
|
|
5685
|
-
const keyHyper = typeof key === "string" ? false : key.hyper;
|
|
5686
5691
|
const bindingKey = getKeyBindingKey({
|
|
5687
|
-
name:
|
|
5688
|
-
ctrl:
|
|
5689
|
-
shift:
|
|
5690
|
-
meta:
|
|
5691
|
-
super:
|
|
5692
|
+
name: key.name,
|
|
5693
|
+
ctrl: key.ctrl,
|
|
5694
|
+
shift: key.shift,
|
|
5695
|
+
meta: key.meta,
|
|
5696
|
+
super: key.super,
|
|
5692
5697
|
action: "move-left"
|
|
5693
5698
|
});
|
|
5694
5699
|
const action = this._keyBindingsMap.get(bindingKey);
|
|
@@ -5721,13 +5726,13 @@ class InputRenderable extends Renderable {
|
|
|
5721
5726
|
return true;
|
|
5722
5727
|
}
|
|
5723
5728
|
}
|
|
5724
|
-
if (!
|
|
5725
|
-
if (
|
|
5729
|
+
if (!key.ctrl && !key.meta && !key.super && !key.hyper) {
|
|
5730
|
+
if (key.name === "space") {
|
|
5726
5731
|
this.insertText(" ");
|
|
5727
5732
|
return true;
|
|
5728
5733
|
}
|
|
5729
|
-
if (
|
|
5730
|
-
this.insertText(
|
|
5734
|
+
if (key.sequence && key.sequence.length === 1 && key.sequence.charCodeAt(0) >= 32 && key.sequence.charCodeAt(0) <= 126) {
|
|
5735
|
+
this.insertText(key.sequence);
|
|
5731
5736
|
return true;
|
|
5732
5737
|
}
|
|
5733
5738
|
}
|
|
@@ -6274,8 +6279,7 @@ class ScrollBarRenderable extends Renderable {
|
|
|
6274
6279
|
}
|
|
6275
6280
|
}
|
|
6276
6281
|
handleKeyPress(key) {
|
|
6277
|
-
|
|
6278
|
-
switch (keyName) {
|
|
6282
|
+
switch (key.name) {
|
|
6279
6283
|
case "left":
|
|
6280
6284
|
case "h":
|
|
6281
6285
|
if (this.orientation !== "horizontal")
|
|
@@ -7194,17 +7198,12 @@ class SelectRenderable extends Renderable {
|
|
|
7194
7198
|
this.requestRender();
|
|
7195
7199
|
}
|
|
7196
7200
|
handleKeyPress(key) {
|
|
7197
|
-
const keyName = typeof key === "string" ? key : key.name;
|
|
7198
|
-
const keyCtrl = typeof key === "string" ? false : key.ctrl;
|
|
7199
|
-
const keyShift = typeof key === "string" ? false : key.shift;
|
|
7200
|
-
const keyMeta = typeof key === "string" ? false : key.meta;
|
|
7201
|
-
const keySuper = typeof key === "string" ? false : key.super;
|
|
7202
7201
|
const bindingKey = getKeyBindingKey({
|
|
7203
|
-
name:
|
|
7204
|
-
ctrl:
|
|
7205
|
-
shift:
|
|
7206
|
-
meta:
|
|
7207
|
-
super:
|
|
7202
|
+
name: key.name,
|
|
7203
|
+
ctrl: key.ctrl,
|
|
7204
|
+
shift: key.shift,
|
|
7205
|
+
meta: key.meta,
|
|
7206
|
+
super: key.super,
|
|
7208
7207
|
action: "move-up"
|
|
7209
7208
|
});
|
|
7210
7209
|
const action = this._keyBindingsMap.get(bindingKey);
|
|
@@ -7567,17 +7566,12 @@ class TabSelectRenderable extends Renderable {
|
|
|
7567
7566
|
return this._tabWidth;
|
|
7568
7567
|
}
|
|
7569
7568
|
handleKeyPress(key) {
|
|
7570
|
-
const keyName = typeof key === "string" ? key : key.name;
|
|
7571
|
-
const keyCtrl = typeof key === "string" ? false : key.ctrl;
|
|
7572
|
-
const keyShift = typeof key === "string" ? false : key.shift;
|
|
7573
|
-
const keyMeta = typeof key === "string" ? false : key.meta;
|
|
7574
|
-
const keySuper = typeof key === "string" ? false : key.super;
|
|
7575
7569
|
const bindingKey = getKeyBindingKey({
|
|
7576
|
-
name:
|
|
7577
|
-
ctrl:
|
|
7578
|
-
shift:
|
|
7579
|
-
meta:
|
|
7580
|
-
super:
|
|
7570
|
+
name: key.name,
|
|
7571
|
+
ctrl: key.ctrl,
|
|
7572
|
+
shift: key.shift,
|
|
7573
|
+
meta: key.meta,
|
|
7574
|
+
super: key.super,
|
|
7581
7575
|
action: "move-left"
|
|
7582
7576
|
});
|
|
7583
7577
|
const action = this._keyBindingsMap.get(bindingKey);
|
|
@@ -8106,8 +8100,13 @@ class EditBufferRenderable extends Renderable {
|
|
|
8106
8100
|
getLineHighlights(lineIdx) {
|
|
8107
8101
|
return this.editBuffer.getLineHighlights(lineIdx);
|
|
8108
8102
|
}
|
|
8109
|
-
setText(text
|
|
8110
|
-
this.editBuffer.setText(text
|
|
8103
|
+
setText(text) {
|
|
8104
|
+
this.editBuffer.setText(text);
|
|
8105
|
+
this.yogaNode.markDirty();
|
|
8106
|
+
this.requestRender();
|
|
8107
|
+
}
|
|
8108
|
+
replaceText(text) {
|
|
8109
|
+
this.editBuffer.replaceText(text);
|
|
8111
8110
|
this.yogaNode.markDirty();
|
|
8112
8111
|
this.requestRender();
|
|
8113
8112
|
}
|
|
@@ -8200,14 +8199,25 @@ var defaultTextareaKeybindings = [
|
|
|
8200
8199
|
{ name: "end", shift: true, action: "select-buffer-end" },
|
|
8201
8200
|
{ name: "a", ctrl: true, action: "line-home" },
|
|
8202
8201
|
{ name: "e", ctrl: true, action: "line-end" },
|
|
8202
|
+
{ name: "a", ctrl: true, shift: true, action: "select-line-home" },
|
|
8203
|
+
{ name: "e", ctrl: true, shift: true, action: "select-line-end" },
|
|
8204
|
+
{ name: "a", meta: true, action: "visual-line-home" },
|
|
8205
|
+
{ name: "e", meta: true, action: "visual-line-end" },
|
|
8206
|
+
{ name: "a", meta: true, shift: true, action: "select-visual-line-home" },
|
|
8207
|
+
{ name: "e", meta: true, shift: true, action: "select-visual-line-end" },
|
|
8203
8208
|
{ name: "f", ctrl: true, action: "move-right" },
|
|
8204
8209
|
{ name: "b", ctrl: true, action: "move-left" },
|
|
8205
|
-
{ name: "d", ctrl: true, action: "delete-word-forward" },
|
|
8206
8210
|
{ name: "w", ctrl: true, action: "delete-word-backward" },
|
|
8211
|
+
{ name: "backspace", ctrl: true, action: "delete-word-backward" },
|
|
8212
|
+
{ name: "d", meta: true, action: "delete-word-forward" },
|
|
8213
|
+
{ name: "delete", meta: true, action: "delete-word-forward" },
|
|
8214
|
+
{ name: "delete", ctrl: true, action: "delete-word-forward" },
|
|
8215
|
+
{ name: "d", ctrl: true, shift: true, action: "delete-line" },
|
|
8207
8216
|
{ name: "k", ctrl: true, action: "delete-to-line-end" },
|
|
8208
8217
|
{ name: "u", ctrl: true, action: "delete-to-line-start" },
|
|
8209
8218
|
{ name: "backspace", action: "backspace" },
|
|
8210
8219
|
{ name: "backspace", shift: true, action: "backspace" },
|
|
8220
|
+
{ name: "d", ctrl: true, action: "delete" },
|
|
8211
8221
|
{ name: "delete", action: "delete" },
|
|
8212
8222
|
{ name: "delete", shift: true, action: "delete" },
|
|
8213
8223
|
{ name: "return", action: "newline" },
|
|
@@ -8221,11 +8231,12 @@ var defaultTextareaKeybindings = [
|
|
|
8221
8231
|
{ name: "b", meta: true, action: "word-backward" },
|
|
8222
8232
|
{ name: "right", meta: true, action: "word-forward" },
|
|
8223
8233
|
{ name: "left", meta: true, action: "word-backward" },
|
|
8234
|
+
{ name: "right", ctrl: true, action: "word-forward" },
|
|
8235
|
+
{ name: "left", ctrl: true, action: "word-backward" },
|
|
8224
8236
|
{ name: "f", meta: true, shift: true, action: "select-word-forward" },
|
|
8225
8237
|
{ name: "b", meta: true, shift: true, action: "select-word-backward" },
|
|
8226
8238
|
{ name: "right", meta: true, shift: true, action: "select-word-forward" },
|
|
8227
8239
|
{ name: "left", meta: true, shift: true, action: "select-word-backward" },
|
|
8228
|
-
{ name: "d", meta: true, action: "delete-line" },
|
|
8229
8240
|
{ name: "backspace", meta: true, action: "delete-word-backward" }
|
|
8230
8241
|
];
|
|
8231
8242
|
|
|
@@ -8301,6 +8312,10 @@ class TextareaRenderable extends EditBufferRenderable {
|
|
|
8301
8312
|
["line-end", () => this.gotoLineEnd()],
|
|
8302
8313
|
["select-line-home", () => this.gotoLineHome({ select: true })],
|
|
8303
8314
|
["select-line-end", () => this.gotoLineEnd({ select: true })],
|
|
8315
|
+
["visual-line-home", () => this.gotoVisualLineHome()],
|
|
8316
|
+
["visual-line-end", () => this.gotoVisualLineEnd()],
|
|
8317
|
+
["select-visual-line-home", () => this.gotoVisualLineHome({ select: true })],
|
|
8318
|
+
["select-visual-line-end", () => this.gotoVisualLineEnd({ select: true })],
|
|
8304
8319
|
["select-buffer-home", () => this.gotoBufferHome({ select: true })],
|
|
8305
8320
|
["select-buffer-end", () => this.gotoBufferEnd({ select: true })],
|
|
8306
8321
|
["buffer-home", () => this.gotoBufferHome()],
|
|
@@ -8326,19 +8341,12 @@ class TextareaRenderable extends EditBufferRenderable {
|
|
|
8326
8341
|
this.insertText(event.text);
|
|
8327
8342
|
}
|
|
8328
8343
|
handleKeyPress(key) {
|
|
8329
|
-
const keyName = typeof key === "string" ? key : key.name;
|
|
8330
|
-
const keySequence = typeof key === "string" ? key : key.sequence;
|
|
8331
|
-
const keyCtrl = typeof key === "string" ? false : key.ctrl;
|
|
8332
|
-
const keyShift = typeof key === "string" ? false : key.shift;
|
|
8333
|
-
const keyMeta = typeof key === "string" ? false : key.meta;
|
|
8334
|
-
const keySuper = typeof key === "string" ? false : key.super;
|
|
8335
|
-
const keyHyper = typeof key === "string" ? false : key.hyper;
|
|
8336
8344
|
const bindingKey = getKeyBindingKey({
|
|
8337
|
-
name:
|
|
8338
|
-
ctrl:
|
|
8339
|
-
shift:
|
|
8340
|
-
meta:
|
|
8341
|
-
super:
|
|
8345
|
+
name: key.name,
|
|
8346
|
+
ctrl: key.ctrl,
|
|
8347
|
+
shift: key.shift,
|
|
8348
|
+
meta: key.meta,
|
|
8349
|
+
super: key.super,
|
|
8342
8350
|
action: "move-left"
|
|
8343
8351
|
});
|
|
8344
8352
|
const action = this._keyBindingsMap.get(bindingKey);
|
|
@@ -8348,20 +8356,20 @@ class TextareaRenderable extends EditBufferRenderable {
|
|
|
8348
8356
|
return handler();
|
|
8349
8357
|
}
|
|
8350
8358
|
}
|
|
8351
|
-
if (!
|
|
8352
|
-
if (
|
|
8359
|
+
if (!key.ctrl && !key.meta && !key.super && !key.hyper) {
|
|
8360
|
+
if (key.name === "space") {
|
|
8353
8361
|
this.insertText(" ");
|
|
8354
8362
|
return true;
|
|
8355
8363
|
}
|
|
8356
|
-
if (
|
|
8357
|
-
const firstCharCode =
|
|
8364
|
+
if (key.sequence) {
|
|
8365
|
+
const firstCharCode = key.sequence.charCodeAt(0);
|
|
8358
8366
|
if (firstCharCode < 32) {
|
|
8359
8367
|
return false;
|
|
8360
8368
|
}
|
|
8361
8369
|
if (firstCharCode === 127) {
|
|
8362
8370
|
return false;
|
|
8363
8371
|
}
|
|
8364
|
-
this.insertText(
|
|
8372
|
+
this.insertText(key.sequence);
|
|
8365
8373
|
return true;
|
|
8366
8374
|
}
|
|
8367
8375
|
}
|
|
@@ -8490,6 +8498,24 @@ class TextareaRenderable extends EditBufferRenderable {
|
|
|
8490
8498
|
this.requestRender();
|
|
8491
8499
|
return true;
|
|
8492
8500
|
}
|
|
8501
|
+
gotoVisualLineHome(options) {
|
|
8502
|
+
const select = options?.select ?? false;
|
|
8503
|
+
this.updateSelectionForMovement(select, true);
|
|
8504
|
+
const sol = this.editorView.getVisualSOL();
|
|
8505
|
+
this.editBuffer.setCursor(sol.logicalRow, sol.logicalCol);
|
|
8506
|
+
this.updateSelectionForMovement(select, false);
|
|
8507
|
+
this.requestRender();
|
|
8508
|
+
return true;
|
|
8509
|
+
}
|
|
8510
|
+
gotoVisualLineEnd(options) {
|
|
8511
|
+
const select = options?.select ?? false;
|
|
8512
|
+
this.updateSelectionForMovement(select, true);
|
|
8513
|
+
const eol = this.editorView.getVisualEOL();
|
|
8514
|
+
this.editBuffer.setCursor(eol.logicalRow, eol.logicalCol);
|
|
8515
|
+
this.updateSelectionForMovement(select, false);
|
|
8516
|
+
this.requestRender();
|
|
8517
|
+
return true;
|
|
8518
|
+
}
|
|
8493
8519
|
gotoBufferHome(options) {
|
|
8494
8520
|
const select = options?.select ?? false;
|
|
8495
8521
|
this.updateSelectionForMovement(select, true);
|
|
@@ -8855,5 +8881,5 @@ export {
|
|
|
8855
8881
|
ASCIIFont
|
|
8856
8882
|
};
|
|
8857
8883
|
|
|
8858
|
-
//# debugId=
|
|
8884
|
+
//# debugId=02ED7CC7E35CA36064756E2164756E21
|
|
8859
8885
|
//# sourceMappingURL=index.js.map
|