@opentui/core 0.5.6 → 0.5.7
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/{chunk-bun-9335djz2.js → chunk-bun-xmsp0nqq.js} +109 -45
- package/{chunk-bun-9335djz2.js.map → chunk-bun-xmsp0nqq.js.map} +6 -6
- package/{chunk-bun-da1keqyp.js → chunk-bun-z4gs6jzg.js} +129 -54
- package/chunk-bun-z4gs6jzg.js.map +32 -0
- package/{chunk-node-2h23nsbj.js → chunk-node-267dafd8.js} +109 -45
- package/{chunk-node-2h23nsbj.js.map → chunk-node-267dafd8.js.map} +6 -6
- package/{chunk-node-ks0581vk.js → chunk-node-591ssncm.js} +129 -54
- package/chunk-node-591ssncm.js.map +32 -0
- package/editor-view.d.ts +9 -2
- package/index.bun.js +4 -4
- package/index.bun.js.map +3 -3
- package/index.node.js +4 -4
- package/index.node.js.map +3 -3
- package/lib/selection.d.ts +4 -2
- package/package.json +9 -9
- package/renderables/EditBufferRenderable.d.ts +5 -1
- package/renderer.d.ts +5 -2
- package/testing.bun.js +2 -2
- package/testing.js +2 -2
- package/text-buffer-view.d.ts +5 -2
- package/types.d.ts +10 -1
- package/yoga.bun.js +1 -1
- package/yoga.js +1 -1
- package/zig.d.ts +12 -5
- package/chunk-bun-da1keqyp.js.map +0 -32
- package/chunk-node-ks0581vk.js.map +0 -32
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
toArrayBuffer,
|
|
41
41
|
treeSitterToTextChunks,
|
|
42
42
|
yoga_default
|
|
43
|
-
} from "./chunk-node-
|
|
43
|
+
} from "./chunk-node-267dafd8.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
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
-
|
|
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.
|
|
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;
|
|
@@ -9088,7 +9151,7 @@ Captured external output:
|
|
|
9088
9151
|
if (mouseEvent.type === "down" && mouseEvent.button === 0 /* LEFT */ && !this.currentSelection?.isDragging && !mouseEvent.modifiers.ctrl) {
|
|
9089
9152
|
const canStartSelection = Boolean(maybeRenderable && maybeRenderable.selectable && !maybeRenderable.isDestroyed && maybeRenderable.shouldStartSelection(mouseEvent.x, mouseEvent.y));
|
|
9090
9153
|
if (canStartSelection && maybeRenderable) {
|
|
9091
|
-
this.startSelection(maybeRenderable, mouseEvent.x, mouseEvent.y);
|
|
9154
|
+
this.startSelection(maybeRenderable, mouseEvent.x, mouseEvent.y, this.nextClickBehavior(maybeRenderable, mouseEvent.x, mouseEvent.y));
|
|
9092
9155
|
this.dispatchMouseEvent(maybeRenderable, mouseEvent);
|
|
9093
9156
|
return true;
|
|
9094
9157
|
}
|
|
@@ -9970,6 +10033,10 @@ Captured external output:
|
|
|
9970
10033
|
return this.selectionContainers.length > 0 ? this.selectionContainers[this.selectionContainers.length - 1] : null;
|
|
9971
10034
|
}
|
|
9972
10035
|
clearSelection() {
|
|
10036
|
+
this.clearSelectionState();
|
|
10037
|
+
this.lastClick = null;
|
|
10038
|
+
}
|
|
10039
|
+
clearSelectionState() {
|
|
9973
10040
|
if (this.currentSelection) {
|
|
9974
10041
|
for (const renderable of this.currentSelection.touchedRenderables) {
|
|
9975
10042
|
if (renderable.selectable && !renderable.isDestroyed) {
|
|
@@ -9980,15 +10047,23 @@ Captured external output:
|
|
|
9980
10047
|
}
|
|
9981
10048
|
this.selectionContainers = [];
|
|
9982
10049
|
}
|
|
9983
|
-
startSelection(renderable, x, y) {
|
|
10050
|
+
startSelection(renderable, x, y, behavior = "cell") {
|
|
9984
10051
|
if (!renderable.selectable)
|
|
9985
10052
|
return;
|
|
9986
|
-
this.
|
|
10053
|
+
this.clearSelectionState();
|
|
9987
10054
|
this.selectionContainers.push(renderable.parent || this.root);
|
|
9988
|
-
this.currentSelection = new Selection(renderable, { x, y }, { x, y });
|
|
10055
|
+
this.currentSelection = new Selection(renderable, { x, y }, { x, y }, behavior);
|
|
9989
10056
|
this.currentSelection.isStart = true;
|
|
9990
10057
|
this.notifySelectablesOfSelectionChange();
|
|
9991
10058
|
}
|
|
10059
|
+
nextClickBehavior(renderable, x, y) {
|
|
10060
|
+
const now = this.clock.now();
|
|
10061
|
+
const last = this.lastClick;
|
|
10062
|
+
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;
|
|
10063
|
+
const count = continued ? Math.min(last.count + 1, 3) : 1;
|
|
10064
|
+
this.lastClick = { count, time: now, x, y, renderableId: renderable.num };
|
|
10065
|
+
return count === 1 ? "cell" : count === 2 ? "word" : "line";
|
|
10066
|
+
}
|
|
9992
10067
|
updateSelection(currentRenderable, x, y, options) {
|
|
9993
10068
|
if (this.currentSelection) {
|
|
9994
10069
|
this.currentSelection.isStart = false;
|
|
@@ -10234,5 +10309,5 @@ Captured external output:
|
|
|
10234
10309
|
|
|
10235
10310
|
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
10311
|
|
|
10237
|
-
//# debugId=
|
|
10238
|
-
//# sourceMappingURL=chunk-node-
|
|
10312
|
+
//# debugId=738652C7CB134A7264756E2164756E21
|
|
10313
|
+
//# sourceMappingURL=chunk-node-591ssncm.js.map
|