@opentui/core 0.1.56 → 0.1.58
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/{index-rrt84m8j.js → index-crebvcxc.js} +42 -10
- package/{index-rrt84m8j.js.map → index-crebvcxc.js.map} +3 -3
- package/index.js +276 -92
- package/index.js.map +10 -10
- package/lib/keymapping.d.ts +4 -1
- package/package.json +7 -7
- package/renderables/Diff.d.ts +4 -0
- package/renderables/Input.d.ts +10 -0
- package/renderables/Select.d.ts +10 -0
- package/renderables/TabSelect.d.ts +10 -0
- package/renderables/Textarea.d.ts +5 -1
- package/renderer.d.ts +11 -0
- package/testing.js +1 -1
package/index.js
CHANGED
|
@@ -137,7 +137,7 @@ import {
|
|
|
137
137
|
white,
|
|
138
138
|
wrapWithDelegates,
|
|
139
139
|
yellow
|
|
140
|
-
} from "./index-
|
|
140
|
+
} from "./index-crebvcxc.js";
|
|
141
141
|
// src/text-buffer-view.ts
|
|
142
142
|
class TextBufferView {
|
|
143
143
|
lib;
|
|
@@ -4573,6 +4573,7 @@ class DiffRenderable extends Renderable {
|
|
|
4573
4573
|
_view;
|
|
4574
4574
|
_parsedDiff = null;
|
|
4575
4575
|
_parseError = null;
|
|
4576
|
+
_fg;
|
|
4576
4577
|
_filetype;
|
|
4577
4578
|
_syntaxStyle;
|
|
4578
4579
|
_wrapMode;
|
|
@@ -4610,6 +4611,7 @@ class DiffRenderable extends Renderable {
|
|
|
4610
4611
|
});
|
|
4611
4612
|
this._diff = options.diff ?? "";
|
|
4612
4613
|
this._view = options.view ?? "unified";
|
|
4614
|
+
this._fg = options.fg ? parseColor(options.fg) : undefined;
|
|
4613
4615
|
this._filetype = options.filetype;
|
|
4614
4616
|
this._syntaxStyle = options.syntaxStyle;
|
|
4615
4617
|
this._wrapMode = options.wrapMode;
|
|
@@ -4770,6 +4772,7 @@ class DiffRenderable extends Renderable {
|
|
|
4770
4772
|
syntaxStyle: this._syntaxStyle ?? SyntaxStyle.create(),
|
|
4771
4773
|
width: "100%",
|
|
4772
4774
|
height: "100%",
|
|
4775
|
+
...this._fg !== undefined && { fg: this._fg },
|
|
4773
4776
|
...drawUnstyledText !== undefined && { drawUnstyledText },
|
|
4774
4777
|
...this._selectionBg !== undefined && { selectionBg: this._selectionBg },
|
|
4775
4778
|
...this._selectionFg !== undefined && { selectionFg: this._selectionFg },
|
|
@@ -4801,6 +4804,9 @@ class DiffRenderable extends Renderable {
|
|
|
4801
4804
|
if (this._selectionFg !== undefined) {
|
|
4802
4805
|
existingRenderable.selectionFg = this._selectionFg;
|
|
4803
4806
|
}
|
|
4807
|
+
if (this._fg !== undefined) {
|
|
4808
|
+
existingRenderable.fg = this._fg;
|
|
4809
|
+
}
|
|
4804
4810
|
return existingRenderable;
|
|
4805
4811
|
}
|
|
4806
4812
|
}
|
|
@@ -5412,8 +5418,78 @@ class DiffRenderable extends Renderable {
|
|
|
5412
5418
|
this.rebuildView();
|
|
5413
5419
|
}
|
|
5414
5420
|
}
|
|
5421
|
+
get fg() {
|
|
5422
|
+
return this._fg;
|
|
5423
|
+
}
|
|
5424
|
+
set fg(value) {
|
|
5425
|
+
const parsed = value ? parseColor(value) : undefined;
|
|
5426
|
+
if (this._fg !== parsed) {
|
|
5427
|
+
this._fg = parsed;
|
|
5428
|
+
if (this.leftCodeRenderable) {
|
|
5429
|
+
this.leftCodeRenderable.fg = parsed;
|
|
5430
|
+
}
|
|
5431
|
+
if (this.rightCodeRenderable) {
|
|
5432
|
+
this.rightCodeRenderable.fg = parsed;
|
|
5433
|
+
}
|
|
5434
|
+
}
|
|
5435
|
+
}
|
|
5436
|
+
}
|
|
5437
|
+
// src/lib/keymapping.ts
|
|
5438
|
+
var defaultKeyAliases = {
|
|
5439
|
+
enter: "return",
|
|
5440
|
+
esc: "escape"
|
|
5441
|
+
};
|
|
5442
|
+
function mergeKeyAliases(defaults, custom) {
|
|
5443
|
+
return { ...defaults, ...custom };
|
|
5444
|
+
}
|
|
5445
|
+
function mergeKeyBindings(defaults, custom) {
|
|
5446
|
+
const map = new Map;
|
|
5447
|
+
for (const binding of defaults) {
|
|
5448
|
+
const key = getKeyBindingKey(binding);
|
|
5449
|
+
map.set(key, binding);
|
|
5450
|
+
}
|
|
5451
|
+
for (const binding of custom) {
|
|
5452
|
+
const key = getKeyBindingKey(binding);
|
|
5453
|
+
map.set(key, binding);
|
|
5454
|
+
}
|
|
5455
|
+
return Array.from(map.values());
|
|
5456
|
+
}
|
|
5457
|
+
function getKeyBindingKey(binding) {
|
|
5458
|
+
return `${binding.name}:${binding.ctrl ? 1 : 0}:${binding.shift ? 1 : 0}:${binding.meta ? 1 : 0}:${binding.super ? 1 : 0}`;
|
|
5459
|
+
}
|
|
5460
|
+
function buildKeyBindingsMap(bindings, aliasMap) {
|
|
5461
|
+
const map = new Map;
|
|
5462
|
+
const aliases = aliasMap || {};
|
|
5463
|
+
for (const binding of bindings) {
|
|
5464
|
+
const key = getKeyBindingKey(binding);
|
|
5465
|
+
map.set(key, binding.action);
|
|
5466
|
+
}
|
|
5467
|
+
for (const binding of bindings) {
|
|
5468
|
+
const normalizedName = aliases[binding.name] || binding.name;
|
|
5469
|
+
if (normalizedName !== binding.name) {
|
|
5470
|
+
const aliasedKey = getKeyBindingKey({ ...binding, name: normalizedName });
|
|
5471
|
+
map.set(aliasedKey, binding.action);
|
|
5472
|
+
}
|
|
5473
|
+
}
|
|
5474
|
+
return map;
|
|
5415
5475
|
}
|
|
5476
|
+
|
|
5416
5477
|
// src/renderables/Input.ts
|
|
5478
|
+
var defaultInputKeybindings = [
|
|
5479
|
+
{ name: "left", action: "move-left" },
|
|
5480
|
+
{ name: "right", action: "move-right" },
|
|
5481
|
+
{ name: "home", action: "move-home" },
|
|
5482
|
+
{ name: "end", action: "move-end" },
|
|
5483
|
+
{ name: "backspace", action: "delete-backward" },
|
|
5484
|
+
{ name: "delete", action: "delete-forward" },
|
|
5485
|
+
{ name: "return", action: "submit" },
|
|
5486
|
+
{ name: "linefeed", action: "submit" },
|
|
5487
|
+
{ name: "a", ctrl: true, action: "move-home" },
|
|
5488
|
+
{ name: "e", ctrl: true, action: "move-end" },
|
|
5489
|
+
{ name: "f", ctrl: true, action: "move-right" },
|
|
5490
|
+
{ name: "b", ctrl: true, action: "move-left" },
|
|
5491
|
+
{ name: "d", ctrl: true, action: "delete-forward" }
|
|
5492
|
+
];
|
|
5417
5493
|
var InputRenderableEvents;
|
|
5418
5494
|
((InputRenderableEvents2) => {
|
|
5419
5495
|
InputRenderableEvents2["INPUT"] = "input";
|
|
@@ -5435,6 +5511,9 @@ class InputRenderable extends Renderable {
|
|
|
5435
5511
|
_cursorStyle;
|
|
5436
5512
|
_maxLength;
|
|
5437
5513
|
_lastCommittedValue = "";
|
|
5514
|
+
_keyBindingsMap;
|
|
5515
|
+
_keyAliasMap;
|
|
5516
|
+
_keyBindings;
|
|
5438
5517
|
_defaultOptions = {
|
|
5439
5518
|
backgroundColor: "transparent",
|
|
5440
5519
|
textColor: "#FFFFFF",
|
|
@@ -5464,6 +5543,10 @@ class InputRenderable extends Renderable {
|
|
|
5464
5543
|
this._placeholderColor = parseColor(options.placeholderColor || this._defaultOptions.placeholderColor);
|
|
5465
5544
|
this._cursorColor = parseColor(options.cursorColor || this._defaultOptions.cursorColor);
|
|
5466
5545
|
this._cursorStyle = options.cursorStyle || this._defaultOptions.cursorStyle;
|
|
5546
|
+
this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, options.keyAliasMap || {});
|
|
5547
|
+
this._keyBindings = options.keyBindings || [];
|
|
5548
|
+
const mergedBindings = mergeKeyBindings(defaultInputKeybindings, this._keyBindings);
|
|
5549
|
+
this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
|
|
5467
5550
|
}
|
|
5468
5551
|
updateCursorPosition() {
|
|
5469
5552
|
if (!this._focused)
|
|
@@ -5594,39 +5677,52 @@ class InputRenderable extends Renderable {
|
|
|
5594
5677
|
handleKeyPress(key) {
|
|
5595
5678
|
const keyName = typeof key === "string" ? key : key.name;
|
|
5596
5679
|
const keySequence = typeof key === "string" ? key : key.sequence;
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
return true;
|
|
5616
|
-
case "return":
|
|
5617
|
-
case "linefeed":
|
|
5618
|
-
if (this._value !== this._lastCommittedValue) {
|
|
5619
|
-
this._lastCommittedValue = this._value;
|
|
5620
|
-
this.emit("change" /* CHANGE */, this._value);
|
|
5621
|
-
}
|
|
5622
|
-
this.emit("enter" /* ENTER */, this._value);
|
|
5623
|
-
return true;
|
|
5624
|
-
default:
|
|
5625
|
-
if (keySequence && keySequence.length === 1 && keySequence.charCodeAt(0) >= 32 && keySequence.charCodeAt(0) <= 126 && (typeof key === "string" || !key.ctrl && !key.meta && !key.super && !key.hyper)) {
|
|
5626
|
-
this.insertText(keySequence);
|
|
5680
|
+
const keyCtrl = typeof key === "string" ? false : key.ctrl;
|
|
5681
|
+
const keyShift = typeof key === "string" ? false : key.shift;
|
|
5682
|
+
const keyMeta = typeof key === "string" ? false : key.meta;
|
|
5683
|
+
const keySuper = typeof key === "string" ? false : key.super;
|
|
5684
|
+
const keyHyper = typeof key === "string" ? false : key.hyper;
|
|
5685
|
+
const bindingKey = getKeyBindingKey({
|
|
5686
|
+
name: keyName,
|
|
5687
|
+
ctrl: keyCtrl,
|
|
5688
|
+
shift: keyShift,
|
|
5689
|
+
meta: keyMeta,
|
|
5690
|
+
super: keySuper,
|
|
5691
|
+
action: "move-left"
|
|
5692
|
+
});
|
|
5693
|
+
const action = this._keyBindingsMap.get(bindingKey);
|
|
5694
|
+
if (action) {
|
|
5695
|
+
switch (action) {
|
|
5696
|
+
case "move-left":
|
|
5697
|
+
this.cursorPosition = this._cursorPosition - 1;
|
|
5627
5698
|
return true;
|
|
5628
|
-
|
|
5629
|
-
|
|
5699
|
+
case "move-right":
|
|
5700
|
+
this.cursorPosition = this._cursorPosition + 1;
|
|
5701
|
+
return true;
|
|
5702
|
+
case "move-home":
|
|
5703
|
+
this.cursorPosition = 0;
|
|
5704
|
+
return true;
|
|
5705
|
+
case "move-end":
|
|
5706
|
+
this.cursorPosition = this._value.length;
|
|
5707
|
+
return true;
|
|
5708
|
+
case "delete-backward":
|
|
5709
|
+
this.deleteCharacter("backward");
|
|
5710
|
+
return true;
|
|
5711
|
+
case "delete-forward":
|
|
5712
|
+
this.deleteCharacter("forward");
|
|
5713
|
+
return true;
|
|
5714
|
+
case "submit":
|
|
5715
|
+
if (this._value !== this._lastCommittedValue) {
|
|
5716
|
+
this._lastCommittedValue = this._value;
|
|
5717
|
+
this.emit("change" /* CHANGE */, this._value);
|
|
5718
|
+
}
|
|
5719
|
+
this.emit("enter" /* ENTER */, this._value);
|
|
5720
|
+
return true;
|
|
5721
|
+
}
|
|
5722
|
+
}
|
|
5723
|
+
if (keySequence && keySequence.length === 1 && keySequence.charCodeAt(0) >= 32 && keySequence.charCodeAt(0) <= 126 && !keyCtrl && !keyMeta && !keySuper && !keyHyper) {
|
|
5724
|
+
this.insertText(keySequence);
|
|
5725
|
+
return true;
|
|
5630
5726
|
}
|
|
5631
5727
|
return false;
|
|
5632
5728
|
}
|
|
@@ -5706,6 +5802,16 @@ class InputRenderable extends Renderable {
|
|
|
5706
5802
|
this._ctx.setCursorPosition(0, 0, false);
|
|
5707
5803
|
}
|
|
5708
5804
|
}
|
|
5805
|
+
set keyBindings(bindings) {
|
|
5806
|
+
this._keyBindings = bindings;
|
|
5807
|
+
const mergedBindings = mergeKeyBindings(defaultInputKeybindings, bindings);
|
|
5808
|
+
this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
|
|
5809
|
+
}
|
|
5810
|
+
set keyAliasMap(aliases) {
|
|
5811
|
+
this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, aliases);
|
|
5812
|
+
const mergedBindings = mergeKeyBindings(defaultInputKeybindings, this._keyBindings);
|
|
5813
|
+
this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
|
|
5814
|
+
}
|
|
5709
5815
|
}
|
|
5710
5816
|
// src/renderables/Slider.ts
|
|
5711
5817
|
var defaultThumbBackgroundColor = RGBA.fromHex("#9a9ea3");
|
|
@@ -6306,7 +6412,7 @@ class ContentRenderable extends BoxRenderable {
|
|
|
6306
6412
|
}
|
|
6307
6413
|
_getVisibleChildren() {
|
|
6308
6414
|
if (this._viewportCulling) {
|
|
6309
|
-
return getObjectsInViewport(this.viewport, this.getChildrenSortedByPrimaryAxis(), this.primaryAxis).map((child) => child.num);
|
|
6415
|
+
return getObjectsInViewport(this.viewport, this.getChildrenSortedByPrimaryAxis(), this.primaryAxis, 0).map((child) => child.num);
|
|
6310
6416
|
}
|
|
6311
6417
|
return this.getChildrenSortedByPrimaryAxis().map((child) => child.num);
|
|
6312
6418
|
}
|
|
@@ -6858,6 +6964,16 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
6858
6964
|
}
|
|
6859
6965
|
}
|
|
6860
6966
|
// src/renderables/Select.ts
|
|
6967
|
+
var defaultSelectKeybindings = [
|
|
6968
|
+
{ name: "up", action: "move-up" },
|
|
6969
|
+
{ name: "k", action: "move-up" },
|
|
6970
|
+
{ name: "down", action: "move-down" },
|
|
6971
|
+
{ name: "j", action: "move-down" },
|
|
6972
|
+
{ name: "up", shift: true, action: "move-up-fast" },
|
|
6973
|
+
{ name: "down", shift: true, action: "move-down-fast" },
|
|
6974
|
+
{ name: "return", action: "select-current" },
|
|
6975
|
+
{ name: "linefeed", action: "select-current" }
|
|
6976
|
+
];
|
|
6861
6977
|
var SelectRenderableEvents;
|
|
6862
6978
|
((SelectRenderableEvents2) => {
|
|
6863
6979
|
SelectRenderableEvents2["SELECTION_CHANGED"] = "selectionChanged";
|
|
@@ -6886,6 +7002,9 @@ class SelectRenderable extends Renderable {
|
|
|
6886
7002
|
linesPerItem;
|
|
6887
7003
|
fontHeight;
|
|
6888
7004
|
_fastScrollStep;
|
|
7005
|
+
_keyBindingsMap;
|
|
7006
|
+
_keyAliasMap;
|
|
7007
|
+
_keyBindings;
|
|
6889
7008
|
_defaultOptions = {
|
|
6890
7009
|
backgroundColor: "transparent",
|
|
6891
7010
|
textColor: "#FFFFFF",
|
|
@@ -6925,6 +7044,10 @@ class SelectRenderable extends Renderable {
|
|
|
6925
7044
|
this._descriptionColor = parseColor(options.descriptionColor || this._defaultOptions.descriptionColor);
|
|
6926
7045
|
this._selectedDescriptionColor = parseColor(options.selectedDescriptionColor || this._defaultOptions.selectedDescriptionColor);
|
|
6927
7046
|
this._fastScrollStep = options.fastScrollStep || this._defaultOptions.fastScrollStep;
|
|
7047
|
+
this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, options.keyAliasMap || {});
|
|
7048
|
+
this._keyBindings = options.keyBindings || [];
|
|
7049
|
+
const mergedBindings = mergeKeyBindings(defaultSelectKeybindings, this._keyBindings);
|
|
7050
|
+
this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
|
|
6928
7051
|
this.requestRender();
|
|
6929
7052
|
}
|
|
6930
7053
|
renderSelf(buffer, deltaTime) {
|
|
@@ -7065,20 +7188,37 @@ class SelectRenderable extends Renderable {
|
|
|
7065
7188
|
}
|
|
7066
7189
|
handleKeyPress(key) {
|
|
7067
7190
|
const keyName = typeof key === "string" ? key : key.name;
|
|
7068
|
-
const
|
|
7069
|
-
|
|
7070
|
-
|
|
7071
|
-
|
|
7072
|
-
|
|
7073
|
-
|
|
7074
|
-
|
|
7075
|
-
|
|
7076
|
-
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
|
|
7191
|
+
const keyCtrl = typeof key === "string" ? false : key.ctrl;
|
|
7192
|
+
const keyShift = typeof key === "string" ? false : key.shift;
|
|
7193
|
+
const keyMeta = typeof key === "string" ? false : key.meta;
|
|
7194
|
+
const keySuper = typeof key === "string" ? false : key.super;
|
|
7195
|
+
const bindingKey = getKeyBindingKey({
|
|
7196
|
+
name: keyName,
|
|
7197
|
+
ctrl: keyCtrl,
|
|
7198
|
+
shift: keyShift,
|
|
7199
|
+
meta: keyMeta,
|
|
7200
|
+
super: keySuper,
|
|
7201
|
+
action: "move-up"
|
|
7202
|
+
});
|
|
7203
|
+
const action = this._keyBindingsMap.get(bindingKey);
|
|
7204
|
+
if (action) {
|
|
7205
|
+
switch (action) {
|
|
7206
|
+
case "move-up":
|
|
7207
|
+
this.moveUp(1);
|
|
7208
|
+
return true;
|
|
7209
|
+
case "move-down":
|
|
7210
|
+
this.moveDown(1);
|
|
7211
|
+
return true;
|
|
7212
|
+
case "move-up-fast":
|
|
7213
|
+
this.moveUp(this._fastScrollStep);
|
|
7214
|
+
return true;
|
|
7215
|
+
case "move-down-fast":
|
|
7216
|
+
this.moveDown(this._fastScrollStep);
|
|
7217
|
+
return true;
|
|
7218
|
+
case "select-current":
|
|
7219
|
+
this.selectCurrent();
|
|
7220
|
+
return true;
|
|
7221
|
+
}
|
|
7082
7222
|
}
|
|
7083
7223
|
return false;
|
|
7084
7224
|
}
|
|
@@ -7184,6 +7324,16 @@ class SelectRenderable extends Renderable {
|
|
|
7184
7324
|
set fastScrollStep(step) {
|
|
7185
7325
|
this._fastScrollStep = step;
|
|
7186
7326
|
}
|
|
7327
|
+
set keyBindings(bindings) {
|
|
7328
|
+
this._keyBindings = bindings;
|
|
7329
|
+
const mergedBindings = mergeKeyBindings(defaultSelectKeybindings, bindings);
|
|
7330
|
+
this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
|
|
7331
|
+
}
|
|
7332
|
+
set keyAliasMap(aliases) {
|
|
7333
|
+
this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, aliases);
|
|
7334
|
+
const mergedBindings = mergeKeyBindings(defaultSelectKeybindings, this._keyBindings);
|
|
7335
|
+
this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
|
|
7336
|
+
}
|
|
7187
7337
|
set selectedIndex(value) {
|
|
7188
7338
|
const newIndex = value ?? this._defaultOptions.selectedIndex;
|
|
7189
7339
|
const clampedIndex = this._options.length > 0 ? Math.min(Math.max(0, newIndex), this._options.length - 1) : 0;
|
|
@@ -7195,6 +7345,14 @@ class SelectRenderable extends Renderable {
|
|
|
7195
7345
|
}
|
|
7196
7346
|
}
|
|
7197
7347
|
// src/renderables/TabSelect.ts
|
|
7348
|
+
var defaultTabSelectKeybindings = [
|
|
7349
|
+
{ name: "left", action: "move-left" },
|
|
7350
|
+
{ name: "[", action: "move-left" },
|
|
7351
|
+
{ name: "right", action: "move-right" },
|
|
7352
|
+
{ name: "]", action: "move-right" },
|
|
7353
|
+
{ name: "return", action: "select-current" },
|
|
7354
|
+
{ name: "linefeed", action: "select-current" }
|
|
7355
|
+
];
|
|
7198
7356
|
var TabSelectRenderableEvents;
|
|
7199
7357
|
((TabSelectRenderableEvents2) => {
|
|
7200
7358
|
TabSelectRenderableEvents2["SELECTION_CHANGED"] = "selectionChanged";
|
|
@@ -7229,6 +7387,9 @@ class TabSelectRenderable extends Renderable {
|
|
|
7229
7387
|
_showDescription;
|
|
7230
7388
|
_showUnderline;
|
|
7231
7389
|
_wrapSelection;
|
|
7390
|
+
_keyBindingsMap;
|
|
7391
|
+
_keyAliasMap;
|
|
7392
|
+
_keyBindings;
|
|
7232
7393
|
constructor(ctx, options) {
|
|
7233
7394
|
const calculatedHeight = calculateDynamicHeight(options.showUnderline ?? true, options.showDescription ?? true);
|
|
7234
7395
|
super(ctx, { ...options, height: calculatedHeight, buffered: true });
|
|
@@ -7246,6 +7407,10 @@ class TabSelectRenderable extends Renderable {
|
|
|
7246
7407
|
this._selectedBackgroundColor = parseColor(options.selectedBackgroundColor || "#334455");
|
|
7247
7408
|
this._selectedTextColor = parseColor(options.selectedTextColor || "#FFFF00");
|
|
7248
7409
|
this._selectedDescriptionColor = parseColor(options.selectedDescriptionColor || "#CCCCCC");
|
|
7410
|
+
this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, options.keyAliasMap || {});
|
|
7411
|
+
this._keyBindings = options.keyBindings || [];
|
|
7412
|
+
const mergedBindings = mergeKeyBindings(defaultTabSelectKeybindings, this._keyBindings);
|
|
7413
|
+
this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
|
|
7249
7414
|
}
|
|
7250
7415
|
calculateDynamicHeight() {
|
|
7251
7416
|
return calculateDynamicHeight(this._showUnderline, this._showDescription);
|
|
@@ -7396,19 +7561,31 @@ class TabSelectRenderable extends Renderable {
|
|
|
7396
7561
|
}
|
|
7397
7562
|
handleKeyPress(key) {
|
|
7398
7563
|
const keyName = typeof key === "string" ? key : key.name;
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
|
|
7411
|
-
|
|
7564
|
+
const keyCtrl = typeof key === "string" ? false : key.ctrl;
|
|
7565
|
+
const keyShift = typeof key === "string" ? false : key.shift;
|
|
7566
|
+
const keyMeta = typeof key === "string" ? false : key.meta;
|
|
7567
|
+
const keySuper = typeof key === "string" ? false : key.super;
|
|
7568
|
+
const bindingKey = getKeyBindingKey({
|
|
7569
|
+
name: keyName,
|
|
7570
|
+
ctrl: keyCtrl,
|
|
7571
|
+
shift: keyShift,
|
|
7572
|
+
meta: keyMeta,
|
|
7573
|
+
super: keySuper,
|
|
7574
|
+
action: "move-left"
|
|
7575
|
+
});
|
|
7576
|
+
const action = this._keyBindingsMap.get(bindingKey);
|
|
7577
|
+
if (action) {
|
|
7578
|
+
switch (action) {
|
|
7579
|
+
case "move-left":
|
|
7580
|
+
this.moveLeft();
|
|
7581
|
+
return true;
|
|
7582
|
+
case "move-right":
|
|
7583
|
+
this.moveRight();
|
|
7584
|
+
return true;
|
|
7585
|
+
case "select-current":
|
|
7586
|
+
this.selectCurrent();
|
|
7587
|
+
return true;
|
|
7588
|
+
}
|
|
7412
7589
|
}
|
|
7413
7590
|
return false;
|
|
7414
7591
|
}
|
|
@@ -7497,6 +7674,16 @@ class TabSelectRenderable extends Renderable {
|
|
|
7497
7674
|
this.updateScrollOffset();
|
|
7498
7675
|
this.requestRender();
|
|
7499
7676
|
}
|
|
7677
|
+
set keyBindings(bindings) {
|
|
7678
|
+
this._keyBindings = bindings;
|
|
7679
|
+
const mergedBindings = mergeKeyBindings(defaultTabSelectKeybindings, bindings);
|
|
7680
|
+
this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
|
|
7681
|
+
}
|
|
7682
|
+
set keyAliasMap(aliases) {
|
|
7683
|
+
this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, aliases);
|
|
7684
|
+
const mergedBindings = mergeKeyBindings(defaultTabSelectKeybindings, this._keyBindings);
|
|
7685
|
+
this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
|
|
7686
|
+
}
|
|
7500
7687
|
}
|
|
7501
7688
|
// src/renderables/EditBufferRenderable.ts
|
|
7502
7689
|
class EditBufferRenderable extends Renderable {
|
|
@@ -7990,31 +8177,6 @@ class EditBufferRenderable extends Renderable {
|
|
|
7990
8177
|
}
|
|
7991
8178
|
}
|
|
7992
8179
|
|
|
7993
|
-
// src/lib/keymapping.ts
|
|
7994
|
-
function mergeKeyBindings(defaults, custom) {
|
|
7995
|
-
const map = new Map;
|
|
7996
|
-
for (const binding of defaults) {
|
|
7997
|
-
const key = getKeyBindingKey(binding);
|
|
7998
|
-
map.set(key, binding);
|
|
7999
|
-
}
|
|
8000
|
-
for (const binding of custom) {
|
|
8001
|
-
const key = getKeyBindingKey(binding);
|
|
8002
|
-
map.set(key, binding);
|
|
8003
|
-
}
|
|
8004
|
-
return Array.from(map.values());
|
|
8005
|
-
}
|
|
8006
|
-
function getKeyBindingKey(binding) {
|
|
8007
|
-
return `${binding.name}:${binding.ctrl ? 1 : 0}:${binding.shift ? 1 : 0}:${binding.meta ? 1 : 0}:${binding.super ? 1 : 0}`;
|
|
8008
|
-
}
|
|
8009
|
-
function buildKeyBindingsMap(bindings) {
|
|
8010
|
-
const map = new Map;
|
|
8011
|
-
for (const binding of bindings) {
|
|
8012
|
-
const key = getKeyBindingKey(binding);
|
|
8013
|
-
map.set(key, binding.action);
|
|
8014
|
-
}
|
|
8015
|
-
return map;
|
|
8016
|
-
}
|
|
8017
|
-
|
|
8018
8180
|
// src/renderables/Textarea.ts
|
|
8019
8181
|
var defaultTextareaKeybindings = [
|
|
8020
8182
|
{ name: "left", action: "move-left" },
|
|
@@ -8067,6 +8229,8 @@ class TextareaRenderable extends EditBufferRenderable {
|
|
|
8067
8229
|
_focusedBackgroundColor;
|
|
8068
8230
|
_focusedTextColor;
|
|
8069
8231
|
_keyBindingsMap;
|
|
8232
|
+
_keyAliasMap;
|
|
8233
|
+
_keyBindings;
|
|
8070
8234
|
_actionHandlers;
|
|
8071
8235
|
_initialValueSet = false;
|
|
8072
8236
|
_submitListener = undefined;
|
|
@@ -8090,8 +8254,10 @@ class TextareaRenderable extends EditBufferRenderable {
|
|
|
8090
8254
|
this._focusedBackgroundColor = parseColor(options.focusedBackgroundColor || options.backgroundColor || defaults.focusedBackgroundColor);
|
|
8091
8255
|
this._focusedTextColor = parseColor(options.focusedTextColor || options.textColor || defaults.focusedTextColor);
|
|
8092
8256
|
this._placeholder = options.placeholder ?? defaults.placeholder;
|
|
8093
|
-
|
|
8094
|
-
this.
|
|
8257
|
+
this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, options.keyAliasMap || {});
|
|
8258
|
+
this._keyBindings = options.keyBindings || [];
|
|
8259
|
+
const mergedBindings = mergeKeyBindings(defaultTextareaKeybindings, this._keyBindings);
|
|
8260
|
+
this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
|
|
8095
8261
|
this._actionHandlers = this.buildActionHandlers();
|
|
8096
8262
|
this._submitListener = options.onSubmit;
|
|
8097
8263
|
if (options.initialValue) {
|
|
@@ -8285,7 +8451,13 @@ class TextareaRenderable extends EditBufferRenderable {
|
|
|
8285
8451
|
const select = options?.select ?? false;
|
|
8286
8452
|
this.updateSelectionForMovement(select, true);
|
|
8287
8453
|
const cursor = this.editorView.getCursor();
|
|
8288
|
-
|
|
8454
|
+
if (cursor.col === 0 && cursor.row > 0) {
|
|
8455
|
+
this.editBuffer.setCursor(cursor.row - 1, 0);
|
|
8456
|
+
const prevLineEol = this.editBuffer.getEOL();
|
|
8457
|
+
this.editBuffer.setCursor(prevLineEol.row, prevLineEol.col);
|
|
8458
|
+
} else {
|
|
8459
|
+
this.editBuffer.setCursor(cursor.row, 0);
|
|
8460
|
+
}
|
|
8289
8461
|
this.updateSelectionForMovement(select, false);
|
|
8290
8462
|
this.requestRender();
|
|
8291
8463
|
return true;
|
|
@@ -8293,8 +8465,14 @@ class TextareaRenderable extends EditBufferRenderable {
|
|
|
8293
8465
|
gotoLineEnd(options) {
|
|
8294
8466
|
const select = options?.select ?? false;
|
|
8295
8467
|
this.updateSelectionForMovement(select, true);
|
|
8468
|
+
const cursor = this.editorView.getCursor();
|
|
8296
8469
|
const eol = this.editBuffer.getEOL();
|
|
8297
|
-
this.editBuffer.
|
|
8470
|
+
const lineCount = this.editBuffer.getLineCount();
|
|
8471
|
+
if (cursor.col === eol.col && cursor.row < lineCount - 1) {
|
|
8472
|
+
this.editBuffer.setCursor(cursor.row + 1, 0);
|
|
8473
|
+
} else {
|
|
8474
|
+
this.editBuffer.setCursor(eol.row, eol.col);
|
|
8475
|
+
}
|
|
8298
8476
|
this.updateSelectionForMovement(select, false);
|
|
8299
8477
|
this.requestRender();
|
|
8300
8478
|
return true;
|
|
@@ -8463,8 +8641,14 @@ class TextareaRenderable extends EditBufferRenderable {
|
|
|
8463
8641
|
return this._submitListener;
|
|
8464
8642
|
}
|
|
8465
8643
|
set keyBindings(bindings) {
|
|
8644
|
+
this._keyBindings = bindings;
|
|
8466
8645
|
const mergedBindings = mergeKeyBindings(defaultTextareaKeybindings, bindings);
|
|
8467
|
-
this._keyBindingsMap = buildKeyBindingsMap(mergedBindings);
|
|
8646
|
+
this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
|
|
8647
|
+
}
|
|
8648
|
+
set keyAliasMap(aliases) {
|
|
8649
|
+
this._keyAliasMap = mergeKeyAliases(defaultKeyAliases, aliases);
|
|
8650
|
+
const mergedBindings = mergeKeyBindings(defaultTextareaKeybindings, this._keyBindings);
|
|
8651
|
+
this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
|
|
8468
8652
|
}
|
|
8469
8653
|
get extmarks() {
|
|
8470
8654
|
return this.editorView.extmarks;
|
|
@@ -8657,5 +8841,5 @@ export {
|
|
|
8657
8841
|
ASCIIFont
|
|
8658
8842
|
};
|
|
8659
8843
|
|
|
8660
|
-
//# debugId=
|
|
8844
|
+
//# debugId=AA9B550CE879718B64756E2164756E21
|
|
8661
8845
|
//# sourceMappingURL=index.js.map
|