@opentui/core 0.1.29 → 0.1.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/3d.js +1 -1
- package/edit-buffer.d.ts +4 -0
- package/editor-view.d.ts +3 -0
- package/{index-bztetjc3.js → index-0qmm1k4p.js} +80 -20
- package/{index-bztetjc3.js.map → index-0qmm1k4p.js.map} +4 -4
- package/index.js +284 -113
- package/index.js.map +8 -7
- package/lib/keymapping.d.ts +10 -0
- package/package.json +7 -7
- package/renderables/EditBufferRenderable.d.ts +8 -1
- package/renderables/Textarea.d.ts +43 -22
- package/testing/mock-keys.d.ts +29 -2
- package/testing.js +41 -4
- package/testing.js.map +3 -3
- package/zig-structs.d.ts +2 -0
- package/zig.d.ts +19 -0
package/index.js
CHANGED
|
@@ -131,7 +131,7 @@ import {
|
|
|
131
131
|
white,
|
|
132
132
|
wrapWithDelegates,
|
|
133
133
|
yellow
|
|
134
|
-
} from "./index-
|
|
134
|
+
} from "./index-0qmm1k4p.js";
|
|
135
135
|
// src/text-buffer-view.ts
|
|
136
136
|
class TextBufferView {
|
|
137
137
|
lib;
|
|
@@ -329,6 +329,10 @@ class EditBuffer extends EventEmitter {
|
|
|
329
329
|
this.guard();
|
|
330
330
|
this.lib.editBufferDeleteCharBackward(this.bufferPtr);
|
|
331
331
|
}
|
|
332
|
+
deleteRange(startLine, startCol, endLine, endCol) {
|
|
333
|
+
this.guard();
|
|
334
|
+
this.lib.editBufferDeleteRange(this.bufferPtr, startLine, startCol, endLine, endCol);
|
|
335
|
+
}
|
|
332
336
|
newLine() {
|
|
333
337
|
this.guard();
|
|
334
338
|
this.lib.editBufferNewLine(this.bufferPtr);
|
|
@@ -373,6 +377,33 @@ class EditBuffer extends EventEmitter {
|
|
|
373
377
|
this.guard();
|
|
374
378
|
return this.lib.editBufferGetCursorPosition(this.bufferPtr);
|
|
375
379
|
}
|
|
380
|
+
getNextWordBoundary() {
|
|
381
|
+
this.guard();
|
|
382
|
+
const boundary = this.lib.editBufferGetNextWordBoundary(this.bufferPtr);
|
|
383
|
+
return {
|
|
384
|
+
line: boundary.row,
|
|
385
|
+
visualColumn: boundary.col,
|
|
386
|
+
offset: boundary.offset
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
getPrevWordBoundary() {
|
|
390
|
+
this.guard();
|
|
391
|
+
const boundary = this.lib.editBufferGetPrevWordBoundary(this.bufferPtr);
|
|
392
|
+
return {
|
|
393
|
+
line: boundary.row,
|
|
394
|
+
visualColumn: boundary.col,
|
|
395
|
+
offset: boundary.offset
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
getEOL() {
|
|
399
|
+
this.guard();
|
|
400
|
+
const boundary = this.lib.editBufferGetEOL(this.bufferPtr);
|
|
401
|
+
return {
|
|
402
|
+
line: boundary.row,
|
|
403
|
+
visualColumn: boundary.col,
|
|
404
|
+
offset: boundary.offset
|
|
405
|
+
};
|
|
406
|
+
}
|
|
376
407
|
debugLogRope() {
|
|
377
408
|
this.guard();
|
|
378
409
|
this.lib.editBufferDebugLogRope(this.bufferPtr);
|
|
@@ -582,6 +613,18 @@ class EditorView {
|
|
|
582
613
|
this.guard();
|
|
583
614
|
this.lib.editorViewSetCursorByOffset(this.viewPtr, offset);
|
|
584
615
|
}
|
|
616
|
+
getNextWordBoundary() {
|
|
617
|
+
this.guard();
|
|
618
|
+
return this.lib.editorViewGetNextWordBoundary(this.viewPtr);
|
|
619
|
+
}
|
|
620
|
+
getPrevWordBoundary() {
|
|
621
|
+
this.guard();
|
|
622
|
+
return this.lib.editorViewGetPrevWordBoundary(this.viewPtr);
|
|
623
|
+
}
|
|
624
|
+
getEOL() {
|
|
625
|
+
this.guard();
|
|
626
|
+
return this.lib.editorViewGetEOL(this.viewPtr);
|
|
627
|
+
}
|
|
585
628
|
getLineInfo() {
|
|
586
629
|
this.guard();
|
|
587
630
|
const textBufferViewPtr = this.lib.editorViewGetTextBufferView(this.viewPtr);
|
|
@@ -5026,8 +5069,12 @@ class EditBufferRenderable extends Renderable {
|
|
|
5026
5069
|
get visualCursor() {
|
|
5027
5070
|
return this.editorView.getVisualCursor();
|
|
5028
5071
|
}
|
|
5072
|
+
get cursorOffset() {
|
|
5073
|
+
return this.editorView.getVisualCursor().offset;
|
|
5074
|
+
}
|
|
5029
5075
|
set cursorOffset(offset) {
|
|
5030
5076
|
this.editorView.setCursorByOffset(offset);
|
|
5077
|
+
this.requestRender();
|
|
5031
5078
|
}
|
|
5032
5079
|
get textColor() {
|
|
5033
5080
|
return this._textColor;
|
|
@@ -5247,9 +5294,94 @@ class EditBufferRenderable extends Renderable {
|
|
|
5247
5294
|
this.editBuffer.setSyntaxStyle(style);
|
|
5248
5295
|
this.requestRender();
|
|
5249
5296
|
}
|
|
5297
|
+
addHighlight(lineIdx, highlight) {
|
|
5298
|
+
this.editBuffer.addHighlight(lineIdx, highlight);
|
|
5299
|
+
this.requestRender();
|
|
5300
|
+
}
|
|
5301
|
+
addHighlightByCharRange(highlight) {
|
|
5302
|
+
this.editBuffer.addHighlightByCharRange(highlight);
|
|
5303
|
+
this.requestRender();
|
|
5304
|
+
}
|
|
5305
|
+
removeHighlightsByRef(hlRef) {
|
|
5306
|
+
this.editBuffer.removeHighlightsByRef(hlRef);
|
|
5307
|
+
this.requestRender();
|
|
5308
|
+
}
|
|
5309
|
+
clearLineHighlights(lineIdx) {
|
|
5310
|
+
this.editBuffer.clearLineHighlights(lineIdx);
|
|
5311
|
+
this.requestRender();
|
|
5312
|
+
}
|
|
5313
|
+
clearAllHighlights() {
|
|
5314
|
+
this.editBuffer.clearAllHighlights();
|
|
5315
|
+
this.requestRender();
|
|
5316
|
+
}
|
|
5317
|
+
getLineHighlights(lineIdx) {
|
|
5318
|
+
return this.editBuffer.getLineHighlights(lineIdx);
|
|
5319
|
+
}
|
|
5320
|
+
}
|
|
5321
|
+
|
|
5322
|
+
// src/lib/keymapping.ts
|
|
5323
|
+
function mergeKeyBindings(defaults, custom) {
|
|
5324
|
+
const map = new Map;
|
|
5325
|
+
for (const binding of defaults) {
|
|
5326
|
+
const key = getKeyBindingKey(binding);
|
|
5327
|
+
map.set(key, binding);
|
|
5328
|
+
}
|
|
5329
|
+
for (const binding of custom) {
|
|
5330
|
+
const key = getKeyBindingKey(binding);
|
|
5331
|
+
map.set(key, binding);
|
|
5332
|
+
}
|
|
5333
|
+
return Array.from(map.values());
|
|
5334
|
+
}
|
|
5335
|
+
function getKeyBindingKey(binding) {
|
|
5336
|
+
return `${binding.name}:${!!binding.ctrl}:${!!binding.shift}:${!!binding.meta}`;
|
|
5337
|
+
}
|
|
5338
|
+
function buildKeyBindingsMap(bindings) {
|
|
5339
|
+
const map = new Map;
|
|
5340
|
+
for (const binding of bindings) {
|
|
5341
|
+
const key = getKeyBindingKey(binding);
|
|
5342
|
+
map.set(key, binding.action);
|
|
5343
|
+
}
|
|
5344
|
+
return map;
|
|
5250
5345
|
}
|
|
5251
5346
|
|
|
5252
5347
|
// src/renderables/Textarea.ts
|
|
5348
|
+
var defaultTextareaKeybindings = [
|
|
5349
|
+
{ name: "left", action: "move-left" },
|
|
5350
|
+
{ name: "right", action: "move-right" },
|
|
5351
|
+
{ name: "up", action: "move-up" },
|
|
5352
|
+
{ name: "down", action: "move-down" },
|
|
5353
|
+
{ name: "left", shift: true, action: "select-left" },
|
|
5354
|
+
{ name: "right", shift: true, action: "select-right" },
|
|
5355
|
+
{ name: "up", shift: true, action: "select-up" },
|
|
5356
|
+
{ name: "down", shift: true, action: "select-down" },
|
|
5357
|
+
{ name: "home", action: "line-home" },
|
|
5358
|
+
{ name: "end", action: "line-end" },
|
|
5359
|
+
{ name: "home", shift: true, action: "select-line-home" },
|
|
5360
|
+
{ name: "end", shift: true, action: "select-line-end" },
|
|
5361
|
+
{ name: "a", ctrl: true, action: "buffer-home" },
|
|
5362
|
+
{ name: "e", ctrl: true, action: "buffer-end" },
|
|
5363
|
+
{ name: "d", ctrl: true, action: "delete-line" },
|
|
5364
|
+
{ name: "k", ctrl: true, action: "delete-to-line-end" },
|
|
5365
|
+
{ name: "backspace", action: "backspace" },
|
|
5366
|
+
{ name: "delete", action: "delete" },
|
|
5367
|
+
{ name: "return", action: "newline" },
|
|
5368
|
+
{ name: "enter", action: "newline" },
|
|
5369
|
+
{ name: "z", ctrl: true, action: "undo" },
|
|
5370
|
+
{ name: "Z", ctrl: true, shift: true, action: "redo" },
|
|
5371
|
+
{ name: "y", ctrl: true, action: "redo" },
|
|
5372
|
+
{ name: "f", meta: true, action: "word-forward" },
|
|
5373
|
+
{ name: "b", meta: true, action: "word-backward" },
|
|
5374
|
+
{ name: "right", meta: true, action: "word-forward" },
|
|
5375
|
+
{ name: "left", meta: true, action: "word-backward" },
|
|
5376
|
+
{ name: "F", meta: true, shift: true, action: "select-word-forward" },
|
|
5377
|
+
{ name: "B", meta: true, shift: true, action: "select-word-backward" },
|
|
5378
|
+
{ name: "right", meta: true, shift: true, action: "select-word-forward" },
|
|
5379
|
+
{ name: "left", meta: true, shift: true, action: "select-word-backward" },
|
|
5380
|
+
{ name: "d", meta: true, action: "delete-word-forward" },
|
|
5381
|
+
{ name: "backspace", meta: true, action: "delete-word-backward" },
|
|
5382
|
+
{ name: "w", ctrl: true, action: "delete-word-backward" }
|
|
5383
|
+
];
|
|
5384
|
+
|
|
5253
5385
|
class TextareaRenderable extends EditBufferRenderable {
|
|
5254
5386
|
_placeholder;
|
|
5255
5387
|
_unfocusedBackgroundColor;
|
|
@@ -5257,6 +5389,8 @@ class TextareaRenderable extends EditBufferRenderable {
|
|
|
5257
5389
|
_focusedBackgroundColor;
|
|
5258
5390
|
_focusedTextColor;
|
|
5259
5391
|
_placeholderColor;
|
|
5392
|
+
_keyBindingsMap;
|
|
5393
|
+
_actionHandlers;
|
|
5260
5394
|
static defaults = {
|
|
5261
5395
|
value: "",
|
|
5262
5396
|
backgroundColor: "transparent",
|
|
@@ -5280,11 +5414,45 @@ class TextareaRenderable extends EditBufferRenderable {
|
|
|
5280
5414
|
this._focusedTextColor = parseColor(options.focusedTextColor || options.textColor || defaults.focusedTextColor);
|
|
5281
5415
|
this._placeholder = options.placeholder ?? defaults.placeholder;
|
|
5282
5416
|
this._placeholderColor = parseColor(options.placeholderColor || defaults.placeholderColor);
|
|
5417
|
+
const mergedBindings = mergeKeyBindings(defaultTextareaKeybindings, options.keyBindings || []);
|
|
5418
|
+
this._keyBindingsMap = buildKeyBindingsMap(mergedBindings);
|
|
5419
|
+
this._actionHandlers = this.buildActionHandlers();
|
|
5283
5420
|
this.updateValue(options.value ?? defaults.value);
|
|
5284
5421
|
this.updateColors();
|
|
5285
5422
|
this.editBuffer.setPlaceholder(this._placeholder);
|
|
5286
5423
|
this.editBuffer.setPlaceholderColor(this._placeholderColor);
|
|
5287
5424
|
}
|
|
5425
|
+
buildActionHandlers() {
|
|
5426
|
+
return new Map([
|
|
5427
|
+
["move-left", () => this.moveCursorLeft()],
|
|
5428
|
+
["move-right", () => this.moveCursorRight()],
|
|
5429
|
+
["move-up", () => this.moveCursorUp()],
|
|
5430
|
+
["move-down", () => this.moveCursorDown()],
|
|
5431
|
+
["select-left", () => this.moveCursorLeft({ select: true })],
|
|
5432
|
+
["select-right", () => this.moveCursorRight({ select: true })],
|
|
5433
|
+
["select-up", () => this.moveCursorUp({ select: true })],
|
|
5434
|
+
["select-down", () => this.moveCursorDown({ select: true })],
|
|
5435
|
+
["line-home", () => this.gotoLineHome()],
|
|
5436
|
+
["line-end", () => this.gotoLineEnd()],
|
|
5437
|
+
["select-line-home", () => this.gotoLineHome({ select: true })],
|
|
5438
|
+
["select-line-end", () => this.gotoLineEnd({ select: true })],
|
|
5439
|
+
["buffer-home", () => this.gotoBufferHome()],
|
|
5440
|
+
["buffer-end", () => this.gotoBufferEnd()],
|
|
5441
|
+
["delete-line", () => this.deleteLine()],
|
|
5442
|
+
["delete-to-line-end", () => this.deleteToLineEnd()],
|
|
5443
|
+
["backspace", () => this.deleteCharBackward()],
|
|
5444
|
+
["delete", () => this.deleteChar()],
|
|
5445
|
+
["newline", () => this.newLine()],
|
|
5446
|
+
["undo", () => this.undo()],
|
|
5447
|
+
["redo", () => this.redo()],
|
|
5448
|
+
["word-forward", () => this.moveWordForward()],
|
|
5449
|
+
["word-backward", () => this.moveWordBackward()],
|
|
5450
|
+
["select-word-forward", () => this.moveWordForward({ select: true })],
|
|
5451
|
+
["select-word-backward", () => this.moveWordBackward({ select: true })],
|
|
5452
|
+
["delete-word-forward", () => this.deleteWordForward()],
|
|
5453
|
+
["delete-word-backward", () => this.deleteWordBackward()]
|
|
5454
|
+
]);
|
|
5455
|
+
}
|
|
5288
5456
|
handlePaste(text) {
|
|
5289
5457
|
this.insertText(text);
|
|
5290
5458
|
}
|
|
@@ -5294,65 +5462,21 @@ class TextareaRenderable extends EditBufferRenderable {
|
|
|
5294
5462
|
const keyCtrl = typeof key === "string" ? false : key.ctrl;
|
|
5295
5463
|
const keyShift = typeof key === "string" ? false : key.shift;
|
|
5296
5464
|
const keyMeta = typeof key === "string" ? false : key.meta;
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
}
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
this.
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
return true;
|
|
5313
|
-
} else if (keyName === "up") {
|
|
5314
|
-
this.handleShiftSelection(keyShift, true);
|
|
5315
|
-
this.moveCursorUp();
|
|
5316
|
-
this.handleShiftSelection(keyShift, false);
|
|
5317
|
-
return true;
|
|
5318
|
-
} else if (keyName === "down") {
|
|
5319
|
-
this.handleShiftSelection(keyShift, true);
|
|
5320
|
-
this.moveCursorDown();
|
|
5321
|
-
this.handleShiftSelection(keyShift, false);
|
|
5322
|
-
return true;
|
|
5323
|
-
} else if (keyName === "home") {
|
|
5324
|
-
this.handleShiftSelection(keyShift, true);
|
|
5325
|
-
const cursor = this.editorView.getCursor();
|
|
5326
|
-
this.editBuffer.setCursor(cursor.row, 0);
|
|
5327
|
-
this.handleShiftSelection(keyShift, false);
|
|
5328
|
-
return true;
|
|
5329
|
-
} else if (keyName === "end") {
|
|
5330
|
-
this.handleShiftSelection(keyShift, true);
|
|
5331
|
-
this.gotoLineEnd();
|
|
5332
|
-
this.handleShiftSelection(keyShift, false);
|
|
5333
|
-
return true;
|
|
5334
|
-
} else if (keyCtrl && keyName === "a") {
|
|
5335
|
-
this.editBuffer.setCursor(0, 0);
|
|
5336
|
-
return true;
|
|
5337
|
-
} else if (keyCtrl && keyName === "e") {
|
|
5338
|
-
this.gotoBufferEnd();
|
|
5339
|
-
return true;
|
|
5340
|
-
} else if (keyCtrl && keyName === "d") {
|
|
5341
|
-
this.deleteLine();
|
|
5342
|
-
return true;
|
|
5343
|
-
} else if (keyCtrl && keyName === "k") {
|
|
5344
|
-
this.deleteToLineEnd();
|
|
5345
|
-
return true;
|
|
5346
|
-
} else if (keyName === "backspace") {
|
|
5347
|
-
this.deleteCharBackward();
|
|
5348
|
-
return true;
|
|
5349
|
-
} else if (keyName === "delete") {
|
|
5350
|
-
this.deleteChar();
|
|
5351
|
-
return true;
|
|
5352
|
-
} else if (keyName === "return" || keyName === "enter") {
|
|
5353
|
-
this.newLine();
|
|
5354
|
-
return true;
|
|
5355
|
-
} else if (keySequence && !keyCtrl && !keyMeta) {
|
|
5465
|
+
const bindingKey = getKeyBindingKey({
|
|
5466
|
+
name: keyName,
|
|
5467
|
+
ctrl: keyCtrl,
|
|
5468
|
+
shift: keyShift,
|
|
5469
|
+
meta: keyMeta,
|
|
5470
|
+
action: "move-left"
|
|
5471
|
+
});
|
|
5472
|
+
const action = this._keyBindingsMap.get(bindingKey);
|
|
5473
|
+
if (action) {
|
|
5474
|
+
const handler = this._actionHandlers.get(action);
|
|
5475
|
+
if (handler) {
|
|
5476
|
+
return handler();
|
|
5477
|
+
}
|
|
5478
|
+
}
|
|
5479
|
+
if (keySequence && !keyCtrl && !keyMeta) {
|
|
5356
5480
|
const firstCharCode = keySequence.charCodeAt(0);
|
|
5357
5481
|
if (firstCharCode < 32) {
|
|
5358
5482
|
return false;
|
|
@@ -5399,20 +5523,22 @@ class TextareaRenderable extends EditBufferRenderable {
|
|
|
5399
5523
|
deleteChar() {
|
|
5400
5524
|
if (this.hasSelection()) {
|
|
5401
5525
|
this.deleteSelectedText();
|
|
5402
|
-
return;
|
|
5526
|
+
return true;
|
|
5403
5527
|
}
|
|
5404
5528
|
this._ctx.clearSelection();
|
|
5405
5529
|
this.editBuffer.deleteChar();
|
|
5406
5530
|
this.requestRender();
|
|
5531
|
+
return true;
|
|
5407
5532
|
}
|
|
5408
5533
|
deleteCharBackward() {
|
|
5409
5534
|
if (this.hasSelection()) {
|
|
5410
5535
|
this.deleteSelectedText();
|
|
5411
|
-
return;
|
|
5536
|
+
return true;
|
|
5412
5537
|
}
|
|
5413
5538
|
this._ctx.clearSelection();
|
|
5414
5539
|
this.editBuffer.deleteCharBackward();
|
|
5415
5540
|
this.requestRender();
|
|
5541
|
+
return true;
|
|
5416
5542
|
}
|
|
5417
5543
|
deleteSelectedText() {
|
|
5418
5544
|
this.editorView.deleteSelectedText();
|
|
@@ -5423,69 +5549,144 @@ class TextareaRenderable extends EditBufferRenderable {
|
|
|
5423
5549
|
this._ctx.clearSelection();
|
|
5424
5550
|
this.editBuffer.newLine();
|
|
5425
5551
|
this.requestRender();
|
|
5552
|
+
return true;
|
|
5426
5553
|
}
|
|
5427
5554
|
deleteLine() {
|
|
5428
5555
|
this._ctx.clearSelection();
|
|
5429
5556
|
this.editBuffer.deleteLine();
|
|
5430
5557
|
this.requestRender();
|
|
5558
|
+
return true;
|
|
5431
5559
|
}
|
|
5432
|
-
moveCursorLeft() {
|
|
5560
|
+
moveCursorLeft(options) {
|
|
5561
|
+
const select = options?.select ?? false;
|
|
5562
|
+
this.handleShiftSelection(select, true);
|
|
5433
5563
|
this.editBuffer.moveCursorLeft();
|
|
5564
|
+
this.handleShiftSelection(select, false);
|
|
5434
5565
|
this.requestRender();
|
|
5566
|
+
return true;
|
|
5435
5567
|
}
|
|
5436
|
-
moveCursorRight() {
|
|
5568
|
+
moveCursorRight(options) {
|
|
5569
|
+
const select = options?.select ?? false;
|
|
5570
|
+
this.handleShiftSelection(select, true);
|
|
5437
5571
|
this.editBuffer.moveCursorRight();
|
|
5572
|
+
this.handleShiftSelection(select, false);
|
|
5438
5573
|
this.requestRender();
|
|
5574
|
+
return true;
|
|
5439
5575
|
}
|
|
5440
|
-
moveCursorUp() {
|
|
5576
|
+
moveCursorUp(options) {
|
|
5577
|
+
const select = options?.select ?? false;
|
|
5578
|
+
this.handleShiftSelection(select, true);
|
|
5441
5579
|
this.editorView.moveUpVisual();
|
|
5580
|
+
this.handleShiftSelection(select, false);
|
|
5442
5581
|
this.requestRender();
|
|
5582
|
+
return true;
|
|
5443
5583
|
}
|
|
5444
|
-
moveCursorDown() {
|
|
5584
|
+
moveCursorDown(options) {
|
|
5585
|
+
const select = options?.select ?? false;
|
|
5586
|
+
this.handleShiftSelection(select, true);
|
|
5445
5587
|
this.editorView.moveDownVisual();
|
|
5588
|
+
this.handleShiftSelection(select, false);
|
|
5446
5589
|
this.requestRender();
|
|
5590
|
+
return true;
|
|
5447
5591
|
}
|
|
5448
5592
|
gotoLine(line) {
|
|
5449
5593
|
this.editBuffer.gotoLine(line);
|
|
5450
5594
|
this.requestRender();
|
|
5451
5595
|
}
|
|
5452
|
-
|
|
5596
|
+
gotoLineHome(options) {
|
|
5597
|
+
const select = options?.select ?? false;
|
|
5598
|
+
this.handleShiftSelection(select, true);
|
|
5453
5599
|
const cursor = this.editorView.getCursor();
|
|
5454
|
-
this.editBuffer.
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5600
|
+
this.editBuffer.setCursor(cursor.row, 0);
|
|
5601
|
+
this.handleShiftSelection(select, false);
|
|
5602
|
+
this.requestRender();
|
|
5603
|
+
return true;
|
|
5604
|
+
}
|
|
5605
|
+
gotoLineEnd(options) {
|
|
5606
|
+
const select = options?.select ?? false;
|
|
5607
|
+
this.handleShiftSelection(select, true);
|
|
5608
|
+
const eol = this.editBuffer.getEOL();
|
|
5609
|
+
this.editBuffer.setCursor(eol.line, eol.visualColumn);
|
|
5610
|
+
this.handleShiftSelection(select, false);
|
|
5611
|
+
this.requestRender();
|
|
5612
|
+
return true;
|
|
5613
|
+
}
|
|
5614
|
+
gotoBufferHome() {
|
|
5615
|
+
this.editBuffer.setCursor(0, 0);
|
|
5459
5616
|
this.requestRender();
|
|
5617
|
+
return true;
|
|
5460
5618
|
}
|
|
5461
5619
|
gotoBufferEnd() {
|
|
5462
5620
|
this.editBuffer.gotoLine(999999);
|
|
5463
5621
|
this.requestRender();
|
|
5622
|
+
return true;
|
|
5464
5623
|
}
|
|
5465
5624
|
deleteToLineEnd() {
|
|
5466
5625
|
const cursor = this.editorView.getCursor();
|
|
5467
|
-
const
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
const endCursor = this.editorView.getCursor();
|
|
5471
|
-
const endCol = endCursor.col;
|
|
5472
|
-
this.editBuffer.setCursor(cursor.row, startCol);
|
|
5473
|
-
if (endCol > startCol) {
|
|
5474
|
-
for (let i = 0;i < endCol - startCol; i++) {
|
|
5475
|
-
this.deleteChar();
|
|
5476
|
-
}
|
|
5626
|
+
const eol = this.editBuffer.getEOL();
|
|
5627
|
+
if (eol.visualColumn > cursor.col) {
|
|
5628
|
+
this.editBuffer.deleteRange(cursor.row, cursor.col, eol.line, eol.visualColumn);
|
|
5477
5629
|
}
|
|
5478
5630
|
this.requestRender();
|
|
5631
|
+
return true;
|
|
5479
5632
|
}
|
|
5480
5633
|
undo() {
|
|
5481
5634
|
this._ctx.clearSelection();
|
|
5482
5635
|
this.editBuffer.undo();
|
|
5483
5636
|
this.requestRender();
|
|
5637
|
+
return true;
|
|
5484
5638
|
}
|
|
5485
5639
|
redo() {
|
|
5486
5640
|
this._ctx.clearSelection();
|
|
5487
5641
|
this.editBuffer.redo();
|
|
5488
5642
|
this.requestRender();
|
|
5643
|
+
return true;
|
|
5644
|
+
}
|
|
5645
|
+
moveWordForward(options) {
|
|
5646
|
+
const select = options?.select ?? false;
|
|
5647
|
+
this.handleShiftSelection(select, true);
|
|
5648
|
+
const nextWord = this.editBuffer.getNextWordBoundary();
|
|
5649
|
+
this.editBuffer.setCursorByOffset(nextWord.offset);
|
|
5650
|
+
this.handleShiftSelection(select, false);
|
|
5651
|
+
this.requestRender();
|
|
5652
|
+
return true;
|
|
5653
|
+
}
|
|
5654
|
+
moveWordBackward(options) {
|
|
5655
|
+
const select = options?.select ?? false;
|
|
5656
|
+
this.handleShiftSelection(select, true);
|
|
5657
|
+
const prevWord = this.editBuffer.getPrevWordBoundary();
|
|
5658
|
+
this.editBuffer.setCursorByOffset(prevWord.offset);
|
|
5659
|
+
this.handleShiftSelection(select, false);
|
|
5660
|
+
this.requestRender();
|
|
5661
|
+
return true;
|
|
5662
|
+
}
|
|
5663
|
+
deleteWordForward() {
|
|
5664
|
+
if (this.hasSelection()) {
|
|
5665
|
+
this.deleteSelectedText();
|
|
5666
|
+
return true;
|
|
5667
|
+
}
|
|
5668
|
+
const currentCursor = this.editBuffer.getCursorPosition();
|
|
5669
|
+
const nextWord = this.editBuffer.getNextWordBoundary();
|
|
5670
|
+
if (nextWord.offset > currentCursor.offset) {
|
|
5671
|
+
this.editBuffer.deleteRange(currentCursor.line, currentCursor.visualColumn, nextWord.line, nextWord.visualColumn);
|
|
5672
|
+
}
|
|
5673
|
+
this._ctx.clearSelection();
|
|
5674
|
+
this.requestRender();
|
|
5675
|
+
return true;
|
|
5676
|
+
}
|
|
5677
|
+
deleteWordBackward() {
|
|
5678
|
+
if (this.hasSelection()) {
|
|
5679
|
+
this.deleteSelectedText();
|
|
5680
|
+
return true;
|
|
5681
|
+
}
|
|
5682
|
+
const currentCursor = this.editBuffer.getCursorPosition();
|
|
5683
|
+
const prevWord = this.editBuffer.getPrevWordBoundary();
|
|
5684
|
+
if (prevWord.offset < currentCursor.offset) {
|
|
5685
|
+
this.editBuffer.deleteRange(prevWord.line, prevWord.visualColumn, currentCursor.line, currentCursor.visualColumn);
|
|
5686
|
+
}
|
|
5687
|
+
this._ctx.clearSelection();
|
|
5688
|
+
this.requestRender();
|
|
5689
|
+
return true;
|
|
5489
5690
|
}
|
|
5490
5691
|
handleShiftSelection(shiftPressed, isBeforeMovement) {
|
|
5491
5692
|
if (!this.selectable)
|
|
@@ -5566,36 +5767,6 @@ class TextareaRenderable extends EditBufferRenderable {
|
|
|
5566
5767
|
this.requestRender();
|
|
5567
5768
|
}
|
|
5568
5769
|
}
|
|
5569
|
-
get cursorOffset() {
|
|
5570
|
-
return this.editorView.getVisualCursor().offset;
|
|
5571
|
-
}
|
|
5572
|
-
set cursorOffset(offset) {
|
|
5573
|
-
this.editorView.setCursorByOffset(offset);
|
|
5574
|
-
this.requestRender();
|
|
5575
|
-
}
|
|
5576
|
-
addHighlight(lineIdx, highlight) {
|
|
5577
|
-
this.editBuffer.addHighlight(lineIdx, highlight);
|
|
5578
|
-
this.requestRender();
|
|
5579
|
-
}
|
|
5580
|
-
addHighlightByCharRange(highlight) {
|
|
5581
|
-
this.editBuffer.addHighlightByCharRange(highlight);
|
|
5582
|
-
this.requestRender();
|
|
5583
|
-
}
|
|
5584
|
-
removeHighlightsByRef(hlRef) {
|
|
5585
|
-
this.editBuffer.removeHighlightsByRef(hlRef);
|
|
5586
|
-
this.requestRender();
|
|
5587
|
-
}
|
|
5588
|
-
clearLineHighlights(lineIdx) {
|
|
5589
|
-
this.editBuffer.clearLineHighlights(lineIdx);
|
|
5590
|
-
this.requestRender();
|
|
5591
|
-
}
|
|
5592
|
-
clearAllHighlights() {
|
|
5593
|
-
this.editBuffer.clearAllHighlights();
|
|
5594
|
-
this.requestRender();
|
|
5595
|
-
}
|
|
5596
|
-
getLineHighlights(lineIdx) {
|
|
5597
|
-
return this.editBuffer.getLineHighlights(lineIdx);
|
|
5598
|
-
}
|
|
5599
5770
|
}
|
|
5600
5771
|
export {
|
|
5601
5772
|
yellow,
|
|
@@ -5777,5 +5948,5 @@ export {
|
|
|
5777
5948
|
ASCIIFont
|
|
5778
5949
|
};
|
|
5779
5950
|
|
|
5780
|
-
//# debugId=
|
|
5951
|
+
//# debugId=C45C47BFE87C68C464756E2164756E21
|
|
5781
5952
|
//# sourceMappingURL=index.js.map
|