groove-dev 0.16.1 → 0.16.3
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/node_modules/@groove-dev/daemon/src/index.js +25 -7
- package/node_modules/@groove-dev/daemon/src/terminal-pty.js +141 -0
- package/node_modules/@groove-dev/gui/dist/assets/{index-Gfb8Zxy9.css → index-BhjOFLBc.css} +32 -1
- package/node_modules/@groove-dev/gui/dist/assets/index-CFeltwTB.js +153 -0
- package/node_modules/@groove-dev/gui/dist/index.html +2 -2
- package/node_modules/@groove-dev/gui/package.json +3 -0
- package/node_modules/@groove-dev/gui/src/components/EditorTabs.jsx +3 -3
- package/node_modules/@groove-dev/gui/src/components/FileTree.jsx +18 -22
- package/node_modules/@groove-dev/gui/src/components/Terminal.jsx +154 -0
- package/node_modules/@groove-dev/gui/src/views/FileEditor.jsx +100 -39
- package/node_modules/@xterm/addon-fit/LICENSE +19 -0
- package/node_modules/@xterm/addon-fit/README.md +24 -0
- package/node_modules/@xterm/addon-fit/lib/addon-fit.js +2 -0
- package/node_modules/@xterm/addon-fit/lib/addon-fit.js.map +1 -0
- package/node_modules/@xterm/addon-fit/lib/addon-fit.mjs +18 -0
- package/node_modules/@xterm/addon-fit/lib/addon-fit.mjs.map +7 -0
- package/node_modules/@xterm/addon-fit/package.json +26 -0
- package/node_modules/@xterm/addon-fit/src/FitAddon.ts +92 -0
- package/node_modules/@xterm/addon-fit/typings/addon-fit.d.ts +55 -0
- package/node_modules/@xterm/addon-web-links/LICENSE +19 -0
- package/node_modules/@xterm/addon-web-links/README.md +21 -0
- package/node_modules/@xterm/addon-web-links/lib/addon-web-links.js +2 -0
- package/node_modules/@xterm/addon-web-links/lib/addon-web-links.js.map +1 -0
- package/node_modules/@xterm/addon-web-links/lib/addon-web-links.mjs +18 -0
- package/node_modules/@xterm/addon-web-links/lib/addon-web-links.mjs.map +7 -0
- package/node_modules/@xterm/addon-web-links/package.json +26 -0
- package/node_modules/@xterm/addon-web-links/src/WebLinkProvider.ts +199 -0
- package/node_modules/@xterm/addon-web-links/src/WebLinksAddon.ts +58 -0
- package/node_modules/@xterm/addon-web-links/typings/addon-web-links.d.ts +57 -0
- package/node_modules/@xterm/xterm/LICENSE +21 -0
- package/node_modules/@xterm/xterm/README.md +243 -0
- package/node_modules/@xterm/xterm/css/xterm.css +285 -0
- package/node_modules/@xterm/xterm/lib/xterm.js +2 -0
- package/node_modules/@xterm/xterm/lib/xterm.js.map +1 -0
- package/node_modules/@xterm/xterm/lib/xterm.mjs +53 -0
- package/node_modules/@xterm/xterm/lib/xterm.mjs.map +7 -0
- package/node_modules/@xterm/xterm/package.json +111 -0
- package/node_modules/@xterm/xterm/src/browser/AccessibilityManager.ts +435 -0
- package/node_modules/@xterm/xterm/src/browser/Clipboard.ts +93 -0
- package/node_modules/@xterm/xterm/src/browser/ColorContrastCache.ts +34 -0
- package/node_modules/@xterm/xterm/src/browser/CoreBrowserTerminal.ts +1339 -0
- package/node_modules/@xterm/xterm/src/browser/Linkifier.ts +403 -0
- package/node_modules/@xterm/xterm/src/browser/LocalizableStrings.ts +23 -0
- package/node_modules/@xterm/xterm/src/browser/OscLinkProvider.ts +129 -0
- package/node_modules/@xterm/xterm/src/browser/RenderDebouncer.ts +84 -0
- package/node_modules/@xterm/xterm/src/browser/TimeBasedDebouncer.ts +86 -0
- package/node_modules/@xterm/xterm/src/browser/Types.ts +226 -0
- package/node_modules/@xterm/xterm/src/browser/Viewport.ts +192 -0
- package/node_modules/@xterm/xterm/src/browser/decorations/BufferDecorationRenderer.ts +139 -0
- package/node_modules/@xterm/xterm/src/browser/decorations/ColorZoneStore.ts +117 -0
- package/node_modules/@xterm/xterm/src/browser/decorations/OverviewRulerRenderer.ts +214 -0
- package/node_modules/@xterm/xterm/src/browser/input/CompositionHelper.ts +248 -0
- package/node_modules/@xterm/xterm/src/browser/input/Mouse.ts +54 -0
- package/node_modules/@xterm/xterm/src/browser/input/MoveToCell.ts +251 -0
- package/node_modules/@xterm/xterm/src/browser/public/Terminal.ts +275 -0
- package/node_modules/@xterm/xterm/src/browser/renderer/dom/DomRenderer.ts +542 -0
- package/node_modules/@xterm/xterm/src/browser/renderer/dom/DomRendererRowFactory.ts +546 -0
- package/node_modules/@xterm/xterm/src/browser/renderer/dom/WidthCache.ts +167 -0
- package/node_modules/@xterm/xterm/src/browser/renderer/shared/Constants.ts +6 -0
- package/node_modules/@xterm/xterm/src/browser/renderer/shared/RendererUtils.ts +95 -0
- package/node_modules/@xterm/xterm/src/browser/renderer/shared/SelectionRenderModel.ts +93 -0
- package/node_modules/@xterm/xterm/src/browser/renderer/shared/Types.ts +84 -0
- package/node_modules/@xterm/xterm/src/browser/selection/SelectionModel.ts +144 -0
- package/node_modules/@xterm/xterm/src/browser/selection/Types.ts +15 -0
- package/node_modules/@xterm/xterm/src/browser/services/CharSizeService.ts +127 -0
- package/node_modules/@xterm/xterm/src/browser/services/CharacterJoinerService.ts +339 -0
- package/node_modules/@xterm/xterm/src/browser/services/CoreBrowserService.ts +137 -0
- package/node_modules/@xterm/xterm/src/browser/services/LinkProviderService.ts +28 -0
- package/node_modules/@xterm/xterm/src/browser/services/MouseService.ts +46 -0
- package/node_modules/@xterm/xterm/src/browser/services/RenderService.ts +376 -0
- package/node_modules/@xterm/xterm/src/browser/services/SelectionService.ts +1039 -0
- package/node_modules/@xterm/xterm/src/browser/services/Services.ts +158 -0
- package/node_modules/@xterm/xterm/src/browser/services/ThemeService.ts +198 -0
- package/node_modules/@xterm/xterm/src/browser/shared/Constants.ts +8 -0
- package/node_modules/@xterm/xterm/src/common/CircularList.ts +241 -0
- package/node_modules/@xterm/xterm/src/common/Clone.ts +23 -0
- package/node_modules/@xterm/xterm/src/common/Color.ts +376 -0
- package/node_modules/@xterm/xterm/src/common/CoreTerminal.ts +283 -0
- package/node_modules/@xterm/xterm/src/common/InputHandler.ts +3495 -0
- package/node_modules/@xterm/xterm/src/common/MultiKeyMap.ts +42 -0
- package/node_modules/@xterm/xterm/src/common/Platform.ts +44 -0
- package/node_modules/@xterm/xterm/src/common/SortedList.ts +194 -0
- package/node_modules/@xterm/xterm/src/common/TaskQueue.ts +166 -0
- package/node_modules/@xterm/xterm/src/common/TypedArrayUtils.ts +17 -0
- package/node_modules/@xterm/xterm/src/common/Types.ts +552 -0
- package/node_modules/@xterm/xterm/src/common/WindowsMode.ts +27 -0
- package/node_modules/@xterm/xterm/src/common/buffer/AttributeData.ts +211 -0
- package/node_modules/@xterm/xterm/src/common/buffer/Buffer.ts +662 -0
- package/node_modules/@xterm/xterm/src/common/buffer/BufferLine.ts +551 -0
- package/node_modules/@xterm/xterm/src/common/buffer/BufferRange.ts +13 -0
- package/node_modules/@xterm/xterm/src/common/buffer/BufferReflow.ts +226 -0
- package/node_modules/@xterm/xterm/src/common/buffer/BufferSet.ts +134 -0
- package/node_modules/@xterm/xterm/src/common/buffer/CellData.ts +94 -0
- package/node_modules/@xterm/xterm/src/common/buffer/Constants.ts +157 -0
- package/node_modules/@xterm/xterm/src/common/buffer/Marker.ts +43 -0
- package/node_modules/@xterm/xterm/src/common/buffer/Types.ts +52 -0
- package/node_modules/@xterm/xterm/src/common/data/Charsets.ts +256 -0
- package/node_modules/@xterm/xterm/src/common/data/EscapeSequences.ts +153 -0
- package/node_modules/@xterm/xterm/src/common/input/Keyboard.ts +373 -0
- package/node_modules/@xterm/xterm/src/common/input/TextDecoder.ts +346 -0
- package/node_modules/@xterm/xterm/src/common/input/UnicodeV6.ts +145 -0
- package/node_modules/@xterm/xterm/src/common/input/WriteBuffer.ts +247 -0
- package/node_modules/@xterm/xterm/src/common/input/XParseColor.ts +80 -0
- package/node_modules/@xterm/xterm/src/common/parser/Constants.ts +58 -0
- package/node_modules/@xterm/xterm/src/common/parser/DcsParser.ts +192 -0
- package/node_modules/@xterm/xterm/src/common/parser/EscapeSequenceParser.ts +792 -0
- package/node_modules/@xterm/xterm/src/common/parser/OscParser.ts +238 -0
- package/node_modules/@xterm/xterm/src/common/parser/Params.ts +229 -0
- package/node_modules/@xterm/xterm/src/common/parser/Types.ts +275 -0
- package/node_modules/@xterm/xterm/src/common/public/AddonManager.ts +53 -0
- package/node_modules/@xterm/xterm/src/common/public/BufferApiView.ts +35 -0
- package/node_modules/@xterm/xterm/src/common/public/BufferLineApiView.ts +29 -0
- package/node_modules/@xterm/xterm/src/common/public/BufferNamespaceApi.ts +36 -0
- package/node_modules/@xterm/xterm/src/common/public/ParserApi.ts +37 -0
- package/node_modules/@xterm/xterm/src/common/public/UnicodeApi.ts +27 -0
- package/node_modules/@xterm/xterm/src/common/services/BufferService.ts +154 -0
- package/node_modules/@xterm/xterm/src/common/services/CharsetService.ts +34 -0
- package/node_modules/@xterm/xterm/src/common/services/CoreMouseService.ts +365 -0
- package/node_modules/@xterm/xterm/src/common/services/CoreService.ts +92 -0
- package/node_modules/@xterm/xterm/src/common/services/DecorationService.ts +140 -0
- package/node_modules/@xterm/xterm/src/common/services/InstantiationService.ts +85 -0
- package/node_modules/@xterm/xterm/src/common/services/LogService.ts +124 -0
- package/node_modules/@xterm/xterm/src/common/services/OptionsService.ts +212 -0
- package/node_modules/@xterm/xterm/src/common/services/OscLinkService.ts +115 -0
- package/node_modules/@xterm/xterm/src/common/services/ServiceRegistry.ts +49 -0
- package/node_modules/@xterm/xterm/src/common/services/Services.ts +396 -0
- package/node_modules/@xterm/xterm/src/common/services/UnicodeService.ts +111 -0
- package/node_modules/@xterm/xterm/src/vs/base/browser/browser.ts +141 -0
- package/node_modules/@xterm/xterm/src/vs/base/browser/canIUse.ts +49 -0
- package/node_modules/@xterm/xterm/src/vs/base/browser/dom.ts +2369 -0
- package/node_modules/@xterm/xterm/src/vs/base/browser/fastDomNode.ts +316 -0
- package/node_modules/@xterm/xterm/src/vs/base/browser/globalPointerMoveMonitor.ts +112 -0
- package/node_modules/@xterm/xterm/src/vs/base/browser/iframe.ts +135 -0
- package/node_modules/@xterm/xterm/src/vs/base/browser/keyboardEvent.ts +213 -0
- package/node_modules/@xterm/xterm/src/vs/base/browser/mouseEvent.ts +229 -0
- package/node_modules/@xterm/xterm/src/vs/base/browser/touch.ts +372 -0
- package/node_modules/@xterm/xterm/src/vs/base/browser/ui/scrollbar/abstractScrollbar.ts +303 -0
- package/node_modules/@xterm/xterm/src/vs/base/browser/ui/scrollbar/horizontalScrollbar.ts +114 -0
- package/node_modules/@xterm/xterm/src/vs/base/browser/ui/scrollbar/scrollableElement.ts +720 -0
- package/node_modules/@xterm/xterm/src/vs/base/browser/ui/scrollbar/scrollableElementOptions.ts +165 -0
- package/node_modules/@xterm/xterm/src/vs/base/browser/ui/scrollbar/scrollbarArrow.ts +114 -0
- package/node_modules/@xterm/xterm/src/vs/base/browser/ui/scrollbar/scrollbarState.ts +243 -0
- package/node_modules/@xterm/xterm/src/vs/base/browser/ui/scrollbar/scrollbarVisibilityController.ts +118 -0
- package/node_modules/@xterm/xterm/src/vs/base/browser/ui/scrollbar/verticalScrollbar.ts +116 -0
- package/node_modules/@xterm/xterm/src/vs/base/browser/ui/widget.ts +57 -0
- package/node_modules/@xterm/xterm/src/vs/base/browser/window.ts +14 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/arrays.ts +887 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/arraysFind.ts +202 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/assert.ts +71 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/async.ts +1992 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/cancellation.ts +148 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/charCode.ts +450 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/collections.ts +140 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/decorators.ts +130 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/equals.ts +146 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/errors.ts +303 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/event.ts +1778 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/functional.ts +32 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/hash.ts +316 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/iterator.ts +159 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/keyCodes.ts +526 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/keybindings.ts +284 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/lazy.ts +47 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/lifecycle.ts +801 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/linkedList.ts +142 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/map.ts +202 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/numbers.ts +98 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/observable.ts +76 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/observableInternal/api.ts +31 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/observableInternal/autorun.ts +281 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/observableInternal/base.ts +489 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/observableInternal/debugName.ts +145 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/observableInternal/derived.ts +428 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/observableInternal/lazyObservableValue.ts +146 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/observableInternal/logging.ts +328 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/observableInternal/promise.ts +209 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/observableInternal/utils.ts +610 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/platform.ts +281 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/scrollable.ts +522 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/sequence.ts +34 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/stopwatch.ts +43 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/strings.ts +557 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/symbols.ts +9 -0
- package/node_modules/@xterm/xterm/src/vs/base/common/uint.ts +59 -0
- package/node_modules/@xterm/xterm/src/vs/patches/nls.ts +90 -0
- package/node_modules/@xterm/xterm/src/vs/typings/base-common.d.ts +20 -0
- package/node_modules/@xterm/xterm/src/vs/typings/require.d.ts +42 -0
- package/node_modules/@xterm/xterm/src/vs/typings/vscode-globals-nls.d.ts +36 -0
- package/node_modules/@xterm/xterm/src/vs/typings/vscode-globals-product.d.ts +33 -0
- package/node_modules/@xterm/xterm/typings/xterm.d.ts +1957 -0
- package/package.json +1 -1
- package/packages/daemon/src/index.js +25 -7
- package/packages/daemon/src/terminal-pty.js +141 -0
- package/packages/gui/dist/assets/{index-Gfb8Zxy9.css → index-BhjOFLBc.css} +32 -1
- package/packages/gui/dist/assets/index-CFeltwTB.js +153 -0
- package/packages/gui/dist/index.html +2 -2
- package/packages/gui/package.json +3 -0
- package/packages/gui/src/components/EditorTabs.jsx +3 -3
- package/packages/gui/src/components/FileTree.jsx +18 -22
- package/packages/gui/src/components/Terminal.jsx +154 -0
- package/packages/gui/src/views/FileEditor.jsx +100 -39
- package/node_modules/@groove-dev/gui/dist/assets/index-BQSznoq0.js +0 -103
- package/packages/gui/dist/assets/index-BQSznoq0.js +0 -103
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
|
|
3
|
+
* @license MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { C0 } from 'common/data/EscapeSequences';
|
|
7
|
+
import { IBufferService } from 'common/services/Services';
|
|
8
|
+
|
|
9
|
+
const enum Direction {
|
|
10
|
+
UP = 'A',
|
|
11
|
+
DOWN = 'B',
|
|
12
|
+
RIGHT = 'C',
|
|
13
|
+
LEFT = 'D'
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Concatenates all the arrow sequences together.
|
|
18
|
+
* Resets the starting row to an unwrapped row, moves to the requested row,
|
|
19
|
+
* then moves to requested col.
|
|
20
|
+
*/
|
|
21
|
+
export function moveToCellSequence(targetX: number, targetY: number, bufferService: IBufferService, applicationCursor: boolean): string {
|
|
22
|
+
const startX = bufferService.buffer.x;
|
|
23
|
+
const startY = bufferService.buffer.y;
|
|
24
|
+
|
|
25
|
+
// The alt buffer should try to navigate between rows
|
|
26
|
+
if (!bufferService.buffer.hasScrollback) {
|
|
27
|
+
return resetStartingRow(startX, startY, targetX, targetY, bufferService, applicationCursor) +
|
|
28
|
+
moveToRequestedRow(startY, targetY, bufferService, applicationCursor) +
|
|
29
|
+
moveToRequestedCol(startX, startY, targetX, targetY, bufferService, applicationCursor);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Only move horizontally for the normal buffer
|
|
33
|
+
let direction;
|
|
34
|
+
if (startY === targetY) {
|
|
35
|
+
direction = startX > targetX ? Direction.LEFT : Direction.RIGHT;
|
|
36
|
+
return repeat(Math.abs(startX - targetX), sequence(direction, applicationCursor));
|
|
37
|
+
}
|
|
38
|
+
direction = startY > targetY ? Direction.LEFT : Direction.RIGHT;
|
|
39
|
+
const rowDifference = Math.abs(startY - targetY);
|
|
40
|
+
const cellsToMove = colsFromRowEnd(startY > targetY ? targetX : startX, bufferService) +
|
|
41
|
+
(rowDifference - 1) * bufferService.cols + 1 /* wrap around 1 row */ +
|
|
42
|
+
colsFromRowBeginning(startY > targetY ? startX : targetX, bufferService);
|
|
43
|
+
return repeat(cellsToMove, sequence(direction, applicationCursor));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Find the number of cols from a row beginning to a col.
|
|
48
|
+
*/
|
|
49
|
+
function colsFromRowBeginning(currX: number, bufferService: IBufferService): number {
|
|
50
|
+
return currX - 1;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Find the number of cols from a col to row end.
|
|
55
|
+
*/
|
|
56
|
+
function colsFromRowEnd(currX: number, bufferService: IBufferService): number {
|
|
57
|
+
return bufferService.cols - currX;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* If the initial position of the cursor is on a row that is wrapped, move the
|
|
62
|
+
* cursor up to the first row that is not wrapped to have accurate vertical
|
|
63
|
+
* positioning.
|
|
64
|
+
*/
|
|
65
|
+
function resetStartingRow(startX: number, startY: number, targetX: number, targetY: number, bufferService: IBufferService, applicationCursor: boolean): string {
|
|
66
|
+
if (moveToRequestedRow(startY, targetY, bufferService, applicationCursor).length === 0) {
|
|
67
|
+
return '';
|
|
68
|
+
}
|
|
69
|
+
return repeat(bufferLine(
|
|
70
|
+
startX, startY, startX,
|
|
71
|
+
startY - wrappedRowsForRow(startY, bufferService), false, bufferService
|
|
72
|
+
).length, sequence(Direction.LEFT, applicationCursor));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Using the reset starting and ending row, move to the requested row,
|
|
77
|
+
* ignoring wrapped rows
|
|
78
|
+
*/
|
|
79
|
+
function moveToRequestedRow(startY: number, targetY: number, bufferService: IBufferService, applicationCursor: boolean): string {
|
|
80
|
+
const startRow = startY - wrappedRowsForRow(startY, bufferService);
|
|
81
|
+
const endRow = targetY - wrappedRowsForRow(targetY, bufferService);
|
|
82
|
+
|
|
83
|
+
const rowsToMove = Math.abs(startRow - endRow) - wrappedRowsCount(startY, targetY, bufferService);
|
|
84
|
+
|
|
85
|
+
return repeat(rowsToMove, sequence(verticalDirection(startY, targetY), applicationCursor));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Move to the requested col on the ending row
|
|
90
|
+
*/
|
|
91
|
+
function moveToRequestedCol(startX: number, startY: number, targetX: number, targetY: number, bufferService: IBufferService, applicationCursor: boolean): string {
|
|
92
|
+
let startRow;
|
|
93
|
+
if (moveToRequestedRow(startY, targetY, bufferService, applicationCursor).length > 0) {
|
|
94
|
+
startRow = targetY - wrappedRowsForRow(targetY, bufferService);
|
|
95
|
+
} else {
|
|
96
|
+
startRow = startY;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const endRow = targetY;
|
|
100
|
+
const direction = horizontalDirection(startX, startY, targetX, targetY, bufferService, applicationCursor);
|
|
101
|
+
|
|
102
|
+
return repeat(bufferLine(
|
|
103
|
+
startX, startRow, targetX, endRow,
|
|
104
|
+
direction === Direction.RIGHT, bufferService
|
|
105
|
+
).length, sequence(direction, applicationCursor));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Utility functions
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Calculates the number of wrapped rows between the unwrapped starting and
|
|
114
|
+
* ending rows. These rows need to ignored since the cursor skips over them.
|
|
115
|
+
*/
|
|
116
|
+
function wrappedRowsCount(startY: number, targetY: number, bufferService: IBufferService): number {
|
|
117
|
+
let wrappedRows = 0;
|
|
118
|
+
const startRow = startY - wrappedRowsForRow(startY, bufferService);
|
|
119
|
+
const endRow = targetY - wrappedRowsForRow(targetY, bufferService);
|
|
120
|
+
|
|
121
|
+
for (let i = 0; i < Math.abs(startRow - endRow); i++) {
|
|
122
|
+
const direction = verticalDirection(startY, targetY) === Direction.UP ? -1 : 1;
|
|
123
|
+
const line = bufferService.buffer.lines.get(startRow + (direction * i));
|
|
124
|
+
if (line?.isWrapped) {
|
|
125
|
+
wrappedRows++;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return wrappedRows;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Calculates the number of wrapped rows that make up a given row.
|
|
134
|
+
* @param currentRow The row to determine how many wrapped rows make it up
|
|
135
|
+
*/
|
|
136
|
+
function wrappedRowsForRow(currentRow: number, bufferService: IBufferService): number {
|
|
137
|
+
let rowCount = 0;
|
|
138
|
+
let line = bufferService.buffer.lines.get(currentRow);
|
|
139
|
+
let lineWraps = line?.isWrapped;
|
|
140
|
+
|
|
141
|
+
while (lineWraps && currentRow >= 0 && currentRow < bufferService.rows) {
|
|
142
|
+
rowCount++;
|
|
143
|
+
line = bufferService.buffer.lines.get(--currentRow);
|
|
144
|
+
lineWraps = line?.isWrapped;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return rowCount;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Direction determiners
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Determines if the right or left arrow is needed
|
|
156
|
+
*/
|
|
157
|
+
function horizontalDirection(startX: number, startY: number, targetX: number, targetY: number, bufferService: IBufferService, applicationCursor: boolean): Direction {
|
|
158
|
+
let startRow;
|
|
159
|
+
if (moveToRequestedRow(targetX, targetY, bufferService, applicationCursor).length > 0) {
|
|
160
|
+
startRow = targetY - wrappedRowsForRow(targetY, bufferService);
|
|
161
|
+
} else {
|
|
162
|
+
startRow = startY;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if ((startX < targetX &&
|
|
166
|
+
startRow <= targetY) || // down/right or same y/right
|
|
167
|
+
(startX >= targetX &&
|
|
168
|
+
startRow < targetY)) { // down/left or same y/left
|
|
169
|
+
return Direction.RIGHT;
|
|
170
|
+
}
|
|
171
|
+
return Direction.LEFT;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Determines if the up or down arrow is needed
|
|
176
|
+
*/
|
|
177
|
+
function verticalDirection(startY: number, targetY: number): Direction {
|
|
178
|
+
return startY > targetY ? Direction.UP : Direction.DOWN;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Constructs the string of chars in the buffer from a starting row and col
|
|
183
|
+
* to an ending row and col
|
|
184
|
+
* @param startCol The starting column position
|
|
185
|
+
* @param startRow The starting row position
|
|
186
|
+
* @param endCol The ending column position
|
|
187
|
+
* @param endRow The ending row position
|
|
188
|
+
* @param forward Direction to move
|
|
189
|
+
*/
|
|
190
|
+
function bufferLine(
|
|
191
|
+
startCol: number,
|
|
192
|
+
startRow: number,
|
|
193
|
+
endCol: number,
|
|
194
|
+
endRow: number,
|
|
195
|
+
forward: boolean,
|
|
196
|
+
bufferService: IBufferService
|
|
197
|
+
): string {
|
|
198
|
+
let currentCol = startCol;
|
|
199
|
+
let currentRow = startRow;
|
|
200
|
+
let bufferStr = '';
|
|
201
|
+
|
|
202
|
+
while ((currentCol !== endCol || currentRow !== endRow) &&
|
|
203
|
+
currentRow >= 0 &&
|
|
204
|
+
currentRow < bufferService.buffer.lines.length) {
|
|
205
|
+
currentCol += forward ? 1 : -1;
|
|
206
|
+
|
|
207
|
+
if (forward && currentCol > bufferService.cols - 1) {
|
|
208
|
+
bufferStr += bufferService.buffer.translateBufferLineToString(
|
|
209
|
+
currentRow, false, startCol, currentCol
|
|
210
|
+
);
|
|
211
|
+
currentCol = 0;
|
|
212
|
+
startCol = 0;
|
|
213
|
+
currentRow++;
|
|
214
|
+
} else if (!forward && currentCol < 0) {
|
|
215
|
+
bufferStr += bufferService.buffer.translateBufferLineToString(
|
|
216
|
+
currentRow, false, 0, startCol + 1
|
|
217
|
+
);
|
|
218
|
+
currentCol = bufferService.cols - 1;
|
|
219
|
+
startCol = currentCol;
|
|
220
|
+
currentRow--;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return bufferStr + bufferService.buffer.translateBufferLineToString(
|
|
225
|
+
currentRow, false, startCol, currentCol
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Constructs the escape sequence for clicking an arrow
|
|
231
|
+
* @param direction The direction to move
|
|
232
|
+
*/
|
|
233
|
+
function sequence(direction: Direction, applicationCursor: boolean): string {
|
|
234
|
+
const mod = applicationCursor ? 'O' : '[';
|
|
235
|
+
return C0.ESC + mod + direction;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Returns a string repeated a given number of times
|
|
240
|
+
* Polyfill from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat
|
|
241
|
+
* @param count The number of times to repeat the string
|
|
242
|
+
* @param str The string that is to be repeated
|
|
243
|
+
*/
|
|
244
|
+
function repeat(count: number, str: string): string {
|
|
245
|
+
count = Math.floor(count);
|
|
246
|
+
let rpt = '';
|
|
247
|
+
for (let i = 0; i < count; i++) {
|
|
248
|
+
rpt += str;
|
|
249
|
+
}
|
|
250
|
+
return rpt;
|
|
251
|
+
}
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
|
|
3
|
+
* @license MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import * as Strings from 'browser/LocalizableStrings';
|
|
7
|
+
import { CoreBrowserTerminal as TerminalCore } from 'browser/CoreBrowserTerminal';
|
|
8
|
+
import { IBufferRange, ITerminal } from 'browser/Types';
|
|
9
|
+
import { Disposable } from 'vs/base/common/lifecycle';
|
|
10
|
+
import { ITerminalOptions } from 'common/Types';
|
|
11
|
+
import { AddonManager } from 'common/public/AddonManager';
|
|
12
|
+
import { BufferNamespaceApi } from 'common/public/BufferNamespaceApi';
|
|
13
|
+
import { ParserApi } from 'common/public/ParserApi';
|
|
14
|
+
import { UnicodeApi } from 'common/public/UnicodeApi';
|
|
15
|
+
import { IBufferNamespace as IBufferNamespaceApi, IDecoration, IDecorationOptions, IDisposable, ILinkProvider, ILocalizableStrings, IMarker, IModes, IParser, ITerminalAddon, Terminal as ITerminalApi, ITerminalInitOnlyOptions, IUnicodeHandling } from '@xterm/xterm';
|
|
16
|
+
import type { Event } from 'vs/base/common/event';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The set of options that only have an effect when set in the Terminal constructor.
|
|
20
|
+
*/
|
|
21
|
+
const CONSTRUCTOR_ONLY_OPTIONS = ['cols', 'rows'];
|
|
22
|
+
|
|
23
|
+
let $value = 0;
|
|
24
|
+
|
|
25
|
+
export class Terminal extends Disposable implements ITerminalApi {
|
|
26
|
+
private _core: ITerminal;
|
|
27
|
+
private _addonManager: AddonManager;
|
|
28
|
+
private _parser: IParser | undefined;
|
|
29
|
+
private _buffer: BufferNamespaceApi | undefined;
|
|
30
|
+
private _publicOptions: Required<ITerminalOptions>;
|
|
31
|
+
|
|
32
|
+
constructor(options?: ITerminalOptions & ITerminalInitOnlyOptions) {
|
|
33
|
+
super();
|
|
34
|
+
|
|
35
|
+
this._core = this._register(new TerminalCore(options));
|
|
36
|
+
this._addonManager = this._register(new AddonManager());
|
|
37
|
+
|
|
38
|
+
this._publicOptions = { ... this._core.options };
|
|
39
|
+
const getter = (propName: string): any => {
|
|
40
|
+
return this._core.options[propName];
|
|
41
|
+
};
|
|
42
|
+
const setter = (propName: string, value: any): void => {
|
|
43
|
+
this._checkReadonlyOptions(propName);
|
|
44
|
+
this._core.options[propName] = value;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
for (const propName in this._core.options) {
|
|
48
|
+
const desc = {
|
|
49
|
+
get: getter.bind(this, propName),
|
|
50
|
+
set: setter.bind(this, propName)
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(this._publicOptions, propName, desc);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private _checkReadonlyOptions(propName: string): void {
|
|
57
|
+
// Throw an error if any constructor only option is modified
|
|
58
|
+
// from terminal.options
|
|
59
|
+
// Modifications from anywhere else are allowed
|
|
60
|
+
if (CONSTRUCTOR_ONLY_OPTIONS.includes(propName)) {
|
|
61
|
+
throw new Error(`Option "${propName}" can only be set in the constructor`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private _checkProposedApi(): void {
|
|
66
|
+
if (!this._core.optionsService.rawOptions.allowProposedApi) {
|
|
67
|
+
throw new Error('You must set the allowProposedApi option to true to use proposed API');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public get onBell(): Event<void> { return this._core.onBell; }
|
|
72
|
+
public get onBinary(): Event<string> { return this._core.onBinary; }
|
|
73
|
+
public get onCursorMove(): Event<void> { return this._core.onCursorMove; }
|
|
74
|
+
public get onData(): Event<string> { return this._core.onData; }
|
|
75
|
+
public get onKey(): Event<{ key: string, domEvent: KeyboardEvent }> { return this._core.onKey; }
|
|
76
|
+
public get onLineFeed(): Event<void> { return this._core.onLineFeed; }
|
|
77
|
+
public get onRender(): Event<{ start: number, end: number }> { return this._core.onRender; }
|
|
78
|
+
public get onResize(): Event<{ cols: number, rows: number }> { return this._core.onResize; }
|
|
79
|
+
public get onScroll(): Event<number> { return this._core.onScroll; }
|
|
80
|
+
public get onSelectionChange(): Event<void> { return this._core.onSelectionChange; }
|
|
81
|
+
public get onTitleChange(): Event<string> { return this._core.onTitleChange; }
|
|
82
|
+
public get onWriteParsed(): Event<void> { return this._core.onWriteParsed; }
|
|
83
|
+
|
|
84
|
+
public get element(): HTMLElement | undefined { return this._core.element; }
|
|
85
|
+
public get parser(): IParser {
|
|
86
|
+
if (!this._parser) {
|
|
87
|
+
this._parser = new ParserApi(this._core);
|
|
88
|
+
}
|
|
89
|
+
return this._parser;
|
|
90
|
+
}
|
|
91
|
+
public get unicode(): IUnicodeHandling {
|
|
92
|
+
this._checkProposedApi();
|
|
93
|
+
return new UnicodeApi(this._core);
|
|
94
|
+
}
|
|
95
|
+
public get textarea(): HTMLTextAreaElement | undefined { return this._core.textarea; }
|
|
96
|
+
public get rows(): number { return this._core.rows; }
|
|
97
|
+
public get cols(): number { return this._core.cols; }
|
|
98
|
+
public get buffer(): IBufferNamespaceApi {
|
|
99
|
+
if (!this._buffer) {
|
|
100
|
+
this._buffer = this._register(new BufferNamespaceApi(this._core));
|
|
101
|
+
}
|
|
102
|
+
return this._buffer;
|
|
103
|
+
}
|
|
104
|
+
public get markers(): ReadonlyArray<IMarker> {
|
|
105
|
+
this._checkProposedApi();
|
|
106
|
+
return this._core.markers;
|
|
107
|
+
}
|
|
108
|
+
public get modes(): IModes {
|
|
109
|
+
const m = this._core.coreService.decPrivateModes;
|
|
110
|
+
let mouseTrackingMode: 'none' | 'x10' | 'vt200' | 'drag' | 'any' = 'none';
|
|
111
|
+
switch (this._core.coreMouseService.activeProtocol) {
|
|
112
|
+
case 'X10': mouseTrackingMode = 'x10'; break;
|
|
113
|
+
case 'VT200': mouseTrackingMode = 'vt200'; break;
|
|
114
|
+
case 'DRAG': mouseTrackingMode = 'drag'; break;
|
|
115
|
+
case 'ANY': mouseTrackingMode = 'any'; break;
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
applicationCursorKeysMode: m.applicationCursorKeys,
|
|
119
|
+
applicationKeypadMode: m.applicationKeypad,
|
|
120
|
+
bracketedPasteMode: m.bracketedPasteMode,
|
|
121
|
+
insertMode: this._core.coreService.modes.insertMode,
|
|
122
|
+
mouseTrackingMode: mouseTrackingMode,
|
|
123
|
+
originMode: m.origin,
|
|
124
|
+
reverseWraparoundMode: m.reverseWraparound,
|
|
125
|
+
sendFocusMode: m.sendFocus,
|
|
126
|
+
synchronizedOutputMode: m.synchronizedOutput,
|
|
127
|
+
wraparoundMode: m.wraparound
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
public get options(): Required<ITerminalOptions> {
|
|
131
|
+
return this._publicOptions;
|
|
132
|
+
}
|
|
133
|
+
public set options(options: ITerminalOptions) {
|
|
134
|
+
for (const propName in options) {
|
|
135
|
+
this._publicOptions[propName] = options[propName];
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
public blur(): void {
|
|
139
|
+
this._core.blur();
|
|
140
|
+
}
|
|
141
|
+
public focus(): void {
|
|
142
|
+
this._core.focus();
|
|
143
|
+
}
|
|
144
|
+
public input(data: string, wasUserInput: boolean = true): void {
|
|
145
|
+
this._core.input(data, wasUserInput);
|
|
146
|
+
}
|
|
147
|
+
public resize(columns: number, rows: number): void {
|
|
148
|
+
this._verifyIntegers(columns, rows);
|
|
149
|
+
this._core.resize(columns, rows);
|
|
150
|
+
}
|
|
151
|
+
public open(parent: HTMLElement): void {
|
|
152
|
+
this._core.open(parent);
|
|
153
|
+
}
|
|
154
|
+
public attachCustomKeyEventHandler(customKeyEventHandler: (event: KeyboardEvent) => boolean): void {
|
|
155
|
+
this._core.attachCustomKeyEventHandler(customKeyEventHandler);
|
|
156
|
+
}
|
|
157
|
+
public attachCustomWheelEventHandler(customWheelEventHandler: (event: WheelEvent) => boolean): void {
|
|
158
|
+
this._core.attachCustomWheelEventHandler(customWheelEventHandler);
|
|
159
|
+
}
|
|
160
|
+
public registerLinkProvider(linkProvider: ILinkProvider): IDisposable {
|
|
161
|
+
return this._core.registerLinkProvider(linkProvider);
|
|
162
|
+
}
|
|
163
|
+
public registerCharacterJoiner(handler: (text: string) => [number, number][]): number {
|
|
164
|
+
this._checkProposedApi();
|
|
165
|
+
return this._core.registerCharacterJoiner(handler);
|
|
166
|
+
}
|
|
167
|
+
public deregisterCharacterJoiner(joinerId: number): void {
|
|
168
|
+
this._checkProposedApi();
|
|
169
|
+
this._core.deregisterCharacterJoiner(joinerId);
|
|
170
|
+
}
|
|
171
|
+
public registerMarker(cursorYOffset: number = 0): IMarker {
|
|
172
|
+
this._verifyIntegers(cursorYOffset);
|
|
173
|
+
return this._core.registerMarker(cursorYOffset);
|
|
174
|
+
}
|
|
175
|
+
public registerDecoration(decorationOptions: IDecorationOptions): IDecoration | undefined {
|
|
176
|
+
this._checkProposedApi();
|
|
177
|
+
this._verifyPositiveIntegers(decorationOptions.x ?? 0, decorationOptions.width ?? 0, decorationOptions.height ?? 0);
|
|
178
|
+
return this._core.registerDecoration(decorationOptions);
|
|
179
|
+
}
|
|
180
|
+
public hasSelection(): boolean {
|
|
181
|
+
return this._core.hasSelection();
|
|
182
|
+
}
|
|
183
|
+
public select(column: number, row: number, length: number): void {
|
|
184
|
+
this._verifyIntegers(column, row, length);
|
|
185
|
+
this._core.select(column, row, length);
|
|
186
|
+
}
|
|
187
|
+
public getSelection(): string {
|
|
188
|
+
return this._core.getSelection();
|
|
189
|
+
}
|
|
190
|
+
public getSelectionPosition(): IBufferRange | undefined {
|
|
191
|
+
return this._core.getSelectionPosition();
|
|
192
|
+
}
|
|
193
|
+
public clearSelection(): void {
|
|
194
|
+
this._core.clearSelection();
|
|
195
|
+
}
|
|
196
|
+
public selectAll(): void {
|
|
197
|
+
this._core.selectAll();
|
|
198
|
+
}
|
|
199
|
+
public selectLines(start: number, end: number): void {
|
|
200
|
+
this._verifyIntegers(start, end);
|
|
201
|
+
this._core.selectLines(start, end);
|
|
202
|
+
}
|
|
203
|
+
public dispose(): void {
|
|
204
|
+
super.dispose();
|
|
205
|
+
}
|
|
206
|
+
public scrollLines(amount: number): void {
|
|
207
|
+
this._verifyIntegers(amount);
|
|
208
|
+
this._core.scrollLines(amount);
|
|
209
|
+
}
|
|
210
|
+
public scrollPages(pageCount: number): void {
|
|
211
|
+
this._verifyIntegers(pageCount);
|
|
212
|
+
this._core.scrollPages(pageCount);
|
|
213
|
+
}
|
|
214
|
+
public scrollToTop(): void {
|
|
215
|
+
this._core.scrollToTop();
|
|
216
|
+
}
|
|
217
|
+
public scrollToBottom(): void {
|
|
218
|
+
this._core.scrollToBottom();
|
|
219
|
+
}
|
|
220
|
+
public scrollToLine(line: number): void {
|
|
221
|
+
this._verifyIntegers(line);
|
|
222
|
+
this._core.scrollToLine(line);
|
|
223
|
+
}
|
|
224
|
+
public clear(): void {
|
|
225
|
+
this._core.clear();
|
|
226
|
+
}
|
|
227
|
+
public write(data: string | Uint8Array, callback?: () => void): void {
|
|
228
|
+
this._core.write(data, callback);
|
|
229
|
+
}
|
|
230
|
+
public writeln(data: string | Uint8Array, callback?: () => void): void {
|
|
231
|
+
this._core.write(data);
|
|
232
|
+
this._core.write('\r\n', callback);
|
|
233
|
+
}
|
|
234
|
+
public paste(data: string): void {
|
|
235
|
+
this._core.paste(data);
|
|
236
|
+
}
|
|
237
|
+
public refresh(start: number, end: number): void {
|
|
238
|
+
this._verifyIntegers(start, end);
|
|
239
|
+
this._core.refresh(start, end);
|
|
240
|
+
}
|
|
241
|
+
public reset(): void {
|
|
242
|
+
this._core.reset();
|
|
243
|
+
}
|
|
244
|
+
public clearTextureAtlas(): void {
|
|
245
|
+
this._core.clearTextureAtlas();
|
|
246
|
+
}
|
|
247
|
+
public loadAddon(addon: ITerminalAddon): void {
|
|
248
|
+
this._addonManager.loadAddon(this, addon);
|
|
249
|
+
}
|
|
250
|
+
public static get strings(): ILocalizableStrings {
|
|
251
|
+
// A wrapper is required here because esbuild prevents setting an `export let`
|
|
252
|
+
return {
|
|
253
|
+
get promptLabel(): string { return Strings.promptLabel.get(); },
|
|
254
|
+
set promptLabel(value: string) { Strings.promptLabel.set(value); },
|
|
255
|
+
get tooMuchOutput(): string { return Strings.tooMuchOutput.get(); },
|
|
256
|
+
set tooMuchOutput(value: string) { Strings.tooMuchOutput.set(value); }
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
private _verifyIntegers(...values: number[]): void {
|
|
261
|
+
for ($value of values) {
|
|
262
|
+
if ($value === Infinity || isNaN($value) || $value % 1 !== 0) {
|
|
263
|
+
throw new Error('This API only accepts integers');
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
private _verifyPositiveIntegers(...values: number[]): void {
|
|
269
|
+
for ($value of values) {
|
|
270
|
+
if ($value && ($value === Infinity || isNaN($value) || $value % 1 !== 0 || $value < 0)) {
|
|
271
|
+
throw new Error('This API only accepts positive integers');
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|