@opentui/core 0.5.4 → 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/README.md +1 -1
- package/buffer.d.ts +2 -2
- package/{chunk-bun-1n307cze.js → chunk-bun-xmsp0nqq.js} +551 -221
- package/{chunk-bun-1n307cze.js.map → chunk-bun-xmsp0nqq.js.map} +8 -8
- package/{chunk-bun-gvv8cwwz.js → chunk-bun-z4gs6jzg.js} +129 -54
- package/chunk-bun-z4gs6jzg.js.map +32 -0
- package/{chunk-node-crchpns1.js → chunk-node-267dafd8.js} +551 -221
- package/{chunk-node-crchpns1.js.map → chunk-node-267dafd8.js.map} +8 -8
- package/{chunk-node-tq0x9mbj.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 +377 -4
- package/index.bun.js.map +5 -4
- package/index.node.js +377 -4
- package/index.node.js.map +5 -3
- package/lib/selection.d.ts +4 -2
- package/package.json +9 -9
- package/renderables/EditBufferRenderable.d.ts +5 -1
- package/renderables/EmbeddedTerminal.d.ts +67 -0
- package/renderables/index.d.ts +1 -0
- 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-structs.d.ts +2 -0
- package/zig.d.ts +76 -11
- package/chunk-bun-gvv8cwwz.js.map +0 -32
- package/chunk-node-tq0x9mbj.js.map +0 -32
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
toArrayBuffer,
|
|
42
42
|
treeSitterToTextChunks,
|
|
43
43
|
yoga_default
|
|
44
|
-
} from "./chunk-bun-
|
|
44
|
+
} from "./chunk-bun-xmsp0nqq.js";
|
|
45
45
|
|
|
46
46
|
// src/Renderable.ts
|
|
47
47
|
import { EventEmitter } from "events";
|
|
@@ -1686,18 +1686,26 @@ class TextBufferView {
|
|
|
1686
1686
|
this.guard();
|
|
1687
1687
|
return this.getSelection() !== null;
|
|
1688
1688
|
}
|
|
1689
|
-
setLocalSelection(anchorX, anchorY, focusX, focusY, bgColor, fgColor) {
|
|
1689
|
+
setLocalSelection(anchorX, anchorY, focusX, focusY, bgColor, fgColor, behavior = "cell") {
|
|
1690
1690
|
this.guard();
|
|
1691
|
-
return this.lib.textBufferViewSetLocalSelection(this.viewPtr, anchorX, anchorY, focusX, focusY, bgColor || null, fgColor || null);
|
|
1691
|
+
return this.lib.textBufferViewSetLocalSelection(this.viewPtr, anchorX, anchorY, focusX, focusY, bgColor || null, fgColor || null, behavior);
|
|
1692
1692
|
}
|
|
1693
|
-
updateLocalSelection(anchorX, anchorY, focusX, focusY, bgColor, fgColor) {
|
|
1693
|
+
updateLocalSelection(anchorX, anchorY, focusX, focusY, bgColor, fgColor, behavior = "cell") {
|
|
1694
1694
|
this.guard();
|
|
1695
|
-
return this.lib.textBufferViewUpdateLocalSelection(this.viewPtr, anchorX, anchorY, focusX, focusY, bgColor || null, fgColor || null);
|
|
1695
|
+
return this.lib.textBufferViewUpdateLocalSelection(this.viewPtr, anchorX, anchorY, focusX, focusY, bgColor || null, fgColor || null, behavior);
|
|
1696
1696
|
}
|
|
1697
1697
|
resetLocalSelection() {
|
|
1698
1698
|
this.guard();
|
|
1699
1699
|
this.lib.textBufferViewResetLocalSelection(this.viewPtr);
|
|
1700
1700
|
}
|
|
1701
|
+
setSelectionOccupancy(occupancy) {
|
|
1702
|
+
this.guard();
|
|
1703
|
+
this.lib.textBufferViewSetSelectionOccupancy(this.viewPtr, occupancy);
|
|
1704
|
+
}
|
|
1705
|
+
getSelectionOccupancy() {
|
|
1706
|
+
this.guard();
|
|
1707
|
+
return this.lib.textBufferViewGetSelectionOccupancy(this.viewPtr);
|
|
1708
|
+
}
|
|
1701
1709
|
setWrapWidth(width) {
|
|
1702
1710
|
this.guard();
|
|
1703
1711
|
this.lib.textBufferViewSetWrapWidth(this.viewPtr, width ?? 0);
|
|
@@ -2162,18 +2170,39 @@ class EditorView {
|
|
|
2162
2170
|
this.guard();
|
|
2163
2171
|
return this.getSelection() !== null;
|
|
2164
2172
|
}
|
|
2165
|
-
setLocalSelection(anchorX, anchorY, focusX, focusY, bgColor, fgColor, updateCursor, followCursor) {
|
|
2173
|
+
setLocalSelection(anchorX, anchorY, focusX, focusY, bgColor, fgColor, updateCursor, followCursor, behavior = "cell") {
|
|
2166
2174
|
this.guard();
|
|
2167
|
-
return this.lib.editorViewSetLocalSelection(this.viewPtr, anchorX, anchorY, focusX, focusY, bgColor || null, fgColor || null, updateCursor ?? false, followCursor ?? false);
|
|
2175
|
+
return this.lib.editorViewSetLocalSelection(this.viewPtr, anchorX, anchorY, focusX, focusY, bgColor || null, fgColor || null, updateCursor ?? false, followCursor ?? false, behavior);
|
|
2168
2176
|
}
|
|
2169
|
-
updateLocalSelection(anchorX, anchorY, focusX, focusY, bgColor, fgColor, updateCursor, followCursor) {
|
|
2177
|
+
updateLocalSelection(anchorX, anchorY, focusX, focusY, bgColor, fgColor, updateCursor, followCursor, behavior = "cell") {
|
|
2170
2178
|
this.guard();
|
|
2171
|
-
return this.lib.editorViewUpdateLocalSelection(this.viewPtr, anchorX, anchorY, focusX, focusY, bgColor || null, fgColor || null, updateCursor ?? false, followCursor ?? false);
|
|
2179
|
+
return this.lib.editorViewUpdateLocalSelection(this.viewPtr, anchorX, anchorY, focusX, focusY, bgColor || null, fgColor || null, updateCursor ?? false, followCursor ?? false, behavior);
|
|
2172
2180
|
}
|
|
2173
2181
|
resetLocalSelection() {
|
|
2174
2182
|
this.guard();
|
|
2175
2183
|
this.lib.editorViewResetLocalSelection(this.viewPtr);
|
|
2176
2184
|
}
|
|
2185
|
+
convertSelectionToCell() {
|
|
2186
|
+
this.guard();
|
|
2187
|
+
return this.lib.editorViewConvertSelectionToCell(this.viewPtr);
|
|
2188
|
+
}
|
|
2189
|
+
setSelectionOccupancy(occupancy) {
|
|
2190
|
+
this.guard();
|
|
2191
|
+
this.lib.editorViewSetSelectionOccupancy(this.viewPtr, occupancy);
|
|
2192
|
+
}
|
|
2193
|
+
getSelectionOccupancy() {
|
|
2194
|
+
this.guard();
|
|
2195
|
+
this._textBufferViewPtr ??= this.lib.editorViewGetTextBufferView(this.viewPtr);
|
|
2196
|
+
return this.lib.textBufferViewGetSelectionOccupancy(this._textBufferViewPtr);
|
|
2197
|
+
}
|
|
2198
|
+
setSelectionInclusive(start, end, bgColor, fgColor) {
|
|
2199
|
+
this.guard();
|
|
2200
|
+
this.lib.editorViewSetSelectionInclusive(this.viewPtr, start, end, bgColor || null, fgColor || null);
|
|
2201
|
+
}
|
|
2202
|
+
setSelectionColors(bgColor, fgColor) {
|
|
2203
|
+
this.guard();
|
|
2204
|
+
this.lib.editorViewSetSelectionColors(this.viewPtr, bgColor || null, fgColor || null);
|
|
2205
|
+
}
|
|
2177
2206
|
getSelectedText() {
|
|
2178
2207
|
this.guard();
|
|
2179
2208
|
const maxLength = 1024 * 1024;
|
|
@@ -2234,6 +2263,10 @@ class EditorView {
|
|
|
2234
2263
|
this.guard();
|
|
2235
2264
|
return this.lib.editorViewGetVisualEOL(this.viewPtr);
|
|
2236
2265
|
}
|
|
2266
|
+
gotoVisualLineEnd() {
|
|
2267
|
+
this.guard();
|
|
2268
|
+
this.lib.editorViewGotoVisualLineEnd(this.viewPtr);
|
|
2269
|
+
}
|
|
2237
2270
|
getLineInfo() {
|
|
2238
2271
|
this.guard();
|
|
2239
2272
|
return this.lib.editorViewGetLineInfo(this.viewPtr);
|
|
@@ -2263,9 +2296,7 @@ class EditorView {
|
|
|
2263
2296
|
}
|
|
2264
2297
|
measureForDimensions(width, height) {
|
|
2265
2298
|
this.guard();
|
|
2266
|
-
|
|
2267
|
-
this._textBufferViewPtr = this.lib.editorViewGetTextBufferView(this.viewPtr);
|
|
2268
|
-
}
|
|
2299
|
+
this._textBufferViewPtr ??= this.lib.editorViewGetTextBufferView(this.viewPtr);
|
|
2269
2300
|
return this.lib.textBufferViewMeasureForDimensions(this._textBufferViewPtr, width, height);
|
|
2270
2301
|
}
|
|
2271
2302
|
destroy() {
|
|
@@ -3016,7 +3047,7 @@ class TextBufferRenderable extends Renderable {
|
|
|
3016
3047
|
this.textBufferView.resetLocalSelection();
|
|
3017
3048
|
return true;
|
|
3018
3049
|
}
|
|
3019
|
-
return this.textBufferView.setLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg);
|
|
3050
|
+
return this.textBufferView.setLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg, localSelection.behavior);
|
|
3020
3051
|
}
|
|
3021
3052
|
updateTextInfo() {
|
|
3022
3053
|
if (this.lastLocalSelection) {
|
|
@@ -3054,9 +3085,9 @@ class TextBufferRenderable extends Renderable {
|
|
|
3054
3085
|
this.textBufferView.resetLocalSelection();
|
|
3055
3086
|
changed = true;
|
|
3056
3087
|
} else if (selection?.isStart) {
|
|
3057
|
-
changed = this.textBufferView.setLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg);
|
|
3088
|
+
changed = this.textBufferView.setLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg, localSelection.behavior);
|
|
3058
3089
|
} else {
|
|
3059
|
-
changed = this.textBufferView.updateLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg);
|
|
3090
|
+
changed = this.textBufferView.updateLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg, localSelection.behavior);
|
|
3060
3091
|
}
|
|
3061
3092
|
if (changed) {
|
|
3062
3093
|
this.requestRender();
|
|
@@ -5535,6 +5566,9 @@ class EditBufferRenderable extends Renderable {
|
|
|
5535
5566
|
this.editorView = EditorView.create(this.editBuffer, this.width || 80, this.height || 24);
|
|
5536
5567
|
this.editorView.setWrapMode(this._wrapMode);
|
|
5537
5568
|
this.editorView.setScrollMargin(this._scrollMargin);
|
|
5569
|
+
if (options.selectionOccupancy === "boundary") {
|
|
5570
|
+
this.editorView.setSelectionOccupancy("boundary");
|
|
5571
|
+
}
|
|
5538
5572
|
this.editBuffer.setDefaultFg(this._textColor);
|
|
5539
5573
|
this.editBuffer.setDefaultBg(this._backgroundColor);
|
|
5540
5574
|
this.editBuffer.setDefaultAttributes(this._defaultAttributes);
|
|
@@ -5596,6 +5630,7 @@ class EditBufferRenderable extends Renderable {
|
|
|
5596
5630
|
return this.editorView.getVisualCursor().offset;
|
|
5597
5631
|
}
|
|
5598
5632
|
set cursorOffset(offset) {
|
|
5633
|
+
this.clearSelection();
|
|
5599
5634
|
this.editorView.setCursorByOffset(offset);
|
|
5600
5635
|
this.requestRender();
|
|
5601
5636
|
}
|
|
@@ -5727,6 +5762,16 @@ class EditBufferRenderable extends Renderable {
|
|
|
5727
5762
|
}
|
|
5728
5763
|
}
|
|
5729
5764
|
}
|
|
5765
|
+
get selectionOccupancy() {
|
|
5766
|
+
return this.editorView.getSelectionOccupancy();
|
|
5767
|
+
}
|
|
5768
|
+
set selectionOccupancy(value) {
|
|
5769
|
+
const occupancy = value ?? "cell";
|
|
5770
|
+
if (this.selectionOccupancy === occupancy)
|
|
5771
|
+
return;
|
|
5772
|
+
this.editorView.setSelectionOccupancy(occupancy);
|
|
5773
|
+
this.requestRender();
|
|
5774
|
+
}
|
|
5730
5775
|
get tabIndicator() {
|
|
5731
5776
|
return this._tabIndicator;
|
|
5732
5777
|
}
|
|
@@ -5805,7 +5850,7 @@ class EditBufferRenderable extends Renderable {
|
|
|
5805
5850
|
this.editorView.resetLocalSelection();
|
|
5806
5851
|
return true;
|
|
5807
5852
|
}
|
|
5808
|
-
return this.editorView.setLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg, false);
|
|
5853
|
+
return this.editorView.setLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg, false, false, localSelection.behavior);
|
|
5809
5854
|
}
|
|
5810
5855
|
shouldStartSelection(x, y) {
|
|
5811
5856
|
if (!this.selectable)
|
|
@@ -5825,9 +5870,9 @@ class EditBufferRenderable extends Renderable {
|
|
|
5825
5870
|
this.editorView.resetLocalSelection();
|
|
5826
5871
|
changed = true;
|
|
5827
5872
|
} else if (selection?.isStart) {
|
|
5828
|
-
changed = this.editorView.setLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg, updateCursor, followCursor);
|
|
5873
|
+
changed = this.editorView.setLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg, updateCursor, followCursor, localSelection.behavior);
|
|
5829
5874
|
} else {
|
|
5830
|
-
changed = this.editorView.updateLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg, updateCursor, followCursor);
|
|
5875
|
+
changed = this.editorView.updateLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg, updateCursor, followCursor, localSelection.behavior);
|
|
5831
5876
|
}
|
|
5832
5877
|
if (changed && localSelection?.isActive && selection?.isDragging) {
|
|
5833
5878
|
const viewport = this.editorView.getViewport();
|
|
@@ -5880,14 +5925,7 @@ class EditBufferRenderable extends Renderable {
|
|
|
5880
5925
|
return this.editorView.getSelection();
|
|
5881
5926
|
}
|
|
5882
5927
|
refreshSelectionStyle() {
|
|
5883
|
-
|
|
5884
|
-
this.updateLocalSelection(this.lastLocalSelection);
|
|
5885
|
-
return;
|
|
5886
|
-
}
|
|
5887
|
-
const selection = this.getSelection();
|
|
5888
|
-
if (!selection)
|
|
5889
|
-
return;
|
|
5890
|
-
this.editorView.setSelection(selection.start, selection.end, this._selectionBg, this._selectionFg);
|
|
5928
|
+
this.editorView.setSelectionColors(this._selectionBg, this._selectionFg);
|
|
5891
5929
|
}
|
|
5892
5930
|
deleteSelectedText() {
|
|
5893
5931
|
this.editorView.deleteSelectedText();
|
|
@@ -5902,12 +5940,15 @@ class EditBufferRenderable extends Renderable {
|
|
|
5902
5940
|
this.requestRender();
|
|
5903
5941
|
}
|
|
5904
5942
|
setSelectionInclusive(start, end) {
|
|
5905
|
-
this.
|
|
5943
|
+
this.lastLocalSelection = null;
|
|
5944
|
+
this.editorView.resetLocalSelection();
|
|
5945
|
+
this._ctx.clearSelection();
|
|
5946
|
+
this.editorView.setSelectionInclusive(start, end, this._selectionBg, this._selectionFg);
|
|
5947
|
+
this.requestRender();
|
|
5906
5948
|
}
|
|
5907
5949
|
clearSelection() {
|
|
5908
5950
|
const had = this.hasSelection();
|
|
5909
5951
|
this.lastLocalSelection = null;
|
|
5910
|
-
this.editorView.resetSelection();
|
|
5911
5952
|
this.editorView.resetLocalSelection();
|
|
5912
5953
|
this._ctx.clearSelection();
|
|
5913
5954
|
if (had) {
|
|
@@ -5923,6 +5964,7 @@ class EditBufferRenderable extends Renderable {
|
|
|
5923
5964
|
return true;
|
|
5924
5965
|
}
|
|
5925
5966
|
setCursor(row, col) {
|
|
5967
|
+
this.clearSelection();
|
|
5926
5968
|
this.editBuffer.setCursor(row, col);
|
|
5927
5969
|
this.requestRender();
|
|
5928
5970
|
}
|
|
@@ -5972,15 +6014,18 @@ class EditBufferRenderable extends Renderable {
|
|
|
5972
6014
|
this.requestRender();
|
|
5973
6015
|
return true;
|
|
5974
6016
|
}
|
|
6017
|
+
collapseSelectionToEdge(edge) {
|
|
6018
|
+
const selection = this.getSelection();
|
|
6019
|
+
if (!selection)
|
|
6020
|
+
return false;
|
|
6021
|
+
this.editBuffer.setCursorByOffset(edge === "start" ? selection.start : selection.end);
|
|
6022
|
+
this.clearSelection();
|
|
6023
|
+
return true;
|
|
6024
|
+
}
|
|
5975
6025
|
moveCursorLeft(options) {
|
|
5976
6026
|
const select = options?.select ?? false;
|
|
5977
|
-
if (!select && this.
|
|
5978
|
-
const selection = this.getSelection();
|
|
5979
|
-
this.editBuffer.setCursorByOffset(selection.start);
|
|
5980
|
-
this._ctx.clearSelection();
|
|
5981
|
-
this.requestRender();
|
|
6027
|
+
if (!select && this.collapseSelectionToEdge("start"))
|
|
5982
6028
|
return true;
|
|
5983
|
-
}
|
|
5984
6029
|
this.updateSelectionForMovement(select, true);
|
|
5985
6030
|
this.editBuffer.moveCursorLeft();
|
|
5986
6031
|
this.updateSelectionForMovement(select, false);
|
|
@@ -5989,14 +6034,8 @@ class EditBufferRenderable extends Renderable {
|
|
|
5989
6034
|
}
|
|
5990
6035
|
moveCursorRight(options) {
|
|
5991
6036
|
const select = options?.select ?? false;
|
|
5992
|
-
if (!select && this.
|
|
5993
|
-
const selection = this.getSelection();
|
|
5994
|
-
const targetOffset = this.cursorOffset === selection.start ? selection.end - 1 : selection.end;
|
|
5995
|
-
this.editBuffer.setCursorByOffset(targetOffset);
|
|
5996
|
-
this._ctx.clearSelection();
|
|
5997
|
-
this.requestRender();
|
|
6037
|
+
if (!select && this.collapseSelectionToEdge("end"))
|
|
5998
6038
|
return true;
|
|
5999
|
-
}
|
|
6000
6039
|
this.updateSelectionForMovement(select, true);
|
|
6001
6040
|
this.editBuffer.moveCursorRight();
|
|
6002
6041
|
this.updateSelectionForMovement(select, false);
|
|
@@ -6020,6 +6059,7 @@ class EditBufferRenderable extends Renderable {
|
|
|
6020
6059
|
return true;
|
|
6021
6060
|
}
|
|
6022
6061
|
gotoLine(line) {
|
|
6062
|
+
this.clearSelection();
|
|
6023
6063
|
this.editBuffer.gotoLine(line);
|
|
6024
6064
|
this.requestRender();
|
|
6025
6065
|
}
|
|
@@ -6032,6 +6072,8 @@ class EditBufferRenderable extends Renderable {
|
|
|
6032
6072
|
}
|
|
6033
6073
|
gotoLineHome(options) {
|
|
6034
6074
|
const select = options?.select ?? false;
|
|
6075
|
+
if (!select && this.collapseSelectionToEdge("start"))
|
|
6076
|
+
return true;
|
|
6035
6077
|
this.updateSelectionForMovement(select, true);
|
|
6036
6078
|
const cursor = this.editorView.getCursor();
|
|
6037
6079
|
if (cursor.col === 0 && cursor.row > 0) {
|
|
@@ -6047,6 +6089,8 @@ class EditBufferRenderable extends Renderable {
|
|
|
6047
6089
|
}
|
|
6048
6090
|
gotoLineEnd(options) {
|
|
6049
6091
|
const select = options?.select ?? false;
|
|
6092
|
+
if (!select && this.collapseSelectionToEdge("end"))
|
|
6093
|
+
return true;
|
|
6050
6094
|
this.updateSelectionForMovement(select, true);
|
|
6051
6095
|
const cursor = this.editorView.getCursor();
|
|
6052
6096
|
const eol = this.editBuffer.getEOL();
|
|
@@ -6062,6 +6106,8 @@ class EditBufferRenderable extends Renderable {
|
|
|
6062
6106
|
}
|
|
6063
6107
|
gotoVisualLineHome(options) {
|
|
6064
6108
|
const select = options?.select ?? false;
|
|
6109
|
+
if (!select && this.collapseSelectionToEdge("start"))
|
|
6110
|
+
return true;
|
|
6065
6111
|
this.updateSelectionForMovement(select, true);
|
|
6066
6112
|
const sol = this.editorView.getVisualSOL();
|
|
6067
6113
|
this.editBuffer.setCursor(sol.logicalRow, sol.logicalCol);
|
|
@@ -6071,15 +6117,18 @@ class EditBufferRenderable extends Renderable {
|
|
|
6071
6117
|
}
|
|
6072
6118
|
gotoVisualLineEnd(options) {
|
|
6073
6119
|
const select = options?.select ?? false;
|
|
6120
|
+
if (!select && this.collapseSelectionToEdge("end"))
|
|
6121
|
+
return true;
|
|
6074
6122
|
this.updateSelectionForMovement(select, true);
|
|
6075
|
-
|
|
6076
|
-
this.editBuffer.setCursor(eol.logicalRow, eol.logicalCol);
|
|
6123
|
+
this.editorView.gotoVisualLineEnd();
|
|
6077
6124
|
this.updateSelectionForMovement(select, false);
|
|
6078
6125
|
this.requestRender();
|
|
6079
6126
|
return true;
|
|
6080
6127
|
}
|
|
6081
6128
|
gotoBufferHome(options) {
|
|
6082
6129
|
const select = options?.select ?? false;
|
|
6130
|
+
if (!select && this.collapseSelectionToEdge("start"))
|
|
6131
|
+
return true;
|
|
6083
6132
|
this.updateSelectionForMovement(select, true);
|
|
6084
6133
|
this.editBuffer.setCursor(0, 0);
|
|
6085
6134
|
this.updateSelectionForMovement(select, false);
|
|
@@ -6088,6 +6137,8 @@ class EditBufferRenderable extends Renderable {
|
|
|
6088
6137
|
}
|
|
6089
6138
|
gotoBufferEnd(options) {
|
|
6090
6139
|
const select = options?.select ?? false;
|
|
6140
|
+
if (!select && this.collapseSelectionToEdge("end"))
|
|
6141
|
+
return true;
|
|
6091
6142
|
this.updateSelectionForMovement(select, true);
|
|
6092
6143
|
this.editBuffer.gotoLine(999999);
|
|
6093
6144
|
this.updateSelectionForMovement(select, false);
|
|
@@ -6132,6 +6183,8 @@ class EditBufferRenderable extends Renderable {
|
|
|
6132
6183
|
}
|
|
6133
6184
|
moveWordForward(options) {
|
|
6134
6185
|
const select = options?.select ?? false;
|
|
6186
|
+
if (!select && this.collapseSelectionToEdge("end"))
|
|
6187
|
+
return true;
|
|
6135
6188
|
this.updateSelectionForMovement(select, true);
|
|
6136
6189
|
const nextWord = this.editBuffer.getNextWordBoundary();
|
|
6137
6190
|
this.editBuffer.setCursorByOffset(nextWord.offset);
|
|
@@ -6141,6 +6194,8 @@ class EditBufferRenderable extends Renderable {
|
|
|
6141
6194
|
}
|
|
6142
6195
|
moveWordBackward(options) {
|
|
6143
6196
|
const select = options?.select ?? false;
|
|
6197
|
+
if (!select && this.collapseSelectionToEdge("start"))
|
|
6198
|
+
return true;
|
|
6144
6199
|
this.updateSelectionForMovement(select, true);
|
|
6145
6200
|
const prevWord = this.editBuffer.getPrevWordBoundary();
|
|
6146
6201
|
this.editBuffer.setCursorByOffset(prevWord.offset);
|
|
@@ -6316,20 +6371,26 @@ class EditBufferRenderable extends Renderable {
|
|
|
6316
6371
|
return this.editBuffer.getTextRangeByCoords(startRow, startCol, endRow, endCol);
|
|
6317
6372
|
}
|
|
6318
6373
|
updateSelectionForMovement(shiftPressed, isBeforeMovement) {
|
|
6319
|
-
if (!this.selectable)
|
|
6320
|
-
return;
|
|
6321
6374
|
if (!shiftPressed) {
|
|
6322
6375
|
this._keyboardSelectionActive = false;
|
|
6323
|
-
this.
|
|
6376
|
+
this.clearSelection();
|
|
6324
6377
|
return;
|
|
6325
6378
|
}
|
|
6379
|
+
if (!this.selectable)
|
|
6380
|
+
return;
|
|
6326
6381
|
this._keyboardSelectionActive = true;
|
|
6327
6382
|
const visualCursor = this.editorView.getVisualCursor();
|
|
6328
6383
|
const cursorX = this.x + visualCursor.visualCol;
|
|
6329
6384
|
const cursorY = this.y + visualCursor.visualRow;
|
|
6330
6385
|
if (isBeforeMovement) {
|
|
6331
|
-
if (!this._ctx.hasSelection) {
|
|
6386
|
+
if (!this._ctx.hasSelection || !this.hasSelection()) {
|
|
6332
6387
|
this._ctx.startSelection(this, cursorX, cursorY);
|
|
6388
|
+
} else if (this._ctx.getSelection()?.behavior !== "cell") {
|
|
6389
|
+
if (this.editorView.convertSelectionToCell()) {
|
|
6390
|
+
const selection = this._ctx.getSelection();
|
|
6391
|
+
if (selection)
|
|
6392
|
+
selection.behavior = "cell";
|
|
6393
|
+
}
|
|
6333
6394
|
}
|
|
6334
6395
|
return;
|
|
6335
6396
|
}
|
|
@@ -6858,7 +6919,7 @@ class ScrollbackSnapshotRenderContext extends EventEmitter5 {
|
|
|
6858
6919
|
return this.lifecyclePasses;
|
|
6859
6920
|
}
|
|
6860
6921
|
clearSelection() {}
|
|
6861
|
-
startSelection(_renderable, _x, _y) {}
|
|
6922
|
+
startSelection(_renderable, _x, _y, _behavior) {}
|
|
6862
6923
|
updateSelection(_currentRenderable, _x, _y, _options) {}
|
|
6863
6924
|
}
|
|
6864
6925
|
var DEFAULT_FORWARDED_ENV_KEYS = [
|
|
@@ -7022,6 +7083,7 @@ var RendererControlState;
|
|
|
7022
7083
|
RendererControlState2["EXPLICIT_SUSPENDED"] = "explicit_suspended";
|
|
7023
7084
|
RendererControlState2["EXPLICIT_STOPPED"] = "explicit_stopped";
|
|
7024
7085
|
})(RendererControlState ||= {});
|
|
7086
|
+
var CLICK_REPEAT_INTERVAL_MS = 500;
|
|
7025
7087
|
|
|
7026
7088
|
class CliRenderer extends EventEmitter5 {
|
|
7027
7089
|
static animationFrameId = 0;
|
|
@@ -7117,6 +7179,7 @@ class CliRenderer extends EventEmitter5 {
|
|
|
7117
7179
|
lastOverRenderable;
|
|
7118
7180
|
currentSelection = null;
|
|
7119
7181
|
selectionContainers = [];
|
|
7182
|
+
lastClick = null;
|
|
7120
7183
|
clipboard;
|
|
7121
7184
|
_splitHeight = 0;
|
|
7122
7185
|
renderOffset = 0;
|
|
@@ -9089,7 +9152,7 @@ Captured external output:
|
|
|
9089
9152
|
if (mouseEvent.type === "down" && mouseEvent.button === 0 /* LEFT */ && !this.currentSelection?.isDragging && !mouseEvent.modifiers.ctrl) {
|
|
9090
9153
|
const canStartSelection = Boolean(maybeRenderable && maybeRenderable.selectable && !maybeRenderable.isDestroyed && maybeRenderable.shouldStartSelection(mouseEvent.x, mouseEvent.y));
|
|
9091
9154
|
if (canStartSelection && maybeRenderable) {
|
|
9092
|
-
this.startSelection(maybeRenderable, mouseEvent.x, mouseEvent.y);
|
|
9155
|
+
this.startSelection(maybeRenderable, mouseEvent.x, mouseEvent.y, this.nextClickBehavior(maybeRenderable, mouseEvent.x, mouseEvent.y));
|
|
9093
9156
|
this.dispatchMouseEvent(maybeRenderable, mouseEvent);
|
|
9094
9157
|
return true;
|
|
9095
9158
|
}
|
|
@@ -9971,6 +10034,10 @@ Captured external output:
|
|
|
9971
10034
|
return this.selectionContainers.length > 0 ? this.selectionContainers[this.selectionContainers.length - 1] : null;
|
|
9972
10035
|
}
|
|
9973
10036
|
clearSelection() {
|
|
10037
|
+
this.clearSelectionState();
|
|
10038
|
+
this.lastClick = null;
|
|
10039
|
+
}
|
|
10040
|
+
clearSelectionState() {
|
|
9974
10041
|
if (this.currentSelection) {
|
|
9975
10042
|
for (const renderable of this.currentSelection.touchedRenderables) {
|
|
9976
10043
|
if (renderable.selectable && !renderable.isDestroyed) {
|
|
@@ -9981,15 +10048,23 @@ Captured external output:
|
|
|
9981
10048
|
}
|
|
9982
10049
|
this.selectionContainers = [];
|
|
9983
10050
|
}
|
|
9984
|
-
startSelection(renderable, x, y) {
|
|
10051
|
+
startSelection(renderable, x, y, behavior = "cell") {
|
|
9985
10052
|
if (!renderable.selectable)
|
|
9986
10053
|
return;
|
|
9987
|
-
this.
|
|
10054
|
+
this.clearSelectionState();
|
|
9988
10055
|
this.selectionContainers.push(renderable.parent || this.root);
|
|
9989
|
-
this.currentSelection = new Selection(renderable, { x, y }, { x, y });
|
|
10056
|
+
this.currentSelection = new Selection(renderable, { x, y }, { x, y }, behavior);
|
|
9990
10057
|
this.currentSelection.isStart = true;
|
|
9991
10058
|
this.notifySelectablesOfSelectionChange();
|
|
9992
10059
|
}
|
|
10060
|
+
nextClickBehavior(renderable, x, y) {
|
|
10061
|
+
const now = this.clock.now();
|
|
10062
|
+
const last = this.lastClick;
|
|
10063
|
+
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;
|
|
10064
|
+
const count = continued ? Math.min(last.count + 1, 3) : 1;
|
|
10065
|
+
this.lastClick = { count, time: now, x, y, renderableId: renderable.num };
|
|
10066
|
+
return count === 1 ? "cell" : count === 2 ? "word" : "line";
|
|
10067
|
+
}
|
|
9993
10068
|
updateSelection(currentRenderable, x, y, options) {
|
|
9994
10069
|
if (this.currentSelection) {
|
|
9995
10070
|
this.currentSelection.isStart = false;
|
|
@@ -10235,5 +10310,5 @@ Captured external output:
|
|
|
10235
10310
|
|
|
10236
10311
|
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 };
|
|
10237
10312
|
|
|
10238
|
-
//# debugId=
|
|
10239
|
-
//# sourceMappingURL=chunk-bun-
|
|
10313
|
+
//# debugId=EED85776C714E18564756E2164756E21
|
|
10314
|
+
//# sourceMappingURL=chunk-bun-z4gs6jzg.js.map
|