@wendongfly/zihi 1.1.0 → 1.1.2
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/dist/index.js +1 -1
- package/dist/lib/xterm/README.md +27 -14
- package/dist/lib/xterm/css/xterm.css +81 -5
- package/dist/lib/xterm/lib/xterm.js +1 -1
- package/dist/lib/xterm/lib/xterm.js.map +1 -1
- package/dist/lib/xterm/lib/xterm.mjs +53 -0
- package/dist/lib/xterm/lib/xterm.mjs.map +7 -0
- package/dist/lib/xterm/package.json +49 -38
- package/dist/lib/xterm/src/browser/AccessibilityManager.ts +185 -50
- package/dist/lib/xterm/src/browser/CoreBrowserTerminal.ts +1339 -0
- package/dist/lib/xterm/src/browser/Linkifier.ts +403 -0
- package/dist/lib/xterm/src/browser/LocalizableStrings.ts +15 -4
- package/dist/lib/xterm/src/browser/OscLinkProvider.ts +2 -1
- package/dist/lib/xterm/src/browser/RenderDebouncer.ts +6 -5
- package/dist/lib/xterm/src/browser/TimeBasedDebouncer.ts +2 -2
- package/dist/lib/xterm/src/browser/Types.ts +226 -0
- package/dist/lib/xterm/src/browser/Viewport.ts +148 -357
- package/dist/lib/xterm/src/browser/decorations/BufferDecorationRenderer.ts +17 -12
- package/dist/lib/xterm/src/browser/decorations/OverviewRulerRenderer.ts +47 -52
- package/dist/lib/xterm/src/browser/input/CompositionHelper.ts +5 -3
- package/dist/lib/xterm/src/browser/input/MoveToCell.ts +3 -1
- package/dist/lib/xterm/src/browser/public/Terminal.ts +39 -24
- package/dist/lib/xterm/src/browser/renderer/dom/DomRenderer.ts +76 -40
- package/dist/lib/xterm/src/browser/renderer/dom/DomRendererRowFactory.ts +47 -23
- package/dist/lib/xterm/src/browser/renderer/dom/WidthCache.ts +19 -9
- package/dist/lib/xterm/src/browser/renderer/shared/Constants.ts +0 -8
- package/dist/lib/xterm/src/browser/renderer/shared/RendererUtils.ts +38 -1
- package/dist/lib/xterm/src/browser/renderer/shared/SelectionRenderModel.ts +6 -4
- package/dist/lib/xterm/src/browser/renderer/shared/Types.ts +84 -0
- package/dist/lib/xterm/src/browser/selection/Types.ts +15 -0
- package/dist/lib/xterm/src/browser/services/CharSizeService.ts +57 -32
- package/dist/lib/xterm/src/browser/services/CoreBrowserService.ts +108 -4
- package/dist/lib/xterm/src/browser/services/LinkProviderService.ts +28 -0
- package/dist/lib/xterm/src/browser/services/RenderService.ts +132 -40
- package/dist/lib/xterm/src/browser/services/SelectionService.ts +19 -9
- package/dist/lib/xterm/src/browser/services/Services.ts +36 -16
- package/dist/lib/xterm/src/browser/services/ThemeService.ts +19 -58
- package/dist/lib/xterm/src/browser/shared/Constants.ts +8 -0
- package/dist/lib/xterm/src/common/CircularList.ts +5 -5
- package/dist/lib/xterm/src/common/Color.ts +34 -14
- package/dist/lib/xterm/src/common/CoreTerminal.ts +40 -41
- package/dist/lib/xterm/src/common/InputHandler.ts +177 -125
- package/dist/lib/xterm/src/common/Platform.ts +2 -1
- package/dist/lib/xterm/src/common/SortedList.ts +86 -10
- package/dist/lib/xterm/src/common/TaskQueue.ts +7 -7
- package/dist/lib/xterm/src/common/Types.ts +552 -0
- package/dist/lib/xterm/src/common/buffer/AttributeData.ts +15 -0
- package/dist/lib/xterm/src/common/buffer/Buffer.ts +15 -7
- package/dist/lib/xterm/src/common/buffer/BufferLine.ts +53 -22
- package/dist/lib/xterm/src/common/buffer/BufferRange.ts +1 -1
- package/dist/lib/xterm/src/common/buffer/BufferReflow.ts +9 -6
- package/dist/lib/xterm/src/common/buffer/BufferSet.ts +5 -5
- package/dist/lib/xterm/src/common/buffer/Constants.ts +10 -2
- package/dist/lib/xterm/src/common/buffer/Marker.ts +4 -4
- package/dist/lib/xterm/src/common/buffer/Types.ts +52 -0
- package/dist/lib/xterm/src/common/input/Keyboard.ts +2 -27
- package/dist/lib/xterm/src/common/input/UnicodeV6.ts +18 -5
- package/dist/lib/xterm/src/common/input/WriteBuffer.ts +9 -8
- package/dist/lib/xterm/src/common/parser/EscapeSequenceParser.ts +13 -13
- package/dist/lib/xterm/src/common/parser/Types.ts +275 -0
- package/dist/lib/xterm/src/common/public/AddonManager.ts +1 -1
- package/dist/lib/xterm/src/common/public/BufferApiView.ts +1 -1
- package/dist/lib/xterm/src/common/public/BufferLineApiView.ts +1 -1
- package/dist/lib/xterm/src/common/public/BufferNamespaceApi.ts +4 -4
- package/dist/lib/xterm/src/common/public/ParserApi.ts +1 -1
- package/dist/lib/xterm/src/common/public/UnicodeApi.ts +1 -1
- package/dist/lib/xterm/src/common/services/BufferService.ts +14 -11
- package/dist/lib/xterm/src/common/services/CoreMouseService.ts +53 -6
- package/dist/lib/xterm/src/common/services/CoreService.ts +13 -8
- package/dist/lib/xterm/src/common/services/DecorationService.ts +11 -11
- package/dist/lib/xterm/src/common/services/InstantiationService.ts +1 -1
- package/dist/lib/xterm/src/common/services/LogService.ts +2 -2
- package/dist/lib/xterm/src/common/services/OptionsService.ts +16 -5
- package/dist/lib/xterm/src/common/services/ServiceRegistry.ts +1 -1
- package/dist/lib/xterm/src/common/services/Services.ts +73 -19
- package/dist/lib/xterm/src/common/services/UnicodeService.ts +30 -5
- package/dist/lib/xterm/src/vs/base/browser/browser.ts +141 -0
- package/dist/lib/xterm/src/vs/base/browser/canIUse.ts +49 -0
- package/dist/lib/xterm/src/vs/base/browser/dom.ts +2369 -0
- package/dist/lib/xterm/src/vs/base/browser/fastDomNode.ts +316 -0
- package/dist/lib/xterm/src/vs/base/browser/globalPointerMoveMonitor.ts +112 -0
- package/dist/lib/xterm/src/vs/base/browser/iframe.ts +135 -0
- package/dist/lib/xterm/src/vs/base/browser/keyboardEvent.ts +213 -0
- package/dist/lib/xterm/src/vs/base/browser/mouseEvent.ts +229 -0
- package/dist/lib/xterm/src/vs/base/browser/touch.ts +372 -0
- package/dist/lib/xterm/src/vs/base/browser/ui/scrollbar/abstractScrollbar.ts +303 -0
- package/dist/lib/xterm/src/vs/base/browser/ui/scrollbar/horizontalScrollbar.ts +114 -0
- package/dist/lib/xterm/src/vs/base/browser/ui/scrollbar/scrollableElement.ts +720 -0
- package/dist/lib/xterm/src/vs/base/browser/ui/scrollbar/scrollableElementOptions.ts +165 -0
- package/dist/lib/xterm/src/vs/base/browser/ui/scrollbar/scrollbarArrow.ts +114 -0
- package/dist/lib/xterm/src/vs/base/browser/ui/scrollbar/scrollbarState.ts +243 -0
- package/dist/lib/xterm/src/vs/base/browser/ui/scrollbar/scrollbarVisibilityController.ts +118 -0
- package/dist/lib/xterm/src/vs/base/browser/ui/scrollbar/verticalScrollbar.ts +116 -0
- package/dist/lib/xterm/src/vs/base/browser/ui/widget.ts +57 -0
- package/dist/lib/xterm/src/vs/base/browser/window.ts +14 -0
- package/dist/lib/xterm/src/vs/base/common/arrays.ts +887 -0
- package/dist/lib/xterm/src/vs/base/common/arraysFind.ts +202 -0
- package/dist/lib/xterm/src/vs/base/common/assert.ts +71 -0
- package/dist/lib/xterm/src/vs/base/common/async.ts +1992 -0
- package/dist/lib/xterm/src/vs/base/common/cancellation.ts +148 -0
- package/dist/lib/xterm/src/vs/base/common/charCode.ts +450 -0
- package/dist/lib/xterm/src/vs/base/common/collections.ts +140 -0
- package/dist/lib/xterm/src/vs/base/common/decorators.ts +130 -0
- package/dist/lib/xterm/src/vs/base/common/equals.ts +146 -0
- package/dist/lib/xterm/src/vs/base/common/errors.ts +303 -0
- package/dist/lib/xterm/src/vs/base/common/event.ts +1778 -0
- package/dist/lib/xterm/src/vs/base/common/functional.ts +32 -0
- package/dist/lib/xterm/src/vs/base/common/hash.ts +316 -0
- package/dist/lib/xterm/src/vs/base/common/iterator.ts +159 -0
- package/dist/lib/xterm/src/vs/base/common/keyCodes.ts +526 -0
- package/dist/lib/xterm/src/vs/base/common/keybindings.ts +284 -0
- package/dist/lib/xterm/src/vs/base/common/lazy.ts +47 -0
- package/dist/lib/xterm/src/vs/base/common/lifecycle.ts +801 -0
- package/dist/lib/xterm/src/vs/base/common/linkedList.ts +142 -0
- package/dist/lib/xterm/src/vs/base/common/map.ts +202 -0
- package/dist/lib/xterm/src/vs/base/common/numbers.ts +98 -0
- package/dist/lib/xterm/src/vs/base/common/observable.ts +76 -0
- package/dist/lib/xterm/src/vs/base/common/observableInternal/api.ts +31 -0
- package/dist/lib/xterm/src/vs/base/common/observableInternal/autorun.ts +281 -0
- package/dist/lib/xterm/src/vs/base/common/observableInternal/base.ts +489 -0
- package/dist/lib/xterm/src/vs/base/common/observableInternal/debugName.ts +145 -0
- package/dist/lib/xterm/src/vs/base/common/observableInternal/derived.ts +428 -0
- package/dist/lib/xterm/src/vs/base/common/observableInternal/lazyObservableValue.ts +146 -0
- package/dist/lib/xterm/src/vs/base/common/observableInternal/logging.ts +328 -0
- package/dist/lib/xterm/src/vs/base/common/observableInternal/promise.ts +209 -0
- package/dist/lib/xterm/src/vs/base/common/observableInternal/utils.ts +610 -0
- package/dist/lib/xterm/src/vs/base/common/platform.ts +281 -0
- package/dist/lib/xterm/src/vs/base/common/scrollable.ts +522 -0
- package/dist/lib/xterm/src/vs/base/common/sequence.ts +34 -0
- package/dist/lib/xterm/src/vs/base/common/stopwatch.ts +43 -0
- package/dist/lib/xterm/src/vs/base/common/strings.ts +557 -0
- package/dist/lib/xterm/src/vs/base/common/symbols.ts +9 -0
- package/dist/lib/xterm/src/vs/base/common/uint.ts +59 -0
- package/dist/lib/xterm/src/vs/patches/nls.ts +90 -0
- package/dist/lib/xterm/src/vs/typings/base-common.d.ts +20 -0
- package/dist/lib/xterm/src/vs/typings/require.d.ts +42 -0
- package/dist/lib/xterm/src/vs/typings/vscode-globals-nls.d.ts +36 -0
- package/dist/lib/xterm/src/vs/typings/vscode-globals-product.d.ts +33 -0
- package/dist/lib/xterm/typings/xterm.d.ts +156 -43
- package/dist/lib/xterm-fit/README.md +5 -5
- package/dist/lib/xterm-fit/lib/addon-fit.js +2 -0
- package/dist/lib/xterm-fit/lib/addon-fit.js.map +1 -0
- package/dist/lib/xterm-fit/lib/addon-fit.mjs +18 -0
- package/dist/lib/xterm-fit/lib/addon-fit.mjs.map +7 -0
- package/dist/lib/xterm-fit/package.json +9 -9
- package/dist/lib/xterm-fit/src/FitAddon.ts +7 -4
- package/dist/lib/xterm-fit/typings/addon-fit.d.ts +55 -0
- package/dist/lib/xterm-links/README.md +5 -5
- package/dist/lib/xterm-links/lib/addon-web-links.js +2 -0
- package/dist/lib/xterm-links/lib/addon-web-links.js.map +1 -0
- package/dist/lib/xterm-links/lib/addon-web-links.mjs +18 -0
- package/dist/lib/xterm-links/lib/addon-web-links.mjs.map +7 -0
- package/dist/lib/xterm-links/package.json +9 -9
- package/dist/lib/xterm-links/src/WebLinkProvider.ts +16 -15
- package/dist/lib/xterm-links/src/WebLinksAddon.ts +4 -3
- package/dist/lib/xterm-links/typings/addon-web-links.d.ts +57 -0
- package/package.json +5 -6
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
|
|
3
|
+
* @license MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { IBufferCellPosition, ILink, ILinkDecorations, ILinkWithState, ILinkifier2, ILinkifierEvent } from 'browser/Types';
|
|
7
|
+
import { Disposable, dispose, toDisposable } from 'vs/base/common/lifecycle';
|
|
8
|
+
import { IDisposable } from 'common/Types';
|
|
9
|
+
import { IBufferService } from 'common/services/Services';
|
|
10
|
+
import { ILinkProviderService, IMouseService, IRenderService } from './services/Services';
|
|
11
|
+
import { Emitter } from 'vs/base/common/event';
|
|
12
|
+
import { addDisposableListener } from 'vs/base/browser/dom';
|
|
13
|
+
|
|
14
|
+
export class Linkifier extends Disposable implements ILinkifier2 {
|
|
15
|
+
public get currentLink(): ILinkWithState | undefined { return this._currentLink; }
|
|
16
|
+
protected _currentLink: ILinkWithState | undefined;
|
|
17
|
+
private _mouseDownLink: ILinkWithState | undefined;
|
|
18
|
+
private _lastMouseEvent: MouseEvent | undefined;
|
|
19
|
+
private _linkCacheDisposables: IDisposable[] = [];
|
|
20
|
+
private _lastBufferCell: IBufferCellPosition | undefined;
|
|
21
|
+
private _isMouseOut: boolean = true;
|
|
22
|
+
private _wasResized: boolean = false;
|
|
23
|
+
private _activeProviderReplies: Map<Number, ILinkWithState[] | undefined> | undefined;
|
|
24
|
+
private _activeLine: number = -1;
|
|
25
|
+
|
|
26
|
+
private readonly _onShowLinkUnderline = this._register(new Emitter<ILinkifierEvent>());
|
|
27
|
+
public readonly onShowLinkUnderline = this._onShowLinkUnderline.event;
|
|
28
|
+
private readonly _onHideLinkUnderline = this._register(new Emitter<ILinkifierEvent>());
|
|
29
|
+
public readonly onHideLinkUnderline = this._onHideLinkUnderline.event;
|
|
30
|
+
|
|
31
|
+
constructor(
|
|
32
|
+
private readonly _element: HTMLElement,
|
|
33
|
+
@IMouseService private readonly _mouseService: IMouseService,
|
|
34
|
+
@IRenderService private readonly _renderService: IRenderService,
|
|
35
|
+
@IBufferService private readonly _bufferService: IBufferService,
|
|
36
|
+
@ILinkProviderService private readonly _linkProviderService: ILinkProviderService
|
|
37
|
+
) {
|
|
38
|
+
super();
|
|
39
|
+
this._register(toDisposable(() => {
|
|
40
|
+
dispose(this._linkCacheDisposables);
|
|
41
|
+
this._linkCacheDisposables.length = 0;
|
|
42
|
+
this._lastMouseEvent = undefined;
|
|
43
|
+
// Clear out link providers as they could easily cause an embedder memory leak
|
|
44
|
+
this._activeProviderReplies?.clear();
|
|
45
|
+
}));
|
|
46
|
+
// Listen to resize to catch the case where it's resized and the cursor is out of the viewport.
|
|
47
|
+
this._register(this._bufferService.onResize(() => {
|
|
48
|
+
this._clearCurrentLink();
|
|
49
|
+
this._wasResized = true;
|
|
50
|
+
}));
|
|
51
|
+
this._register(addDisposableListener(this._element, 'mouseleave', () => {
|
|
52
|
+
this._isMouseOut = true;
|
|
53
|
+
this._clearCurrentLink();
|
|
54
|
+
}));
|
|
55
|
+
this._register(addDisposableListener(this._element, 'mousemove', this._handleMouseMove.bind(this)));
|
|
56
|
+
this._register(addDisposableListener(this._element, 'mousedown', this._handleMouseDown.bind(this)));
|
|
57
|
+
this._register(addDisposableListener(this._element, 'mouseup', this._handleMouseUp.bind(this)));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
private _handleMouseMove(event: MouseEvent): void {
|
|
61
|
+
this._lastMouseEvent = event;
|
|
62
|
+
|
|
63
|
+
const position = this._positionFromMouseEvent(event, this._element, this._mouseService);
|
|
64
|
+
if (!position) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
this._isMouseOut = false;
|
|
68
|
+
|
|
69
|
+
// Ignore the event if it's an embedder created hover widget
|
|
70
|
+
const composedPath = event.composedPath() as HTMLElement[];
|
|
71
|
+
for (let i = 0; i < composedPath.length; i++) {
|
|
72
|
+
const target = composedPath[i];
|
|
73
|
+
// Hit Terminal.element, break and continue
|
|
74
|
+
if (target.classList.contains('xterm')) {
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
// It's a hover, don't respect hover event
|
|
78
|
+
if (target.classList.contains('xterm-hover')) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (!this._lastBufferCell || (position.x !== this._lastBufferCell.x || position.y !== this._lastBufferCell.y)) {
|
|
84
|
+
this._handleHover(position);
|
|
85
|
+
this._lastBufferCell = position;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private _handleHover(position: IBufferCellPosition): void {
|
|
90
|
+
// TODO: This currently does not cache link provider results across wrapped lines, activeLine
|
|
91
|
+
// should be something like `activeRange: {startY, endY}`
|
|
92
|
+
// Check if we need to clear the link
|
|
93
|
+
if (this._activeLine !== position.y || this._wasResized) {
|
|
94
|
+
this._clearCurrentLink();
|
|
95
|
+
this._askForLink(position, false);
|
|
96
|
+
this._wasResized = false;
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Check the if the link is in the mouse position
|
|
101
|
+
const isCurrentLinkInPosition = this._currentLink && this._linkAtPosition(this._currentLink.link, position);
|
|
102
|
+
if (!isCurrentLinkInPosition) {
|
|
103
|
+
this._clearCurrentLink();
|
|
104
|
+
this._askForLink(position, true);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private _askForLink(position: IBufferCellPosition, useLineCache: boolean): void {
|
|
109
|
+
if (!this._activeProviderReplies || !useLineCache) {
|
|
110
|
+
this._activeProviderReplies?.forEach(reply => {
|
|
111
|
+
reply?.forEach(linkWithState => {
|
|
112
|
+
if (linkWithState.link.dispose) {
|
|
113
|
+
linkWithState.link.dispose();
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
this._activeProviderReplies = new Map();
|
|
118
|
+
this._activeLine = position.y;
|
|
119
|
+
}
|
|
120
|
+
let linkProvided = false;
|
|
121
|
+
|
|
122
|
+
// There is no link cached, so ask for one
|
|
123
|
+
for (const [i, linkProvider] of this._linkProviderService.linkProviders.entries()) {
|
|
124
|
+
if (useLineCache) {
|
|
125
|
+
const existingReply = this._activeProviderReplies?.get(i);
|
|
126
|
+
// If there isn't a reply, the provider hasn't responded yet.
|
|
127
|
+
|
|
128
|
+
// TODO: If there isn't a reply yet it means that the provider is still resolving. Ensuring
|
|
129
|
+
// provideLinks isn't triggered again saves ILink.hover firing twice though. This probably
|
|
130
|
+
// needs promises to get fixed
|
|
131
|
+
if (existingReply) {
|
|
132
|
+
linkProvided = this._checkLinkProviderResult(i, position, linkProvided);
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
linkProvider.provideLinks(position.y, (links: ILink[] | undefined) => {
|
|
136
|
+
if (this._isMouseOut) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const linksWithState: ILinkWithState[] | undefined = links?.map(link => ({ link }));
|
|
140
|
+
this._activeProviderReplies?.set(i, linksWithState);
|
|
141
|
+
linkProvided = this._checkLinkProviderResult(i, position, linkProvided);
|
|
142
|
+
|
|
143
|
+
// If all providers have responded, remove lower priority links that intersect ranges of
|
|
144
|
+
// higher priority links
|
|
145
|
+
if (this._activeProviderReplies?.size === this._linkProviderService.linkProviders.length) {
|
|
146
|
+
this._removeIntersectingLinks(position.y, this._activeProviderReplies);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
private _removeIntersectingLinks(y: number, replies: Map<Number, ILinkWithState[] | undefined>): void {
|
|
154
|
+
const occupiedCells = new Set<number>();
|
|
155
|
+
for (let i = 0; i < replies.size; i++) {
|
|
156
|
+
const providerReply = replies.get(i);
|
|
157
|
+
if (!providerReply) {
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
for (let i = 0; i < providerReply.length; i++) {
|
|
161
|
+
const linkWithState = providerReply[i];
|
|
162
|
+
const startX = linkWithState.link.range.start.y < y ? 0 : linkWithState.link.range.start.x;
|
|
163
|
+
const endX = linkWithState.link.range.end.y > y ? this._bufferService.cols : linkWithState.link.range.end.x;
|
|
164
|
+
for (let x = startX; x <= endX; x++) {
|
|
165
|
+
if (occupiedCells.has(x)) {
|
|
166
|
+
providerReply.splice(i--, 1);
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
occupiedCells.add(x);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
private _checkLinkProviderResult(index: number, position: IBufferCellPosition, linkProvided: boolean): boolean {
|
|
176
|
+
if (!this._activeProviderReplies) {
|
|
177
|
+
return linkProvided;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const links = this._activeProviderReplies.get(index);
|
|
181
|
+
|
|
182
|
+
// Check if every provider before this one has come back undefined
|
|
183
|
+
let hasLinkBefore = false;
|
|
184
|
+
for (let j = 0; j < index; j++) {
|
|
185
|
+
if (!this._activeProviderReplies.has(j) || this._activeProviderReplies.get(j)) {
|
|
186
|
+
hasLinkBefore = true;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// If all providers with higher priority came back undefined, then this provider's link for
|
|
191
|
+
// the position should be used
|
|
192
|
+
if (!hasLinkBefore && links) {
|
|
193
|
+
const linkAtPosition = links.find(link => this._linkAtPosition(link.link, position));
|
|
194
|
+
if (linkAtPosition) {
|
|
195
|
+
linkProvided = true;
|
|
196
|
+
this._handleNewLink(linkAtPosition);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Check if all the providers have responded
|
|
201
|
+
if (this._activeProviderReplies.size === this._linkProviderService.linkProviders.length && !linkProvided) {
|
|
202
|
+
// Respect the order of the link providers
|
|
203
|
+
for (let j = 0; j < this._activeProviderReplies.size; j++) {
|
|
204
|
+
const currentLink = this._activeProviderReplies.get(j)?.find(link => this._linkAtPosition(link.link, position));
|
|
205
|
+
if (currentLink) {
|
|
206
|
+
linkProvided = true;
|
|
207
|
+
this._handleNewLink(currentLink);
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return linkProvided;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
private _handleMouseDown(): void {
|
|
217
|
+
this._mouseDownLink = this._currentLink;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
private _handleMouseUp(event: MouseEvent): void {
|
|
221
|
+
if (!this._currentLink) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const position = this._positionFromMouseEvent(event, this._element, this._mouseService);
|
|
226
|
+
if (!position) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (this._mouseDownLink && linkEquals(this._mouseDownLink.link, this._currentLink.link) && this._linkAtPosition(this._currentLink.link, position)) {
|
|
231
|
+
this._currentLink.link.activate(event, this._currentLink.link.text);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
private _clearCurrentLink(startRow?: number, endRow?: number): void {
|
|
236
|
+
if (!this._currentLink || !this._lastMouseEvent) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// If we have a start and end row, check that the link is within it
|
|
241
|
+
if (!startRow || !endRow || (this._currentLink.link.range.start.y >= startRow && this._currentLink.link.range.end.y <= endRow)) {
|
|
242
|
+
this._linkLeave(this._element, this._currentLink.link, this._lastMouseEvent);
|
|
243
|
+
this._currentLink = undefined;
|
|
244
|
+
dispose(this._linkCacheDisposables);
|
|
245
|
+
this._linkCacheDisposables.length = 0;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
private _handleNewLink(linkWithState: ILinkWithState): void {
|
|
250
|
+
if (!this._lastMouseEvent) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const position = this._positionFromMouseEvent(this._lastMouseEvent, this._element, this._mouseService);
|
|
255
|
+
|
|
256
|
+
if (!position) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Trigger hover if the we have a link at the position
|
|
261
|
+
if (this._linkAtPosition(linkWithState.link, position)) {
|
|
262
|
+
this._currentLink = linkWithState;
|
|
263
|
+
this._currentLink.state = {
|
|
264
|
+
decorations: {
|
|
265
|
+
underline: linkWithState.link.decorations === undefined ? true : linkWithState.link.decorations.underline,
|
|
266
|
+
pointerCursor: linkWithState.link.decorations === undefined ? true : linkWithState.link.decorations.pointerCursor
|
|
267
|
+
},
|
|
268
|
+
isHovered: true
|
|
269
|
+
};
|
|
270
|
+
this._linkHover(this._element, linkWithState.link, this._lastMouseEvent);
|
|
271
|
+
|
|
272
|
+
// Add listener for tracking decorations changes
|
|
273
|
+
linkWithState.link.decorations = {} as ILinkDecorations;
|
|
274
|
+
Object.defineProperties(linkWithState.link.decorations, {
|
|
275
|
+
pointerCursor: {
|
|
276
|
+
get: () => this._currentLink?.state?.decorations.pointerCursor,
|
|
277
|
+
set: v => {
|
|
278
|
+
if (this._currentLink?.state && this._currentLink.state.decorations.pointerCursor !== v) {
|
|
279
|
+
this._currentLink.state.decorations.pointerCursor = v;
|
|
280
|
+
if (this._currentLink.state.isHovered) {
|
|
281
|
+
this._element.classList.toggle('xterm-cursor-pointer', v);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
underline: {
|
|
287
|
+
get: () => this._currentLink?.state?.decorations.underline,
|
|
288
|
+
set: v => {
|
|
289
|
+
if (this._currentLink?.state && this._currentLink?.state?.decorations.underline !== v) {
|
|
290
|
+
this._currentLink.state.decorations.underline = v;
|
|
291
|
+
if (this._currentLink.state.isHovered) {
|
|
292
|
+
this._fireUnderlineEvent(linkWithState.link, v);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
// Listen to viewport changes to re-render the link under the cursor (only when the line the
|
|
300
|
+
// link is on changes)
|
|
301
|
+
this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e => {
|
|
302
|
+
// Sanity check, this shouldn't happen in practice as this listener would be disposed
|
|
303
|
+
if (!this._currentLink) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
// When start is 0 a scroll most likely occurred, make sure links above the fold also get
|
|
307
|
+
// cleared.
|
|
308
|
+
const start = e.start === 0 ? 0 : e.start + 1 + this._bufferService.buffer.ydisp;
|
|
309
|
+
const end = this._bufferService.buffer.ydisp + 1 + e.end;
|
|
310
|
+
// Only clear the link if the viewport change happened on this line
|
|
311
|
+
if (this._currentLink.link.range.start.y >= start && this._currentLink.link.range.end.y <= end) {
|
|
312
|
+
this._clearCurrentLink(start, end);
|
|
313
|
+
if (this._lastMouseEvent) {
|
|
314
|
+
// re-eval previously active link after changes
|
|
315
|
+
const position = this._positionFromMouseEvent(this._lastMouseEvent, this._element, this._mouseService!);
|
|
316
|
+
if (position) {
|
|
317
|
+
this._askForLink(position, false);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}));
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
protected _linkHover(element: HTMLElement, link: ILink, event: MouseEvent): void {
|
|
326
|
+
if (this._currentLink?.state) {
|
|
327
|
+
this._currentLink.state.isHovered = true;
|
|
328
|
+
if (this._currentLink.state.decorations.underline) {
|
|
329
|
+
this._fireUnderlineEvent(link, true);
|
|
330
|
+
}
|
|
331
|
+
if (this._currentLink.state.decorations.pointerCursor) {
|
|
332
|
+
element.classList.add('xterm-cursor-pointer');
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if (link.hover) {
|
|
337
|
+
link.hover(event, link.text);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
private _fireUnderlineEvent(link: ILink, showEvent: boolean): void {
|
|
342
|
+
const range = link.range;
|
|
343
|
+
const scrollOffset = this._bufferService.buffer.ydisp;
|
|
344
|
+
const event = this._createLinkUnderlineEvent(range.start.x - 1, range.start.y - scrollOffset - 1, range.end.x, range.end.y - scrollOffset - 1, undefined);
|
|
345
|
+
const emitter = showEvent ? this._onShowLinkUnderline : this._onHideLinkUnderline;
|
|
346
|
+
emitter.fire(event);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
protected _linkLeave(element: HTMLElement, link: ILink, event: MouseEvent): void {
|
|
350
|
+
if (this._currentLink?.state) {
|
|
351
|
+
this._currentLink.state.isHovered = false;
|
|
352
|
+
if (this._currentLink.state.decorations.underline) {
|
|
353
|
+
this._fireUnderlineEvent(link, false);
|
|
354
|
+
}
|
|
355
|
+
if (this._currentLink.state.decorations.pointerCursor) {
|
|
356
|
+
element.classList.remove('xterm-cursor-pointer');
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
if (link.leave) {
|
|
361
|
+
link.leave(event, link.text);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Check if the buffer position is within the link
|
|
367
|
+
* @param link
|
|
368
|
+
* @param position
|
|
369
|
+
*/
|
|
370
|
+
private _linkAtPosition(link: ILink, position: IBufferCellPosition): boolean {
|
|
371
|
+
const lower = link.range.start.y * this._bufferService.cols + link.range.start.x;
|
|
372
|
+
const upper = link.range.end.y * this._bufferService.cols + link.range.end.x;
|
|
373
|
+
const current = position.y * this._bufferService.cols + position.x;
|
|
374
|
+
return (lower <= current && current <= upper);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Get the buffer position from a mouse event
|
|
379
|
+
* @param event
|
|
380
|
+
*/
|
|
381
|
+
private _positionFromMouseEvent(event: MouseEvent, element: HTMLElement, mouseService: IMouseService): IBufferCellPosition | undefined {
|
|
382
|
+
const coords = mouseService.getCoords(event, element, this._bufferService.cols, this._bufferService.rows);
|
|
383
|
+
if (!coords) {
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
return { x: coords[0], y: coords[1] + this._bufferService.buffer.ydisp };
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
private _createLinkUnderlineEvent(x1: number, y1: number, x2: number, y2: number, fg: number | undefined): ILinkifierEvent {
|
|
391
|
+
return { x1, y1, x2, y2, cols: this._bufferService.cols, fg };
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
function linkEquals(a: ILink, b: ILink): boolean {
|
|
396
|
+
return (
|
|
397
|
+
a.text === b.text &&
|
|
398
|
+
a.range.start.x === b.range.start.x &&
|
|
399
|
+
a.range.start.y === b.range.start.y &&
|
|
400
|
+
a.range.end.x === b.range.end.x &&
|
|
401
|
+
a.range.end.y === b.range.end.y
|
|
402
|
+
);
|
|
403
|
+
}
|
|
@@ -5,8 +5,19 @@
|
|
|
5
5
|
|
|
6
6
|
// This file contains strings that get exported in the API so they can be localized
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
let promptLabelInternal = 'Terminal input';
|
|
9
|
+
const promptLabel = {
|
|
10
|
+
get: () => promptLabelInternal,
|
|
11
|
+
set: (value: string) => promptLabelInternal = value
|
|
12
|
+
};
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
let tooMuchOutputInternal = 'Too much output to announce, navigate to rows manually to read';
|
|
15
|
+
const tooMuchOutput = {
|
|
16
|
+
get: () => tooMuchOutputInternal,
|
|
17
|
+
set: (value: string) => tooMuchOutputInternal = value
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
promptLabel,
|
|
22
|
+
tooMuchOutput
|
|
23
|
+
};
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* @license MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { IBufferRange, ILink
|
|
6
|
+
import { IBufferRange, ILink } from 'browser/Types';
|
|
7
|
+
import { ILinkProvider } from 'browser/services/Services';
|
|
7
8
|
import { CellData } from 'common/buffer/CellData';
|
|
8
9
|
import { IBufferService, IOptionsService, IOscLinkService } from 'common/services/Services';
|
|
9
10
|
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { IRenderDebouncerWithCallback } from 'browser/Types';
|
|
7
|
+
import { ICoreBrowserService } from 'browser/services/Services';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Debounces calls to render terminal rows using animation frames.
|
|
@@ -16,14 +17,14 @@ export class RenderDebouncer implements IRenderDebouncerWithCallback {
|
|
|
16
17
|
private _refreshCallbacks: FrameRequestCallback[] = [];
|
|
17
18
|
|
|
18
19
|
constructor(
|
|
19
|
-
private
|
|
20
|
-
private
|
|
20
|
+
private _renderCallback: (start: number, end: number) => void,
|
|
21
|
+
private readonly _coreBrowserService: ICoreBrowserService
|
|
21
22
|
) {
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
public dispose(): void {
|
|
25
26
|
if (this._animationFrame) {
|
|
26
|
-
this.
|
|
27
|
+
this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame);
|
|
27
28
|
this._animationFrame = undefined;
|
|
28
29
|
}
|
|
29
30
|
}
|
|
@@ -31,7 +32,7 @@ export class RenderDebouncer implements IRenderDebouncerWithCallback {
|
|
|
31
32
|
public addRefreshCallback(callback: FrameRequestCallback): number {
|
|
32
33
|
this._refreshCallbacks.push(callback);
|
|
33
34
|
if (!this._animationFrame) {
|
|
34
|
-
this._animationFrame = this.
|
|
35
|
+
this._animationFrame = this._coreBrowserService.window.requestAnimationFrame(() => this._innerRefresh());
|
|
35
36
|
}
|
|
36
37
|
return this._animationFrame;
|
|
37
38
|
}
|
|
@@ -49,7 +50,7 @@ export class RenderDebouncer implements IRenderDebouncerWithCallback {
|
|
|
49
50
|
return;
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
this._animationFrame = this.
|
|
53
|
+
this._animationFrame = this._coreBrowserService.window.requestAnimationFrame(() => this._innerRefresh());
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
private _innerRefresh(): void {
|
|
@@ -45,7 +45,7 @@ export class TimeBasedDebouncer implements IRenderDebouncer {
|
|
|
45
45
|
|
|
46
46
|
// Only refresh if the time since last refresh is above a threshold, otherwise wait for
|
|
47
47
|
// enough time to pass before refreshing again.
|
|
48
|
-
const refreshRequestTime: number =
|
|
48
|
+
const refreshRequestTime: number = performance.now();
|
|
49
49
|
if (refreshRequestTime - this._lastRefreshMs >= this._debounceThresholdMS) {
|
|
50
50
|
// Enough time has lapsed since the last refresh; refresh immediately
|
|
51
51
|
this._lastRefreshMs = refreshRequestTime;
|
|
@@ -57,7 +57,7 @@ export class TimeBasedDebouncer implements IRenderDebouncer {
|
|
|
57
57
|
this._additionalRefreshRequested = true;
|
|
58
58
|
|
|
59
59
|
this._refreshTimeoutID = window.setTimeout(() => {
|
|
60
|
-
this._lastRefreshMs =
|
|
60
|
+
this._lastRefreshMs = performance.now();
|
|
61
61
|
this._innerRefresh();
|
|
62
62
|
this._additionalRefreshRequested = false;
|
|
63
63
|
this._refreshTimeoutID = undefined; // No longer need to clear the timeout
|