@xterm/xterm 5.6.0-beta.14 → 5.6.0-beta.140
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 +9 -3
- package/css/xterm.css +71 -4
- package/lib/xterm.js +1 -1
- package/lib/xterm.js.map +1 -1
- package/lib/xterm.mjs +53 -0
- package/lib/xterm.mjs.map +7 -0
- package/package.json +45 -33
- package/src/browser/AccessibilityManager.ts +54 -26
- package/src/browser/{Terminal.ts → CoreBrowserTerminal.ts} +159 -145
- package/src/browser/Linkifier.ts +26 -14
- package/src/browser/LocalizableStrings.ts +15 -4
- package/src/browser/TimeBasedDebouncer.ts +2 -2
- package/src/browser/{Types.d.ts → Types.ts} +67 -15
- package/src/browser/Viewport.ts +148 -370
- package/src/browser/decorations/BufferDecorationRenderer.ts +14 -9
- package/src/browser/decorations/OverviewRulerRenderer.ts +40 -44
- package/src/browser/input/CompositionHelper.ts +2 -1
- package/src/browser/input/MoveToCell.ts +3 -1
- package/src/browser/public/Terminal.ts +25 -19
- package/src/browser/renderer/dom/DomRenderer.ts +19 -14
- package/src/browser/renderer/dom/DomRendererRowFactory.ts +35 -15
- package/src/browser/renderer/shared/Constants.ts +0 -8
- package/src/browser/renderer/shared/Types.ts +84 -0
- package/src/browser/services/CharSizeService.ts +6 -6
- package/src/browser/services/CoreBrowserService.ts +16 -20
- package/src/browser/services/LinkProviderService.ts +2 -2
- package/src/browser/services/RenderService.ts +20 -20
- package/src/browser/services/SelectionService.ts +16 -8
- package/src/browser/services/Services.ts +13 -13
- package/src/browser/services/ThemeService.ts +19 -58
- package/src/browser/shared/Constants.ts +8 -0
- package/src/common/CircularList.ts +5 -5
- package/src/common/CoreTerminal.ts +35 -41
- package/src/common/InputHandler.ts +89 -59
- package/src/common/TaskQueue.ts +7 -7
- package/src/common/{Types.d.ts → Types.ts} +13 -17
- package/src/common/buffer/Buffer.ts +15 -7
- package/src/common/buffer/BufferReflow.ts +9 -6
- package/src/common/buffer/BufferSet.ts +5 -5
- package/src/common/buffer/Marker.ts +4 -4
- package/src/common/buffer/{Types.d.ts → Types.ts} +2 -2
- package/src/common/input/Keyboard.ts +0 -24
- package/src/common/input/WriteBuffer.ts +9 -8
- package/src/common/parser/EscapeSequenceParser.ts +4 -4
- package/src/common/public/BufferNamespaceApi.ts +3 -3
- package/src/common/services/BufferService.ts +14 -11
- package/src/common/services/CoreMouseService.ts +53 -6
- package/src/common/services/CoreService.ts +12 -8
- package/src/common/services/DecorationService.ts +8 -9
- package/src/common/services/InstantiationService.ts +1 -1
- package/src/common/services/LogService.ts +2 -2
- package/src/common/services/OptionsService.ts +8 -6
- package/src/common/services/ServiceRegistry.ts +1 -1
- package/src/common/services/Services.ts +39 -17
- package/src/common/services/UnicodeService.ts +2 -2
- package/src/vs/base/browser/browser.ts +141 -0
- package/src/vs/base/browser/canIUse.ts +49 -0
- package/src/vs/base/browser/dom.ts +2369 -0
- package/src/vs/base/browser/fastDomNode.ts +316 -0
- package/src/vs/base/browser/globalPointerMoveMonitor.ts +112 -0
- package/src/vs/base/browser/iframe.ts +135 -0
- package/src/vs/base/browser/keyboardEvent.ts +213 -0
- package/src/vs/base/browser/mouseEvent.ts +229 -0
- package/src/vs/base/browser/touch.ts +372 -0
- package/src/vs/base/browser/ui/scrollbar/abstractScrollbar.ts +303 -0
- package/src/vs/base/browser/ui/scrollbar/horizontalScrollbar.ts +114 -0
- package/src/vs/base/browser/ui/scrollbar/scrollableElement.ts +720 -0
- package/src/vs/base/browser/ui/scrollbar/scrollableElementOptions.ts +165 -0
- package/src/vs/base/browser/ui/scrollbar/scrollbarArrow.ts +114 -0
- package/src/vs/base/browser/ui/scrollbar/scrollbarState.ts +243 -0
- package/src/vs/base/browser/ui/scrollbar/scrollbarVisibilityController.ts +118 -0
- package/src/vs/base/browser/ui/scrollbar/verticalScrollbar.ts +116 -0
- package/src/vs/base/browser/ui/widget.ts +57 -0
- package/src/vs/base/browser/window.ts +14 -0
- package/src/vs/base/common/arrays.ts +887 -0
- package/src/vs/base/common/arraysFind.ts +202 -0
- package/src/vs/base/common/assert.ts +71 -0
- package/src/vs/base/common/async.ts +1992 -0
- package/src/vs/base/common/cancellation.ts +148 -0
- package/src/vs/base/common/charCode.ts +450 -0
- package/src/vs/base/common/collections.ts +140 -0
- package/src/vs/base/common/decorators.ts +130 -0
- package/src/vs/base/common/equals.ts +146 -0
- package/src/vs/base/common/errors.ts +303 -0
- package/src/vs/base/common/event.ts +1778 -0
- package/src/vs/base/common/functional.ts +32 -0
- package/src/vs/base/common/hash.ts +316 -0
- package/src/vs/base/common/iterator.ts +159 -0
- package/src/vs/base/common/keyCodes.ts +526 -0
- package/src/vs/base/common/keybindings.ts +284 -0
- package/src/vs/base/common/lazy.ts +47 -0
- package/src/vs/base/common/lifecycle.ts +801 -0
- package/src/vs/base/common/linkedList.ts +142 -0
- package/src/vs/base/common/map.ts +202 -0
- package/src/vs/base/common/numbers.ts +98 -0
- package/src/vs/base/common/observable.ts +76 -0
- package/src/vs/base/common/observableInternal/api.ts +31 -0
- package/src/vs/base/common/observableInternal/autorun.ts +281 -0
- package/src/vs/base/common/observableInternal/base.ts +489 -0
- package/src/vs/base/common/observableInternal/debugName.ts +145 -0
- package/src/vs/base/common/observableInternal/derived.ts +428 -0
- package/src/vs/base/common/observableInternal/lazyObservableValue.ts +146 -0
- package/src/vs/base/common/observableInternal/logging.ts +328 -0
- package/src/vs/base/common/observableInternal/promise.ts +209 -0
- package/src/vs/base/common/observableInternal/utils.ts +610 -0
- package/src/vs/base/common/platform.ts +281 -0
- package/src/vs/base/common/scrollable.ts +522 -0
- package/src/vs/base/common/sequence.ts +34 -0
- package/src/vs/base/common/stopwatch.ts +43 -0
- package/src/vs/base/common/strings.ts +557 -0
- package/src/vs/base/common/symbols.ts +9 -0
- package/src/vs/base/common/uint.ts +59 -0
- package/src/vs/patches/nls.ts +90 -0
- package/src/vs/typings/base-common.d.ts +20 -0
- package/src/vs/typings/require.d.ts +42 -0
- package/src/vs/typings/vscode-globals-nls.d.ts +36 -0
- package/src/vs/typings/vscode-globals-product.d.ts +33 -0
- package/typings/xterm.d.ts +80 -14
- package/src/browser/Lifecycle.ts +0 -33
- package/src/browser/renderer/shared/CellColorResolver.ts +0 -236
- package/src/browser/renderer/shared/CharAtlasCache.ts +0 -96
- package/src/browser/renderer/shared/CharAtlasUtils.ts +0 -75
- package/src/browser/renderer/shared/CursorBlinkStateManager.ts +0 -146
- package/src/browser/renderer/shared/CustomGlyphs.ts +0 -687
- package/src/browser/renderer/shared/DevicePixelObserver.ts +0 -41
- package/src/browser/renderer/shared/TextureAtlas.ts +0 -1100
- package/src/browser/renderer/shared/Types.d.ts +0 -173
- package/src/common/EventEmitter.ts +0 -78
- package/src/common/Lifecycle.ts +0 -108
- /package/src/browser/selection/{Types.d.ts → Types.ts} +0 -0
- /package/src/common/parser/{Types.d.ts → Types.ts} +0 -0
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
* @license MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import { Disposable } from 'common/Lifecycle';
|
|
6
|
+
import { Disposable } from 'vs/base/common/lifecycle';
|
|
8
7
|
import { IAttributeData } from 'common/Types';
|
|
9
8
|
import { Buffer } from 'common/buffer/Buffer';
|
|
10
9
|
import { IBuffer, IBufferSet } from 'common/buffer/Types';
|
|
11
10
|
import { IBufferService, IOptionsService } from 'common/services/Services';
|
|
11
|
+
import { Emitter } from 'vs/base/common/event';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* The BufferSet represents the set of two buffers used by xterm terminals (normal and alt) and
|
|
@@ -19,7 +19,7 @@ export class BufferSet extends Disposable implements IBufferSet {
|
|
|
19
19
|
private _alt!: Buffer;
|
|
20
20
|
private _activeBuffer!: Buffer;
|
|
21
21
|
|
|
22
|
-
private readonly _onBufferActivate = this.
|
|
22
|
+
private readonly _onBufferActivate = this._register(new Emitter<{ activeBuffer: IBuffer, inactiveBuffer: IBuffer }>());
|
|
23
23
|
public readonly onBufferActivate = this._onBufferActivate.event;
|
|
24
24
|
|
|
25
25
|
/**
|
|
@@ -31,8 +31,8 @@ export class BufferSet extends Disposable implements IBufferSet {
|
|
|
31
31
|
) {
|
|
32
32
|
super();
|
|
33
33
|
this.reset();
|
|
34
|
-
this.
|
|
35
|
-
this.
|
|
34
|
+
this._register(this._optionsService.onSpecificOptionChange('scrollback', () => this.resize(this._bufferService.cols, this._bufferService.rows)));
|
|
35
|
+
this._register(this._optionsService.onSpecificOptionChange('tabStopWidth', () => this.setupTabStops()));
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
public reset(): void {
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* @license MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { EventEmitter } from 'common/EventEmitter';
|
|
7
|
-
import { disposeArray } from 'common/Lifecycle';
|
|
8
6
|
import { IDisposable, IMarker } from 'common/Types';
|
|
7
|
+
import { Emitter } from 'vs/base/common/event';
|
|
8
|
+
import { dispose } from 'vs/base/common/lifecycle';
|
|
9
9
|
|
|
10
10
|
export class Marker implements IMarker {
|
|
11
11
|
private static _nextId = 1;
|
|
@@ -16,7 +16,7 @@ export class Marker implements IMarker {
|
|
|
16
16
|
private readonly _id: number = Marker._nextId++;
|
|
17
17
|
public get id(): number { return this._id; }
|
|
18
18
|
|
|
19
|
-
private readonly _onDispose = this.register(new
|
|
19
|
+
private readonly _onDispose = this.register(new Emitter<void>());
|
|
20
20
|
public readonly onDispose = this._onDispose.event;
|
|
21
21
|
|
|
22
22
|
constructor(
|
|
@@ -32,7 +32,7 @@ export class Marker implements IMarker {
|
|
|
32
32
|
this.line = -1;
|
|
33
33
|
// Emit before super.dispose such that dispose listeners get a change to react
|
|
34
34
|
this._onDispose.fire();
|
|
35
|
-
|
|
35
|
+
dispose(this._disposables);
|
|
36
36
|
this._disposables.length = 0;
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { IAttributeData, ICircularList, IBufferLine, ICellData, IMarker, ICharset, IDisposable } from 'common/Types';
|
|
7
|
-
import {
|
|
7
|
+
import type { Event } from 'vs/base/common/event';
|
|
8
8
|
|
|
9
9
|
// BufferIndex denotes a position in the buffer: [rowIndex, colIndex]
|
|
10
10
|
export type BufferIndex = [number, number];
|
|
@@ -42,7 +42,7 @@ export interface IBufferSet extends IDisposable {
|
|
|
42
42
|
normal: IBuffer;
|
|
43
43
|
active: IBuffer;
|
|
44
44
|
|
|
45
|
-
onBufferActivate:
|
|
45
|
+
onBufferActivate: Event<{ activeBuffer: IBuffer, inactiveBuffer: IBuffer }>;
|
|
46
46
|
|
|
47
47
|
activateNormalBuffer(): void;
|
|
48
48
|
activateAltBuffer(fillAttr?: IAttributeData): void;
|
|
@@ -117,12 +117,6 @@ export function evaluateKeyboardEvent(
|
|
|
117
117
|
}
|
|
118
118
|
if (modifiers) {
|
|
119
119
|
result.key = C0.ESC + '[1;' + (modifiers + 1) + 'D';
|
|
120
|
-
// HACK: Make Alt + left-arrow behave like Ctrl + left-arrow: move one word backwards
|
|
121
|
-
// http://unix.stackexchange.com/a/108106
|
|
122
|
-
// macOS uses different escape sequences than linux
|
|
123
|
-
if (result.key === C0.ESC + '[1;3D') {
|
|
124
|
-
result.key = C0.ESC + (isMac ? 'b' : '[1;5D');
|
|
125
|
-
}
|
|
126
120
|
} else if (applicationCursorMode) {
|
|
127
121
|
result.key = C0.ESC + 'OD';
|
|
128
122
|
} else {
|
|
@@ -136,12 +130,6 @@ export function evaluateKeyboardEvent(
|
|
|
136
130
|
}
|
|
137
131
|
if (modifiers) {
|
|
138
132
|
result.key = C0.ESC + '[1;' + (modifiers + 1) + 'C';
|
|
139
|
-
// HACK: Make Alt + right-arrow behave like Ctrl + right-arrow: move one word forward
|
|
140
|
-
// http://unix.stackexchange.com/a/108106
|
|
141
|
-
// macOS uses different escape sequences than linux
|
|
142
|
-
if (result.key === C0.ESC + '[1;3C') {
|
|
143
|
-
result.key = C0.ESC + (isMac ? 'f' : '[1;5C');
|
|
144
|
-
}
|
|
145
133
|
} else if (applicationCursorMode) {
|
|
146
134
|
result.key = C0.ESC + 'OC';
|
|
147
135
|
} else {
|
|
@@ -155,12 +143,6 @@ export function evaluateKeyboardEvent(
|
|
|
155
143
|
}
|
|
156
144
|
if (modifiers) {
|
|
157
145
|
result.key = C0.ESC + '[1;' + (modifiers + 1) + 'A';
|
|
158
|
-
// HACK: Make Alt + up-arrow behave like Ctrl + up-arrow
|
|
159
|
-
// http://unix.stackexchange.com/a/108106
|
|
160
|
-
// macOS uses different escape sequences than linux
|
|
161
|
-
if (!isMac && result.key === C0.ESC + '[1;3A') {
|
|
162
|
-
result.key = C0.ESC + '[1;5A';
|
|
163
|
-
}
|
|
164
146
|
} else if (applicationCursorMode) {
|
|
165
147
|
result.key = C0.ESC + 'OA';
|
|
166
148
|
} else {
|
|
@@ -174,12 +156,6 @@ export function evaluateKeyboardEvent(
|
|
|
174
156
|
}
|
|
175
157
|
if (modifiers) {
|
|
176
158
|
result.key = C0.ESC + '[1;' + (modifiers + 1) + 'B';
|
|
177
|
-
// HACK: Make Alt + down-arrow behave like Ctrl + down-arrow
|
|
178
|
-
// http://unix.stackexchange.com/a/108106
|
|
179
|
-
// macOS uses different escape sequences than linux
|
|
180
|
-
if (!isMac && result.key === C0.ESC + '[1;3B') {
|
|
181
|
-
result.key = C0.ESC + '[1;5B';
|
|
182
|
-
}
|
|
183
159
|
} else if (applicationCursorMode) {
|
|
184
160
|
result.key = C0.ESC + 'OB';
|
|
185
161
|
} else {
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { Disposable } from 'vs/base/common/lifecycle';
|
|
8
|
+
import { Emitter } from 'vs/base/common/event';
|
|
9
9
|
|
|
10
10
|
declare const setTimeout: (handler: () => void, timeout?: number) => void;
|
|
11
11
|
|
|
@@ -43,7 +43,7 @@ export class WriteBuffer extends Disposable {
|
|
|
43
43
|
private _syncCalls = 0;
|
|
44
44
|
private _didUserInput = false;
|
|
45
45
|
|
|
46
|
-
private readonly _onWriteParsed = this.
|
|
46
|
+
private readonly _onWriteParsed = this._register(new Emitter<void>());
|
|
47
47
|
public readonly onWriteParsed = this._onWriteParsed.event;
|
|
48
48
|
|
|
49
49
|
constructor(private _action: (data: string | Uint8Array, promiseResult?: boolean) => void | Promise<boolean>) {
|
|
@@ -137,7 +137,7 @@ export class WriteBuffer extends Disposable {
|
|
|
137
137
|
* effectively lowering the redrawing needs, schematically:
|
|
138
138
|
*
|
|
139
139
|
* macroTask _innerWrite:
|
|
140
|
-
* if (
|
|
140
|
+
* if (performance.now() - (lastTime | 0) < WRITE_TIMEOUT_MS):
|
|
141
141
|
* schedule microTask _innerWrite(lastTime)
|
|
142
142
|
* else:
|
|
143
143
|
* schedule macroTask _innerWrite(0)
|
|
@@ -158,7 +158,7 @@ export class WriteBuffer extends Disposable {
|
|
|
158
158
|
* Note, for pure sync code `lastTime` and `promiseResult` have no meaning.
|
|
159
159
|
*/
|
|
160
160
|
protected _innerWrite(lastTime: number = 0, promiseResult: boolean = true): void {
|
|
161
|
-
const startTime = lastTime ||
|
|
161
|
+
const startTime = lastTime || performance.now();
|
|
162
162
|
while (this._writeBuffer.length > this._bufferOffset) {
|
|
163
163
|
const data = this._writeBuffer[this._bufferOffset];
|
|
164
164
|
const result = this._action(data, promiseResult);
|
|
@@ -186,7 +186,7 @@ export class WriteBuffer extends Disposable {
|
|
|
186
186
|
* responsibility to slice hard work), but we can at least schedule a screen update as we
|
|
187
187
|
* gain control.
|
|
188
188
|
*/
|
|
189
|
-
const continuation: (r: boolean) => void = (r: boolean) =>
|
|
189
|
+
const continuation: (r: boolean) => void = (r: boolean) => performance.now() - startTime >= WRITE_TIMEOUT_MS
|
|
190
190
|
? setTimeout(() => this._innerWrite(0, r))
|
|
191
191
|
: this._innerWrite(startTime, r);
|
|
192
192
|
|
|
@@ -202,7 +202,8 @@ export class WriteBuffer extends Disposable {
|
|
|
202
202
|
* throughput by eval'ing `startTime` upfront pulling at least one more chunk into the
|
|
203
203
|
* current microtask queue (executed before setTimeout).
|
|
204
204
|
*/
|
|
205
|
-
// const continuation: (r: boolean) => void =
|
|
205
|
+
// const continuation: (r: boolean) => void = performance.now() - startTime >=
|
|
206
|
+
// WRITE_TIMEOUT_MS
|
|
206
207
|
// ? r => setTimeout(() => this._innerWrite(0, r))
|
|
207
208
|
// : r => this._innerWrite(startTime, r);
|
|
208
209
|
|
|
@@ -222,7 +223,7 @@ export class WriteBuffer extends Disposable {
|
|
|
222
223
|
this._bufferOffset++;
|
|
223
224
|
this._pendingData -= data.length;
|
|
224
225
|
|
|
225
|
-
if (
|
|
226
|
+
if (performance.now() - startTime >= WRITE_TIMEOUT_MS) {
|
|
226
227
|
break;
|
|
227
228
|
}
|
|
228
229
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { IParsingState, IDcsHandler, IEscapeSequenceParser, IParams, IOscHandler, IHandlerCollection, CsiHandlerType, OscFallbackHandlerType, IOscParser, EscHandlerType, IDcsParser, DcsFallbackHandlerType, IFunctionIdentifier, ExecuteFallbackHandlerType, CsiFallbackHandlerType, EscFallbackHandlerType, PrintHandlerType, PrintFallbackHandlerType, ExecuteHandlerType, IParserStackState, ParserStackType, ResumableHandlersType } from 'common/parser/Types';
|
|
7
7
|
import { ParserState, ParserAction } from 'common/parser/Constants';
|
|
8
|
-
import { Disposable, toDisposable } from 'common/
|
|
8
|
+
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
|
|
9
9
|
import { IDisposable } from 'common/Types';
|
|
10
10
|
import { Params } from 'common/parser/Params';
|
|
11
11
|
import { OscParser } from 'common/parser/OscParser';
|
|
@@ -283,13 +283,13 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
|
|
|
283
283
|
this._executeHandlers = Object.create(null);
|
|
284
284
|
this._csiHandlers = Object.create(null);
|
|
285
285
|
this._escHandlers = Object.create(null);
|
|
286
|
-
this.
|
|
286
|
+
this._register(toDisposable(() => {
|
|
287
287
|
this._csiHandlers = Object.create(null);
|
|
288
288
|
this._executeHandlers = Object.create(null);
|
|
289
289
|
this._escHandlers = Object.create(null);
|
|
290
290
|
}));
|
|
291
|
-
this._oscParser = this.
|
|
292
|
-
this._dcsParser = this.
|
|
291
|
+
this._oscParser = this._register(new OscParser());
|
|
292
|
+
this._dcsParser = this._register(new DcsParser());
|
|
293
293
|
this._errorHandler = this._errorHandlerFb;
|
|
294
294
|
|
|
295
295
|
// swallow 7bit ST (ESC+\)
|
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
|
|
6
6
|
import { IBuffer as IBufferApi, IBufferNamespace as IBufferNamespaceApi } from '@xterm/xterm';
|
|
7
7
|
import { BufferApiView } from 'common/public/BufferApiView';
|
|
8
|
-
import { EventEmitter } from 'common/EventEmitter';
|
|
9
8
|
import { ICoreTerminal } from 'common/Types';
|
|
10
|
-
import { Disposable } from 'common/
|
|
9
|
+
import { Disposable } from 'vs/base/common/lifecycle';
|
|
10
|
+
import { Emitter } from 'vs/base/common/event';
|
|
11
11
|
|
|
12
12
|
export class BufferNamespaceApi extends Disposable implements IBufferNamespaceApi {
|
|
13
13
|
private _normal: BufferApiView;
|
|
14
14
|
private _alternate: BufferApiView;
|
|
15
15
|
|
|
16
|
-
private readonly _onBufferChange = this.
|
|
16
|
+
private readonly _onBufferChange = this._register(new Emitter<IBufferApi>());
|
|
17
17
|
public readonly onBufferChange = this._onBufferChange.event;
|
|
18
18
|
|
|
19
19
|
constructor(private _core: ICoreTerminal) {
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
* @license MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { IAttributeData, IBufferLine, ScrollSource } from 'common/Types';
|
|
6
|
+
import { Disposable } from 'vs/base/common/lifecycle';
|
|
7
|
+
import { IAttributeData, IBufferLine } from 'common/Types';
|
|
9
8
|
import { BufferSet } from 'common/buffer/BufferSet';
|
|
10
9
|
import { IBuffer, IBufferSet } from 'common/buffer/Types';
|
|
11
|
-
import { IBufferService, IOptionsService } from 'common/services/Services';
|
|
10
|
+
import { IBufferService, IOptionsService, type IBufferResizeEvent } from 'common/services/Services';
|
|
11
|
+
import { Emitter } from 'vs/base/common/event';
|
|
12
12
|
|
|
13
13
|
export const MINIMUM_COLS = 2; // Less than 2 can mess with wide chars
|
|
14
14
|
export const MINIMUM_ROWS = 1;
|
|
@@ -22,9 +22,9 @@ export class BufferService extends Disposable implements IBufferService {
|
|
|
22
22
|
/** Whether the user is scrolling (locks the scroll position) */
|
|
23
23
|
public isUserScrolling: boolean = false;
|
|
24
24
|
|
|
25
|
-
private readonly _onResize = this.
|
|
25
|
+
private readonly _onResize = this._register(new Emitter<IBufferResizeEvent>());
|
|
26
26
|
public readonly onResize = this._onResize.event;
|
|
27
|
-
private readonly _onScroll = this.
|
|
27
|
+
private readonly _onScroll = this._register(new Emitter<number>());
|
|
28
28
|
public readonly onScroll = this._onScroll.event;
|
|
29
29
|
|
|
30
30
|
public get buffer(): IBuffer { return this.buffers.active; }
|
|
@@ -36,16 +36,19 @@ export class BufferService extends Disposable implements IBufferService {
|
|
|
36
36
|
super();
|
|
37
37
|
this.cols = Math.max(optionsService.rawOptions.cols || 0, MINIMUM_COLS);
|
|
38
38
|
this.rows = Math.max(optionsService.rawOptions.rows || 0, MINIMUM_ROWS);
|
|
39
|
-
this.buffers = this.
|
|
39
|
+
this.buffers = this._register(new BufferSet(optionsService, this));
|
|
40
|
+
this._register(this.buffers.onBufferActivate(e => {
|
|
41
|
+
this._onScroll.fire(e.activeBuffer.ydisp);
|
|
42
|
+
}));
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
public resize(cols: number, rows: number): void {
|
|
46
|
+
const colsChanged = this.cols !== cols;
|
|
47
|
+
const rowsChanged = this.rows !== rows;
|
|
43
48
|
this.cols = cols;
|
|
44
49
|
this.rows = rows;
|
|
45
50
|
this.buffers.resize(cols, rows);
|
|
46
|
-
|
|
47
|
-
// event
|
|
48
|
-
this._onResize.fire({ cols, rows });
|
|
51
|
+
this._onResize.fire({ cols, rows, colsChanged, rowsChanged });
|
|
49
52
|
}
|
|
50
53
|
|
|
51
54
|
public reset(): void {
|
|
@@ -125,7 +128,7 @@ export class BufferService extends Disposable implements IBufferService {
|
|
|
125
128
|
* to avoid unwanted events being handled by the viewport when the event was triggered from the
|
|
126
129
|
* viewport originally.
|
|
127
130
|
*/
|
|
128
|
-
public scrollLines(disp: number, suppressScrollEvent?: boolean
|
|
131
|
+
public scrollLines(disp: number, suppressScrollEvent?: boolean): void {
|
|
129
132
|
const buffer = this.buffer;
|
|
130
133
|
if (disp < 0) {
|
|
131
134
|
if (buffer.ydisp === 0) {
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
|
|
3
3
|
* @license MIT
|
|
4
4
|
*/
|
|
5
|
-
import { IBufferService, ICoreService, ICoreMouseService } from 'common/services/Services';
|
|
6
|
-
import { EventEmitter } from 'common/EventEmitter';
|
|
5
|
+
import { IBufferService, ICoreService, ICoreMouseService, IOptionsService } from 'common/services/Services';
|
|
7
6
|
import { ICoreMouseProtocol, ICoreMouseEvent, CoreMouseEncoding, CoreMouseEventType, CoreMouseButton, CoreMouseAction } from 'common/Types';
|
|
8
|
-
import { Disposable } from 'common/
|
|
7
|
+
import { Disposable } from 'vs/base/common/lifecycle';
|
|
8
|
+
import { Emitter } from 'vs/base/common/event';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Supported default protocols.
|
|
@@ -167,18 +167,22 @@ const DEFAULT_ENCODINGS: { [key: string]: CoreMouseEncoding } = {
|
|
|
167
167
|
* To send a mouse event call `triggerMouseEvent`.
|
|
168
168
|
*/
|
|
169
169
|
export class CoreMouseService extends Disposable implements ICoreMouseService {
|
|
170
|
+
public serviceBrand: any;
|
|
171
|
+
|
|
170
172
|
private _protocols: { [name: string]: ICoreMouseProtocol } = {};
|
|
171
173
|
private _encodings: { [name: string]: CoreMouseEncoding } = {};
|
|
172
174
|
private _activeProtocol: string = '';
|
|
173
175
|
private _activeEncoding: string = '';
|
|
174
176
|
private _lastEvent: ICoreMouseEvent | null = null;
|
|
177
|
+
private _wheelPartialScroll: number = 0;
|
|
175
178
|
|
|
176
|
-
private readonly _onProtocolChange = this.
|
|
177
|
-
public readonly onProtocolChange =
|
|
179
|
+
private readonly _onProtocolChange = this._register(new Emitter<CoreMouseEventType>());
|
|
180
|
+
public readonly onProtocolChange = this._onProtocolChange.event;
|
|
178
181
|
|
|
179
182
|
constructor(
|
|
180
183
|
@IBufferService private readonly _bufferService: IBufferService,
|
|
181
|
-
@ICoreService private readonly _coreService: ICoreService
|
|
184
|
+
@ICoreService private readonly _coreService: ICoreService,
|
|
185
|
+
@IOptionsService private readonly _optionsService: IOptionsService
|
|
182
186
|
) {
|
|
183
187
|
super();
|
|
184
188
|
// register default protocols and encodings
|
|
@@ -227,6 +231,49 @@ export class CoreMouseService extends Disposable implements ICoreMouseService {
|
|
|
227
231
|
this.activeProtocol = 'NONE';
|
|
228
232
|
this.activeEncoding = 'DEFAULT';
|
|
229
233
|
this._lastEvent = null;
|
|
234
|
+
this._wheelPartialScroll = 0;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Processes a wheel event, accounting for partial scrolls for trackpad, mouse scrolls.
|
|
239
|
+
* This prevents hyper-sensitive scrolling in alt buffer.
|
|
240
|
+
*/
|
|
241
|
+
public consumeWheelEvent(ev: WheelEvent, cellHeight?: number, dpr?: number): number {
|
|
242
|
+
// Do nothing if it's not a vertical scroll event
|
|
243
|
+
if (ev.deltaY === 0 || ev.shiftKey) {
|
|
244
|
+
return 0;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (cellHeight === undefined || dpr === undefined) {
|
|
248
|
+
return 0;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const targetWheelEventPixels = cellHeight / dpr;
|
|
252
|
+
let amount = this._applyScrollModifier(ev.deltaY, ev);
|
|
253
|
+
|
|
254
|
+
if (ev.deltaMode === WheelEvent.DOM_DELTA_PIXEL) {
|
|
255
|
+
amount /= (targetWheelEventPixels + 0.0); // Prevent integer division
|
|
256
|
+
|
|
257
|
+
const isLikelyTrackpad = Math.abs(ev.deltaY) < 50;
|
|
258
|
+
if (isLikelyTrackpad) {
|
|
259
|
+
amount *= 0.3;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
this._wheelPartialScroll += amount;
|
|
263
|
+
amount = Math.floor(Math.abs(this._wheelPartialScroll)) * (this._wheelPartialScroll > 0 ? 1 : -1);
|
|
264
|
+
this._wheelPartialScroll %= 1;
|
|
265
|
+
} else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
|
|
266
|
+
amount *= this._bufferService.rows;
|
|
267
|
+
}
|
|
268
|
+
return amount;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
private _applyScrollModifier(amount: number, ev: WheelEvent): number {
|
|
272
|
+
// Multiply the scroll speed when the modifier key is pressed
|
|
273
|
+
if (ev.altKey || ev.ctrlKey || ev.shiftKey) {
|
|
274
|
+
return amount * this._optionsService.rawOptions.fastScrollSensitivity * this._optionsService.rawOptions.scrollSensitivity;
|
|
275
|
+
}
|
|
276
|
+
return amount * this._optionsService.rawOptions.scrollSensitivity;
|
|
230
277
|
}
|
|
231
278
|
|
|
232
279
|
/**
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { clone } from 'common/Clone';
|
|
7
|
-
import {
|
|
8
|
-
import { Disposable } from 'common/Lifecycle';
|
|
7
|
+
import { Disposable } from 'vs/base/common/lifecycle';
|
|
9
8
|
import { IDecPrivateModes, IModes } from 'common/Types';
|
|
10
9
|
import { IBufferService, ICoreService, ILogService, IOptionsService } from 'common/services/Services';
|
|
10
|
+
import { Emitter } from 'vs/base/common/event';
|
|
11
11
|
|
|
12
12
|
const DEFAULT_MODES: IModes = Object.freeze({
|
|
13
13
|
insertMode: false
|
|
@@ -17,6 +17,8 @@ const DEFAULT_DEC_PRIVATE_MODES: IDecPrivateModes = Object.freeze({
|
|
|
17
17
|
applicationCursorKeys: false,
|
|
18
18
|
applicationKeypad: false,
|
|
19
19
|
bracketedPasteMode: false,
|
|
20
|
+
cursorBlink: undefined,
|
|
21
|
+
cursorStyle: undefined,
|
|
20
22
|
origin: false,
|
|
21
23
|
reverseWraparound: false,
|
|
22
24
|
sendFocus: false,
|
|
@@ -31,13 +33,13 @@ export class CoreService extends Disposable implements ICoreService {
|
|
|
31
33
|
public modes: IModes;
|
|
32
34
|
public decPrivateModes: IDecPrivateModes;
|
|
33
35
|
|
|
34
|
-
private readonly _onData = this.
|
|
36
|
+
private readonly _onData = this._register(new Emitter<string>());
|
|
35
37
|
public readonly onData = this._onData.event;
|
|
36
|
-
private readonly _onUserInput = this.
|
|
38
|
+
private readonly _onUserInput = this._register(new Emitter<void>());
|
|
37
39
|
public readonly onUserInput = this._onUserInput.event;
|
|
38
|
-
private readonly _onBinary = this.
|
|
40
|
+
private readonly _onBinary = this._register(new Emitter<string>());
|
|
39
41
|
public readonly onBinary = this._onBinary.event;
|
|
40
|
-
private readonly _onRequestScrollToBottom = this.
|
|
42
|
+
private readonly _onRequestScrollToBottom = this._register(new Emitter<void>());
|
|
41
43
|
public readonly onRequestScrollToBottom = this._onRequestScrollToBottom.event;
|
|
42
44
|
|
|
43
45
|
constructor(
|
|
@@ -73,7 +75,8 @@ export class CoreService extends Disposable implements ICoreService {
|
|
|
73
75
|
}
|
|
74
76
|
|
|
75
77
|
// Fire onData API
|
|
76
|
-
this._logService.debug(`sending data "${data}"
|
|
78
|
+
this._logService.debug(`sending data "${data}"`);
|
|
79
|
+
this._logService.trace(`sending data (codes)`, () => data.split('').map(e => e.charCodeAt(0)));
|
|
77
80
|
this._onData.fire(data);
|
|
78
81
|
}
|
|
79
82
|
|
|
@@ -81,7 +84,8 @@ export class CoreService extends Disposable implements ICoreService {
|
|
|
81
84
|
if (this._optionsService.rawOptions.disableStdin) {
|
|
82
85
|
return;
|
|
83
86
|
}
|
|
84
|
-
this._logService.debug(`sending binary "${data}"
|
|
87
|
+
this._logService.debug(`sending binary "${data}"`);
|
|
88
|
+
this._logService.trace(`sending binary (codes)`, () => data.split('').map(e => e.charCodeAt(0)));
|
|
85
89
|
this._onBinary.fire(data);
|
|
86
90
|
}
|
|
87
91
|
}
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { css } from 'common/Color';
|
|
7
|
-
import {
|
|
8
|
-
import { Disposable, toDisposable } from 'common/Lifecycle';
|
|
7
|
+
import { Disposable, DisposableStore, toDisposable } from 'vs/base/common/lifecycle';
|
|
9
8
|
import { IDecorationService, IInternalDecoration } from 'common/services/Services';
|
|
10
9
|
import { SortedList } from 'common/SortedList';
|
|
11
10
|
import { IColor } from 'common/Types';
|
|
12
11
|
import { IDecoration, IDecorationOptions, IMarker } from '@xterm/xterm';
|
|
12
|
+
import { Emitter } from 'vs/base/common/event';
|
|
13
13
|
|
|
14
14
|
// Work variables to avoid garbage collection
|
|
15
15
|
let $xmin = 0;
|
|
@@ -25,9 +25,9 @@ export class DecorationService extends Disposable implements IDecorationService
|
|
|
25
25
|
*/
|
|
26
26
|
private readonly _decorations: SortedList<IInternalDecoration> = new SortedList(e => e?.marker.line);
|
|
27
27
|
|
|
28
|
-
private readonly _onDecorationRegistered = this.
|
|
28
|
+
private readonly _onDecorationRegistered = this._register(new Emitter<IInternalDecoration>());
|
|
29
29
|
public readonly onDecorationRegistered = this._onDecorationRegistered.event;
|
|
30
|
-
private readonly _onDecorationRemoved = this.
|
|
30
|
+
private readonly _onDecorationRemoved = this._register(new Emitter<IInternalDecoration>());
|
|
31
31
|
public readonly onDecorationRemoved = this._onDecorationRemoved.event;
|
|
32
32
|
|
|
33
33
|
public get decorations(): IterableIterator<IInternalDecoration> { return this._decorations.values(); }
|
|
@@ -35,7 +35,7 @@ export class DecorationService extends Disposable implements IDecorationService
|
|
|
35
35
|
constructor() {
|
|
36
36
|
super();
|
|
37
37
|
|
|
38
|
-
this.
|
|
38
|
+
this._register(toDisposable(() => this.reset()));
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
public registerDecoration(options: IDecorationOptions): IDecoration | undefined {
|
|
@@ -90,14 +90,13 @@ export class DecorationService extends Disposable implements IDecorationService
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
class Decoration extends
|
|
93
|
+
class Decoration extends DisposableStore implements IInternalDecoration {
|
|
94
94
|
public readonly marker: IMarker;
|
|
95
95
|
public element: HTMLElement | undefined;
|
|
96
|
-
public get isDisposed(): boolean { return this._isDisposed; }
|
|
97
96
|
|
|
98
|
-
public readonly onRenderEmitter = this.
|
|
97
|
+
public readonly onRenderEmitter = this.add(new Emitter<HTMLElement>());
|
|
99
98
|
public readonly onRender = this.onRenderEmitter.event;
|
|
100
|
-
private readonly _onDispose = this.
|
|
99
|
+
private readonly _onDispose = this.add(new Emitter<void>());
|
|
101
100
|
public readonly onDispose = this._onDispose.event;
|
|
102
101
|
|
|
103
102
|
private _cachedBg: IColor | undefined | null = null;
|
|
@@ -67,7 +67,7 @@ export class InstantiationService implements IInstantiationService {
|
|
|
67
67
|
for (const dependency of serviceDependencies) {
|
|
68
68
|
const service = this._services.get(dependency.id);
|
|
69
69
|
if (!service) {
|
|
70
|
-
throw new Error(`[createInstance] ${ctor.name} depends on UNKNOWN service ${dependency.id}.`);
|
|
70
|
+
throw new Error(`[createInstance] ${ctor.name} depends on UNKNOWN service ${dependency.id._id}.`);
|
|
71
71
|
}
|
|
72
72
|
serviceArgs.push(service);
|
|
73
73
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @license MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { Disposable } from 'common/
|
|
6
|
+
import { Disposable } from 'vs/base/common/lifecycle';
|
|
7
7
|
import { ILogService, IOptionsService, LogLevelEnum } from 'common/services/Services';
|
|
8
8
|
|
|
9
9
|
type LogType = (message?: any, ...optionalParams: any[]) => void;
|
|
@@ -42,7 +42,7 @@ export class LogService extends Disposable implements ILogService {
|
|
|
42
42
|
) {
|
|
43
43
|
super();
|
|
44
44
|
this._updateLogLevel();
|
|
45
|
-
this.
|
|
45
|
+
this._register(this._optionsService.onSpecificOptionChange('logLevel', () => this._updateLogLevel()));
|
|
46
46
|
|
|
47
47
|
// For trace logging, assume the latest created log service is valid
|
|
48
48
|
traceLogger = this;
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* @license MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import { Disposable, toDisposable } from 'common/Lifecycle';
|
|
6
|
+
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
|
|
8
7
|
import { isMac } from 'common/Platform';
|
|
9
8
|
import { CursorStyle, IDisposable } from 'common/Types';
|
|
10
9
|
import { FontWeight, IOptionsService, ITerminalOptions } from 'common/services/Services';
|
|
10
|
+
import { Emitter } from 'vs/base/common/event';
|
|
11
11
|
|
|
12
12
|
export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
|
|
13
13
|
cols: 80,
|
|
@@ -21,7 +21,7 @@ export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
|
|
|
21
21
|
documentOverride: null,
|
|
22
22
|
fastScrollModifier: 'alt',
|
|
23
23
|
fastScrollSensitivity: 5,
|
|
24
|
-
fontFamily: '
|
|
24
|
+
fontFamily: 'monospace',
|
|
25
25
|
fontSize: 15,
|
|
26
26
|
fontWeight: 'normal',
|
|
27
27
|
fontWeightBold: 'bold',
|
|
@@ -32,6 +32,7 @@ export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
|
|
|
32
32
|
logLevel: 'info',
|
|
33
33
|
logger: null,
|
|
34
34
|
scrollback: 1000,
|
|
35
|
+
scrollOnEraseInDisplay: false,
|
|
35
36
|
scrollOnUserInput: true,
|
|
36
37
|
scrollSensitivity: 1,
|
|
37
38
|
screenReaderMode: false,
|
|
@@ -44,6 +45,7 @@ export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
|
|
|
44
45
|
allowTransparency: false,
|
|
45
46
|
tabStopWidth: 8,
|
|
46
47
|
theme: {},
|
|
48
|
+
reflowCursorLine: false,
|
|
47
49
|
rescaleOverlappingGlyphs: false,
|
|
48
50
|
rightClickSelectsWord: isMac,
|
|
49
51
|
windowOptions: {},
|
|
@@ -54,7 +56,7 @@ export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
|
|
|
54
56
|
convertEol: false,
|
|
55
57
|
termName: 'xterm',
|
|
56
58
|
cancelEvents: false,
|
|
57
|
-
|
|
59
|
+
overviewRuler: {}
|
|
58
60
|
};
|
|
59
61
|
|
|
60
62
|
const FONT_WEIGHT_OPTIONS: Extract<FontWeight, string>[] = ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'];
|
|
@@ -65,7 +67,7 @@ export class OptionsService extends Disposable implements IOptionsService {
|
|
|
65
67
|
public readonly rawOptions: Required<ITerminalOptions>;
|
|
66
68
|
public options: Required<ITerminalOptions>;
|
|
67
69
|
|
|
68
|
-
private readonly _onOptionChange = this.
|
|
70
|
+
private readonly _onOptionChange = this._register(new Emitter<keyof ITerminalOptions>());
|
|
69
71
|
public readonly onOptionChange = this._onOptionChange.event;
|
|
70
72
|
|
|
71
73
|
constructor(options: Partial<ITerminalOptions>) {
|
|
@@ -90,7 +92,7 @@ export class OptionsService extends Disposable implements IOptionsService {
|
|
|
90
92
|
|
|
91
93
|
// Clear out options that could link outside xterm.js as they could easily cause an embedder
|
|
92
94
|
// memory leak
|
|
93
|
-
this.
|
|
95
|
+
this._register(toDisposable(() => {
|
|
94
96
|
this.rawOptions.linkHandler = null;
|
|
95
97
|
this.rawOptions.documentOverride = null;
|
|
96
98
|
}));
|