@xterm/xterm 6.1.0-beta.28 → 6.1.0-beta.280
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 +62 -38
- package/css/xterm.css +29 -22
- package/lib/xterm.js +1 -1
- package/lib/xterm.js.map +1 -1
- package/lib/xterm.mjs +8 -34
- package/lib/xterm.mjs.map +4 -4
- package/package.json +56 -45
- package/src/browser/AccessibilityManager.ts +18 -13
- package/src/browser/Clipboard.ts +8 -5
- package/src/browser/ColorContrastCache.ts +3 -3
- package/src/browser/CoreBrowserTerminal.ts +179 -348
- package/src/browser/Dom.ts +178 -0
- package/src/browser/Linkifier.ts +14 -14
- package/src/browser/OscLinkProvider.ts +86 -18
- package/src/browser/RenderDebouncer.ts +7 -9
- package/src/browser/TimeBasedDebouncer.ts +12 -5
- package/src/browser/Types.ts +16 -14
- package/src/browser/Viewport.ts +58 -23
- package/src/browser/decorations/BufferDecorationRenderer.ts +3 -3
- package/src/browser/decorations/ColorZoneStore.ts +1 -1
- package/src/browser/decorations/OverviewRulerRenderer.ts +36 -20
- package/src/browser/input/CompositionHelper.ts +47 -11
- package/src/browser/input/Mouse.ts +5 -9
- package/src/browser/input/MoveToCell.ts +3 -3
- package/src/browser/public/Terminal.ts +33 -36
- package/src/browser/renderer/dom/DomRenderer.ts +265 -89
- package/src/browser/renderer/dom/DomRendererRowFactory.ts +34 -27
- package/src/browser/renderer/dom/WidthCache.ts +57 -55
- package/src/browser/renderer/shared/Constants.ts +7 -0
- package/src/browser/renderer/shared/RendererUtils.ts +1 -1
- package/src/browser/renderer/shared/SelectionRenderModel.ts +2 -2
- package/src/browser/renderer/shared/TextBlinkStateManager.ts +97 -0
- package/src/browser/renderer/shared/Types.ts +10 -4
- package/src/browser/scrollable/abstractScrollbar.ts +300 -0
- package/src/browser/scrollable/fastDomNode.ts +126 -0
- package/src/browser/scrollable/globalPointerMoveMonitor.ts +90 -0
- package/src/browser/scrollable/horizontalScrollbar.ts +85 -0
- package/src/browser/scrollable/mouseEvent.ts +292 -0
- package/src/browser/scrollable/scrollable.ts +486 -0
- package/src/browser/scrollable/scrollableElement.ts +581 -0
- package/src/browser/scrollable/scrollableElementOptions.ts +161 -0
- package/src/browser/scrollable/scrollbarArrow.ts +110 -0
- package/src/browser/scrollable/scrollbarState.ts +246 -0
- package/src/browser/scrollable/scrollbarVisibilityController.ts +113 -0
- package/src/browser/scrollable/touch.ts +485 -0
- package/src/browser/scrollable/verticalScrollbar.ts +143 -0
- package/src/browser/scrollable/widget.ts +23 -0
- package/src/browser/selection/SelectionModel.ts +1 -1
- package/src/browser/services/CharSizeService.ts +4 -4
- package/src/browser/services/CharacterJoinerService.ts +13 -11
- package/src/browser/services/CoreBrowserService.ts +7 -5
- package/src/browser/services/KeyboardService.ts +67 -0
- package/src/browser/services/LinkProviderService.ts +3 -3
- package/src/browser/services/MouseCoordsService.ts +47 -0
- package/src/browser/services/MouseService.ts +619 -23
- package/src/browser/services/RenderService.ts +33 -21
- package/src/browser/services/SelectionService.ts +72 -54
- package/src/browser/services/Services.ts +44 -21
- package/src/browser/services/ThemeService.ts +9 -9
- package/src/common/Async.ts +141 -0
- package/src/common/CircularList.ts +24 -3
- package/src/common/Color.ts +13 -5
- package/src/common/CoreTerminal.ts +61 -35
- package/src/common/Event.ts +118 -0
- package/src/common/InputHandler.ts +286 -105
- package/src/common/Lifecycle.ts +113 -0
- package/src/common/Platform.ts +15 -5
- package/src/common/SortedList.ts +8 -4
- package/src/common/StringBuilder.ts +67 -0
- package/src/common/TaskQueue.ts +17 -8
- package/src/common/Types.ts +68 -206
- package/src/common/Version.ts +1 -1
- package/src/common/WindowsMode.ts +2 -2
- package/src/common/buffer/AttributeData.ts +3 -2
- package/src/common/buffer/Buffer.ts +47 -32
- package/src/common/buffer/BufferLine.ts +175 -100
- package/src/common/buffer/BufferLineStringCache.ts +69 -0
- package/src/common/buffer/BufferReflow.ts +7 -4
- package/src/common/buffer/BufferSet.ts +13 -9
- package/src/common/buffer/CellData.ts +61 -4
- package/src/common/buffer/Constants.ts +13 -13
- package/src/common/buffer/Marker.ts +4 -4
- package/src/common/buffer/Types.ts +153 -3
- package/src/common/data/Charsets.ts +4 -7
- package/src/common/data/EscapeSequences.ts +71 -70
- package/src/common/input/Keyboard.ts +17 -10
- package/src/common/input/KittyKeyboard.ts +526 -0
- package/src/common/input/TextDecoder.ts +3 -3
- package/src/common/input/UnicodeV6.ts +3 -2
- package/src/common/input/Win32InputMode.ts +297 -0
- package/src/common/input/WriteBuffer.ts +108 -39
- package/src/common/input/XParseColor.ts +2 -2
- package/src/common/parser/ApcParser.ts +196 -0
- package/src/common/parser/Constants.ts +14 -4
- package/src/common/parser/DcsParser.ts +15 -16
- package/src/common/parser/EscapeSequenceParser.ts +214 -72
- package/src/common/parser/OscParser.ts +14 -15
- package/src/common/parser/Params.ts +31 -12
- package/src/common/parser/Types.ts +40 -30
- package/src/common/public/BufferApiView.ts +3 -3
- package/src/common/public/BufferLineApiView.ts +4 -4
- package/src/common/public/BufferNamespaceApi.ts +5 -5
- package/src/common/public/ParserApi.ts +5 -2
- package/src/common/public/UnicodeApi.ts +1 -1
- package/src/common/services/BufferService.ts +17 -13
- package/src/common/services/CharsetService.ts +6 -2
- package/src/common/services/CoreService.ts +23 -10
- package/src/common/services/DecorationService.ts +260 -15
- package/src/common/services/InstantiationService.ts +2 -2
- package/src/common/services/LogService.ts +2 -32
- package/src/common/services/{CoreMouseService.ts → MouseStateService.ts} +22 -133
- package/src/common/services/OptionsService.ts +17 -7
- package/src/common/services/OscLinkService.ts +3 -2
- package/src/common/services/ServiceRegistry.ts +14 -8
- package/src/common/services/Services.ts +54 -50
- package/src/common/services/UnicodeService.ts +6 -11
- package/typings/xterm.d.ts +329 -34
- package/src/common/Clone.ts +0 -23
- package/src/common/TypedArrayUtils.ts +0 -17
- package/src/vs/base/browser/browser.ts +0 -141
- package/src/vs/base/browser/canIUse.ts +0 -49
- package/src/vs/base/browser/dom.ts +0 -2369
- package/src/vs/base/browser/fastDomNode.ts +0 -316
- package/src/vs/base/browser/globalPointerMoveMonitor.ts +0 -112
- package/src/vs/base/browser/iframe.ts +0 -135
- package/src/vs/base/browser/keyboardEvent.ts +0 -213
- package/src/vs/base/browser/mouseEvent.ts +0 -229
- package/src/vs/base/browser/touch.ts +0 -372
- package/src/vs/base/browser/ui/scrollbar/abstractScrollbar.ts +0 -303
- package/src/vs/base/browser/ui/scrollbar/horizontalScrollbar.ts +0 -114
- package/src/vs/base/browser/ui/scrollbar/scrollableElement.ts +0 -720
- package/src/vs/base/browser/ui/scrollbar/scrollableElementOptions.ts +0 -165
- package/src/vs/base/browser/ui/scrollbar/scrollbarArrow.ts +0 -114
- package/src/vs/base/browser/ui/scrollbar/scrollbarState.ts +0 -243
- package/src/vs/base/browser/ui/scrollbar/scrollbarVisibilityController.ts +0 -118
- package/src/vs/base/browser/ui/scrollbar/verticalScrollbar.ts +0 -116
- package/src/vs/base/browser/ui/widget.ts +0 -57
- package/src/vs/base/browser/window.ts +0 -14
- package/src/vs/base/common/arrays.ts +0 -887
- package/src/vs/base/common/arraysFind.ts +0 -202
- package/src/vs/base/common/assert.ts +0 -71
- package/src/vs/base/common/async.ts +0 -1992
- package/src/vs/base/common/cancellation.ts +0 -148
- package/src/vs/base/common/charCode.ts +0 -450
- package/src/vs/base/common/collections.ts +0 -140
- package/src/vs/base/common/decorators.ts +0 -130
- package/src/vs/base/common/equals.ts +0 -146
- package/src/vs/base/common/errors.ts +0 -303
- package/src/vs/base/common/event.ts +0 -1778
- package/src/vs/base/common/functional.ts +0 -32
- package/src/vs/base/common/hash.ts +0 -316
- package/src/vs/base/common/iterator.ts +0 -159
- package/src/vs/base/common/keyCodes.ts +0 -526
- package/src/vs/base/common/keybindings.ts +0 -284
- package/src/vs/base/common/lazy.ts +0 -47
- package/src/vs/base/common/lifecycle.ts +0 -801
- package/src/vs/base/common/linkedList.ts +0 -142
- package/src/vs/base/common/map.ts +0 -202
- package/src/vs/base/common/numbers.ts +0 -98
- package/src/vs/base/common/observable.ts +0 -76
- package/src/vs/base/common/observableInternal/api.ts +0 -31
- package/src/vs/base/common/observableInternal/autorun.ts +0 -281
- package/src/vs/base/common/observableInternal/base.ts +0 -489
- package/src/vs/base/common/observableInternal/debugName.ts +0 -145
- package/src/vs/base/common/observableInternal/derived.ts +0 -428
- package/src/vs/base/common/observableInternal/lazyObservableValue.ts +0 -146
- package/src/vs/base/common/observableInternal/logging.ts +0 -328
- package/src/vs/base/common/observableInternal/promise.ts +0 -209
- package/src/vs/base/common/observableInternal/utils.ts +0 -610
- package/src/vs/base/common/platform.ts +0 -281
- package/src/vs/base/common/scrollable.ts +0 -522
- package/src/vs/base/common/sequence.ts +0 -34
- package/src/vs/base/common/stopwatch.ts +0 -43
- package/src/vs/base/common/strings.ts +0 -557
- package/src/vs/base/common/symbols.ts +0 -9
- package/src/vs/base/common/uint.ts +0 -59
- package/src/vs/patches/nls.ts +0 -90
- package/src/vs/typings/base-common.d.ts +0 -20
- package/src/vs/typings/require.d.ts +0 -42
- package/src/vs/typings/vscode-globals-nls.d.ts +0 -36
- package/src/vs/typings/vscode-globals-product.d.ts +0 -33
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
* @license MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { RenderDebouncer } from '
|
|
7
|
-
import { IRenderDebouncerWithCallback } from '
|
|
8
|
-
import { IRenderDimensions, IRenderer } from '
|
|
9
|
-
import { ICharSizeService, ICoreBrowserService, IRenderService, IThemeService } from '
|
|
10
|
-
import { Disposable, MutableDisposable, toDisposable } from '
|
|
11
|
-
import { DebouncedIdleTask } from 'common/TaskQueue';
|
|
12
|
-
import { IBufferService, ICoreService, IDecorationService, IOptionsService } from 'common/services/Services';
|
|
13
|
-
import { Emitter } from '
|
|
6
|
+
import { RenderDebouncer } from '../RenderDebouncer';
|
|
7
|
+
import { IRenderDebouncerWithCallback } from '../Types';
|
|
8
|
+
import { IRenderDimensions, IRenderer } from '../renderer/shared/Types';
|
|
9
|
+
import { ICharSizeService, ICoreBrowserService, IRenderService, IThemeService } from './Services';
|
|
10
|
+
import { Disposable, MutableDisposable, toDisposable } from '../../common/Lifecycle';
|
|
11
|
+
import { DebouncedIdleTask } from '../../common/TaskQueue';
|
|
12
|
+
import { IBufferService, ICoreService, IDecorationService, ILogService, IOptionsService } from '../../common/services/Services';
|
|
13
|
+
import { Emitter } from '../../common/Event';
|
|
14
14
|
|
|
15
15
|
interface ISelectionState {
|
|
16
16
|
start: [number, number] | undefined;
|
|
@@ -27,8 +27,9 @@ export class RenderService extends Disposable implements IRenderService {
|
|
|
27
27
|
|
|
28
28
|
private _renderer: MutableDisposable<IRenderer> = this._register(new MutableDisposable());
|
|
29
29
|
private _renderDebouncer: IRenderDebouncerWithCallback;
|
|
30
|
-
private _pausedResizeTask
|
|
30
|
+
private _pausedResizeTask: DebouncedIdleTask;
|
|
31
31
|
private _observerDisposable = this._register(new MutableDisposable());
|
|
32
|
+
private _intersectionObserver: IntersectionObserver | undefined;
|
|
32
33
|
|
|
33
34
|
private _isPaused: boolean = false;
|
|
34
35
|
private _needsFullRefresh: boolean = false;
|
|
@@ -58,6 +59,7 @@ export class RenderService extends Disposable implements IRenderService {
|
|
|
58
59
|
private _rowCount: number,
|
|
59
60
|
screenElement: HTMLElement,
|
|
60
61
|
@IOptionsService private readonly _optionsService: IOptionsService,
|
|
62
|
+
@ILogService private readonly _logService: ILogService,
|
|
61
63
|
@ICharSizeService private readonly _charSizeService: ICharSizeService,
|
|
62
64
|
@ICoreService private readonly _coreService: ICoreService,
|
|
63
65
|
@IDecorationService decorationService: IDecorationService,
|
|
@@ -67,6 +69,8 @@ export class RenderService extends Disposable implements IRenderService {
|
|
|
67
69
|
) {
|
|
68
70
|
super();
|
|
69
71
|
|
|
72
|
+
this._pausedResizeTask = this._register(new DebouncedIdleTask(this._logService));
|
|
73
|
+
|
|
70
74
|
this._renderDebouncer = new RenderDebouncer((start, end) => this._renderRows(start, end), this._coreBrowserService);
|
|
71
75
|
this._register(this._renderDebouncer);
|
|
72
76
|
|
|
@@ -111,7 +115,7 @@ export class RenderService extends Disposable implements IRenderService {
|
|
|
111
115
|
this._register(this._optionsService.onMultipleOptionChange([
|
|
112
116
|
'cursorBlink',
|
|
113
117
|
'cursorStyle'
|
|
114
|
-
], () => this.refreshRows(bufferService.buffer.y, bufferService.buffer.y, true)));
|
|
118
|
+
], () => this.refreshRows(bufferService.buffer.y, bufferService.buffer.y, undefined, true)));
|
|
115
119
|
|
|
116
120
|
this._register(themeService.onChangeColors(() => this._fullRefresh()));
|
|
117
121
|
|
|
@@ -124,13 +128,18 @@ export class RenderService extends Disposable implements IRenderService {
|
|
|
124
128
|
// and resume based on terminal visibility if so
|
|
125
129
|
if ('IntersectionObserver' in w) {
|
|
126
130
|
const observer = new w.IntersectionObserver(e => this._handleIntersectionChange(e[e.length - 1]), { threshold: 0 });
|
|
131
|
+
this._observerDisposable.value = toDisposable(() => {
|
|
132
|
+
this._intersectionObserver?.disconnect();
|
|
133
|
+
this._intersectionObserver = undefined;
|
|
134
|
+
});
|
|
135
|
+
this._intersectionObserver = observer;
|
|
127
136
|
observer.observe(screenElement);
|
|
128
|
-
this._observerDisposable.value = toDisposable(() => observer.disconnect());
|
|
129
137
|
}
|
|
130
138
|
}
|
|
131
139
|
|
|
132
140
|
private _handleIntersectionChange(entry: IntersectionObserverEntry): void {
|
|
133
141
|
this._isPaused = entry.isIntersecting === undefined ? (entry.intersectionRatio === 0) : !entry.isIntersecting;
|
|
142
|
+
this._renderer.value?.handleViewportVisibilityChange?.(!this._isPaused);
|
|
134
143
|
|
|
135
144
|
// Terminal was hidden on open
|
|
136
145
|
if (!this._isPaused && !this._charSizeService.hasValidSize) {
|
|
@@ -144,7 +153,7 @@ export class RenderService extends Disposable implements IRenderService {
|
|
|
144
153
|
}
|
|
145
154
|
}
|
|
146
155
|
|
|
147
|
-
public refreshRows(start: number, end: number, isRedrawOnly: boolean = false): void {
|
|
156
|
+
public refreshRows(start: number, end: number, sync: boolean = false, isRedrawOnly: boolean = false): void {
|
|
148
157
|
if (this._isPaused) {
|
|
149
158
|
this._needsFullRefresh = true;
|
|
150
159
|
return;
|
|
@@ -164,7 +173,12 @@ export class RenderService extends Disposable implements IRenderService {
|
|
|
164
173
|
if (!isRedrawOnly) {
|
|
165
174
|
this._isNextRenderRedrawOnly = false;
|
|
166
175
|
}
|
|
167
|
-
|
|
176
|
+
|
|
177
|
+
if (sync) {
|
|
178
|
+
this._renderRows(start, end);
|
|
179
|
+
} else {
|
|
180
|
+
this._renderDebouncer.refresh(start, end, this._rowCount);
|
|
181
|
+
}
|
|
168
182
|
}
|
|
169
183
|
|
|
170
184
|
private _renderRows(start: number, end: number): void {
|
|
@@ -234,7 +248,7 @@ export class RenderService extends Disposable implements IRenderService {
|
|
|
234
248
|
this._renderer.value = renderer;
|
|
235
249
|
// If the value was not set, the terminal is being disposed so ignore it
|
|
236
250
|
if (this._renderer.value) {
|
|
237
|
-
this._renderer.value.onRequestRedraw(e => this.refreshRows(e.start, e.end, true));
|
|
251
|
+
this._renderer.value.onRequestRedraw(e => this.refreshRows(e.start, e.end, e.sync, true));
|
|
238
252
|
|
|
239
253
|
// Force a refresh
|
|
240
254
|
this._needsSelectionRefresh = true;
|
|
@@ -342,13 +356,11 @@ class SynchronizedOutputHandler {
|
|
|
342
356
|
this._end = Math.max(this._end, end);
|
|
343
357
|
}
|
|
344
358
|
|
|
345
|
-
|
|
346
|
-
this._timeout =
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
}, Constants.SYNCHRONIZED_OUTPUT_TIMEOUT_MS);
|
|
351
|
-
}
|
|
359
|
+
this._timeout ??= this._coreBrowserService.window.setTimeout(() => {
|
|
360
|
+
this._timeout = undefined;
|
|
361
|
+
this._coreService.decPrivateModes.synchronizedOutput = false;
|
|
362
|
+
this._onTimeout();
|
|
363
|
+
}, Constants.SYNCHRONIZED_OUTPUT_TIMEOUT_MS);
|
|
352
364
|
}
|
|
353
365
|
|
|
354
366
|
public flush(): { start: number, end: number } | undefined {
|
|
@@ -3,42 +3,41 @@
|
|
|
3
3
|
* @license MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { IBufferRange, ILinkifier2 } from '
|
|
7
|
-
import { getCoordsRelativeToElement } from '
|
|
8
|
-
import { moveToCellSequence } from '
|
|
9
|
-
import { SelectionModel } from '
|
|
10
|
-
import { ISelectionRedrawRequestEvent, ISelectionRequestScrollLinesEvent } from '
|
|
11
|
-
import { ICoreBrowserService,
|
|
12
|
-
import { Disposable, toDisposable } from '
|
|
13
|
-
import * as Browser from 'common/Platform';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import { IBufferService, ICoreService, IOptionsService } from 'common/services/Services';
|
|
19
|
-
import { Emitter } from '
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const ALT_CLICK_MOVE_CURSOR_TIME = 500;
|
|
6
|
+
import { IBufferRange, ILinkifier2 } from '../Types';
|
|
7
|
+
import { getCoordsRelativeToElement } from '../input/Mouse';
|
|
8
|
+
import { moveToCellSequence } from '../input/MoveToCell';
|
|
9
|
+
import { SelectionModel } from '../selection/SelectionModel';
|
|
10
|
+
import { ISelectionRedrawRequestEvent, ISelectionRequestScrollLinesEvent } from '../selection/Types';
|
|
11
|
+
import { ICoreBrowserService, IMouseCoordsService, IRenderService, ISelectionService } from './Services';
|
|
12
|
+
import { Disposable, MutableDisposable, toDisposable } from '../../common/Lifecycle';
|
|
13
|
+
import * as Browser from '../../common/Platform';
|
|
14
|
+
import { IDisposable } from '../../common/Types';
|
|
15
|
+
import { IBuffer, IBufferLine, ICellData } from '../../common/buffer/Types';
|
|
16
|
+
import { getRangeLength } from '../../common/buffer/BufferRange';
|
|
17
|
+
import { CellData } from '../../common/buffer/CellData';
|
|
18
|
+
import { IBufferService, ICoreService, IMouseStateService, IOptionsService } from '../../common/services/Services';
|
|
19
|
+
import { Emitter } from '../../common/Event';
|
|
20
|
+
|
|
21
|
+
const enum Constants {
|
|
22
|
+
/**
|
|
23
|
+
* The number of pixels the mouse needs to be above or below the viewport in
|
|
24
|
+
* order to scroll at the maximum speed.
|
|
25
|
+
*/
|
|
26
|
+
DRAG_SCROLL_MAX_THRESHOLD = 50,
|
|
27
|
+
/**
|
|
28
|
+
* The maximum scrolling speed
|
|
29
|
+
*/
|
|
30
|
+
DRAG_SCROLL_MAX_SPEED = 15,
|
|
31
|
+
/**
|
|
32
|
+
* The number of milliseconds between drag scroll updates.
|
|
33
|
+
*/
|
|
34
|
+
DRAG_SCROLL_INTERVAL = 50,
|
|
35
|
+
/**
|
|
36
|
+
* The maximum amount of time that can have elapsed for an alt click to move the
|
|
37
|
+
* cursor.
|
|
38
|
+
*/
|
|
39
|
+
ALT_CLICK_MOVE_CURSOR_TIME = 500
|
|
40
|
+
}
|
|
42
41
|
|
|
43
42
|
const NON_BREAKING_SPACE_CHAR = String.fromCharCode(160);
|
|
44
43
|
const ALL_NON_BREAKING_SPACE_REGEX = new RegExp(NON_BREAKING_SPACE_CHAR, 'g');
|
|
@@ -103,7 +102,7 @@ export class SelectionService extends Disposable implements ISelectionService {
|
|
|
103
102
|
|
|
104
103
|
private _mouseMoveListener: EventListener;
|
|
105
104
|
private _mouseUpListener: EventListener;
|
|
106
|
-
private _trimListener
|
|
105
|
+
private readonly _trimListener = this._register(new MutableDisposable<IDisposable>());
|
|
107
106
|
private _workCell: CellData = new CellData();
|
|
108
107
|
|
|
109
108
|
private _mouseDownTimeStamp: number = 0;
|
|
@@ -126,8 +125,9 @@ export class SelectionService extends Disposable implements ISelectionService {
|
|
|
126
125
|
private readonly _linkifier: ILinkifier2,
|
|
127
126
|
@IBufferService private readonly _bufferService: IBufferService,
|
|
128
127
|
@ICoreService private readonly _coreService: ICoreService,
|
|
129
|
-
@
|
|
128
|
+
@IMouseCoordsService private readonly _mouseCoordsService: IMouseCoordsService,
|
|
130
129
|
@IOptionsService private readonly _optionsService: IOptionsService,
|
|
130
|
+
@IMouseStateService private readonly _mouseStateService: IMouseStateService,
|
|
131
131
|
@IRenderService private readonly _renderService: IRenderService,
|
|
132
132
|
@ICoreBrowserService private readonly _coreBrowserService: ICoreBrowserService
|
|
133
133
|
) {
|
|
@@ -141,7 +141,7 @@ export class SelectionService extends Disposable implements ISelectionService {
|
|
|
141
141
|
this.clearSelection();
|
|
142
142
|
}
|
|
143
143
|
});
|
|
144
|
-
this._trimListener = this._bufferService.buffer.lines.onTrim(amount => this._handleTrim(amount));
|
|
144
|
+
this._trimListener.value = this._bufferService.buffer.lines.onTrim(amount => this._handleTrim(amount));
|
|
145
145
|
this._register(this._bufferService.buffers.onBufferActivate(e => this._handleBufferActivate(e)));
|
|
146
146
|
|
|
147
147
|
this.enable();
|
|
@@ -395,7 +395,7 @@ export class SelectionService extends Disposable implements ISelectionService {
|
|
|
395
395
|
* @param event The mouse event.
|
|
396
396
|
*/
|
|
397
397
|
private _getMouseBufferCoords(event: MouseEvent): [number, number] | undefined {
|
|
398
|
-
const coords = this.
|
|
398
|
+
const coords = this._mouseCoordsService.getCoords(event, this._screenElement, this._bufferService.cols, this._bufferService.rows, true);
|
|
399
399
|
if (!coords) {
|
|
400
400
|
return undefined;
|
|
401
401
|
}
|
|
@@ -424,9 +424,9 @@ export class SelectionService extends Disposable implements ISelectionService {
|
|
|
424
424
|
offset -= terminalHeight;
|
|
425
425
|
}
|
|
426
426
|
|
|
427
|
-
offset = Math.min(Math.max(offset, -DRAG_SCROLL_MAX_THRESHOLD), DRAG_SCROLL_MAX_THRESHOLD);
|
|
428
|
-
offset /= DRAG_SCROLL_MAX_THRESHOLD;
|
|
429
|
-
return (offset / Math.abs(offset)) + Math.round(offset * (DRAG_SCROLL_MAX_SPEED - 1));
|
|
427
|
+
offset = Math.min(Math.max(offset, -Constants.DRAG_SCROLL_MAX_THRESHOLD), Constants.DRAG_SCROLL_MAX_THRESHOLD);
|
|
428
|
+
offset /= Constants.DRAG_SCROLL_MAX_THRESHOLD;
|
|
429
|
+
return (offset / Math.abs(offset)) + Math.round(offset * (Constants.DRAG_SCROLL_MAX_SPEED - 1));
|
|
430
430
|
}
|
|
431
431
|
|
|
432
432
|
/**
|
|
@@ -435,6 +435,10 @@ export class SelectionService extends Disposable implements ISelectionService {
|
|
|
435
435
|
* @param event The mouse event.
|
|
436
436
|
*/
|
|
437
437
|
public shouldForceSelection(event: MouseEvent): boolean {
|
|
438
|
+
if (this._optionsService.rawOptions.mouseEventsRequireAlt && this._mouseStateService.areMouseEventsActive) {
|
|
439
|
+
return !event.altKey;
|
|
440
|
+
}
|
|
441
|
+
|
|
438
442
|
if (Browser.isMac) {
|
|
439
443
|
return event.altKey && this._optionsService.rawOptions.macOptionClickForcesSelection;
|
|
440
444
|
}
|
|
@@ -459,6 +463,10 @@ export class SelectionService extends Disposable implements ISelectionService {
|
|
|
459
463
|
return;
|
|
460
464
|
}
|
|
461
465
|
|
|
466
|
+
if (this._optionsService.rawOptions.mouseEventsRequireAlt && this._mouseStateService.areMouseEventsActive && event.altKey) {
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
|
|
462
470
|
// Allow selection when using a specific modifier key, even when disabled
|
|
463
471
|
if (!this._enabled) {
|
|
464
472
|
if (!this.shouldForceSelection(event)) {
|
|
@@ -500,7 +508,7 @@ export class SelectionService extends Disposable implements ISelectionService {
|
|
|
500
508
|
this._screenElement.ownerDocument.addEventListener('mousemove', this._mouseMoveListener);
|
|
501
509
|
this._screenElement.ownerDocument.addEventListener('mouseup', this._mouseUpListener);
|
|
502
510
|
}
|
|
503
|
-
this._dragScrollIntervalTimer = this._coreBrowserService.window.setInterval(() => this._dragScroll(), DRAG_SCROLL_INTERVAL);
|
|
511
|
+
this._dragScrollIntervalTimer = this._coreBrowserService.window.setInterval(() => this._dragScroll(), Constants.DRAG_SCROLL_INTERVAL);
|
|
504
512
|
}
|
|
505
513
|
|
|
506
514
|
/**
|
|
@@ -532,6 +540,9 @@ export class SelectionService extends Disposable implements ISelectionService {
|
|
|
532
540
|
* @param event The mouse event.
|
|
533
541
|
*/
|
|
534
542
|
private _handleSingleClick(event: MouseEvent): void {
|
|
543
|
+
// Track if there was a selection before clearing
|
|
544
|
+
const hadSelection = this.hasSelection;
|
|
545
|
+
|
|
535
546
|
this._model.selectionStartLength = 0;
|
|
536
547
|
this._model.isSelectAllActive = false;
|
|
537
548
|
this._activeSelectionMode = this.shouldColumnSelect(event) ? SelectionMode.COLUMN : SelectionMode.NORMAL;
|
|
@@ -543,6 +554,11 @@ export class SelectionService extends Disposable implements ISelectionService {
|
|
|
543
554
|
}
|
|
544
555
|
this._model.selectionEnd = undefined;
|
|
545
556
|
|
|
557
|
+
// Fire selection change event if a selection was cleared
|
|
558
|
+
if (hadSelection) {
|
|
559
|
+
this._fireOnSelectionChange(this._model.finalSelectionStart, this._model.finalSelectionEnd, false);
|
|
560
|
+
}
|
|
561
|
+
|
|
546
562
|
// Ensure the line exists
|
|
547
563
|
const line = this._bufferService.buffer.lines.get(this._model.selectionStart[1]);
|
|
548
564
|
if (!line) {
|
|
@@ -589,6 +605,9 @@ export class SelectionService extends Disposable implements ISelectionService {
|
|
|
589
605
|
* @param event the mouse or keyboard event
|
|
590
606
|
*/
|
|
591
607
|
public shouldColumnSelect(event: KeyboardEvent | MouseEvent): boolean {
|
|
608
|
+
if (this._optionsService.rawOptions.mouseEventsRequireAlt && this._mouseStateService.areMouseEventsActive) {
|
|
609
|
+
return false;
|
|
610
|
+
}
|
|
592
611
|
return event.altKey && !(Browser.isMac && this._optionsService.rawOptions.macOptionClickForcesSelection);
|
|
593
612
|
}
|
|
594
613
|
|
|
@@ -667,7 +686,7 @@ export class SelectionService extends Disposable implements ISelectionService {
|
|
|
667
686
|
}
|
|
668
687
|
|
|
669
688
|
/**
|
|
670
|
-
* The callback that occurs every DRAG_SCROLL_INTERVAL ms that does the
|
|
689
|
+
* The callback that occurs every Constants.DRAG_SCROLL_INTERVAL ms that does the
|
|
671
690
|
* scrolling of the viewport.
|
|
672
691
|
*/
|
|
673
692
|
private _dragScroll(): void {
|
|
@@ -705,9 +724,9 @@ export class SelectionService extends Disposable implements ISelectionService {
|
|
|
705
724
|
|
|
706
725
|
this._removeMouseDownListeners();
|
|
707
726
|
|
|
708
|
-
if (this.selectionText.length <= 1 && timeElapsed < ALT_CLICK_MOVE_CURSOR_TIME && event.altKey && this._optionsService.rawOptions.altClickMovesCursor) {
|
|
727
|
+
if (this.selectionText.length <= 1 && timeElapsed < Constants.ALT_CLICK_MOVE_CURSOR_TIME && event.altKey && this._optionsService.rawOptions.altClickMovesCursor) {
|
|
709
728
|
if (this._bufferService.buffer.ybase === this._bufferService.buffer.ydisp) {
|
|
710
|
-
const coordinates = this.
|
|
729
|
+
const coordinates = this._mouseCoordsService.getCoords(
|
|
711
730
|
event,
|
|
712
731
|
this._element,
|
|
713
732
|
this._bufferService.cols,
|
|
@@ -762,8 +781,7 @@ export class SelectionService extends Disposable implements ISelectionService {
|
|
|
762
781
|
// reverseIndex) and delete in a splice is only ever used when the same
|
|
763
782
|
// number of elements was just added. Given this is could actually be
|
|
764
783
|
// beneficial to leave the selection as is for these cases.
|
|
765
|
-
this._trimListener.
|
|
766
|
-
this._trimListener = e.activeBuffer.lines.onTrim(amount => this._handleTrim(amount));
|
|
784
|
+
this._trimListener.value = e.activeBuffer.lines.onTrim(amount => this._handleTrim(amount));
|
|
767
785
|
}
|
|
768
786
|
|
|
769
787
|
/**
|
|
@@ -912,10 +930,10 @@ export class SelectionService extends Disposable implements ISelectionService {
|
|
|
912
930
|
// Calculate the start _column_, converting the the string indexes back to
|
|
913
931
|
// column coordinates.
|
|
914
932
|
let start =
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
933
|
+
startIndex // The index of the selection's start char in the line string
|
|
934
|
+
+ charOffset // The difference between the initial char's column and index
|
|
935
|
+
- leftWideCharCount // The number of wide chars left of the initial char
|
|
936
|
+
+ leftLongCharOffset; // The number of additional chars left of the initial char added by columns with strings longer than 1 (emojis)
|
|
919
937
|
|
|
920
938
|
// Calculate the length in _columns_, converting the the string indexes back
|
|
921
939
|
// to column coordinates.
|
|
@@ -1013,7 +1031,7 @@ export class SelectionService extends Disposable implements ISelectionService {
|
|
|
1013
1031
|
* word logic.
|
|
1014
1032
|
* @param cell The cell to check.
|
|
1015
1033
|
*/
|
|
1016
|
-
private _isCharWordSeparator(cell:
|
|
1034
|
+
private _isCharWordSeparator(cell: ICellData): boolean {
|
|
1017
1035
|
// Zero width characters are never separators as they are always to the
|
|
1018
1036
|
// right of wide characters
|
|
1019
1037
|
if (cell.getWidth() === 0) {
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
* @license MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { IRenderDimensions, IRenderer } from '
|
|
7
|
-
import { IColorSet, ILink, ReadonlyColorSet } from '
|
|
8
|
-
import { ISelectionRedrawRequestEvent as ISelectionRequestRedrawEvent, ISelectionRequestScrollLinesEvent } from '
|
|
9
|
-
import { createDecorator } from 'common/services/ServiceRegistry';
|
|
10
|
-
import { AllColorIndex, IDisposable } from 'common/Types';
|
|
11
|
-
import type {
|
|
6
|
+
import { IRenderDimensions, IRenderer } from '../renderer/shared/Types';
|
|
7
|
+
import { IColorSet, ILink, ReadonlyColorSet } from '../Types';
|
|
8
|
+
import { ISelectionRedrawRequestEvent as ISelectionRequestRedrawEvent, ISelectionRequestScrollLinesEvent } from '../selection/Types';
|
|
9
|
+
import { createDecorator } from '../../common/services/ServiceRegistry';
|
|
10
|
+
import { AllColorIndex, IDisposable, IKeyboardResult } from '../../common/Types';
|
|
11
|
+
import type { IEvent } from '../../common/Event';
|
|
12
12
|
|
|
13
13
|
export const ICharSizeService = createDecorator<ICharSizeService>('CharSizeService');
|
|
14
14
|
export interface ICharSizeService {
|
|
@@ -18,7 +18,7 @@ export interface ICharSizeService {
|
|
|
18
18
|
readonly height: number;
|
|
19
19
|
readonly hasValidSize: boolean;
|
|
20
20
|
|
|
21
|
-
readonly onCharSizeChange:
|
|
21
|
+
readonly onCharSizeChange: IEvent<void>;
|
|
22
22
|
|
|
23
23
|
measure(): void;
|
|
24
24
|
}
|
|
@@ -29,8 +29,8 @@ export interface ICoreBrowserService {
|
|
|
29
29
|
|
|
30
30
|
readonly isFocused: boolean;
|
|
31
31
|
|
|
32
|
-
readonly onDprChange:
|
|
33
|
-
readonly onWindowChange:
|
|
32
|
+
readonly onDprChange: IEvent<number>;
|
|
33
|
+
readonly onWindowChange: IEvent<Window & typeof globalThis>;
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Gets or sets the parent window that the terminal is rendered into. DOM and rendering APIs (e.g.
|
|
@@ -49,35 +49,49 @@ export interface ICoreBrowserService {
|
|
|
49
49
|
readonly dpr: number;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
export const
|
|
53
|
-
export interface
|
|
52
|
+
export const IMouseCoordsService = createDecorator<IMouseCoordsService>('MouseCoordsService');
|
|
53
|
+
export interface IMouseCoordsService {
|
|
54
54
|
serviceBrand: undefined;
|
|
55
55
|
|
|
56
56
|
getCoords(event: {clientX: number, clientY: number}, element: HTMLElement, colCount: number, rowCount: number, isSelection?: boolean): [number, number] | undefined;
|
|
57
57
|
getMouseReportCoords(event: MouseEvent, element: HTMLElement): { col: number, row: number, x: number, y: number } | undefined;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
export const IMouseService = createDecorator<IMouseService>('MouseService');
|
|
61
|
+
export interface IMouseService {
|
|
62
|
+
serviceBrand: undefined;
|
|
63
|
+
|
|
64
|
+
bindMouse(target: IMouseServiceTarget, register: (disposable: IDisposable) => void, focus: () => void): void;
|
|
65
|
+
reset(): void;
|
|
66
|
+
}
|
|
67
|
+
export interface IMouseServiceTarget {
|
|
68
|
+
element: HTMLElement;
|
|
69
|
+
screenElement: HTMLElement;
|
|
70
|
+
document: Document;
|
|
71
|
+
handleTouchScroll?(amount: number): void;
|
|
72
|
+
}
|
|
73
|
+
|
|
60
74
|
export const IRenderService = createDecorator<IRenderService>('RenderService');
|
|
61
75
|
export interface IRenderService extends IDisposable {
|
|
62
76
|
serviceBrand: undefined;
|
|
63
77
|
|
|
64
|
-
onDimensionsChange:
|
|
78
|
+
onDimensionsChange: IEvent<IRenderDimensions>;
|
|
65
79
|
/**
|
|
66
80
|
* Fires when buffer changes are rendered. This does not fire when only cursor
|
|
67
81
|
* or selections are rendered.
|
|
68
82
|
*/
|
|
69
|
-
onRenderedViewportChange:
|
|
83
|
+
onRenderedViewportChange: IEvent<{ start: number, end: number }>;
|
|
70
84
|
/**
|
|
71
85
|
* Fires on render
|
|
72
86
|
*/
|
|
73
|
-
onRender:
|
|
74
|
-
onRefreshRequest:
|
|
87
|
+
onRender: IEvent<{ start: number, end: number }>;
|
|
88
|
+
onRefreshRequest: IEvent<{ start: number, end: number }>;
|
|
75
89
|
|
|
76
90
|
dimensions: IRenderDimensions;
|
|
77
91
|
|
|
78
92
|
addRefreshCallback(callback: FrameRequestCallback): number;
|
|
79
93
|
|
|
80
|
-
refreshRows(start: number, end: number): void;
|
|
94
|
+
refreshRows(start: number, end: number, sync?: boolean): void;
|
|
81
95
|
clearTextureAtlas(): void;
|
|
82
96
|
resize(cols: number, rows: number): void;
|
|
83
97
|
hasRenderer(): boolean;
|
|
@@ -101,10 +115,10 @@ export interface ISelectionService {
|
|
|
101
115
|
readonly selectionStart: [number, number] | undefined;
|
|
102
116
|
readonly selectionEnd: [number, number] | undefined;
|
|
103
117
|
|
|
104
|
-
readonly onLinuxMouseSelection:
|
|
105
|
-
readonly onRequestRedraw:
|
|
106
|
-
readonly onRequestScrollLines:
|
|
107
|
-
readonly onSelectionChange:
|
|
118
|
+
readonly onLinuxMouseSelection: IEvent<string>;
|
|
119
|
+
readonly onRequestRedraw: IEvent<ISelectionRequestRedrawEvent>;
|
|
120
|
+
readonly onRequestScrollLines: IEvent<ISelectionRequestScrollLinesEvent>;
|
|
121
|
+
readonly onSelectionChange: IEvent<void>;
|
|
108
122
|
|
|
109
123
|
disable(): void;
|
|
110
124
|
enable(): void;
|
|
@@ -136,7 +150,7 @@ export interface IThemeService {
|
|
|
136
150
|
|
|
137
151
|
readonly colors: ReadonlyColorSet;
|
|
138
152
|
|
|
139
|
-
readonly onChangeColors:
|
|
153
|
+
readonly onChangeColors: IEvent<ReadonlyColorSet>;
|
|
140
154
|
|
|
141
155
|
restoreColor(slot?: AllColorIndex): void;
|
|
142
156
|
/**
|
|
@@ -156,3 +170,12 @@ export interface ILinkProviderService extends IDisposable {
|
|
|
156
170
|
export interface ILinkProvider {
|
|
157
171
|
provideLinks(y: number, callback: (links: ILink[] | undefined) => void): void;
|
|
158
172
|
}
|
|
173
|
+
|
|
174
|
+
export const IKeyboardService = createDecorator<IKeyboardService>('KeyboardService');
|
|
175
|
+
export interface IKeyboardService {
|
|
176
|
+
serviceBrand: undefined;
|
|
177
|
+
evaluateKeyDown(event: KeyboardEvent): IKeyboardResult;
|
|
178
|
+
evaluateKeyUp(event: KeyboardEvent): IKeyboardResult | undefined;
|
|
179
|
+
readonly useKitty: boolean;
|
|
180
|
+
readonly useWin32InputMode: boolean;
|
|
181
|
+
}
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
* @license MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { ColorContrastCache } from '
|
|
7
|
-
import { IThemeService } from '
|
|
8
|
-
import { DEFAULT_ANSI_COLORS, IColorContrastCache, IColorSet, ReadonlyColorSet } from '
|
|
9
|
-
import { color, css, NULL_COLOR } from 'common/Color';
|
|
10
|
-
import { Disposable } from '
|
|
11
|
-
import { IOptionsService, ITheme } from 'common/services/Services';
|
|
12
|
-
import { AllColorIndex, IColor, SpecialColorIndex } from 'common/Types';
|
|
13
|
-
import { Emitter } from '
|
|
6
|
+
import { ColorContrastCache } from '../ColorContrastCache';
|
|
7
|
+
import { IThemeService } from './Services';
|
|
8
|
+
import { DEFAULT_ANSI_COLORS, IColorContrastCache, IColorSet, ReadonlyColorSet } from '../Types';
|
|
9
|
+
import { color, css, NULL_COLOR } from '../../common/Color';
|
|
10
|
+
import { Disposable } from '../../common/Lifecycle';
|
|
11
|
+
import { IOptionsService, ITheme } from '../../common/services/Services';
|
|
12
|
+
import { AllColorIndex, IColor, SpecialColorIndex } from '../../common/Types';
|
|
13
|
+
import { Emitter } from '../../common/Event';
|
|
14
14
|
|
|
15
15
|
interface IRestoreColorSet {
|
|
16
16
|
foreground: IColor;
|
|
@@ -132,7 +132,7 @@ export class ThemeService extends Disposable implements IThemeService {
|
|
|
132
132
|
colors.ansi[i + 16] = parseColor(theme.extendedAnsi[i], DEFAULT_ANSI_COLORS[i + 16]);
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
-
// Clear
|
|
135
|
+
// Clear the cache
|
|
136
136
|
this._contrastCache.clear();
|
|
137
137
|
this._halfContrastCache.clear();
|
|
138
138
|
this._updateRestoreColors();
|