@opentui/core 0.1.60 → 0.1.62

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/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-916mvx7m.js";
146
+ } from "./index-mrwvcpzb.js";
142
147
  // src/text-buffer-view.ts
143
148
  class TextBufferView {
144
149
  lib;
@@ -167,6 +172,10 @@ class TextBufferView {
167
172
  this.guard();
168
173
  this.lib.textBufferViewSetSelection(this.viewPtr, start, end, bgColor || null, fgColor || null);
169
174
  }
175
+ updateSelection(end, bgColor, fgColor) {
176
+ this.guard();
177
+ this.lib.textBufferViewUpdateSelection(this.viewPtr, end, bgColor || null, fgColor || null);
178
+ }
170
179
  resetSelection() {
171
180
  this.guard();
172
181
  this.lib.textBufferViewResetSelection(this.viewPtr);
@@ -183,6 +192,10 @@ class TextBufferView {
183
192
  this.guard();
184
193
  return this.lib.textBufferViewSetLocalSelection(this.viewPtr, anchorX, anchorY, focusX, focusY, bgColor || null, fgColor || null);
185
194
  }
195
+ updateLocalSelection(anchorX, anchorY, focusX, focusY, bgColor, fgColor) {
196
+ this.guard();
197
+ return this.lib.textBufferViewUpdateLocalSelection(this.viewPtr, anchorX, anchorY, focusX, focusY, bgColor || null, fgColor || null);
198
+ }
186
199
  resetLocalSelection() {
187
200
  this.guard();
188
201
  this.lib.textBufferViewResetLocalSelection(this.viewPtr);
@@ -596,6 +609,10 @@ class EditorView {
596
609
  this.guard();
597
610
  this.lib.editorViewSetViewportSize(this.viewPtr, width, height);
598
611
  }
612
+ setViewport(x, y, width, height, moveCursor = true) {
613
+ this.guard();
614
+ this.lib.editorViewSetViewport(this.viewPtr, x, y, width, height, moveCursor);
615
+ }
599
616
  getViewport() {
600
617
  this.guard();
601
618
  return this.lib.editorViewGetViewport(this.viewPtr);
@@ -620,6 +637,10 @@ class EditorView {
620
637
  this.guard();
621
638
  this.lib.editorViewSetSelection(this.viewPtr, start, end, bgColor || null, fgColor || null);
622
639
  }
640
+ updateSelection(end, bgColor, fgColor) {
641
+ this.guard();
642
+ this.lib.editorViewUpdateSelection(this.viewPtr, end, bgColor || null, fgColor || null);
643
+ }
623
644
  resetSelection() {
624
645
  this.guard();
625
646
  this.lib.editorViewResetSelection(this.viewPtr);
@@ -632,9 +653,13 @@ class EditorView {
632
653
  this.guard();
633
654
  return this.getSelection() !== null;
634
655
  }
635
- setLocalSelection(anchorX, anchorY, focusX, focusY, bgColor, fgColor) {
656
+ setLocalSelection(anchorX, anchorY, focusX, focusY, bgColor, fgColor, updateCursor) {
657
+ this.guard();
658
+ return this.lib.editorViewSetLocalSelection(this.viewPtr, anchorX, anchorY, focusX, focusY, bgColor || null, fgColor || null, updateCursor ?? false);
659
+ }
660
+ updateLocalSelection(anchorX, anchorY, focusX, focusY, bgColor, fgColor, updateCursor) {
636
661
  this.guard();
637
- return this.lib.editorViewSetLocalSelection(this.viewPtr, anchorX, anchorY, focusX, focusY, bgColor || null, fgColor || null);
662
+ return this.lib.editorViewUpdateLocalSelection(this.viewPtr, anchorX, anchorY, focusX, focusY, bgColor || null, fgColor || null, updateCursor ?? false);
638
663
  }
639
664
  resetLocalSelection() {
640
665
  this.guard();
@@ -692,6 +717,14 @@ class EditorView {
692
717
  this.guard();
693
718
  return this.lib.editorViewGetEOL(this.viewPtr);
694
719
  }
720
+ getVisualSOL() {
721
+ this.guard();
722
+ return this.lib.editorViewGetVisualSOL(this.viewPtr);
723
+ }
724
+ getVisualEOL() {
725
+ this.guard();
726
+ return this.lib.editorViewGetVisualEOL(this.viewPtr);
727
+ }
695
728
  getLineInfo() {
696
729
  this.guard();
697
730
  return this.lib.editorViewGetLineInfo(this.viewPtr);
@@ -2662,13 +2695,9 @@ class TextBufferRenderable extends Renderable {
2662
2695
  }
2663
2696
  onResize(width, height) {
2664
2697
  this.textBufferView.setViewport(this._scrollX, this._scrollY, width, height);
2665
- this.updateTextInfo();
2666
- if (this.lastLocalSelection) {
2667
- const changed = this.updateLocalSelection(this.lastLocalSelection);
2668
- if (changed) {
2669
- this.requestRender();
2670
- }
2671
- }
2698
+ this.yogaNode.markDirty();
2699
+ this.requestRender();
2700
+ this.emit("line-info-change");
2672
2701
  }
2673
2702
  refreshLocalSelection() {
2674
2703
  if (this.lastLocalSelection) {
@@ -2726,7 +2755,15 @@ class TextBufferRenderable extends Renderable {
2726
2755
  onSelectionChanged(selection) {
2727
2756
  const localSelection = convertGlobalToLocalSelection(selection, this.x, this.y);
2728
2757
  this.lastLocalSelection = localSelection;
2729
- const changed = this.updateLocalSelection(localSelection);
2758
+ let changed;
2759
+ if (!localSelection?.isActive) {
2760
+ this.textBufferView.resetLocalSelection();
2761
+ changed = true;
2762
+ } else if (selection?.isStart) {
2763
+ changed = this.textBufferView.setLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg);
2764
+ } else {
2765
+ changed = this.textBufferView.updateLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg);
2766
+ }
2730
2767
  if (changed) {
2731
2768
  this.requestRender();
2732
2769
  }
@@ -5439,46 +5476,6 @@ class DiffRenderable extends Renderable {
5439
5476
  }
5440
5477
  }
5441
5478
  }
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
5479
  // src/renderables/Input.ts
5483
5480
  var defaultInputKeybindings = [
5484
5481
  { name: "left", action: "move-left" },
@@ -5680,19 +5677,12 @@ class InputRenderable extends Renderable {
5680
5677
  }
5681
5678
  }
5682
5679
  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
5680
  const bindingKey = getKeyBindingKey({
5691
- name: keyName,
5692
- ctrl: keyCtrl,
5693
- shift: keyShift,
5694
- meta: keyMeta,
5695
- super: keySuper,
5681
+ name: key.name,
5682
+ ctrl: key.ctrl,
5683
+ shift: key.shift,
5684
+ meta: key.meta,
5685
+ super: key.super,
5696
5686
  action: "move-left"
5697
5687
  });
5698
5688
  const action = this._keyBindingsMap.get(bindingKey);
@@ -5725,13 +5715,13 @@ class InputRenderable extends Renderable {
5725
5715
  return true;
5726
5716
  }
5727
5717
  }
5728
- if (!keyCtrl && !keyMeta && !keySuper && !keyHyper) {
5729
- if (keyName === "space") {
5718
+ if (!key.ctrl && !key.meta && !key.super && !key.hyper) {
5719
+ if (key.name === "space") {
5730
5720
  this.insertText(" ");
5731
5721
  return true;
5732
5722
  }
5733
- if (keySequence && keySequence.length === 1 && keySequence.charCodeAt(0) >= 32 && keySequence.charCodeAt(0) <= 126) {
5734
- this.insertText(keySequence);
5723
+ if (key.sequence && key.sequence.length === 1 && key.sequence.charCodeAt(0) >= 32 && key.sequence.charCodeAt(0) <= 126) {
5724
+ this.insertText(key.sequence);
5735
5725
  return true;
5736
5726
  }
5737
5727
  }
@@ -6278,8 +6268,7 @@ class ScrollBarRenderable extends Renderable {
6278
6268
  }
6279
6269
  }
6280
6270
  handleKeyPress(key) {
6281
- const keyName = typeof key === "string" ? key : key.name;
6282
- switch (keyName) {
6271
+ switch (key.name) {
6283
6272
  case "left":
6284
6273
  case "h":
6285
6274
  if (this.orientation !== "horizontal")
@@ -7198,17 +7187,12 @@ class SelectRenderable extends Renderable {
7198
7187
  this.requestRender();
7199
7188
  }
7200
7189
  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
7190
  const bindingKey = getKeyBindingKey({
7207
- name: keyName,
7208
- ctrl: keyCtrl,
7209
- shift: keyShift,
7210
- meta: keyMeta,
7211
- super: keySuper,
7191
+ name: key.name,
7192
+ ctrl: key.ctrl,
7193
+ shift: key.shift,
7194
+ meta: key.meta,
7195
+ super: key.super,
7212
7196
  action: "move-up"
7213
7197
  });
7214
7198
  const action = this._keyBindingsMap.get(bindingKey);
@@ -7571,17 +7555,12 @@ class TabSelectRenderable extends Renderable {
7571
7555
  return this._tabWidth;
7572
7556
  }
7573
7557
  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
7558
  const bindingKey = getKeyBindingKey({
7580
- name: keyName,
7581
- ctrl: keyCtrl,
7582
- shift: keyShift,
7583
- meta: keyMeta,
7584
- super: keySuper,
7559
+ name: key.name,
7560
+ ctrl: key.ctrl,
7561
+ shift: key.shift,
7562
+ meta: key.meta,
7563
+ super: key.super,
7585
7564
  action: "move-left"
7586
7565
  });
7587
7566
  const action = this._keyBindingsMap.get(bindingKey);
@@ -7713,9 +7692,11 @@ class EditBufferRenderable extends Renderable {
7713
7692
  lastLocalSelection = null;
7714
7693
  _tabIndicator;
7715
7694
  _tabIndicatorColor;
7716
- _selectionAnchorState = null;
7717
7695
  _cursorChangeListener = undefined;
7718
7696
  _contentChangeListener = undefined;
7697
+ _autoScrollVelocity = 0;
7698
+ _autoScrollAccumulator = 0;
7699
+ _scrollSpeed = 16;
7719
7700
  editBuffer;
7720
7701
  editorView;
7721
7702
  _defaultOptions = {
@@ -7727,6 +7708,7 @@ class EditBufferRenderable extends Renderable {
7727
7708
  attributes: 0,
7728
7709
  wrapMode: "word",
7729
7710
  scrollMargin: 0.2,
7711
+ scrollSpeed: 16,
7730
7712
  showCursor: true,
7731
7713
  cursorColor: RGBA.fromValues(1, 1, 1, 1),
7732
7714
  cursorStyle: {
@@ -7746,6 +7728,7 @@ class EditBufferRenderable extends Renderable {
7746
7728
  this.selectable = options.selectable ?? this._defaultOptions.selectable;
7747
7729
  this._wrapMode = options.wrapMode ?? this._defaultOptions.wrapMode;
7748
7730
  this._scrollMargin = options.scrollMargin ?? this._defaultOptions.scrollMargin;
7731
+ this._scrollSpeed = options.scrollSpeed ?? this._defaultOptions.scrollSpeed;
7749
7732
  this._showCursor = options.showCursor ?? this._defaultOptions.showCursor;
7750
7733
  this._cursorColor = parseColor(options.cursorColor ?? this._defaultOptions.cursorColor);
7751
7734
  this._cursorStyle = options.cursorStyle ?? this._defaultOptions.cursorStyle;
@@ -7946,15 +7929,48 @@ class EditBufferRenderable extends Renderable {
7946
7929
  this.requestRender();
7947
7930
  }
7948
7931
  }
7949
- onResize(width, height) {
7950
- this.editorView.setViewportSize(width, height);
7951
- if (this.lastLocalSelection) {
7952
- const changed = this.updateLocalSelection(this.lastLocalSelection);
7953
- if (changed) {
7932
+ get scrollSpeed() {
7933
+ return this._scrollSpeed;
7934
+ }
7935
+ set scrollSpeed(value) {
7936
+ this._scrollSpeed = Math.max(0, value);
7937
+ }
7938
+ onMouseEvent(event) {
7939
+ if (event.type === "scroll") {
7940
+ this.handleScroll(event);
7941
+ }
7942
+ }
7943
+ handleScroll(event) {
7944
+ if (!event.scroll)
7945
+ return;
7946
+ const { direction, delta } = event.scroll;
7947
+ const viewport = this.editorView.getViewport();
7948
+ if (direction === "up") {
7949
+ const newOffsetY = Math.max(0, viewport.offsetY - delta);
7950
+ this.editorView.setViewport(viewport.offsetX, newOffsetY, viewport.width, viewport.height, true);
7951
+ this.requestRender();
7952
+ } else if (direction === "down") {
7953
+ const totalVirtualLines = this.editorView.getTotalVirtualLineCount();
7954
+ const maxOffsetY = Math.max(0, totalVirtualLines - viewport.height);
7955
+ const newOffsetY = Math.min(viewport.offsetY + delta, maxOffsetY);
7956
+ this.editorView.setViewport(viewport.offsetX, newOffsetY, viewport.width, viewport.height, true);
7957
+ this.requestRender();
7958
+ }
7959
+ if (this._wrapMode === "none") {
7960
+ if (direction === "left") {
7961
+ const newOffsetX = Math.max(0, viewport.offsetX - delta);
7962
+ this.editorView.setViewport(newOffsetX, viewport.offsetY, viewport.width, viewport.height, true);
7963
+ this.requestRender();
7964
+ } else if (direction === "right") {
7965
+ const newOffsetX = viewport.offsetX + delta;
7966
+ this.editorView.setViewport(newOffsetX, viewport.offsetY, viewport.width, viewport.height, true);
7954
7967
  this.requestRender();
7955
7968
  }
7956
7969
  }
7957
7970
  }
7971
+ onResize(width, height) {
7972
+ this.editorView.setViewportSize(width, height);
7973
+ }
7958
7974
  refreshLocalSelection() {
7959
7975
  if (this.lastLocalSelection) {
7960
7976
  return this.updateLocalSelection(this.lastLocalSelection);
@@ -7966,7 +7982,7 @@ class EditBufferRenderable extends Renderable {
7966
7982
  this.editorView.resetLocalSelection();
7967
7983
  return true;
7968
7984
  }
7969
- return this.editorView.setLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg);
7985
+ return this.editorView.setLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg, false);
7970
7986
  }
7971
7987
  shouldStartSelection(x, y) {
7972
7988
  if (!this.selectable)
@@ -7978,12 +7994,56 @@ class EditBufferRenderable extends Renderable {
7978
7994
  onSelectionChanged(selection) {
7979
7995
  const localSelection = convertGlobalToLocalSelection(selection, this.x, this.y);
7980
7996
  this.lastLocalSelection = localSelection;
7981
- const changed = this.updateLocalSelection(localSelection);
7997
+ const updateCursor = true;
7998
+ let changed;
7999
+ if (!localSelection?.isActive) {
8000
+ this.editorView.resetLocalSelection();
8001
+ changed = true;
8002
+ } else if (selection?.isStart) {
8003
+ changed = this.editorView.setLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg, updateCursor);
8004
+ } else {
8005
+ changed = this.editorView.updateLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg, updateCursor);
8006
+ }
8007
+ if (changed && localSelection?.isActive && selection?.isSelecting) {
8008
+ const viewport = this.editorView.getViewport();
8009
+ const focusY = localSelection.focusY;
8010
+ const scrollMargin = Math.max(1, Math.floor(viewport.height * this._scrollMargin));
8011
+ if (focusY < scrollMargin) {
8012
+ this._autoScrollVelocity = -this._scrollSpeed;
8013
+ } else if (focusY >= viewport.height - scrollMargin) {
8014
+ this._autoScrollVelocity = this._scrollSpeed;
8015
+ } else {
8016
+ this._autoScrollVelocity = 0;
8017
+ }
8018
+ } else {
8019
+ this._autoScrollVelocity = 0;
8020
+ this._autoScrollAccumulator = 0;
8021
+ }
7982
8022
  if (changed) {
7983
8023
  this.requestRender();
7984
8024
  }
7985
8025
  return this.hasSelection();
7986
8026
  }
8027
+ onUpdate(deltaTime) {
8028
+ super.onUpdate(deltaTime);
8029
+ if (this._autoScrollVelocity !== 0 && this.hasSelection()) {
8030
+ const deltaSeconds = deltaTime / 1000;
8031
+ this._autoScrollAccumulator += this._autoScrollVelocity * deltaSeconds;
8032
+ const linesToScroll = Math.floor(Math.abs(this._autoScrollAccumulator));
8033
+ if (linesToScroll > 0) {
8034
+ const direction = this._autoScrollVelocity > 0 ? 1 : -1;
8035
+ const viewport = this.editorView.getViewport();
8036
+ const totalVirtualLines = this.editorView.getTotalVirtualLineCount();
8037
+ const maxOffsetY = Math.max(0, totalVirtualLines - viewport.height);
8038
+ const newOffsetY = Math.max(0, Math.min(viewport.offsetY + direction * linesToScroll, maxOffsetY));
8039
+ if (newOffsetY !== viewport.offsetY) {
8040
+ this.editorView.setViewport(viewport.offsetX, newOffsetY, viewport.width, viewport.height, false);
8041
+ this._ctx.requestSelectionUpdate();
8042
+ }
8043
+ this._autoScrollAccumulator -= direction * linesToScroll;
8044
+ }
8045
+ }
8046
+ }
7987
8047
  getSelectedText() {
7988
8048
  return this.editorView.getSelectedText();
7989
8049
  }
@@ -8147,48 +8207,17 @@ class EditBufferRenderable extends Renderable {
8147
8207
  return;
8148
8208
  if (!shiftPressed) {
8149
8209
  this._ctx.clearSelection();
8150
- this._selectionAnchorState = null;
8151
8210
  return;
8152
8211
  }
8153
8212
  const visualCursor = this.editorView.getVisualCursor();
8154
- const viewport = this.editorView.getViewport();
8155
8213
  const cursorX = this.x + visualCursor.visualCol;
8156
8214
  const cursorY = this.y + visualCursor.visualRow;
8157
8215
  if (isBeforeMovement) {
8158
8216
  if (!this._ctx.hasSelection) {
8159
8217
  this._ctx.startSelection(this, cursorX, cursorY);
8160
- this._selectionAnchorState = {
8161
- screenX: cursorX,
8162
- screenY: cursorY,
8163
- viewportX: viewport.offsetX,
8164
- viewportY: viewport.offsetY
8165
- };
8166
- } else if (!this._selectionAnchorState) {
8167
- const selection = this._ctx.getSelection();
8168
- if (selection && selection.isActive) {
8169
- this._selectionAnchorState = {
8170
- screenX: selection.anchor.x,
8171
- screenY: selection.anchor.y,
8172
- viewportX: viewport.offsetX,
8173
- viewportY: viewport.offsetY
8174
- };
8175
- }
8176
8218
  }
8177
8219
  } else {
8178
- if (this._selectionAnchorState) {
8179
- const deltaY = viewport.offsetY - this._selectionAnchorState.viewportY;
8180
- const deltaX = viewport.offsetX - this._selectionAnchorState.viewportX;
8181
- if (deltaY !== 0 || deltaX !== 0) {
8182
- const newAnchorX = this._selectionAnchorState.screenX - deltaX;
8183
- const newAnchorY = this._selectionAnchorState.screenY - deltaY;
8184
- this._ctx.startSelection(this, newAnchorX, newAnchorY);
8185
- this._ctx.updateSelection(this, cursorX, cursorY);
8186
- } else {
8187
- this._ctx.updateSelection(this, cursorX, cursorY);
8188
- }
8189
- } else {
8190
- this._ctx.updateSelection(this, cursorX, cursorY);
8191
- }
8220
+ this._ctx.updateSelection(this, cursorX, cursorY);
8192
8221
  }
8193
8222
  }
8194
8223
  }
@@ -8209,10 +8238,20 @@ var defaultTextareaKeybindings = [
8209
8238
  { name: "end", shift: true, action: "select-buffer-end" },
8210
8239
  { name: "a", ctrl: true, action: "line-home" },
8211
8240
  { name: "e", ctrl: true, action: "line-end" },
8241
+ { name: "a", ctrl: true, shift: true, action: "select-line-home" },
8242
+ { name: "e", ctrl: true, shift: true, action: "select-line-end" },
8243
+ { name: "a", meta: true, action: "visual-line-home" },
8244
+ { name: "e", meta: true, action: "visual-line-end" },
8245
+ { name: "a", meta: true, shift: true, action: "select-visual-line-home" },
8246
+ { name: "e", meta: true, shift: true, action: "select-visual-line-end" },
8212
8247
  { name: "f", ctrl: true, action: "move-right" },
8213
8248
  { name: "b", ctrl: true, action: "move-left" },
8214
- { name: "w", ctrl: true, shift: true, action: "delete-word-forward" },
8215
8249
  { name: "w", ctrl: true, action: "delete-word-backward" },
8250
+ { name: "backspace", ctrl: true, action: "delete-word-backward" },
8251
+ { name: "d", meta: true, action: "delete-word-forward" },
8252
+ { name: "delete", meta: true, action: "delete-word-forward" },
8253
+ { name: "delete", ctrl: true, action: "delete-word-forward" },
8254
+ { name: "d", ctrl: true, shift: true, action: "delete-line" },
8216
8255
  { name: "k", ctrl: true, action: "delete-to-line-end" },
8217
8256
  { name: "u", ctrl: true, action: "delete-to-line-start" },
8218
8257
  { name: "backspace", action: "backspace" },
@@ -8231,11 +8270,12 @@ var defaultTextareaKeybindings = [
8231
8270
  { name: "b", meta: true, action: "word-backward" },
8232
8271
  { name: "right", meta: true, action: "word-forward" },
8233
8272
  { name: "left", meta: true, action: "word-backward" },
8273
+ { name: "right", ctrl: true, action: "word-forward" },
8274
+ { name: "left", ctrl: true, action: "word-backward" },
8234
8275
  { name: "f", meta: true, shift: true, action: "select-word-forward" },
8235
8276
  { name: "b", meta: true, shift: true, action: "select-word-backward" },
8236
8277
  { name: "right", meta: true, shift: true, action: "select-word-forward" },
8237
8278
  { name: "left", meta: true, shift: true, action: "select-word-backward" },
8238
- { name: "d", meta: true, action: "delete-line" },
8239
8279
  { name: "backspace", meta: true, action: "delete-word-backward" }
8240
8280
  ];
8241
8281
 
@@ -8311,6 +8351,10 @@ class TextareaRenderable extends EditBufferRenderable {
8311
8351
  ["line-end", () => this.gotoLineEnd()],
8312
8352
  ["select-line-home", () => this.gotoLineHome({ select: true })],
8313
8353
  ["select-line-end", () => this.gotoLineEnd({ select: true })],
8354
+ ["visual-line-home", () => this.gotoVisualLineHome()],
8355
+ ["visual-line-end", () => this.gotoVisualLineEnd()],
8356
+ ["select-visual-line-home", () => this.gotoVisualLineHome({ select: true })],
8357
+ ["select-visual-line-end", () => this.gotoVisualLineEnd({ select: true })],
8314
8358
  ["select-buffer-home", () => this.gotoBufferHome({ select: true })],
8315
8359
  ["select-buffer-end", () => this.gotoBufferEnd({ select: true })],
8316
8360
  ["buffer-home", () => this.gotoBufferHome()],
@@ -8336,19 +8380,12 @@ class TextareaRenderable extends EditBufferRenderable {
8336
8380
  this.insertText(event.text);
8337
8381
  }
8338
8382
  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
8383
  const bindingKey = getKeyBindingKey({
8347
- name: keyName,
8348
- ctrl: keyCtrl,
8349
- shift: keyShift,
8350
- meta: keyMeta,
8351
- super: keySuper,
8384
+ name: key.name,
8385
+ ctrl: key.ctrl,
8386
+ shift: key.shift,
8387
+ meta: key.meta,
8388
+ super: key.super,
8352
8389
  action: "move-left"
8353
8390
  });
8354
8391
  const action = this._keyBindingsMap.get(bindingKey);
@@ -8358,20 +8395,20 @@ class TextareaRenderable extends EditBufferRenderable {
8358
8395
  return handler();
8359
8396
  }
8360
8397
  }
8361
- if (!keyCtrl && !keyMeta && !keySuper && !keyHyper) {
8362
- if (keyName === "space") {
8398
+ if (!key.ctrl && !key.meta && !key.super && !key.hyper) {
8399
+ if (key.name === "space") {
8363
8400
  this.insertText(" ");
8364
8401
  return true;
8365
8402
  }
8366
- if (keySequence) {
8367
- const firstCharCode = keySequence.charCodeAt(0);
8403
+ if (key.sequence) {
8404
+ const firstCharCode = key.sequence.charCodeAt(0);
8368
8405
  if (firstCharCode < 32) {
8369
8406
  return false;
8370
8407
  }
8371
8408
  if (firstCharCode === 127) {
8372
8409
  return false;
8373
8410
  }
8374
- this.insertText(keySequence);
8411
+ this.insertText(key.sequence);
8375
8412
  return true;
8376
8413
  }
8377
8414
  }
@@ -8500,6 +8537,24 @@ class TextareaRenderable extends EditBufferRenderable {
8500
8537
  this.requestRender();
8501
8538
  return true;
8502
8539
  }
8540
+ gotoVisualLineHome(options) {
8541
+ const select = options?.select ?? false;
8542
+ this.updateSelectionForMovement(select, true);
8543
+ const sol = this.editorView.getVisualSOL();
8544
+ this.editBuffer.setCursor(sol.logicalRow, sol.logicalCol);
8545
+ this.updateSelectionForMovement(select, false);
8546
+ this.requestRender();
8547
+ return true;
8548
+ }
8549
+ gotoVisualLineEnd(options) {
8550
+ const select = options?.select ?? false;
8551
+ this.updateSelectionForMovement(select, true);
8552
+ const eol = this.editorView.getVisualEOL();
8553
+ this.editBuffer.setCursor(eol.logicalRow, eol.logicalCol);
8554
+ this.updateSelectionForMovement(select, false);
8555
+ this.requestRender();
8556
+ return true;
8557
+ }
8503
8558
  gotoBufferHome(options) {
8504
8559
  const select = options?.select ?? false;
8505
8560
  this.updateSelectionForMovement(select, true);
@@ -8865,5 +8920,5 @@ export {
8865
8920
  ASCIIFont
8866
8921
  };
8867
8922
 
8868
- //# debugId=8034F385F70736E264756E2164756E21
8923
+ //# debugId=36CCE839639ECF0564756E2164756E21
8869
8924
  //# sourceMappingURL=index.js.map