@xterm/xterm 5.6.0-beta.6 → 5.6.0-beta.60
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 +7 -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 +43 -33
- package/src/browser/AccessibilityManager.ts +53 -25
- package/src/browser/{Terminal.ts → CoreBrowserTerminal.ts} +132 -144
- package/src/browser/Linkifier.ts +15 -13
- package/src/browser/LocalizableStrings.ts +15 -4
- package/src/browser/{Types.d.ts → Types.ts} +67 -15
- package/src/browser/Viewport.ts +142 -370
- package/src/browser/decorations/BufferDecorationRenderer.ts +14 -9
- package/src/browser/decorations/OverviewRulerRenderer.ts +40 -44
- package/src/browser/public/Terminal.ts +25 -19
- package/src/browser/renderer/dom/DomRenderer.ts +14 -16
- package/src/browser/renderer/shared/CharAtlasUtils.ts +4 -0
- package/src/browser/renderer/shared/CustomGlyphs.ts +6 -0
- package/src/browser/renderer/shared/DevicePixelObserver.ts +1 -2
- package/src/browser/renderer/shared/TextureAtlas.ts +3 -3
- package/src/browser/renderer/shared/{Types.d.ts → Types.ts} +4 -4
- package/src/browser/services/CharSizeService.ts +6 -6
- package/src/browser/services/CoreBrowserService.ts +15 -15
- package/src/browser/services/LinkProviderService.ts +2 -2
- package/src/browser/services/RenderService.ts +20 -20
- package/src/browser/services/SelectionService.ts +8 -8
- package/src/browser/services/Services.ts +13 -13
- package/src/browser/services/ThemeService.ts +17 -56
- 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 +34 -28
- package/src/common/{Types.d.ts → Types.ts} +11 -17
- package/src/common/buffer/Buffer.ts +5 -1
- 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/WriteBuffer.ts +3 -3
- package/src/common/parser/EscapeSequenceParser.ts +4 -4
- package/src/common/public/BufferNamespaceApi.ts +3 -3
- package/src/common/services/BufferService.ts +7 -7
- package/src/common/services/CoreMouseService.ts +5 -3
- package/src/common/services/CoreService.ts +6 -6
- package/src/common/services/DecorationService.ts +8 -9
- package/src/common/services/LogService.ts +2 -2
- package/src/common/services/OptionsService.ts +5 -5
- package/src/common/services/Services.ts +24 -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/thenable.d.ts +12 -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 +59 -15
- package/src/browser/Lifecycle.ts +0 -33
- 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
|
@@ -4,10 +4,14 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
|
|
6
6
|
import { ColorZoneStore, IColorZone, IColorZoneStore } from 'browser/decorations/ColorZoneStore';
|
|
7
|
-
import { ICoreBrowserService, IRenderService } from 'browser/services/Services';
|
|
8
|
-
import { Disposable, toDisposable } from 'common/
|
|
7
|
+
import { ICoreBrowserService, IRenderService, IThemeService } from 'browser/services/Services';
|
|
8
|
+
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
|
|
9
9
|
import { IBufferService, IDecorationService, IOptionsService } from 'common/services/Services';
|
|
10
10
|
|
|
11
|
+
const enum Constants {
|
|
12
|
+
OVERVIEW_RULER_BORDER_WIDTH = 1
|
|
13
|
+
}
|
|
14
|
+
|
|
11
15
|
// Helper objects to avoid excessive calculation and garbage collection during rendering. These are
|
|
12
16
|
// static values for each render and can be accessed using the decoration position as the key.
|
|
13
17
|
const drawHeight = {
|
|
@@ -34,7 +38,7 @@ export class OverviewRulerRenderer extends Disposable {
|
|
|
34
38
|
private readonly _ctx: CanvasRenderingContext2D;
|
|
35
39
|
private readonly _colorZoneStore: IColorZoneStore = new ColorZoneStore();
|
|
36
40
|
private get _width(): number {
|
|
37
|
-
return this._optionsService.options.
|
|
41
|
+
return this._optionsService.options.overviewRuler?.width || 0;
|
|
38
42
|
}
|
|
39
43
|
private _animationFrame: number | undefined;
|
|
40
44
|
|
|
@@ -51,6 +55,7 @@ export class OverviewRulerRenderer extends Disposable {
|
|
|
51
55
|
@IDecorationService private readonly _decorationService: IDecorationService,
|
|
52
56
|
@IRenderService private readonly _renderService: IRenderService,
|
|
53
57
|
@IOptionsService private readonly _optionsService: IOptionsService,
|
|
58
|
+
@IThemeService private readonly _themeService: IThemeService,
|
|
54
59
|
@ICoreBrowserService private readonly _coreBrowserService: ICoreBrowserService
|
|
55
60
|
) {
|
|
56
61
|
super();
|
|
@@ -58,68 +63,47 @@ export class OverviewRulerRenderer extends Disposable {
|
|
|
58
63
|
this._canvas.classList.add('xterm-decoration-overview-ruler');
|
|
59
64
|
this._refreshCanvasDimensions();
|
|
60
65
|
this._viewportElement.parentElement?.insertBefore(this._canvas, this._viewportElement);
|
|
66
|
+
this._register(toDisposable(() => this._canvas?.remove()));
|
|
67
|
+
|
|
61
68
|
const ctx = this._canvas.getContext('2d');
|
|
62
69
|
if (!ctx) {
|
|
63
70
|
throw new Error('Ctx cannot be null');
|
|
64
71
|
} else {
|
|
65
72
|
this._ctx = ctx;
|
|
66
73
|
}
|
|
67
|
-
this._registerDecorationListeners();
|
|
68
|
-
this._registerBufferChangeListeners();
|
|
69
|
-
this._registerDimensionChangeListeners();
|
|
70
|
-
this.register(toDisposable(() => {
|
|
71
|
-
this._canvas?.remove();
|
|
72
|
-
}));
|
|
73
|
-
}
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
*/
|
|
78
|
-
private _registerDecorationListeners(): void {
|
|
79
|
-
this.register(this._decorationService.onDecorationRegistered(() => this._queueRefresh(undefined, true)));
|
|
80
|
-
this.register(this._decorationService.onDecorationRemoved(() => this._queueRefresh(undefined, true)));
|
|
81
|
-
}
|
|
75
|
+
this._register(this._decorationService.onDecorationRegistered(() => this._queueRefresh(undefined, true)));
|
|
76
|
+
this._register(this._decorationService.onDecorationRemoved(() => this._queueRefresh(undefined, true)));
|
|
82
77
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
* and hide the canvas if the alt buffer is active
|
|
86
|
-
*/
|
|
87
|
-
private _registerBufferChangeListeners(): void {
|
|
88
|
-
this.register(this._renderService.onRenderedViewportChange(() => this._queueRefresh()));
|
|
89
|
-
this.register(this._bufferService.buffers.onBufferActivate(() => {
|
|
78
|
+
this._register(this._renderService.onRenderedViewportChange(() => this._queueRefresh()));
|
|
79
|
+
this._register(this._bufferService.buffers.onBufferActivate(() => {
|
|
90
80
|
this._canvas!.style.display = this._bufferService.buffer === this._bufferService.buffers.alt ? 'none' : 'block';
|
|
91
81
|
}));
|
|
92
|
-
this.
|
|
82
|
+
this._register(this._bufferService.onScroll(() => {
|
|
93
83
|
if (this._lastKnownBufferLength !== this._bufferService.buffers.normal.lines.length) {
|
|
94
84
|
this._refreshDrawHeightConstants();
|
|
95
85
|
this._refreshColorZonePadding();
|
|
96
86
|
}
|
|
97
87
|
}));
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
* and then redraw
|
|
102
|
-
*/
|
|
103
|
-
private _registerDimensionChangeListeners(): void {
|
|
104
|
-
// container height changed
|
|
105
|
-
this.register(this._renderService.onRender((): void => {
|
|
88
|
+
|
|
89
|
+
// Container height changed
|
|
90
|
+
this._register(this._renderService.onRender((): void => {
|
|
106
91
|
if (!this._containerHeight || this._containerHeight !== this._screenElement.clientHeight) {
|
|
107
92
|
this._queueRefresh(true);
|
|
108
93
|
this._containerHeight = this._screenElement.clientHeight;
|
|
109
94
|
}
|
|
110
95
|
}));
|
|
111
|
-
|
|
112
|
-
this.
|
|
113
|
-
|
|
114
|
-
this.
|
|
115
|
-
// set the canvas dimensions
|
|
96
|
+
|
|
97
|
+
this._register(this._coreBrowserService.onDprChange(() => this._queueRefresh(true)));
|
|
98
|
+
this._register(this._optionsService.onSpecificOptionChange('overviewRuler', () => this._queueRefresh(true)));
|
|
99
|
+
this._register(this._themeService.onChangeColors(() => this._queueRefresh()));
|
|
116
100
|
this._queueRefresh(true);
|
|
117
101
|
}
|
|
118
102
|
|
|
119
103
|
private _refreshDrawConstants(): void {
|
|
120
104
|
// width
|
|
121
|
-
const outerWidth = Math.floor(this._canvas.width / 3);
|
|
122
|
-
const innerWidth = Math.ceil(this._canvas.width / 3);
|
|
105
|
+
const outerWidth = Math.floor((this._canvas.width - Constants.OVERVIEW_RULER_BORDER_WIDTH) / 3);
|
|
106
|
+
const innerWidth = Math.ceil((this._canvas.width - Constants.OVERVIEW_RULER_BORDER_WIDTH) / 3);
|
|
123
107
|
drawWidth.full = this._canvas.width;
|
|
124
108
|
drawWidth.left = outerWidth;
|
|
125
109
|
drawWidth.center = innerWidth;
|
|
@@ -127,10 +111,10 @@ export class OverviewRulerRenderer extends Disposable {
|
|
|
127
111
|
// height
|
|
128
112
|
this._refreshDrawHeightConstants();
|
|
129
113
|
// x
|
|
130
|
-
drawX.full =
|
|
131
|
-
drawX.left =
|
|
132
|
-
drawX.center = drawWidth.left;
|
|
133
|
-
drawX.right = drawWidth.left + drawWidth.center;
|
|
114
|
+
drawX.full = Constants.OVERVIEW_RULER_BORDER_WIDTH;
|
|
115
|
+
drawX.left = Constants.OVERVIEW_RULER_BORDER_WIDTH;
|
|
116
|
+
drawX.center = Constants.OVERVIEW_RULER_BORDER_WIDTH + drawWidth.left;
|
|
117
|
+
drawX.right = Constants.OVERVIEW_RULER_BORDER_WIDTH + drawWidth.left + drawWidth.center;
|
|
134
118
|
}
|
|
135
119
|
|
|
136
120
|
private _refreshDrawHeightConstants(): void {
|
|
@@ -173,6 +157,7 @@ export class OverviewRulerRenderer extends Disposable {
|
|
|
173
157
|
this._colorZoneStore.addDecoration(decoration);
|
|
174
158
|
}
|
|
175
159
|
this._ctx.lineWidth = 1;
|
|
160
|
+
this._renderRulerOutline();
|
|
176
161
|
const zones = this._colorZoneStore.zones;
|
|
177
162
|
for (const zone of zones) {
|
|
178
163
|
if (zone.position !== 'full') {
|
|
@@ -188,6 +173,17 @@ export class OverviewRulerRenderer extends Disposable {
|
|
|
188
173
|
this._shouldUpdateAnchor = false;
|
|
189
174
|
}
|
|
190
175
|
|
|
176
|
+
private _renderRulerOutline(): void {
|
|
177
|
+
this._ctx.fillStyle = this._themeService.colors.overviewRulerBorder.css;
|
|
178
|
+
this._ctx.fillRect(0, 0, Constants.OVERVIEW_RULER_BORDER_WIDTH, this._canvas.height);
|
|
179
|
+
if (this._optionsService.rawOptions.overviewRuler.showTopBorder) {
|
|
180
|
+
this._ctx.fillRect(Constants.OVERVIEW_RULER_BORDER_WIDTH, 0, this._canvas.width - Constants.OVERVIEW_RULER_BORDER_WIDTH, Constants.OVERVIEW_RULER_BORDER_WIDTH);
|
|
181
|
+
}
|
|
182
|
+
if (this._optionsService.rawOptions.overviewRuler.showBottomBorder) {
|
|
183
|
+
this._ctx.fillRect(Constants.OVERVIEW_RULER_BORDER_WIDTH, this._canvas.height - Constants.OVERVIEW_RULER_BORDER_WIDTH, this._canvas.width - Constants.OVERVIEW_RULER_BORDER_WIDTH, this._canvas.height);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
191
187
|
private _renderColorZone(zone: IColorZone): void {
|
|
192
188
|
this._ctx.fillStyle = zone.color;
|
|
193
189
|
this._ctx.fillRect(
|
|
@@ -4,16 +4,16 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import * as Strings from 'browser/LocalizableStrings';
|
|
7
|
-
import {
|
|
7
|
+
import { CoreBrowserTerminal as TerminalCore } from 'browser/CoreBrowserTerminal';
|
|
8
8
|
import { IBufferRange, ITerminal } from 'browser/Types';
|
|
9
|
-
import {
|
|
10
|
-
import { Disposable } from 'common/Lifecycle';
|
|
9
|
+
import { Disposable } from 'vs/base/common/lifecycle';
|
|
11
10
|
import { ITerminalOptions } from 'common/Types';
|
|
12
11
|
import { AddonManager } from 'common/public/AddonManager';
|
|
13
12
|
import { BufferNamespaceApi } from 'common/public/BufferNamespaceApi';
|
|
14
13
|
import { ParserApi } from 'common/public/ParserApi';
|
|
15
14
|
import { UnicodeApi } from 'common/public/UnicodeApi';
|
|
16
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
17
|
|
|
18
18
|
/**
|
|
19
19
|
* The set of options that only have an effect when set in the Terminal constructor.
|
|
@@ -32,8 +32,8 @@ export class Terminal extends Disposable implements ITerminalApi {
|
|
|
32
32
|
constructor(options?: ITerminalOptions & ITerminalInitOnlyOptions) {
|
|
33
33
|
super();
|
|
34
34
|
|
|
35
|
-
this._core = this.
|
|
36
|
-
this._addonManager = this.
|
|
35
|
+
this._core = this._register(new TerminalCore(options));
|
|
36
|
+
this._addonManager = this._register(new AddonManager());
|
|
37
37
|
|
|
38
38
|
this._publicOptions = { ... this._core.options };
|
|
39
39
|
const getter = (propName: string): any => {
|
|
@@ -68,18 +68,18 @@ export class Terminal extends Disposable implements ITerminalApi {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
public get onBell():
|
|
72
|
-
public get onBinary():
|
|
73
|
-
public get onCursorMove():
|
|
74
|
-
public get onData():
|
|
75
|
-
public get onKey():
|
|
76
|
-
public get onLineFeed():
|
|
77
|
-
public get onRender():
|
|
78
|
-
public get onResize():
|
|
79
|
-
public get onScroll():
|
|
80
|
-
public get onSelectionChange():
|
|
81
|
-
public get onTitleChange():
|
|
82
|
-
public get onWriteParsed():
|
|
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
83
|
|
|
84
84
|
public get element(): HTMLElement | undefined { return this._core.element; }
|
|
85
85
|
public get parser(): IParser {
|
|
@@ -97,7 +97,7 @@ export class Terminal extends Disposable implements ITerminalApi {
|
|
|
97
97
|
public get cols(): number { return this._core.cols; }
|
|
98
98
|
public get buffer(): IBufferNamespaceApi {
|
|
99
99
|
if (!this._buffer) {
|
|
100
|
-
this._buffer = this.
|
|
100
|
+
this._buffer = this._register(new BufferNamespaceApi(this._core));
|
|
101
101
|
}
|
|
102
102
|
return this._buffer;
|
|
103
103
|
}
|
|
@@ -247,7 +247,13 @@ export class Terminal extends Disposable implements ITerminalApi {
|
|
|
247
247
|
this._addonManager.loadAddon(this, addon);
|
|
248
248
|
}
|
|
249
249
|
public static get strings(): ILocalizableStrings {
|
|
250
|
-
|
|
250
|
+
// A wrapper is required here because esbuild prevents setting an `export let`
|
|
251
|
+
return {
|
|
252
|
+
get promptLabel(): string { return Strings.promptLabel.get(); },
|
|
253
|
+
set promptLabel(value: string) { Strings.promptLabel.set(value); },
|
|
254
|
+
get tooMuchOutput(): string { return Strings.tooMuchOutput.get(); },
|
|
255
|
+
set tooMuchOutput(value: string) { Strings.tooMuchOutput.set(value); }
|
|
256
|
+
};
|
|
251
257
|
}
|
|
252
258
|
|
|
253
259
|
private _verifyIntegers(...values: number[]): void {
|
|
@@ -12,9 +12,9 @@ import { IRenderDimensions, IRenderer, IRequestRedrawEvent, ISelectionRenderMode
|
|
|
12
12
|
import { ICharSizeService, ICoreBrowserService, IThemeService } from 'browser/services/Services';
|
|
13
13
|
import { ILinkifier2, ILinkifierEvent, ITerminal, ReadonlyColorSet } from 'browser/Types';
|
|
14
14
|
import { color } from 'common/Color';
|
|
15
|
-
import {
|
|
16
|
-
import { Disposable, toDisposable } from 'common/Lifecycle';
|
|
15
|
+
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
|
|
17
16
|
import { IBufferService, IInstantiationService, IOptionsService } from 'common/services/Services';
|
|
17
|
+
import { Emitter } from 'vs/base/common/event';
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
const TERMINAL_CLASS_PREFIX = 'xterm-dom-renderer-owner-';
|
|
@@ -27,9 +27,9 @@ const SELECTION_CLASS = 'xterm-selection';
|
|
|
27
27
|
let nextTerminalId = 1;
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
31
|
-
* particularly fast
|
|
32
|
-
*
|
|
30
|
+
* The standard renderer and fallback for when the webgl addon is slow. This is not meant to be
|
|
31
|
+
* particularly fast and will even lack some features such as custom glyphs, hoever this is more
|
|
32
|
+
* reliable as webgl may not work on some machines.
|
|
33
33
|
*/
|
|
34
34
|
export class DomRenderer extends Disposable implements IRenderer {
|
|
35
35
|
private _rowFactory: DomRendererRowFactory;
|
|
@@ -45,7 +45,7 @@ export class DomRenderer extends Disposable implements IRenderer {
|
|
|
45
45
|
|
|
46
46
|
public dimensions: IRenderDimensions;
|
|
47
47
|
|
|
48
|
-
public readonly onRequestRedraw = this.
|
|
48
|
+
public readonly onRequestRedraw = this._register(new Emitter<IRequestRedrawEvent>()).event;
|
|
49
49
|
|
|
50
50
|
constructor(
|
|
51
51
|
private readonly _terminal: ITerminal,
|
|
@@ -74,9 +74,9 @@ export class DomRenderer extends Disposable implements IRenderer {
|
|
|
74
74
|
|
|
75
75
|
this.dimensions = createRenderDimensions();
|
|
76
76
|
this._updateDimensions();
|
|
77
|
-
this.
|
|
77
|
+
this._register(this._optionsService.onOptionChange(() => this._handleOptionsChanged()));
|
|
78
78
|
|
|
79
|
-
this.
|
|
79
|
+
this._register(this._themeService.onChangeColors(e => this._injectCss(e)));
|
|
80
80
|
this._injectCss(this._themeService.colors);
|
|
81
81
|
|
|
82
82
|
this._rowFactory = instantiationService.createInstance(DomRendererRowFactory, document);
|
|
@@ -85,10 +85,10 @@ export class DomRenderer extends Disposable implements IRenderer {
|
|
|
85
85
|
this._screenElement.appendChild(this._rowContainer);
|
|
86
86
|
this._screenElement.appendChild(this._selectionContainer);
|
|
87
87
|
|
|
88
|
-
this.
|
|
89
|
-
this.
|
|
88
|
+
this._register(this._linkifier2.onShowLinkUnderline(e => this._handleLinkHover(e)));
|
|
89
|
+
this._register(this._linkifier2.onHideLinkUnderline(e => this._handleLinkLeave(e)));
|
|
90
90
|
|
|
91
|
-
this.
|
|
91
|
+
this._register(toDisposable(() => {
|
|
92
92
|
this._element.classList.remove(TERMINAL_CLASS_PREFIX + this._terminalClass);
|
|
93
93
|
|
|
94
94
|
// Outside influences such as React unmounts may manipulate the DOM before our disposal.
|
|
@@ -343,6 +343,9 @@ export class DomRenderer extends Disposable implements IRenderer {
|
|
|
343
343
|
}
|
|
344
344
|
|
|
345
345
|
this._selectionRenderModel.update(this._terminal, start, end, columnSelectMode);
|
|
346
|
+
if (!this._selectionRenderModel.hasSelection) {
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
346
349
|
|
|
347
350
|
// Translate from buffer position to viewport position
|
|
348
351
|
const viewportStartRow = this._selectionRenderModel.viewportStartRow;
|
|
@@ -350,11 +353,6 @@ export class DomRenderer extends Disposable implements IRenderer {
|
|
|
350
353
|
const viewportCappedStartRow = this._selectionRenderModel.viewportCappedStartRow;
|
|
351
354
|
const viewportCappedEndRow = this._selectionRenderModel.viewportCappedEndRow;
|
|
352
355
|
|
|
353
|
-
// No need to draw the selection
|
|
354
|
-
if (viewportCappedStartRow >= this._bufferService.rows || viewportCappedEndRow < 0) {
|
|
355
|
-
return;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
356
|
// Create the selections
|
|
359
357
|
const documentFragment = this._document.createDocumentFragment();
|
|
360
358
|
|
|
@@ -21,6 +21,10 @@ export function generateConfig(deviceCellWidth: number, deviceCellHeight: number
|
|
|
21
21
|
selectionBackgroundOpaque: NULL_COLOR,
|
|
22
22
|
selectionInactiveBackgroundTransparent: NULL_COLOR,
|
|
23
23
|
selectionInactiveBackgroundOpaque: NULL_COLOR,
|
|
24
|
+
overviewRulerBorder: NULL_COLOR,
|
|
25
|
+
scrollbarSliderBackground: NULL_COLOR,
|
|
26
|
+
scrollbarSliderHoverBackground: NULL_COLOR,
|
|
27
|
+
scrollbarSliderActiveBackground: NULL_COLOR,
|
|
24
28
|
// For the static char atlas, we only use the first 16 colors, but we need all 256 for the
|
|
25
29
|
// dynamic character atlas.
|
|
26
30
|
ansi: colors.ansi.slice(),
|
|
@@ -355,6 +355,12 @@ const enum VectorType {
|
|
|
355
355
|
* Original symbols defined in https://github.com/powerline/fontpatcher
|
|
356
356
|
*/
|
|
357
357
|
export const powerlineDefinitions: { [index: string]: IVectorShape } = {
|
|
358
|
+
// Git branch
|
|
359
|
+
'\u{E0A0}': { d: 'M.3,1 L.03,1 L.03,.88 C.03,.82,.06,.78,.11,.73 C.15,.7,.2,.68,.28,.65 L.43,.6 C.49,.58,.53,.56,.56,.53 C.59,.5,.6,.47,.6,.43 L.6,.27 L.4,.27 L.69,.1 L.98,.27 L.78,.27 L.78,.46 C.78,.52,.76,.56,.72,.61 C.68,.66,.63,.67,.56,.7 L.48,.72 C.42,.74,.38,.76,.35,.78 C.32,.8,.31,.84,.31,.88 L.31,1 M.3,.5 L.03,.59 L.03,.09 L.3,.09 L.3,.655', type: VectorType.FILL },
|
|
360
|
+
// L N
|
|
361
|
+
'\u{E0A1}': { d: 'M.7,.4 L.7,.47 L.2,.47 L.2,.03 L.355,.03 L.355,.4 L.705,.4 M.7,.5 L.86,.5 L.86,.95 L.69,.95 L.44,.66 L.46,.86 L.46,.95 L.3,.95 L.3,.49 L.46,.49 L.71,.78 L.69,.565 L.69,.5', type: VectorType.FILL },
|
|
362
|
+
// Lock
|
|
363
|
+
'\u{E0A2}': { d: 'M.25,.94 C.16,.94,.11,.92,.11,.87 L.11,.53 C.11,.48,.15,.455,.23,.45 L.23,.3 C.23,.25,.26,.22,.31,.19 C.36,.16,.43,.15,.51,.15 C.59,.15,.66,.16,.71,.19 C.77,.22,.79,.26,.79,.3 L.79,.45 C.87,.45,.91,.48,.91,.53 L.91,.87 C.91,.92,.86,.94,.77,.94 L.24,.94 M.53,.2 C.49,.2,.45,.21,.42,.23 C.39,.25,.38,.27,.38,.3 L.38,.45 L.68,.45 L.68,.3 C.68,.27,.67,.25,.64,.23 C.61,.21,.58,.2,.53,.2 M.58,.82 L.58,.66 C.63,.65,.65,.63,.65,.6 C.65,.58,.64,.57,.61,.56 C.58,.55,.56,.54,.52,.54 C.48,.54,.46,.55,.43,.56 C.4,.57,.39,.59,.39,.6 C.39,.63,.41,.64,.46,.66 L.46,.82 L.57,.82', type: VectorType.FILL },
|
|
358
364
|
// Right triangle solid
|
|
359
365
|
'\u{E0B0}': { d: 'M0,0 L1,.5 L0,1', type: VectorType.FILL, rightPadding: 2 },
|
|
360
366
|
// Right triangle line
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
* @license MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { toDisposable } from 'common/
|
|
7
|
-
import { IDisposable } from 'common/Types';
|
|
6
|
+
import { toDisposable, IDisposable } from 'vs/base/common/lifecycle';
|
|
8
7
|
|
|
9
8
|
export function observeDevicePixelDimensions(element: HTMLElement, parentWindow: Window & typeof globalThis, callback: (deviceWidth: number, deviceHeight: number) => void): IDisposable {
|
|
10
9
|
// Observe any resizes to the element and extract the actual pixel size of the element if the
|
|
@@ -9,13 +9,13 @@ import { tryDrawCustomChar } from 'browser/renderer/shared/CustomGlyphs';
|
|
|
9
9
|
import { computeNextVariantOffset, treatGlyphAsBackgroundColor, isPowerlineGlyph, isRestrictedPowerlineGlyph, throwIfFalsy } from 'browser/renderer/shared/RendererUtils';
|
|
10
10
|
import { IBoundingBox, ICharAtlasConfig, IRasterizedGlyph, ITextureAtlas } from 'browser/renderer/shared/Types';
|
|
11
11
|
import { NULL_COLOR, channels, color, rgba } from 'common/Color';
|
|
12
|
-
import { EventEmitter } from 'common/EventEmitter';
|
|
13
12
|
import { FourKeyMap } from 'common/MultiKeyMap';
|
|
14
13
|
import { IdleTaskQueue } from 'common/TaskQueue';
|
|
15
14
|
import { IColor } from 'common/Types';
|
|
16
15
|
import { AttributeData } from 'common/buffer/AttributeData';
|
|
17
16
|
import { Attributes, DEFAULT_COLOR, DEFAULT_EXT, UnderlineStyle } from 'common/buffer/Constants';
|
|
18
17
|
import { IUnicodeService } from 'common/services/Services';
|
|
18
|
+
import { Emitter } from 'vs/base/common/event';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* A shared object which is used to draw nothing for a particular cell.
|
|
@@ -79,9 +79,9 @@ export class TextureAtlas implements ITextureAtlas {
|
|
|
79
79
|
public static maxAtlasPages: number | undefined;
|
|
80
80
|
public static maxTextureSize: number | undefined;
|
|
81
81
|
|
|
82
|
-
private readonly _onAddTextureAtlasCanvas = new
|
|
82
|
+
private readonly _onAddTextureAtlasCanvas = new Emitter<HTMLCanvasElement>();
|
|
83
83
|
public readonly onAddTextureAtlasCanvas = this._onAddTextureAtlasCanvas.event;
|
|
84
|
-
private readonly _onRemoveTextureAtlasCanvas = new
|
|
84
|
+
private readonly _onRemoveTextureAtlasCanvas = new Emitter<HTMLCanvasElement>();
|
|
85
85
|
public readonly onRemoveTextureAtlasCanvas = this._onRemoveTextureAtlasCanvas.event;
|
|
86
86
|
|
|
87
87
|
constructor(
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { FontWeight, Terminal } from '@xterm/xterm';
|
|
7
7
|
import { IColorSet, ITerminal } from 'browser/Types';
|
|
8
8
|
import { IDisposable } from 'common/Types';
|
|
9
|
-
import {
|
|
9
|
+
import type { Event } from 'vs/base/common/event';
|
|
10
10
|
|
|
11
11
|
export interface ICharAtlasConfig {
|
|
12
12
|
customGlyphs: boolean;
|
|
@@ -71,7 +71,7 @@ export interface IRenderer extends IDisposable {
|
|
|
71
71
|
* Fires when the renderer is requesting to be redrawn on the next animation
|
|
72
72
|
* frame but is _not_ a result of content changing (eg. selection changes).
|
|
73
73
|
*/
|
|
74
|
-
readonly onRequestRedraw:
|
|
74
|
+
readonly onRequestRedraw: Event<IRequestRedrawEvent>;
|
|
75
75
|
|
|
76
76
|
dispose(): void;
|
|
77
77
|
handleDevicePixelRatioChange(): void;
|
|
@@ -89,8 +89,8 @@ export interface IRenderer extends IDisposable {
|
|
|
89
89
|
export interface ITextureAtlas extends IDisposable {
|
|
90
90
|
readonly pages: { canvas: HTMLCanvasElement, version: number }[];
|
|
91
91
|
|
|
92
|
-
onAddTextureAtlasCanvas:
|
|
93
|
-
onRemoveTextureAtlasCanvas:
|
|
92
|
+
onAddTextureAtlasCanvas: Event<HTMLCanvasElement>;
|
|
93
|
+
onRemoveTextureAtlasCanvas: Event<HTMLCanvasElement>;
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
96
|
* Warm up the texture atlas, adding common glyphs to avoid slowing early frame.
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { IOptionsService } from 'common/services/Services';
|
|
7
|
-
import { EventEmitter } from 'common/EventEmitter';
|
|
8
7
|
import { ICharSizeService } from 'browser/services/Services';
|
|
9
|
-
import { Disposable } from 'common/
|
|
8
|
+
import { Disposable } from 'vs/base/common/lifecycle';
|
|
9
|
+
import { Emitter } from 'vs/base/common/event';
|
|
10
10
|
|
|
11
11
|
export class CharSizeService extends Disposable implements ICharSizeService {
|
|
12
12
|
public serviceBrand: undefined;
|
|
@@ -17,7 +17,7 @@ export class CharSizeService extends Disposable implements ICharSizeService {
|
|
|
17
17
|
|
|
18
18
|
public get hasValidSize(): boolean { return this.width > 0 && this.height > 0; }
|
|
19
19
|
|
|
20
|
-
private readonly _onCharSizeChange = this.
|
|
20
|
+
private readonly _onCharSizeChange = this._register(new Emitter<void>());
|
|
21
21
|
public readonly onCharSizeChange = this._onCharSizeChange.event;
|
|
22
22
|
|
|
23
23
|
constructor(
|
|
@@ -27,11 +27,11 @@ export class CharSizeService extends Disposable implements ICharSizeService {
|
|
|
27
27
|
) {
|
|
28
28
|
super();
|
|
29
29
|
try {
|
|
30
|
-
this._measureStrategy = this.
|
|
30
|
+
this._measureStrategy = this._register(new TextMetricsMeasureStrategy(this._optionsService));
|
|
31
31
|
} catch {
|
|
32
|
-
this._measureStrategy = this.
|
|
32
|
+
this._measureStrategy = this._register(new DomMeasureStrategy(document, parentElement, this._optionsService));
|
|
33
33
|
}
|
|
34
|
-
this.
|
|
34
|
+
this._register(this._optionsService.onMultipleOptionChange(['fontFamily', 'fontSize'], () => this.measure()));
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
public measure(): void {
|
|
@@ -3,21 +3,21 @@
|
|
|
3
3
|
* @license MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { Disposable, MutableDisposable, toDisposable } from 'common/Lifecycle';
|
|
7
6
|
import { ICoreBrowserService } from './Services';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { Emitter, Event } from 'vs/base/common/event';
|
|
8
|
+
import { addDisposableListener } from 'vs/base/browser/dom';
|
|
9
|
+
import { Disposable, MutableDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
|
10
10
|
|
|
11
11
|
export class CoreBrowserService extends Disposable implements ICoreBrowserService {
|
|
12
12
|
public serviceBrand: undefined;
|
|
13
13
|
|
|
14
14
|
private _isFocused = false;
|
|
15
15
|
private _cachedIsFocused: boolean | undefined = undefined;
|
|
16
|
-
private _screenDprMonitor = new ScreenDprMonitor(this._window);
|
|
16
|
+
private _screenDprMonitor = this._register(new ScreenDprMonitor(this._window));
|
|
17
17
|
|
|
18
|
-
private readonly _onDprChange = this.
|
|
18
|
+
private readonly _onDprChange = this._register(new Emitter<number>());
|
|
19
19
|
public readonly onDprChange = this._onDprChange.event;
|
|
20
|
-
private readonly _onWindowChange = this.
|
|
20
|
+
private readonly _onWindowChange = this._register(new Emitter<Window & typeof globalThis>());
|
|
21
21
|
public readonly onWindowChange = this._onWindowChange.event;
|
|
22
22
|
|
|
23
23
|
constructor(
|
|
@@ -28,11 +28,11 @@ export class CoreBrowserService extends Disposable implements ICoreBrowserServic
|
|
|
28
28
|
super();
|
|
29
29
|
|
|
30
30
|
// Monitor device pixel ratio
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
31
|
+
this._register(this.onWindowChange(w => this._screenDprMonitor.setWindow(w)));
|
|
32
|
+
this._register(Event.forward(this._screenDprMonitor.onDprChange, this._onDprChange));
|
|
33
33
|
|
|
34
|
-
this._textarea
|
|
35
|
-
this._textarea
|
|
34
|
+
this._register(addDisposableListener(this._textarea, 'focus', () => this._isFocused = true));
|
|
35
|
+
this._register(addDisposableListener(this._textarea, 'blur', () => this._isFocused = false));
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
public get window(): Window & typeof globalThis {
|
|
@@ -65,7 +65,7 @@ export class CoreBrowserService extends Disposable implements ICoreBrowserServic
|
|
|
65
65
|
* window.devicePixelRatio value changes. This is done not with polling but with
|
|
66
66
|
* the use of window.matchMedia to watch media queries. When the event fires,
|
|
67
67
|
* the listener will be reattached using a different media query to ensure that
|
|
68
|
-
* any further changes will
|
|
68
|
+
* any further changes will _register.
|
|
69
69
|
*
|
|
70
70
|
* The listener should fire on both window zoom changes and switching to a
|
|
71
71
|
* monitor with a different DPI.
|
|
@@ -74,9 +74,9 @@ class ScreenDprMonitor extends Disposable {
|
|
|
74
74
|
private _currentDevicePixelRatio: number;
|
|
75
75
|
private _outerListener: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | undefined;
|
|
76
76
|
private _resolutionMediaMatchList: MediaQueryList | undefined;
|
|
77
|
-
private _windowResizeListener = this.
|
|
77
|
+
private _windowResizeListener = this._register(new MutableDisposable());
|
|
78
78
|
|
|
79
|
-
private readonly _onDprChange = this.
|
|
79
|
+
private readonly _onDprChange = this._register(new Emitter<number>());
|
|
80
80
|
public readonly onDprChange = this._onDprChange.event;
|
|
81
81
|
|
|
82
82
|
constructor(private _parentWindow: Window) {
|
|
@@ -91,7 +91,7 @@ class ScreenDprMonitor extends Disposable {
|
|
|
91
91
|
this._setWindowResizeListener();
|
|
92
92
|
|
|
93
93
|
// Setup additional disposables
|
|
94
|
-
this.
|
|
94
|
+
this._register(toDisposable(() => this.clearListener()));
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
|
|
@@ -102,7 +102,7 @@ class ScreenDprMonitor extends Disposable {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
private _setWindowResizeListener(): void {
|
|
105
|
-
this._windowResizeListener.value =
|
|
105
|
+
this._windowResizeListener.value = addDisposableListener(this._parentWindow, 'resize', () => this._setDprAndFireIfDiffers());
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
private _setDprAndFireIfDiffers(): void {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ILinkProvider, ILinkProviderService } from 'browser/services/Services';
|
|
2
|
-
import { Disposable, toDisposable } from 'common/
|
|
2
|
+
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
|
|
3
3
|
import { IDisposable } from 'common/Types';
|
|
4
4
|
|
|
5
5
|
export class LinkProviderService extends Disposable implements ILinkProviderService {
|
|
@@ -9,7 +9,7 @@ export class LinkProviderService extends Disposable implements ILinkProviderServ
|
|
|
9
9
|
|
|
10
10
|
constructor() {
|
|
11
11
|
super();
|
|
12
|
-
this.
|
|
12
|
+
this._register(toDisposable(() => this.linkProviders.length = 0));
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
public registerLinkProvider(linkProvider: ILinkProvider): IDisposable {
|