@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
|
@@ -1,401 +1,192 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) 2024 The xterm.js authors. All rights reserved.
|
|
3
3
|
* @license MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
6
|
+
import { ICoreBrowserService, IRenderService, IThemeService } from 'browser/services/Services';
|
|
7
|
+
import { ViewportConstants } from 'browser/shared/Constants';
|
|
8
|
+
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
|
|
9
|
+
import { IBufferService, ICoreMouseService, IOptionsService } from 'common/services/Services';
|
|
10
|
+
import { CoreMouseEventType } from 'common/Types';
|
|
11
|
+
import { scheduleAtNextAnimationFrame } from 'vs/base/browser/dom';
|
|
12
|
+
import { SmoothScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement';
|
|
13
|
+
import type { ScrollableElementChangeOptions } from 'vs/base/browser/ui/scrollbar/scrollableElementOptions';
|
|
14
|
+
import { Emitter, Event } from 'vs/base/common/event';
|
|
15
|
+
import { Scrollable, ScrollbarVisibility, type ScrollEvent } from 'vs/base/common/scrollable';
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
export class Viewport extends Disposable {
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
origin: number;
|
|
20
|
-
target: number;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Represents the viewport of a terminal, the visible area within the larger buffer of output.
|
|
25
|
-
* Logic for the virtual scroll bar is included in this object.
|
|
26
|
-
*/
|
|
27
|
-
export class Viewport extends Disposable implements IViewport {
|
|
28
|
-
public scrollBarWidth: number = 0;
|
|
29
|
-
private _currentRowHeight: number = 0;
|
|
30
|
-
private _currentDeviceCellHeight: number = 0;
|
|
31
|
-
private _lastRecordedBufferLength: number = 0;
|
|
32
|
-
private _lastRecordedViewportHeight: number = 0;
|
|
33
|
-
private _lastRecordedBufferHeight: number = 0;
|
|
34
|
-
private _lastTouchY: number = 0;
|
|
35
|
-
private _lastScrollTop: number = 0;
|
|
36
|
-
private _activeBuffer: IBuffer;
|
|
37
|
-
private _renderDimensions: IRenderDimensions;
|
|
38
|
-
|
|
39
|
-
// Stores a partial line amount when scrolling, this is used to keep track of how much of a line
|
|
40
|
-
// is scrolled so we can "scroll" over partial lines and feel natural on touchpads. This is a
|
|
41
|
-
// quick fix and could have a more robust solution in place that reset the value when needed.
|
|
42
|
-
private _wheelPartialScroll: number = 0;
|
|
19
|
+
protected _onRequestScrollLines = this._register(new Emitter<number>());
|
|
20
|
+
public readonly onRequestScrollLines = this._onRequestScrollLines.event;
|
|
43
21
|
|
|
44
|
-
private
|
|
45
|
-
private
|
|
46
|
-
private _smoothScrollState: ISmoothScrollState = {
|
|
47
|
-
startTime: 0,
|
|
48
|
-
origin: -1,
|
|
49
|
-
target: -1
|
|
50
|
-
};
|
|
22
|
+
private _scrollableElement: SmoothScrollableElement;
|
|
23
|
+
private _styleElement: HTMLStyleElement;
|
|
51
24
|
|
|
52
|
-
private
|
|
53
|
-
|
|
25
|
+
private _queuedAnimationFrame?: number;
|
|
26
|
+
private _latestYDisp?: number;
|
|
27
|
+
private _isSyncing: boolean = false;
|
|
28
|
+
private _isHandlingScroll: boolean = false;
|
|
29
|
+
private _suppressOnScrollHandler: boolean = false;
|
|
54
30
|
|
|
55
31
|
constructor(
|
|
56
|
-
|
|
57
|
-
|
|
32
|
+
element: HTMLElement,
|
|
33
|
+
screenElement: HTMLElement,
|
|
58
34
|
@IBufferService private readonly _bufferService: IBufferService,
|
|
35
|
+
@ICoreBrowserService coreBrowserService: ICoreBrowserService,
|
|
36
|
+
@ICoreMouseService coreMouseService: ICoreMouseService,
|
|
37
|
+
@IThemeService themeService: IThemeService,
|
|
59
38
|
@IOptionsService private readonly _optionsService: IOptionsService,
|
|
60
|
-
@
|
|
61
|
-
@IRenderService private readonly _renderService: IRenderService,
|
|
62
|
-
@ICoreBrowserService private readonly _coreBrowserService: ICoreBrowserService,
|
|
63
|
-
@IThemeService themeService: IThemeService
|
|
39
|
+
@IRenderService private readonly _renderService: IRenderService
|
|
64
40
|
) {
|
|
65
41
|
super();
|
|
66
42
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
this.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
this.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
this.
|
|
97
|
-
this.
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
43
|
+
const scrollable = this._register(new Scrollable({
|
|
44
|
+
forceIntegerValues: false,
|
|
45
|
+
smoothScrollDuration: this._optionsService.rawOptions.smoothScrollDuration,
|
|
46
|
+
// This is used over `IRenderService.addRefreshCallback` since it can be canceled
|
|
47
|
+
scheduleAtNextAnimationFrame: cb => scheduleAtNextAnimationFrame(coreBrowserService.window, cb)
|
|
48
|
+
}));
|
|
49
|
+
this._register(this._optionsService.onSpecificOptionChange('smoothScrollDuration', () => {
|
|
50
|
+
scrollable.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration);
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
this._scrollableElement = this._register(new SmoothScrollableElement(screenElement, {
|
|
54
|
+
vertical: ScrollbarVisibility.Auto,
|
|
55
|
+
horizontal: ScrollbarVisibility.Hidden,
|
|
56
|
+
useShadows: false,
|
|
57
|
+
mouseWheelSmoothScroll: true,
|
|
58
|
+
...this._getChangeOptions()
|
|
59
|
+
}, scrollable));
|
|
60
|
+
this._register(this._optionsService.onMultipleOptionChange([
|
|
61
|
+
'scrollSensitivity',
|
|
62
|
+
'fastScrollSensitivity',
|
|
63
|
+
'overviewRuler'
|
|
64
|
+
], () => this._scrollableElement.updateOptions(this._getChangeOptions())));
|
|
65
|
+
// Don't handle mouse wheel if wheel events are supported by the current mouse prototcol
|
|
66
|
+
this._register(coreMouseService.onProtocolChange(type => {
|
|
67
|
+
this._scrollableElement.updateOptions({
|
|
68
|
+
handleMouseWheel: !(type & CoreMouseEventType.WHEEL)
|
|
69
|
+
});
|
|
70
|
+
}));
|
|
71
|
+
|
|
72
|
+
this._scrollableElement.setScrollDimensions({ height: 0, scrollHeight: 0 });
|
|
73
|
+
this._register(Event.runAndSubscribe(themeService.onChangeColors, () => {
|
|
74
|
+
this._scrollableElement.getDomNode().style.backgroundColor = themeService.colors.background.css;
|
|
75
|
+
}));
|
|
76
|
+
element.appendChild(this._scrollableElement.getDomNode());
|
|
77
|
+
this._register(toDisposable(() => this._scrollableElement.getDomNode().remove()));
|
|
78
|
+
|
|
79
|
+
this._styleElement = coreBrowserService.mainDocument.createElement('style');
|
|
80
|
+
screenElement.appendChild(this._styleElement);
|
|
81
|
+
this._register(toDisposable(() => this._styleElement.remove()));
|
|
82
|
+
this._register(Event.runAndSubscribe(themeService.onChangeColors, () => {
|
|
83
|
+
this._styleElement.textContent = [
|
|
84
|
+
`.xterm .xterm-scrollable-element > .scrollbar > .slider {`,
|
|
85
|
+
` background: ${themeService.colors.scrollbarSliderBackground.css};`,
|
|
86
|
+
`}`,
|
|
87
|
+
`.xterm .xterm-scrollable-element > .scrollbar > .slider:hover {`,
|
|
88
|
+
` background: ${themeService.colors.scrollbarSliderHoverBackground.css};`,
|
|
89
|
+
`}`,
|
|
90
|
+
`.xterm .xterm-scrollable-element > .scrollbar > .slider.active {`,
|
|
91
|
+
` background: ${themeService.colors.scrollbarSliderActiveBackground.css};`,
|
|
92
|
+
`}`
|
|
93
|
+
].join('\n');
|
|
94
|
+
}));
|
|
95
|
+
|
|
96
|
+
this._register(this._bufferService.onResize(() => this.queueSync()));
|
|
97
|
+
this._register(this._bufferService.buffers.onBufferActivate(() => {
|
|
98
|
+
// Reset _latestYDisp when switching buffers to prevent stale scroll position
|
|
99
|
+
// from alt buffer contaminating normal buffer scroll position
|
|
100
|
+
this._latestYDisp = undefined;
|
|
101
|
+
this.queueSync();
|
|
102
|
+
}));
|
|
103
|
+
this._register(this._bufferService.onScroll(() => this._sync()));
|
|
104
|
+
|
|
105
|
+
this._register(this._scrollableElement.onScroll(e => this._handleScroll(e)));
|
|
101
106
|
}
|
|
102
107
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
this._innerRefresh();
|
|
110
|
-
if (this._refreshAnimationFrame !== null) {
|
|
111
|
-
this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame);
|
|
112
|
-
}
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
if (this._refreshAnimationFrame === null) {
|
|
116
|
-
this._refreshAnimationFrame = this._coreBrowserService.window.requestAnimationFrame(() => this._innerRefresh());
|
|
117
|
-
}
|
|
108
|
+
public scrollLines(disp: number): void {
|
|
109
|
+
const pos = this._scrollableElement.getScrollPosition();
|
|
110
|
+
this._scrollableElement.setScrollPosition({
|
|
111
|
+
reuseAnimation: true,
|
|
112
|
+
scrollTop: pos.scrollTop + disp * this._renderService.dimensions.css.cell.height
|
|
113
|
+
});
|
|
118
114
|
}
|
|
119
115
|
|
|
120
|
-
|
|
121
|
-
if (
|
|
122
|
-
this.
|
|
123
|
-
this._currentDeviceCellHeight = this._renderService.dimensions.device.cell.height;
|
|
124
|
-
this._lastRecordedViewportHeight = this._viewportElement.offsetHeight;
|
|
125
|
-
const newBufferHeight = Math.round(this._currentRowHeight * this._lastRecordedBufferLength) + (this._lastRecordedViewportHeight - this._renderService.dimensions.css.canvas.height);
|
|
126
|
-
if (this._lastRecordedBufferHeight !== newBufferHeight) {
|
|
127
|
-
this._lastRecordedBufferHeight = newBufferHeight;
|
|
128
|
-
this._scrollArea.style.height = this._lastRecordedBufferHeight + 'px';
|
|
129
|
-
}
|
|
116
|
+
public scrollToLine(line: number, disableSmoothScroll?: boolean): void {
|
|
117
|
+
if (disableSmoothScroll) {
|
|
118
|
+
this._latestYDisp = line;
|
|
130
119
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
// Ignore the next scroll event which will be triggered by setting the scrollTop as we do not
|
|
136
|
-
// want this event to scroll the terminal
|
|
137
|
-
this._ignoreNextScrollEvent = true;
|
|
138
|
-
this._viewportElement.scrollTop = scrollTop;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
this._refreshAnimationFrame = null;
|
|
120
|
+
this._scrollableElement.setScrollPosition({
|
|
121
|
+
reuseAnimation: !disableSmoothScroll,
|
|
122
|
+
scrollTop: line * this._renderService.dimensions.css.cell.height
|
|
123
|
+
});
|
|
142
124
|
}
|
|
143
125
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
this._lastRecordedBufferLength = this._bufferService.buffer.lines.length;
|
|
151
|
-
this._refresh(immediate);
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// If viewport height changed
|
|
156
|
-
if (this._lastRecordedViewportHeight !== this._renderService.dimensions.css.canvas.height) {
|
|
157
|
-
this._refresh(immediate);
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// If the buffer position doesn't match last scroll top
|
|
162
|
-
if (this._lastScrollTop !== this._activeBuffer.ydisp * this._currentRowHeight) {
|
|
163
|
-
this._refresh(immediate);
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// If row height changed
|
|
168
|
-
if (this._renderDimensions.device.cell.height !== this._currentDeviceCellHeight) {
|
|
169
|
-
this._refresh(immediate);
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
126
|
+
private _getChangeOptions(): ScrollableElementChangeOptions {
|
|
127
|
+
return {
|
|
128
|
+
mouseWheelScrollSensitivity: this._optionsService.rawOptions.scrollSensitivity,
|
|
129
|
+
fastScrollSensitivity: this._optionsService.rawOptions.fastScrollSensitivity,
|
|
130
|
+
verticalScrollbarSize: this._optionsService.rawOptions.overviewRuler?.width || ViewportConstants.DEFAULT_SCROLL_BAR_WIDTH
|
|
131
|
+
};
|
|
172
132
|
}
|
|
173
133
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
*/
|
|
179
|
-
private _handleScroll(ev: Event): void {
|
|
180
|
-
// Record current scroll top position
|
|
181
|
-
this._lastScrollTop = this._viewportElement.scrollTop;
|
|
182
|
-
|
|
183
|
-
// Don't attempt to scroll if the element is not visible, otherwise scrollTop will be corrupt
|
|
184
|
-
// which causes the terminal to scroll the buffer to the top
|
|
185
|
-
if (!this._viewportElement.offsetParent) {
|
|
186
|
-
return;
|
|
134
|
+
public queueSync(ydisp?: number): void {
|
|
135
|
+
// Update state
|
|
136
|
+
if (ydisp !== undefined) {
|
|
137
|
+
this._latestYDisp = ydisp;
|
|
187
138
|
}
|
|
188
139
|
|
|
189
|
-
//
|
|
190
|
-
if (this.
|
|
191
|
-
this._ignoreNextScrollEvent = false;
|
|
192
|
-
// Still trigger the scroll so lines get refreshed
|
|
193
|
-
this._onRequestScrollLines.fire({ amount: 0, suppressScrollEvent: true });
|
|
140
|
+
// Don't queue more than one callback
|
|
141
|
+
if (this._queuedAnimationFrame !== undefined) {
|
|
194
142
|
return;
|
|
195
143
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
144
|
+
this._queuedAnimationFrame = this._renderService.addRefreshCallback(() => {
|
|
145
|
+
this._queuedAnimationFrame = undefined;
|
|
146
|
+
this._sync(this._latestYDisp);
|
|
147
|
+
});
|
|
200
148
|
}
|
|
201
149
|
|
|
202
|
-
private
|
|
203
|
-
|
|
204
|
-
if (this._isDisposed || this._smoothScrollState.origin === -1 || this._smoothScrollState.target === -1) {
|
|
150
|
+
private _sync(ydisp: number = this._bufferService.buffer.ydisp): void {
|
|
151
|
+
if (!this._renderService || this._isSyncing) {
|
|
205
152
|
return;
|
|
206
153
|
}
|
|
154
|
+
this._isSyncing = true;
|
|
207
155
|
|
|
208
|
-
//
|
|
209
|
-
|
|
210
|
-
this.
|
|
156
|
+
// Ignore any onScroll event that happens as a result of dimensions changing as this should
|
|
157
|
+
// never cause a scrollLines call, only setScrollPosition can do that.
|
|
158
|
+
this._suppressOnScrollHandler = true;
|
|
159
|
+
this._scrollableElement.setScrollDimensions({
|
|
160
|
+
height: this._renderService.dimensions.css.canvas.height,
|
|
161
|
+
scrollHeight: this._renderService.dimensions.css.cell.height * this._bufferService.buffer.lines.length
|
|
162
|
+
});
|
|
163
|
+
this._suppressOnScrollHandler = false;
|
|
211
164
|
|
|
212
|
-
//
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
165
|
+
// If ydisp has been changed by some other component (input/buffer), then stop animating smooth
|
|
166
|
+
// scroll and scroll there immediately.
|
|
167
|
+
if (ydisp !== this._latestYDisp) {
|
|
168
|
+
this._scrollableElement.setScrollPosition({
|
|
169
|
+
scrollTop: ydisp * this._renderService.dimensions.css.cell.height
|
|
170
|
+
});
|
|
217
171
|
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
private _smoothScrollPercent(): number {
|
|
221
|
-
if (!this._optionsService.rawOptions.smoothScrollDuration || !this._smoothScrollState.startTime) {
|
|
222
|
-
return 1;
|
|
223
|
-
}
|
|
224
|
-
return Math.max(Math.min((Date.now() - this._smoothScrollState.startTime) / this._optionsService.rawOptions.smoothScrollDuration, 1), 0);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
private _clearSmoothScrollState(): void {
|
|
228
|
-
this._smoothScrollState.startTime = 0;
|
|
229
|
-
this._smoothScrollState.origin = -1;
|
|
230
|
-
this._smoothScrollState.target = -1;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Handles bubbling of scroll event in case the viewport has reached top or bottom
|
|
235
|
-
* @param ev The scroll event.
|
|
236
|
-
* @param amount The amount scrolled
|
|
237
|
-
*/
|
|
238
|
-
private _bubbleScroll(ev: Event, amount: number): boolean {
|
|
239
|
-
const scrollPosFromTop = this._viewportElement.scrollTop + this._lastRecordedViewportHeight;
|
|
240
|
-
if ((amount < 0 && this._viewportElement.scrollTop !== 0) ||
|
|
241
|
-
(amount > 0 && scrollPosFromTop < this._lastRecordedBufferHeight)) {
|
|
242
|
-
if (ev.cancelable) {
|
|
243
|
-
ev.preventDefault();
|
|
244
|
-
}
|
|
245
|
-
return false;
|
|
246
|
-
}
|
|
247
|
-
return true;
|
|
248
|
-
}
|
|
249
172
|
|
|
250
|
-
|
|
251
|
-
* Handles mouse wheel events by adjusting the viewport's scrollTop and delegating the actual
|
|
252
|
-
* scrolling to `onScroll`, this event needs to be attached manually by the consumer of
|
|
253
|
-
* `Viewport`.
|
|
254
|
-
* @param ev The mouse wheel event.
|
|
255
|
-
*/
|
|
256
|
-
public handleWheel(ev: WheelEvent): boolean {
|
|
257
|
-
const amount = this._getPixelsScrolled(ev);
|
|
258
|
-
if (amount === 0) {
|
|
259
|
-
return false;
|
|
260
|
-
}
|
|
261
|
-
if (!this._optionsService.rawOptions.smoothScrollDuration) {
|
|
262
|
-
this._viewportElement.scrollTop += amount;
|
|
263
|
-
} else {
|
|
264
|
-
this._smoothScrollState.startTime = Date.now();
|
|
265
|
-
if (this._smoothScrollPercent() < 1) {
|
|
266
|
-
this._smoothScrollState.origin = this._viewportElement.scrollTop;
|
|
267
|
-
if (this._smoothScrollState.target === -1) {
|
|
268
|
-
this._smoothScrollState.target = this._viewportElement.scrollTop + amount;
|
|
269
|
-
} else {
|
|
270
|
-
this._smoothScrollState.target += amount;
|
|
271
|
-
}
|
|
272
|
-
this._smoothScrollState.target = Math.max(Math.min(this._smoothScrollState.target, this._viewportElement.scrollHeight), 0);
|
|
273
|
-
this._smoothScroll();
|
|
274
|
-
} else {
|
|
275
|
-
this._clearSmoothScrollState();
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
return this._bubbleScroll(ev, amount);
|
|
173
|
+
this._isSyncing = false;
|
|
279
174
|
}
|
|
280
175
|
|
|
281
|
-
|
|
282
|
-
if (
|
|
176
|
+
private _handleScroll(e: ScrollEvent): void {
|
|
177
|
+
if (!this._renderService) {
|
|
283
178
|
return;
|
|
284
179
|
}
|
|
285
|
-
if (
|
|
286
|
-
|
|
287
|
-
} else {
|
|
288
|
-
const amount = disp * this._currentRowHeight;
|
|
289
|
-
this._smoothScrollState.startTime = Date.now();
|
|
290
|
-
if (this._smoothScrollPercent() < 1) {
|
|
291
|
-
this._smoothScrollState.origin = this._viewportElement.scrollTop;
|
|
292
|
-
this._smoothScrollState.target = this._smoothScrollState.origin + amount;
|
|
293
|
-
this._smoothScrollState.target = Math.max(Math.min(this._smoothScrollState.target, this._viewportElement.scrollHeight), 0);
|
|
294
|
-
this._smoothScroll();
|
|
295
|
-
} else {
|
|
296
|
-
this._clearSmoothScrollState();
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
private _getPixelsScrolled(ev: WheelEvent): number {
|
|
302
|
-
// Do nothing if it's not a vertical scroll event
|
|
303
|
-
if (ev.deltaY === 0 || ev.shiftKey) {
|
|
304
|
-
return 0;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
// Fallback to WheelEvent.DOM_DELTA_PIXEL
|
|
308
|
-
let amount = this._applyScrollModifier(ev.deltaY, ev);
|
|
309
|
-
if (ev.deltaMode === WheelEvent.DOM_DELTA_LINE) {
|
|
310
|
-
amount *= this._currentRowHeight;
|
|
311
|
-
} else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
|
|
312
|
-
amount *= this._currentRowHeight * this._bufferService.rows;
|
|
313
|
-
}
|
|
314
|
-
return amount;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
public getBufferElements(startLine: number, endLine?: number): { bufferElements: HTMLElement[], cursorElement?: HTMLElement } {
|
|
319
|
-
let currentLine: string = '';
|
|
320
|
-
let cursorElement: HTMLElement | undefined;
|
|
321
|
-
const bufferElements: HTMLElement[] = [];
|
|
322
|
-
const end = endLine ?? this._bufferService.buffer.lines.length;
|
|
323
|
-
const lines = this._bufferService.buffer.lines;
|
|
324
|
-
for (let i = startLine; i < end; i++) {
|
|
325
|
-
const line = lines.get(i);
|
|
326
|
-
if (!line) {
|
|
327
|
-
continue;
|
|
328
|
-
}
|
|
329
|
-
const isWrapped = lines.get(i + 1)?.isWrapped;
|
|
330
|
-
currentLine += line.translateToString(!isWrapped);
|
|
331
|
-
if (!isWrapped || i === lines.length - 1) {
|
|
332
|
-
const div = document.createElement('div');
|
|
333
|
-
div.textContent = currentLine;
|
|
334
|
-
bufferElements.push(div);
|
|
335
|
-
if (currentLine.length > 0) {
|
|
336
|
-
cursorElement = div;
|
|
337
|
-
}
|
|
338
|
-
currentLine = '';
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
return { bufferElements, cursorElement };
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
/**
|
|
345
|
-
* Gets the number of pixels scrolled by the mouse event taking into account what type of delta
|
|
346
|
-
* is being used.
|
|
347
|
-
* @param ev The mouse wheel event.
|
|
348
|
-
*/
|
|
349
|
-
public getLinesScrolled(ev: WheelEvent): number {
|
|
350
|
-
// Do nothing if it's not a vertical scroll event
|
|
351
|
-
if (ev.deltaY === 0 || ev.shiftKey) {
|
|
352
|
-
return 0;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
// Fallback to WheelEvent.DOM_DELTA_LINE
|
|
356
|
-
let amount = this._applyScrollModifier(ev.deltaY, ev);
|
|
357
|
-
if (ev.deltaMode === WheelEvent.DOM_DELTA_PIXEL) {
|
|
358
|
-
amount /= this._currentRowHeight + 0.0; // Prevent integer division
|
|
359
|
-
this._wheelPartialScroll += amount;
|
|
360
|
-
amount = Math.floor(Math.abs(this._wheelPartialScroll)) * (this._wheelPartialScroll > 0 ? 1 : -1);
|
|
361
|
-
this._wheelPartialScroll %= 1;
|
|
362
|
-
} else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
|
|
363
|
-
amount *= this._bufferService.rows;
|
|
364
|
-
}
|
|
365
|
-
return amount;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
private _applyScrollModifier(amount: number, ev: WheelEvent): number {
|
|
369
|
-
const modifier = this._optionsService.rawOptions.fastScrollModifier;
|
|
370
|
-
// Multiply the scroll speed when the modifier is down
|
|
371
|
-
if ((modifier === 'alt' && ev.altKey) ||
|
|
372
|
-
(modifier === 'ctrl' && ev.ctrlKey) ||
|
|
373
|
-
(modifier === 'shift' && ev.shiftKey)) {
|
|
374
|
-
return amount * this._optionsService.rawOptions.fastScrollSensitivity * this._optionsService.rawOptions.scrollSensitivity;
|
|
180
|
+
if (this._isHandlingScroll || this._suppressOnScrollHandler) {
|
|
181
|
+
return;
|
|
375
182
|
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
* @param ev The touch event.
|
|
383
|
-
*/
|
|
384
|
-
public handleTouchStart(ev: TouchEvent): void {
|
|
385
|
-
this._lastTouchY = ev.touches[0].pageY;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
/**
|
|
389
|
-
* Handles the touchmove event, scrolling the viewport if the position shifted.
|
|
390
|
-
* @param ev The touch event.
|
|
391
|
-
*/
|
|
392
|
-
public handleTouchMove(ev: TouchEvent): boolean {
|
|
393
|
-
const deltaY = this._lastTouchY - ev.touches[0].pageY;
|
|
394
|
-
this._lastTouchY = ev.touches[0].pageY;
|
|
395
|
-
if (deltaY === 0) {
|
|
396
|
-
return false;
|
|
183
|
+
this._isHandlingScroll = true;
|
|
184
|
+
const newRow = Math.round(e.scrollTop / this._renderService.dimensions.css.cell.height);
|
|
185
|
+
const diff = newRow - this._bufferService.buffer.ydisp;
|
|
186
|
+
if (diff !== 0) {
|
|
187
|
+
this._latestYDisp = newRow;
|
|
188
|
+
this._onRequestScrollLines.fire(diff);
|
|
397
189
|
}
|
|
398
|
-
this.
|
|
399
|
-
return this._bubbleScroll(ev, deltaY);
|
|
190
|
+
this._isHandlingScroll = false;
|
|
400
191
|
}
|
|
401
192
|
}
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { Disposable, toDisposable } from 'common/Lifecycle';
|
|
6
|
+
import { ICoreBrowserService, IRenderService } from 'browser/services/Services';
|
|
7
|
+
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
|
|
9
8
|
import { IBufferService, IDecorationService, IInternalDecoration } from 'common/services/Services';
|
|
10
9
|
|
|
11
10
|
export class BufferDecorationRenderer extends Disposable {
|
|
@@ -19,6 +18,7 @@ export class BufferDecorationRenderer extends Disposable {
|
|
|
19
18
|
constructor(
|
|
20
19
|
private readonly _screenElement: HTMLElement,
|
|
21
20
|
@IBufferService private readonly _bufferService: IBufferService,
|
|
21
|
+
@ICoreBrowserService private readonly _coreBrowserService: ICoreBrowserService,
|
|
22
22
|
@IDecorationService private readonly _decorationService: IDecorationService,
|
|
23
23
|
@IRenderService private readonly _renderService: IRenderService
|
|
24
24
|
) {
|
|
@@ -28,18 +28,18 @@ export class BufferDecorationRenderer extends Disposable {
|
|
|
28
28
|
this._container.classList.add('xterm-decoration-container');
|
|
29
29
|
this._screenElement.appendChild(this._container);
|
|
30
30
|
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
31
|
+
this._register(this._renderService.onRenderedViewportChange(() => this._doRefreshDecorations()));
|
|
32
|
+
this._register(this._renderService.onDimensionsChange(() => {
|
|
33
33
|
this._dimensionsChanged = true;
|
|
34
34
|
this._queueRefresh();
|
|
35
35
|
}));
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
36
|
+
this._register(this._coreBrowserService.onDprChange(() => this._queueRefresh()));
|
|
37
|
+
this._register(this._bufferService.buffers.onBufferActivate(() => {
|
|
38
38
|
this._altBufferIsActive = this._bufferService.buffer === this._bufferService.buffers.alt;
|
|
39
39
|
}));
|
|
40
|
-
this.
|
|
41
|
-
this.
|
|
42
|
-
this.
|
|
40
|
+
this._register(this._decorationService.onDecorationRegistered(() => this._queueRefresh()));
|
|
41
|
+
this._register(this._decorationService.onDecorationRemoved(decoration => this._removeDecoration(decoration)));
|
|
42
|
+
this._register(toDisposable(() => {
|
|
43
43
|
this._container.remove();
|
|
44
44
|
this._decorationElements.clear();
|
|
45
45
|
}));
|
|
@@ -70,7 +70,7 @@ export class BufferDecorationRenderer extends Disposable {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
private _createElement(decoration: IInternalDecoration): HTMLElement {
|
|
73
|
-
const element =
|
|
73
|
+
const element = this._coreBrowserService.mainDocument.createElement('div');
|
|
74
74
|
element.classList.add('xterm-decoration');
|
|
75
75
|
element.classList.toggle('xterm-decoration-top-layer', decoration?.options?.layer === 'top');
|
|
76
76
|
element.style.width = `${Math.round((decoration.options.width || 1) * this._renderService.dimensions.css.cell.width)}px`;
|
|
@@ -108,8 +108,13 @@ export class BufferDecorationRenderer extends Disposable {
|
|
|
108
108
|
element!.remove();
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
-
element.style.top = `${line * this._renderService.dimensions.css.cell.height}px`;
|
|
112
111
|
element.style.display = this._altBufferIsActive ? 'none' : 'block';
|
|
112
|
+
if (!this._altBufferIsActive) {
|
|
113
|
+
element.style.width = `${Math.round((decoration.options.width || 1) * this._renderService.dimensions.css.cell.width)}px`;
|
|
114
|
+
element.style.height = `${(decoration.options.height || 1) * this._renderService.dimensions.css.cell.height}px`;
|
|
115
|
+
element.style.top = `${line * this._renderService.dimensions.css.cell.height}px`;
|
|
116
|
+
element.style.lineHeight = `${this._renderService.dimensions.css.cell.height}px`;
|
|
117
|
+
}
|
|
113
118
|
decoration.onRenderEmitter.fire(element);
|
|
114
119
|
}
|
|
115
120
|
}
|