@opentui/core 0.5.6 → 0.5.8

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.
@@ -40,7 +40,7 @@ import {
40
40
  toArrayBuffer,
41
41
  treeSitterToTextChunks,
42
42
  yoga_default
43
- } from "./chunk-node-2h23nsbj.js";
43
+ } from "./chunk-node-mfda59vq.js";
44
44
 
45
45
  // src/Renderable.ts
46
46
  import { EventEmitter } from "events";
@@ -1685,18 +1685,26 @@ class TextBufferView {
1685
1685
  this.guard();
1686
1686
  return this.getSelection() !== null;
1687
1687
  }
1688
- setLocalSelection(anchorX, anchorY, focusX, focusY, bgColor, fgColor) {
1688
+ setLocalSelection(anchorX, anchorY, focusX, focusY, bgColor, fgColor, behavior = "cell") {
1689
1689
  this.guard();
1690
- return this.lib.textBufferViewSetLocalSelection(this.viewPtr, anchorX, anchorY, focusX, focusY, bgColor || null, fgColor || null);
1690
+ return this.lib.textBufferViewSetLocalSelection(this.viewPtr, anchorX, anchorY, focusX, focusY, bgColor || null, fgColor || null, behavior);
1691
1691
  }
1692
- updateLocalSelection(anchorX, anchorY, focusX, focusY, bgColor, fgColor) {
1692
+ updateLocalSelection(anchorX, anchorY, focusX, focusY, bgColor, fgColor, behavior = "cell") {
1693
1693
  this.guard();
1694
- return this.lib.textBufferViewUpdateLocalSelection(this.viewPtr, anchorX, anchorY, focusX, focusY, bgColor || null, fgColor || null);
1694
+ return this.lib.textBufferViewUpdateLocalSelection(this.viewPtr, anchorX, anchorY, focusX, focusY, bgColor || null, fgColor || null, behavior);
1695
1695
  }
1696
1696
  resetLocalSelection() {
1697
1697
  this.guard();
1698
1698
  this.lib.textBufferViewResetLocalSelection(this.viewPtr);
1699
1699
  }
1700
+ setSelectionOccupancy(occupancy) {
1701
+ this.guard();
1702
+ this.lib.textBufferViewSetSelectionOccupancy(this.viewPtr, occupancy);
1703
+ }
1704
+ getSelectionOccupancy() {
1705
+ this.guard();
1706
+ return this.lib.textBufferViewGetSelectionOccupancy(this.viewPtr);
1707
+ }
1700
1708
  setWrapWidth(width) {
1701
1709
  this.guard();
1702
1710
  this.lib.textBufferViewSetWrapWidth(this.viewPtr, width ?? 0);
@@ -2161,18 +2169,39 @@ class EditorView {
2161
2169
  this.guard();
2162
2170
  return this.getSelection() !== null;
2163
2171
  }
2164
- setLocalSelection(anchorX, anchorY, focusX, focusY, bgColor, fgColor, updateCursor, followCursor) {
2172
+ setLocalSelection(anchorX, anchorY, focusX, focusY, bgColor, fgColor, updateCursor, followCursor, behavior = "cell") {
2165
2173
  this.guard();
2166
- return this.lib.editorViewSetLocalSelection(this.viewPtr, anchorX, anchorY, focusX, focusY, bgColor || null, fgColor || null, updateCursor ?? false, followCursor ?? false);
2174
+ return this.lib.editorViewSetLocalSelection(this.viewPtr, anchorX, anchorY, focusX, focusY, bgColor || null, fgColor || null, updateCursor ?? false, followCursor ?? false, behavior);
2167
2175
  }
2168
- updateLocalSelection(anchorX, anchorY, focusX, focusY, bgColor, fgColor, updateCursor, followCursor) {
2176
+ updateLocalSelection(anchorX, anchorY, focusX, focusY, bgColor, fgColor, updateCursor, followCursor, behavior = "cell") {
2169
2177
  this.guard();
2170
- return this.lib.editorViewUpdateLocalSelection(this.viewPtr, anchorX, anchorY, focusX, focusY, bgColor || null, fgColor || null, updateCursor ?? false, followCursor ?? false);
2178
+ return this.lib.editorViewUpdateLocalSelection(this.viewPtr, anchorX, anchorY, focusX, focusY, bgColor || null, fgColor || null, updateCursor ?? false, followCursor ?? false, behavior);
2171
2179
  }
2172
2180
  resetLocalSelection() {
2173
2181
  this.guard();
2174
2182
  this.lib.editorViewResetLocalSelection(this.viewPtr);
2175
2183
  }
2184
+ convertSelectionToCell() {
2185
+ this.guard();
2186
+ return this.lib.editorViewConvertSelectionToCell(this.viewPtr);
2187
+ }
2188
+ setSelectionOccupancy(occupancy) {
2189
+ this.guard();
2190
+ this.lib.editorViewSetSelectionOccupancy(this.viewPtr, occupancy);
2191
+ }
2192
+ getSelectionOccupancy() {
2193
+ this.guard();
2194
+ this._textBufferViewPtr ??= this.lib.editorViewGetTextBufferView(this.viewPtr);
2195
+ return this.lib.textBufferViewGetSelectionOccupancy(this._textBufferViewPtr);
2196
+ }
2197
+ setSelectionInclusive(start, end, bgColor, fgColor) {
2198
+ this.guard();
2199
+ this.lib.editorViewSetSelectionInclusive(this.viewPtr, start, end, bgColor || null, fgColor || null);
2200
+ }
2201
+ setSelectionColors(bgColor, fgColor) {
2202
+ this.guard();
2203
+ this.lib.editorViewSetSelectionColors(this.viewPtr, bgColor || null, fgColor || null);
2204
+ }
2176
2205
  getSelectedText() {
2177
2206
  this.guard();
2178
2207
  const maxLength = 1024 * 1024;
@@ -2233,6 +2262,10 @@ class EditorView {
2233
2262
  this.guard();
2234
2263
  return this.lib.editorViewGetVisualEOL(this.viewPtr);
2235
2264
  }
2265
+ gotoVisualLineEnd() {
2266
+ this.guard();
2267
+ this.lib.editorViewGotoVisualLineEnd(this.viewPtr);
2268
+ }
2236
2269
  getLineInfo() {
2237
2270
  this.guard();
2238
2271
  return this.lib.editorViewGetLineInfo(this.viewPtr);
@@ -2262,9 +2295,7 @@ class EditorView {
2262
2295
  }
2263
2296
  measureForDimensions(width, height) {
2264
2297
  this.guard();
2265
- if (!this._textBufferViewPtr) {
2266
- this._textBufferViewPtr = this.lib.editorViewGetTextBufferView(this.viewPtr);
2267
- }
2298
+ this._textBufferViewPtr ??= this.lib.editorViewGetTextBufferView(this.viewPtr);
2268
2299
  return this.lib.textBufferViewMeasureForDimensions(this._textBufferViewPtr, width, height);
2269
2300
  }
2270
2301
  destroy() {
@@ -3015,7 +3046,7 @@ class TextBufferRenderable extends Renderable {
3015
3046
  this.textBufferView.resetLocalSelection();
3016
3047
  return true;
3017
3048
  }
3018
- return this.textBufferView.setLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg);
3049
+ return this.textBufferView.setLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg, localSelection.behavior);
3019
3050
  }
3020
3051
  updateTextInfo() {
3021
3052
  if (this.lastLocalSelection) {
@@ -3053,9 +3084,9 @@ class TextBufferRenderable extends Renderable {
3053
3084
  this.textBufferView.resetLocalSelection();
3054
3085
  changed = true;
3055
3086
  } else if (selection?.isStart) {
3056
- changed = this.textBufferView.setLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg);
3087
+ changed = this.textBufferView.setLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg, localSelection.behavior);
3057
3088
  } else {
3058
- changed = this.textBufferView.updateLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg);
3089
+ changed = this.textBufferView.updateLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg, localSelection.behavior);
3059
3090
  }
3060
3091
  if (changed) {
3061
3092
  this.requestRender();
@@ -5534,6 +5565,9 @@ class EditBufferRenderable extends Renderable {
5534
5565
  this.editorView = EditorView.create(this.editBuffer, this.width || 80, this.height || 24);
5535
5566
  this.editorView.setWrapMode(this._wrapMode);
5536
5567
  this.editorView.setScrollMargin(this._scrollMargin);
5568
+ if (options.selectionOccupancy === "boundary") {
5569
+ this.editorView.setSelectionOccupancy("boundary");
5570
+ }
5537
5571
  this.editBuffer.setDefaultFg(this._textColor);
5538
5572
  this.editBuffer.setDefaultBg(this._backgroundColor);
5539
5573
  this.editBuffer.setDefaultAttributes(this._defaultAttributes);
@@ -5595,6 +5629,7 @@ class EditBufferRenderable extends Renderable {
5595
5629
  return this.editorView.getVisualCursor().offset;
5596
5630
  }
5597
5631
  set cursorOffset(offset) {
5632
+ this.clearSelection();
5598
5633
  this.editorView.setCursorByOffset(offset);
5599
5634
  this.requestRender();
5600
5635
  }
@@ -5726,6 +5761,16 @@ class EditBufferRenderable extends Renderable {
5726
5761
  }
5727
5762
  }
5728
5763
  }
5764
+ get selectionOccupancy() {
5765
+ return this.editorView.getSelectionOccupancy();
5766
+ }
5767
+ set selectionOccupancy(value) {
5768
+ const occupancy = value ?? "cell";
5769
+ if (this.selectionOccupancy === occupancy)
5770
+ return;
5771
+ this.editorView.setSelectionOccupancy(occupancy);
5772
+ this.requestRender();
5773
+ }
5729
5774
  get tabIndicator() {
5730
5775
  return this._tabIndicator;
5731
5776
  }
@@ -5804,7 +5849,7 @@ class EditBufferRenderable extends Renderable {
5804
5849
  this.editorView.resetLocalSelection();
5805
5850
  return true;
5806
5851
  }
5807
- return this.editorView.setLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg, false);
5852
+ return this.editorView.setLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg, false, false, localSelection.behavior);
5808
5853
  }
5809
5854
  shouldStartSelection(x, y) {
5810
5855
  if (!this.selectable)
@@ -5824,9 +5869,9 @@ class EditBufferRenderable extends Renderable {
5824
5869
  this.editorView.resetLocalSelection();
5825
5870
  changed = true;
5826
5871
  } else if (selection?.isStart) {
5827
- changed = this.editorView.setLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg, updateCursor, followCursor);
5872
+ changed = this.editorView.setLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg, updateCursor, followCursor, localSelection.behavior);
5828
5873
  } else {
5829
- changed = this.editorView.updateLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg, updateCursor, followCursor);
5874
+ changed = this.editorView.updateLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg, updateCursor, followCursor, localSelection.behavior);
5830
5875
  }
5831
5876
  if (changed && localSelection?.isActive && selection?.isDragging) {
5832
5877
  const viewport = this.editorView.getViewport();
@@ -5879,14 +5924,7 @@ class EditBufferRenderable extends Renderable {
5879
5924
  return this.editorView.getSelection();
5880
5925
  }
5881
5926
  refreshSelectionStyle() {
5882
- if (this.lastLocalSelection) {
5883
- this.updateLocalSelection(this.lastLocalSelection);
5884
- return;
5885
- }
5886
- const selection = this.getSelection();
5887
- if (!selection)
5888
- return;
5889
- this.editorView.setSelection(selection.start, selection.end, this._selectionBg, this._selectionFg);
5927
+ this.editorView.setSelectionColors(this._selectionBg, this._selectionFg);
5890
5928
  }
5891
5929
  deleteSelectedText() {
5892
5930
  this.editorView.deleteSelectedText();
@@ -5901,12 +5939,15 @@ class EditBufferRenderable extends Renderable {
5901
5939
  this.requestRender();
5902
5940
  }
5903
5941
  setSelectionInclusive(start, end) {
5904
- this.setSelection(Math.min(start, end), Math.max(start, end) + 1);
5942
+ this.lastLocalSelection = null;
5943
+ this.editorView.resetLocalSelection();
5944
+ this._ctx.clearSelection();
5945
+ this.editorView.setSelectionInclusive(start, end, this._selectionBg, this._selectionFg);
5946
+ this.requestRender();
5905
5947
  }
5906
5948
  clearSelection() {
5907
5949
  const had = this.hasSelection();
5908
5950
  this.lastLocalSelection = null;
5909
- this.editorView.resetSelection();
5910
5951
  this.editorView.resetLocalSelection();
5911
5952
  this._ctx.clearSelection();
5912
5953
  if (had) {
@@ -5922,6 +5963,7 @@ class EditBufferRenderable extends Renderable {
5922
5963
  return true;
5923
5964
  }
5924
5965
  setCursor(row, col) {
5966
+ this.clearSelection();
5925
5967
  this.editBuffer.setCursor(row, col);
5926
5968
  this.requestRender();
5927
5969
  }
@@ -5971,15 +6013,18 @@ class EditBufferRenderable extends Renderable {
5971
6013
  this.requestRender();
5972
6014
  return true;
5973
6015
  }
6016
+ collapseSelectionToEdge(edge) {
6017
+ const selection = this.getSelection();
6018
+ if (!selection)
6019
+ return false;
6020
+ this.editBuffer.setCursorByOffset(edge === "start" ? selection.start : selection.end);
6021
+ this.clearSelection();
6022
+ return true;
6023
+ }
5974
6024
  moveCursorLeft(options) {
5975
6025
  const select = options?.select ?? false;
5976
- if (!select && this.hasSelection()) {
5977
- const selection = this.getSelection();
5978
- this.editBuffer.setCursorByOffset(selection.start);
5979
- this._ctx.clearSelection();
5980
- this.requestRender();
6026
+ if (!select && this.collapseSelectionToEdge("start"))
5981
6027
  return true;
5982
- }
5983
6028
  this.updateSelectionForMovement(select, true);
5984
6029
  this.editBuffer.moveCursorLeft();
5985
6030
  this.updateSelectionForMovement(select, false);
@@ -5988,14 +6033,8 @@ class EditBufferRenderable extends Renderable {
5988
6033
  }
5989
6034
  moveCursorRight(options) {
5990
6035
  const select = options?.select ?? false;
5991
- if (!select && this.hasSelection()) {
5992
- const selection = this.getSelection();
5993
- const targetOffset = this.cursorOffset === selection.start ? selection.end - 1 : selection.end;
5994
- this.editBuffer.setCursorByOffset(targetOffset);
5995
- this._ctx.clearSelection();
5996
- this.requestRender();
6036
+ if (!select && this.collapseSelectionToEdge("end"))
5997
6037
  return true;
5998
- }
5999
6038
  this.updateSelectionForMovement(select, true);
6000
6039
  this.editBuffer.moveCursorRight();
6001
6040
  this.updateSelectionForMovement(select, false);
@@ -6019,6 +6058,7 @@ class EditBufferRenderable extends Renderable {
6019
6058
  return true;
6020
6059
  }
6021
6060
  gotoLine(line) {
6061
+ this.clearSelection();
6022
6062
  this.editBuffer.gotoLine(line);
6023
6063
  this.requestRender();
6024
6064
  }
@@ -6031,6 +6071,8 @@ class EditBufferRenderable extends Renderable {
6031
6071
  }
6032
6072
  gotoLineHome(options) {
6033
6073
  const select = options?.select ?? false;
6074
+ if (!select && this.collapseSelectionToEdge("start"))
6075
+ return true;
6034
6076
  this.updateSelectionForMovement(select, true);
6035
6077
  const cursor = this.editorView.getCursor();
6036
6078
  if (cursor.col === 0 && cursor.row > 0) {
@@ -6046,6 +6088,8 @@ class EditBufferRenderable extends Renderable {
6046
6088
  }
6047
6089
  gotoLineEnd(options) {
6048
6090
  const select = options?.select ?? false;
6091
+ if (!select && this.collapseSelectionToEdge("end"))
6092
+ return true;
6049
6093
  this.updateSelectionForMovement(select, true);
6050
6094
  const cursor = this.editorView.getCursor();
6051
6095
  const eol = this.editBuffer.getEOL();
@@ -6061,6 +6105,8 @@ class EditBufferRenderable extends Renderable {
6061
6105
  }
6062
6106
  gotoVisualLineHome(options) {
6063
6107
  const select = options?.select ?? false;
6108
+ if (!select && this.collapseSelectionToEdge("start"))
6109
+ return true;
6064
6110
  this.updateSelectionForMovement(select, true);
6065
6111
  const sol = this.editorView.getVisualSOL();
6066
6112
  this.editBuffer.setCursor(sol.logicalRow, sol.logicalCol);
@@ -6070,15 +6116,18 @@ class EditBufferRenderable extends Renderable {
6070
6116
  }
6071
6117
  gotoVisualLineEnd(options) {
6072
6118
  const select = options?.select ?? false;
6119
+ if (!select && this.collapseSelectionToEdge("end"))
6120
+ return true;
6073
6121
  this.updateSelectionForMovement(select, true);
6074
- const eol = this.editorView.getVisualEOL();
6075
- this.editBuffer.setCursor(eol.logicalRow, eol.logicalCol);
6122
+ this.editorView.gotoVisualLineEnd();
6076
6123
  this.updateSelectionForMovement(select, false);
6077
6124
  this.requestRender();
6078
6125
  return true;
6079
6126
  }
6080
6127
  gotoBufferHome(options) {
6081
6128
  const select = options?.select ?? false;
6129
+ if (!select && this.collapseSelectionToEdge("start"))
6130
+ return true;
6082
6131
  this.updateSelectionForMovement(select, true);
6083
6132
  this.editBuffer.setCursor(0, 0);
6084
6133
  this.updateSelectionForMovement(select, false);
@@ -6087,6 +6136,8 @@ class EditBufferRenderable extends Renderable {
6087
6136
  }
6088
6137
  gotoBufferEnd(options) {
6089
6138
  const select = options?.select ?? false;
6139
+ if (!select && this.collapseSelectionToEdge("end"))
6140
+ return true;
6090
6141
  this.updateSelectionForMovement(select, true);
6091
6142
  this.editBuffer.gotoLine(999999);
6092
6143
  this.updateSelectionForMovement(select, false);
@@ -6131,6 +6182,8 @@ class EditBufferRenderable extends Renderable {
6131
6182
  }
6132
6183
  moveWordForward(options) {
6133
6184
  const select = options?.select ?? false;
6185
+ if (!select && this.collapseSelectionToEdge("end"))
6186
+ return true;
6134
6187
  this.updateSelectionForMovement(select, true);
6135
6188
  const nextWord = this.editBuffer.getNextWordBoundary();
6136
6189
  this.editBuffer.setCursorByOffset(nextWord.offset);
@@ -6140,6 +6193,8 @@ class EditBufferRenderable extends Renderable {
6140
6193
  }
6141
6194
  moveWordBackward(options) {
6142
6195
  const select = options?.select ?? false;
6196
+ if (!select && this.collapseSelectionToEdge("start"))
6197
+ return true;
6143
6198
  this.updateSelectionForMovement(select, true);
6144
6199
  const prevWord = this.editBuffer.getPrevWordBoundary();
6145
6200
  this.editBuffer.setCursorByOffset(prevWord.offset);
@@ -6315,20 +6370,26 @@ class EditBufferRenderable extends Renderable {
6315
6370
  return this.editBuffer.getTextRangeByCoords(startRow, startCol, endRow, endCol);
6316
6371
  }
6317
6372
  updateSelectionForMovement(shiftPressed, isBeforeMovement) {
6318
- if (!this.selectable)
6319
- return;
6320
6373
  if (!shiftPressed) {
6321
6374
  this._keyboardSelectionActive = false;
6322
- this._ctx.clearSelection();
6375
+ this.clearSelection();
6323
6376
  return;
6324
6377
  }
6378
+ if (!this.selectable)
6379
+ return;
6325
6380
  this._keyboardSelectionActive = true;
6326
6381
  const visualCursor = this.editorView.getVisualCursor();
6327
6382
  const cursorX = this.x + visualCursor.visualCol;
6328
6383
  const cursorY = this.y + visualCursor.visualRow;
6329
6384
  if (isBeforeMovement) {
6330
- if (!this._ctx.hasSelection) {
6385
+ if (!this._ctx.hasSelection || !this.hasSelection()) {
6331
6386
  this._ctx.startSelection(this, cursorX, cursorY);
6387
+ } else if (this._ctx.getSelection()?.behavior !== "cell") {
6388
+ if (this.editorView.convertSelectionToCell()) {
6389
+ const selection = this._ctx.getSelection();
6390
+ if (selection)
6391
+ selection.behavior = "cell";
6392
+ }
6332
6393
  }
6333
6394
  return;
6334
6395
  }
@@ -6857,7 +6918,7 @@ class ScrollbackSnapshotRenderContext extends EventEmitter5 {
6857
6918
  return this.lifecyclePasses;
6858
6919
  }
6859
6920
  clearSelection() {}
6860
- startSelection(_renderable, _x, _y) {}
6921
+ startSelection(_renderable, _x, _y, _behavior) {}
6861
6922
  updateSelection(_currentRenderable, _x, _y, _options) {}
6862
6923
  }
6863
6924
  var DEFAULT_FORWARDED_ENV_KEYS = [
@@ -7021,6 +7082,7 @@ var RendererControlState;
7021
7082
  RendererControlState2["EXPLICIT_SUSPENDED"] = "explicit_suspended";
7022
7083
  RendererControlState2["EXPLICIT_STOPPED"] = "explicit_stopped";
7023
7084
  })(RendererControlState ||= {});
7085
+ var CLICK_REPEAT_INTERVAL_MS = 500;
7024
7086
 
7025
7087
  class CliRenderer extends EventEmitter5 {
7026
7088
  static animationFrameId = 0;
@@ -7116,6 +7178,7 @@ class CliRenderer extends EventEmitter5 {
7116
7178
  lastOverRenderable;
7117
7179
  currentSelection = null;
7118
7180
  selectionContainers = [];
7181
+ lastClick = null;
7119
7182
  clipboard;
7120
7183
  _splitHeight = 0;
7121
7184
  renderOffset = 0;
@@ -7544,8 +7607,7 @@ Captured external output:
7544
7607
  this.lib.hitGridClearScissorRects(this.rendererPtr);
7545
7608
  }
7546
7609
  get widthMethod() {
7547
- const caps = this.capabilities;
7548
- return caps?.unicode === "wcwidth" ? "wcwidth" : "unicode";
7610
+ return this.capabilities?.unicode ?? this.nextRenderBuffer.widthMethod;
7549
7611
  }
7550
7612
  get frameId() {
7551
7613
  return this._frameId;
@@ -9088,7 +9150,7 @@ Captured external output:
9088
9150
  if (mouseEvent.type === "down" && mouseEvent.button === 0 /* LEFT */ && !this.currentSelection?.isDragging && !mouseEvent.modifiers.ctrl) {
9089
9151
  const canStartSelection = Boolean(maybeRenderable && maybeRenderable.selectable && !maybeRenderable.isDestroyed && maybeRenderable.shouldStartSelection(mouseEvent.x, mouseEvent.y));
9090
9152
  if (canStartSelection && maybeRenderable) {
9091
- this.startSelection(maybeRenderable, mouseEvent.x, mouseEvent.y);
9153
+ this.startSelection(maybeRenderable, mouseEvent.x, mouseEvent.y, this.nextClickBehavior(maybeRenderable, mouseEvent.x, mouseEvent.y));
9092
9154
  this.dispatchMouseEvent(maybeRenderable, mouseEvent);
9093
9155
  return true;
9094
9156
  }
@@ -9104,7 +9166,7 @@ Captured external output:
9104
9166
  }
9105
9167
  return true;
9106
9168
  }
9107
- if (mouseEvent.type === "up" && this.currentSelection?.isDragging) {
9169
+ if (mouseEvent.type === "up" && mouseEvent.button === 0 /* LEFT */ && this.currentSelection?.isDragging) {
9108
9170
  if (maybeRenderable) {
9109
9171
  const event2 = new MouseEvent(maybeRenderable, {
9110
9172
  ...mouseEvent,
@@ -9177,7 +9239,7 @@ Captured external output:
9177
9239
  this.setCapturedRenderable(undefined);
9178
9240
  this.lastOverRenderable = undefined;
9179
9241
  }
9180
- if (!event?.defaultPrevented && mouseEvent.type === "down" && this.currentSelection) {
9242
+ if (!event?.defaultPrevented && mouseEvent.type === "down" && mouseEvent.button === 0 /* LEFT */ && this.currentSelection) {
9181
9243
  this.clearSelection();
9182
9244
  }
9183
9245
  return true;
@@ -9970,6 +10032,10 @@ Captured external output:
9970
10032
  return this.selectionContainers.length > 0 ? this.selectionContainers[this.selectionContainers.length - 1] : null;
9971
10033
  }
9972
10034
  clearSelection() {
10035
+ this.clearSelectionState();
10036
+ this.lastClick = null;
10037
+ }
10038
+ clearSelectionState() {
9973
10039
  if (this.currentSelection) {
9974
10040
  for (const renderable of this.currentSelection.touchedRenderables) {
9975
10041
  if (renderable.selectable && !renderable.isDestroyed) {
@@ -9980,15 +10046,23 @@ Captured external output:
9980
10046
  }
9981
10047
  this.selectionContainers = [];
9982
10048
  }
9983
- startSelection(renderable, x, y) {
10049
+ startSelection(renderable, x, y, behavior = "cell") {
9984
10050
  if (!renderable.selectable)
9985
10051
  return;
9986
- this.clearSelection();
10052
+ this.clearSelectionState();
9987
10053
  this.selectionContainers.push(renderable.parent || this.root);
9988
- this.currentSelection = new Selection(renderable, { x, y }, { x, y });
10054
+ this.currentSelection = new Selection(renderable, { x, y }, { x, y }, behavior);
9989
10055
  this.currentSelection.isStart = true;
9990
10056
  this.notifySelectablesOfSelectionChange();
9991
10057
  }
10058
+ nextClickBehavior(renderable, x, y) {
10059
+ const now = this.clock.now();
10060
+ const last = this.lastClick;
10061
+ const continued = last !== null && renderable.num === last.renderableId && now - last.time <= CLICK_REPEAT_INTERVAL_MS && Math.max(Math.abs(x - last.x), Math.abs(y - last.y)) <= 1;
10062
+ const count = continued ? Math.min(last.count + 1, 3) : 1;
10063
+ this.lastClick = { count, time: now, x, y, renderableId: renderable.num };
10064
+ return count === 1 ? "cell" : count === 2 ? "word" : "line";
10065
+ }
9992
10066
  updateSelection(currentRenderable, x, y, options) {
9993
10067
  if (this.currentSelection) {
9994
10068
  this.currentSelection.isStart = false;
@@ -10234,5 +10308,5 @@ Captured external output:
10234
10308
 
10235
10309
  export { h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, LayoutEvents, RenderableEvents, isRenderable, BaseRenderable, Renderable, RootRenderable, TextBufferView, EditBuffer, EditorView, convertThemeToStyles, SyntaxStyle, ANSI, BoxRenderable, TextBufferRenderable, CodeRenderable, isTextNodeRenderable, TextNodeRenderable, RootTextNodeRenderable, TextRenderable, NativeSpanFeed, defaultKeyAliases, mergeKeyAliases, mergeKeyBindings, getKeyBindingAction, buildKeyBindingsMap, capture, ConsolePosition, TerminalConsole, getObjectsInViewport, EditBufferRenderableEvents, isEditBufferRenderable, EditBufferRenderable, buildKittyKeyboardFlags, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, RendererControlState, CliRenderer };
10236
10310
 
10237
- //# debugId=1FDBB1F69A93F1BC64756E2164756E21
10238
- //# sourceMappingURL=chunk-node-ks0581vk.js.map
10311
+ //# debugId=DFE44A27128A73E264756E2164756E21
10312
+ //# sourceMappingURL=chunk-node-kr27pp2p.js.map