@opentui/core 0.1.60 → 0.1.61
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/console.d.ts +53 -1
- package/editor-view.d.ts +2 -0
- package/{index-916mvx7m.js → index-rysm4rsr.js} +682 -142
- package/{index-916mvx7m.js.map → index-rysm4rsr.js.map} +10 -9
- package/index.js +80 -99
- package/index.js.map +10 -11
- package/lib/keymapping.d.ts +11 -0
- package/package.json +8 -8
- 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/renderer.d.ts +1 -0
- package/testing.js +13 -5
- package/testing.js.map +3 -3
- package/zig.d.ts +6 -0
package/index.js
CHANGED
|
@@ -61,6 +61,7 @@ import {
|
|
|
61
61
|
brightRed,
|
|
62
62
|
brightWhite,
|
|
63
63
|
brightYellow,
|
|
64
|
+
buildKeyBindingsMap,
|
|
64
65
|
buildKittyKeyboardFlags,
|
|
65
66
|
capture,
|
|
66
67
|
clearEnvCache,
|
|
@@ -71,6 +72,7 @@ import {
|
|
|
71
72
|
createTerminalPalette,
|
|
72
73
|
createTextAttributes,
|
|
73
74
|
cyan,
|
|
75
|
+
defaultKeyAliases,
|
|
74
76
|
delegate,
|
|
75
77
|
dim,
|
|
76
78
|
env,
|
|
@@ -85,6 +87,7 @@ import {
|
|
|
85
87
|
getBorderSides,
|
|
86
88
|
getCharacterPositions,
|
|
87
89
|
getDataPaths,
|
|
90
|
+
getKeyBindingKey,
|
|
88
91
|
getObjectsInViewport,
|
|
89
92
|
getTreeSitterClient,
|
|
90
93
|
green,
|
|
@@ -102,6 +105,8 @@ import {
|
|
|
102
105
|
main,
|
|
103
106
|
maybeMakeRenderable,
|
|
104
107
|
measureText,
|
|
108
|
+
mergeKeyAliases,
|
|
109
|
+
mergeKeyBindings,
|
|
105
110
|
nonAlphanumericKeys,
|
|
106
111
|
parseAlign,
|
|
107
112
|
parseBoxSizing,
|
|
@@ -138,7 +143,7 @@ import {
|
|
|
138
143
|
white,
|
|
139
144
|
wrapWithDelegates,
|
|
140
145
|
yellow
|
|
141
|
-
} from "./index-
|
|
146
|
+
} from "./index-rysm4rsr.js";
|
|
142
147
|
// src/text-buffer-view.ts
|
|
143
148
|
class TextBufferView {
|
|
144
149
|
lib;
|
|
@@ -692,6 +697,14 @@ class EditorView {
|
|
|
692
697
|
this.guard();
|
|
693
698
|
return this.lib.editorViewGetEOL(this.viewPtr);
|
|
694
699
|
}
|
|
700
|
+
getVisualSOL() {
|
|
701
|
+
this.guard();
|
|
702
|
+
return this.lib.editorViewGetVisualSOL(this.viewPtr);
|
|
703
|
+
}
|
|
704
|
+
getVisualEOL() {
|
|
705
|
+
this.guard();
|
|
706
|
+
return this.lib.editorViewGetVisualEOL(this.viewPtr);
|
|
707
|
+
}
|
|
695
708
|
getLineInfo() {
|
|
696
709
|
this.guard();
|
|
697
710
|
return this.lib.editorViewGetLineInfo(this.viewPtr);
|
|
@@ -5439,46 +5452,6 @@ class DiffRenderable extends Renderable {
|
|
|
5439
5452
|
}
|
|
5440
5453
|
}
|
|
5441
5454
|
}
|
|
5442
|
-
// src/lib/keymapping.ts
|
|
5443
|
-
var defaultKeyAliases = {
|
|
5444
|
-
enter: "return",
|
|
5445
|
-
esc: "escape"
|
|
5446
|
-
};
|
|
5447
|
-
function mergeKeyAliases(defaults, custom) {
|
|
5448
|
-
return { ...defaults, ...custom };
|
|
5449
|
-
}
|
|
5450
|
-
function mergeKeyBindings(defaults, custom) {
|
|
5451
|
-
const map = new Map;
|
|
5452
|
-
for (const binding of defaults) {
|
|
5453
|
-
const key = getKeyBindingKey(binding);
|
|
5454
|
-
map.set(key, binding);
|
|
5455
|
-
}
|
|
5456
|
-
for (const binding of custom) {
|
|
5457
|
-
const key = getKeyBindingKey(binding);
|
|
5458
|
-
map.set(key, binding);
|
|
5459
|
-
}
|
|
5460
|
-
return Array.from(map.values());
|
|
5461
|
-
}
|
|
5462
|
-
function getKeyBindingKey(binding) {
|
|
5463
|
-
return `${binding.name}:${binding.ctrl ? 1 : 0}:${binding.shift ? 1 : 0}:${binding.meta ? 1 : 0}:${binding.super ? 1 : 0}`;
|
|
5464
|
-
}
|
|
5465
|
-
function buildKeyBindingsMap(bindings, aliasMap) {
|
|
5466
|
-
const map = new Map;
|
|
5467
|
-
const aliases = aliasMap || {};
|
|
5468
|
-
for (const binding of bindings) {
|
|
5469
|
-
const key = getKeyBindingKey(binding);
|
|
5470
|
-
map.set(key, binding.action);
|
|
5471
|
-
}
|
|
5472
|
-
for (const binding of bindings) {
|
|
5473
|
-
const normalizedName = aliases[binding.name] || binding.name;
|
|
5474
|
-
if (normalizedName !== binding.name) {
|
|
5475
|
-
const aliasedKey = getKeyBindingKey({ ...binding, name: normalizedName });
|
|
5476
|
-
map.set(aliasedKey, binding.action);
|
|
5477
|
-
}
|
|
5478
|
-
}
|
|
5479
|
-
return map;
|
|
5480
|
-
}
|
|
5481
|
-
|
|
5482
5455
|
// src/renderables/Input.ts
|
|
5483
5456
|
var defaultInputKeybindings = [
|
|
5484
5457
|
{ name: "left", action: "move-left" },
|
|
@@ -5680,19 +5653,12 @@ class InputRenderable extends Renderable {
|
|
|
5680
5653
|
}
|
|
5681
5654
|
}
|
|
5682
5655
|
handleKeyPress(key) {
|
|
5683
|
-
const keyName = typeof key === "string" ? key : key.name;
|
|
5684
|
-
const keySequence = typeof key === "string" ? key : key.sequence;
|
|
5685
|
-
const keyCtrl = typeof key === "string" ? false : key.ctrl;
|
|
5686
|
-
const keyShift = typeof key === "string" ? false : key.shift;
|
|
5687
|
-
const keyMeta = typeof key === "string" ? false : key.meta;
|
|
5688
|
-
const keySuper = typeof key === "string" ? false : key.super;
|
|
5689
|
-
const keyHyper = typeof key === "string" ? false : key.hyper;
|
|
5690
5656
|
const bindingKey = getKeyBindingKey({
|
|
5691
|
-
name:
|
|
5692
|
-
ctrl:
|
|
5693
|
-
shift:
|
|
5694
|
-
meta:
|
|
5695
|
-
super:
|
|
5657
|
+
name: key.name,
|
|
5658
|
+
ctrl: key.ctrl,
|
|
5659
|
+
shift: key.shift,
|
|
5660
|
+
meta: key.meta,
|
|
5661
|
+
super: key.super,
|
|
5696
5662
|
action: "move-left"
|
|
5697
5663
|
});
|
|
5698
5664
|
const action = this._keyBindingsMap.get(bindingKey);
|
|
@@ -5725,13 +5691,13 @@ class InputRenderable extends Renderable {
|
|
|
5725
5691
|
return true;
|
|
5726
5692
|
}
|
|
5727
5693
|
}
|
|
5728
|
-
if (!
|
|
5729
|
-
if (
|
|
5694
|
+
if (!key.ctrl && !key.meta && !key.super && !key.hyper) {
|
|
5695
|
+
if (key.name === "space") {
|
|
5730
5696
|
this.insertText(" ");
|
|
5731
5697
|
return true;
|
|
5732
5698
|
}
|
|
5733
|
-
if (
|
|
5734
|
-
this.insertText(
|
|
5699
|
+
if (key.sequence && key.sequence.length === 1 && key.sequence.charCodeAt(0) >= 32 && key.sequence.charCodeAt(0) <= 126) {
|
|
5700
|
+
this.insertText(key.sequence);
|
|
5735
5701
|
return true;
|
|
5736
5702
|
}
|
|
5737
5703
|
}
|
|
@@ -6278,8 +6244,7 @@ class ScrollBarRenderable extends Renderable {
|
|
|
6278
6244
|
}
|
|
6279
6245
|
}
|
|
6280
6246
|
handleKeyPress(key) {
|
|
6281
|
-
|
|
6282
|
-
switch (keyName) {
|
|
6247
|
+
switch (key.name) {
|
|
6283
6248
|
case "left":
|
|
6284
6249
|
case "h":
|
|
6285
6250
|
if (this.orientation !== "horizontal")
|
|
@@ -7198,17 +7163,12 @@ class SelectRenderable extends Renderable {
|
|
|
7198
7163
|
this.requestRender();
|
|
7199
7164
|
}
|
|
7200
7165
|
handleKeyPress(key) {
|
|
7201
|
-
const keyName = typeof key === "string" ? key : key.name;
|
|
7202
|
-
const keyCtrl = typeof key === "string" ? false : key.ctrl;
|
|
7203
|
-
const keyShift = typeof key === "string" ? false : key.shift;
|
|
7204
|
-
const keyMeta = typeof key === "string" ? false : key.meta;
|
|
7205
|
-
const keySuper = typeof key === "string" ? false : key.super;
|
|
7206
7166
|
const bindingKey = getKeyBindingKey({
|
|
7207
|
-
name:
|
|
7208
|
-
ctrl:
|
|
7209
|
-
shift:
|
|
7210
|
-
meta:
|
|
7211
|
-
super:
|
|
7167
|
+
name: key.name,
|
|
7168
|
+
ctrl: key.ctrl,
|
|
7169
|
+
shift: key.shift,
|
|
7170
|
+
meta: key.meta,
|
|
7171
|
+
super: key.super,
|
|
7212
7172
|
action: "move-up"
|
|
7213
7173
|
});
|
|
7214
7174
|
const action = this._keyBindingsMap.get(bindingKey);
|
|
@@ -7571,17 +7531,12 @@ class TabSelectRenderable extends Renderable {
|
|
|
7571
7531
|
return this._tabWidth;
|
|
7572
7532
|
}
|
|
7573
7533
|
handleKeyPress(key) {
|
|
7574
|
-
const keyName = typeof key === "string" ? key : key.name;
|
|
7575
|
-
const keyCtrl = typeof key === "string" ? false : key.ctrl;
|
|
7576
|
-
const keyShift = typeof key === "string" ? false : key.shift;
|
|
7577
|
-
const keyMeta = typeof key === "string" ? false : key.meta;
|
|
7578
|
-
const keySuper = typeof key === "string" ? false : key.super;
|
|
7579
7534
|
const bindingKey = getKeyBindingKey({
|
|
7580
|
-
name:
|
|
7581
|
-
ctrl:
|
|
7582
|
-
shift:
|
|
7583
|
-
meta:
|
|
7584
|
-
super:
|
|
7535
|
+
name: key.name,
|
|
7536
|
+
ctrl: key.ctrl,
|
|
7537
|
+
shift: key.shift,
|
|
7538
|
+
meta: key.meta,
|
|
7539
|
+
super: key.super,
|
|
7585
7540
|
action: "move-left"
|
|
7586
7541
|
});
|
|
7587
7542
|
const action = this._keyBindingsMap.get(bindingKey);
|
|
@@ -8209,10 +8164,20 @@ var defaultTextareaKeybindings = [
|
|
|
8209
8164
|
{ name: "end", shift: true, action: "select-buffer-end" },
|
|
8210
8165
|
{ name: "a", ctrl: true, action: "line-home" },
|
|
8211
8166
|
{ name: "e", ctrl: true, action: "line-end" },
|
|
8167
|
+
{ name: "a", ctrl: true, shift: true, action: "select-line-home" },
|
|
8168
|
+
{ name: "e", ctrl: true, shift: true, action: "select-line-end" },
|
|
8169
|
+
{ name: "a", meta: true, action: "visual-line-home" },
|
|
8170
|
+
{ name: "e", meta: true, action: "visual-line-end" },
|
|
8171
|
+
{ name: "a", meta: true, shift: true, action: "select-visual-line-home" },
|
|
8172
|
+
{ name: "e", meta: true, shift: true, action: "select-visual-line-end" },
|
|
8212
8173
|
{ name: "f", ctrl: true, action: "move-right" },
|
|
8213
8174
|
{ name: "b", ctrl: true, action: "move-left" },
|
|
8214
|
-
{ name: "w", ctrl: true, shift: true, action: "delete-word-forward" },
|
|
8215
8175
|
{ name: "w", ctrl: true, action: "delete-word-backward" },
|
|
8176
|
+
{ name: "backspace", ctrl: true, action: "delete-word-backward" },
|
|
8177
|
+
{ name: "d", meta: true, action: "delete-word-forward" },
|
|
8178
|
+
{ name: "delete", meta: true, action: "delete-word-forward" },
|
|
8179
|
+
{ name: "delete", ctrl: true, action: "delete-word-forward" },
|
|
8180
|
+
{ name: "d", ctrl: true, shift: true, action: "delete-line" },
|
|
8216
8181
|
{ name: "k", ctrl: true, action: "delete-to-line-end" },
|
|
8217
8182
|
{ name: "u", ctrl: true, action: "delete-to-line-start" },
|
|
8218
8183
|
{ name: "backspace", action: "backspace" },
|
|
@@ -8231,11 +8196,12 @@ var defaultTextareaKeybindings = [
|
|
|
8231
8196
|
{ name: "b", meta: true, action: "word-backward" },
|
|
8232
8197
|
{ name: "right", meta: true, action: "word-forward" },
|
|
8233
8198
|
{ name: "left", meta: true, action: "word-backward" },
|
|
8199
|
+
{ name: "right", ctrl: true, action: "word-forward" },
|
|
8200
|
+
{ name: "left", ctrl: true, action: "word-backward" },
|
|
8234
8201
|
{ name: "f", meta: true, shift: true, action: "select-word-forward" },
|
|
8235
8202
|
{ name: "b", meta: true, shift: true, action: "select-word-backward" },
|
|
8236
8203
|
{ name: "right", meta: true, shift: true, action: "select-word-forward" },
|
|
8237
8204
|
{ name: "left", meta: true, shift: true, action: "select-word-backward" },
|
|
8238
|
-
{ name: "d", meta: true, action: "delete-line" },
|
|
8239
8205
|
{ name: "backspace", meta: true, action: "delete-word-backward" }
|
|
8240
8206
|
];
|
|
8241
8207
|
|
|
@@ -8311,6 +8277,10 @@ class TextareaRenderable extends EditBufferRenderable {
|
|
|
8311
8277
|
["line-end", () => this.gotoLineEnd()],
|
|
8312
8278
|
["select-line-home", () => this.gotoLineHome({ select: true })],
|
|
8313
8279
|
["select-line-end", () => this.gotoLineEnd({ select: true })],
|
|
8280
|
+
["visual-line-home", () => this.gotoVisualLineHome()],
|
|
8281
|
+
["visual-line-end", () => this.gotoVisualLineEnd()],
|
|
8282
|
+
["select-visual-line-home", () => this.gotoVisualLineHome({ select: true })],
|
|
8283
|
+
["select-visual-line-end", () => this.gotoVisualLineEnd({ select: true })],
|
|
8314
8284
|
["select-buffer-home", () => this.gotoBufferHome({ select: true })],
|
|
8315
8285
|
["select-buffer-end", () => this.gotoBufferEnd({ select: true })],
|
|
8316
8286
|
["buffer-home", () => this.gotoBufferHome()],
|
|
@@ -8336,19 +8306,12 @@ class TextareaRenderable extends EditBufferRenderable {
|
|
|
8336
8306
|
this.insertText(event.text);
|
|
8337
8307
|
}
|
|
8338
8308
|
handleKeyPress(key) {
|
|
8339
|
-
const keyName = typeof key === "string" ? key : key.name;
|
|
8340
|
-
const keySequence = typeof key === "string" ? key : key.sequence;
|
|
8341
|
-
const keyCtrl = typeof key === "string" ? false : key.ctrl;
|
|
8342
|
-
const keyShift = typeof key === "string" ? false : key.shift;
|
|
8343
|
-
const keyMeta = typeof key === "string" ? false : key.meta;
|
|
8344
|
-
const keySuper = typeof key === "string" ? false : key.super;
|
|
8345
|
-
const keyHyper = typeof key === "string" ? false : key.hyper;
|
|
8346
8309
|
const bindingKey = getKeyBindingKey({
|
|
8347
|
-
name:
|
|
8348
|
-
ctrl:
|
|
8349
|
-
shift:
|
|
8350
|
-
meta:
|
|
8351
|
-
super:
|
|
8310
|
+
name: key.name,
|
|
8311
|
+
ctrl: key.ctrl,
|
|
8312
|
+
shift: key.shift,
|
|
8313
|
+
meta: key.meta,
|
|
8314
|
+
super: key.super,
|
|
8352
8315
|
action: "move-left"
|
|
8353
8316
|
});
|
|
8354
8317
|
const action = this._keyBindingsMap.get(bindingKey);
|
|
@@ -8358,20 +8321,20 @@ class TextareaRenderable extends EditBufferRenderable {
|
|
|
8358
8321
|
return handler();
|
|
8359
8322
|
}
|
|
8360
8323
|
}
|
|
8361
|
-
if (!
|
|
8362
|
-
if (
|
|
8324
|
+
if (!key.ctrl && !key.meta && !key.super && !key.hyper) {
|
|
8325
|
+
if (key.name === "space") {
|
|
8363
8326
|
this.insertText(" ");
|
|
8364
8327
|
return true;
|
|
8365
8328
|
}
|
|
8366
|
-
if (
|
|
8367
|
-
const firstCharCode =
|
|
8329
|
+
if (key.sequence) {
|
|
8330
|
+
const firstCharCode = key.sequence.charCodeAt(0);
|
|
8368
8331
|
if (firstCharCode < 32) {
|
|
8369
8332
|
return false;
|
|
8370
8333
|
}
|
|
8371
8334
|
if (firstCharCode === 127) {
|
|
8372
8335
|
return false;
|
|
8373
8336
|
}
|
|
8374
|
-
this.insertText(
|
|
8337
|
+
this.insertText(key.sequence);
|
|
8375
8338
|
return true;
|
|
8376
8339
|
}
|
|
8377
8340
|
}
|
|
@@ -8500,6 +8463,24 @@ class TextareaRenderable extends EditBufferRenderable {
|
|
|
8500
8463
|
this.requestRender();
|
|
8501
8464
|
return true;
|
|
8502
8465
|
}
|
|
8466
|
+
gotoVisualLineHome(options) {
|
|
8467
|
+
const select = options?.select ?? false;
|
|
8468
|
+
this.updateSelectionForMovement(select, true);
|
|
8469
|
+
const sol = this.editorView.getVisualSOL();
|
|
8470
|
+
this.editBuffer.setCursor(sol.logicalRow, sol.logicalCol);
|
|
8471
|
+
this.updateSelectionForMovement(select, false);
|
|
8472
|
+
this.requestRender();
|
|
8473
|
+
return true;
|
|
8474
|
+
}
|
|
8475
|
+
gotoVisualLineEnd(options) {
|
|
8476
|
+
const select = options?.select ?? false;
|
|
8477
|
+
this.updateSelectionForMovement(select, true);
|
|
8478
|
+
const eol = this.editorView.getVisualEOL();
|
|
8479
|
+
this.editBuffer.setCursor(eol.logicalRow, eol.logicalCol);
|
|
8480
|
+
this.updateSelectionForMovement(select, false);
|
|
8481
|
+
this.requestRender();
|
|
8482
|
+
return true;
|
|
8483
|
+
}
|
|
8503
8484
|
gotoBufferHome(options) {
|
|
8504
8485
|
const select = options?.select ?? false;
|
|
8505
8486
|
this.updateSelectionForMovement(select, true);
|
|
@@ -8865,5 +8846,5 @@ export {
|
|
|
8865
8846
|
ASCIIFont
|
|
8866
8847
|
};
|
|
8867
8848
|
|
|
8868
|
-
//# debugId=
|
|
8849
|
+
//# debugId=7F98B9DEC58574A464756E2164756E21
|
|
8869
8850
|
//# sourceMappingURL=index.js.map
|