@xterm/xterm 5.6.0-beta.7 → 5.6.0-beta.71
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 +6 -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} +135 -146
- package/src/browser/Linkifier.ts +26 -14
- package/src/browser/LocalizableStrings.ts +15 -4
- package/src/browser/{Types.d.ts → Types.ts} +67 -15
- package/src/browser/Viewport.ts +143 -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 +18 -57
- 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 +15 -7
- package/src/common/buffer/BufferReflow.ts +9 -6
- package/src/common/buffer/BufferSet.ts +5 -5
- package/src/common/buffer/Marker.ts +4 -4
- package/src/common/buffer/{Types.d.ts → Types.ts} +2 -2
- package/src/common/input/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 +6 -5
- package/src/common/services/Services.ts +25 -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 +66 -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
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
|
|
6
|
+
import * as browser from 'vs/base/browser/browser';
|
|
7
|
+
import { EVENT_KEY_CODE_MAP, KeyCode, KeyCodeUtils, KeyMod } from 'vs/base/common/keyCodes';
|
|
8
|
+
import { KeyCodeChord } from 'vs/base/common/keybindings';
|
|
9
|
+
import * as platform from 'vs/base/common/platform';
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
function extractKeyCode(e: KeyboardEvent): KeyCode {
|
|
14
|
+
if (e.charCode) {
|
|
15
|
+
// "keypress" events mostly
|
|
16
|
+
const char = String.fromCharCode(e.charCode).toUpperCase();
|
|
17
|
+
return KeyCodeUtils.fromString(char);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const keyCode = e.keyCode;
|
|
21
|
+
|
|
22
|
+
// browser quirks
|
|
23
|
+
if (keyCode === 3) {
|
|
24
|
+
return KeyCode.PauseBreak;
|
|
25
|
+
} else if (browser.isFirefox) {
|
|
26
|
+
switch (keyCode) {
|
|
27
|
+
case 59: return KeyCode.Semicolon;
|
|
28
|
+
case 60:
|
|
29
|
+
if (platform.isLinux) { return KeyCode.IntlBackslash; }
|
|
30
|
+
break;
|
|
31
|
+
case 61: return KeyCode.Equal;
|
|
32
|
+
// based on: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode#numpad_keys
|
|
33
|
+
case 107: return KeyCode.NumpadAdd;
|
|
34
|
+
case 109: return KeyCode.NumpadSubtract;
|
|
35
|
+
case 173: return KeyCode.Minus;
|
|
36
|
+
case 224:
|
|
37
|
+
if (platform.isMacintosh) { return KeyCode.Meta; }
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
} else if (browser.isWebKit) {
|
|
41
|
+
if (platform.isMacintosh && keyCode === 93) {
|
|
42
|
+
// the two meta keys in the Mac have different key codes (91 and 93)
|
|
43
|
+
return KeyCode.Meta;
|
|
44
|
+
} else if (!platform.isMacintosh && keyCode === 92) {
|
|
45
|
+
return KeyCode.Meta;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// cross browser keycodes:
|
|
50
|
+
return EVENT_KEY_CODE_MAP[keyCode] || KeyCode.Unknown;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface IKeyboardEvent {
|
|
54
|
+
|
|
55
|
+
readonly _standardKeyboardEventBrand: true;
|
|
56
|
+
|
|
57
|
+
readonly browserEvent: KeyboardEvent;
|
|
58
|
+
readonly target: HTMLElement;
|
|
59
|
+
|
|
60
|
+
readonly ctrlKey: boolean;
|
|
61
|
+
readonly shiftKey: boolean;
|
|
62
|
+
readonly altKey: boolean;
|
|
63
|
+
readonly metaKey: boolean;
|
|
64
|
+
readonly altGraphKey: boolean;
|
|
65
|
+
readonly keyCode: KeyCode;
|
|
66
|
+
readonly code: string;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
toKeyCodeChord(): KeyCodeChord;
|
|
72
|
+
equals(keybinding: number): boolean;
|
|
73
|
+
|
|
74
|
+
preventDefault(): void;
|
|
75
|
+
stopPropagation(): void;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const ctrlKeyMod = (platform.isMacintosh ? KeyMod.WinCtrl : KeyMod.CtrlCmd);
|
|
79
|
+
const altKeyMod = KeyMod.Alt;
|
|
80
|
+
const shiftKeyMod = KeyMod.Shift;
|
|
81
|
+
const metaKeyMod = (platform.isMacintosh ? KeyMod.CtrlCmd : KeyMod.WinCtrl);
|
|
82
|
+
|
|
83
|
+
export function printKeyboardEvent(e: KeyboardEvent): string {
|
|
84
|
+
const modifiers: string[] = [];
|
|
85
|
+
if (e.ctrlKey) {
|
|
86
|
+
modifiers.push(`ctrl`);
|
|
87
|
+
}
|
|
88
|
+
if (e.shiftKey) {
|
|
89
|
+
modifiers.push(`shift`);
|
|
90
|
+
}
|
|
91
|
+
if (e.altKey) {
|
|
92
|
+
modifiers.push(`alt`);
|
|
93
|
+
}
|
|
94
|
+
if (e.metaKey) {
|
|
95
|
+
modifiers.push(`meta`);
|
|
96
|
+
}
|
|
97
|
+
return `modifiers: [${modifiers.join(',')}], code: ${e.code}, keyCode: ${e.keyCode}, key: ${e.key}`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function printStandardKeyboardEvent(e: StandardKeyboardEvent): string {
|
|
101
|
+
const modifiers: string[] = [];
|
|
102
|
+
if (e.ctrlKey) {
|
|
103
|
+
modifiers.push(`ctrl`);
|
|
104
|
+
}
|
|
105
|
+
if (e.shiftKey) {
|
|
106
|
+
modifiers.push(`shift`);
|
|
107
|
+
}
|
|
108
|
+
if (e.altKey) {
|
|
109
|
+
modifiers.push(`alt`);
|
|
110
|
+
}
|
|
111
|
+
if (e.metaKey) {
|
|
112
|
+
modifiers.push(`meta`);
|
|
113
|
+
}
|
|
114
|
+
return `modifiers: [${modifiers.join(',')}], code: ${e.code}, keyCode: ${e.keyCode} ('${KeyCodeUtils.toString(e.keyCode)}')`;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export class StandardKeyboardEvent implements IKeyboardEvent {
|
|
118
|
+
|
|
119
|
+
readonly _standardKeyboardEventBrand = true;
|
|
120
|
+
|
|
121
|
+
public readonly browserEvent: KeyboardEvent;
|
|
122
|
+
public readonly target: HTMLElement;
|
|
123
|
+
|
|
124
|
+
public readonly ctrlKey: boolean;
|
|
125
|
+
public readonly shiftKey: boolean;
|
|
126
|
+
public readonly altKey: boolean;
|
|
127
|
+
public readonly metaKey: boolean;
|
|
128
|
+
public readonly altGraphKey: boolean;
|
|
129
|
+
public readonly keyCode: KeyCode;
|
|
130
|
+
public readonly code: string;
|
|
131
|
+
|
|
132
|
+
private _asKeybinding: number;
|
|
133
|
+
private _asKeyCodeChord: KeyCodeChord;
|
|
134
|
+
|
|
135
|
+
constructor(source: KeyboardEvent) {
|
|
136
|
+
const e = source;
|
|
137
|
+
|
|
138
|
+
this.browserEvent = e;
|
|
139
|
+
this.target = <HTMLElement>e.target;
|
|
140
|
+
|
|
141
|
+
this.ctrlKey = e.ctrlKey;
|
|
142
|
+
this.shiftKey = e.shiftKey;
|
|
143
|
+
this.altKey = e.altKey;
|
|
144
|
+
this.metaKey = e.metaKey;
|
|
145
|
+
this.altGraphKey = e.getModifierState?.('AltGraph');
|
|
146
|
+
this.keyCode = extractKeyCode(e);
|
|
147
|
+
this.code = e.code;
|
|
148
|
+
|
|
149
|
+
// console.info(e.type + ": keyCode: " + e.keyCode + ", which: " + e.which + ", charCode: " + e.charCode + ", detail: " + e.detail + " ====> " + this.keyCode + ' -- ' + KeyCode[this.keyCode]);
|
|
150
|
+
|
|
151
|
+
this.ctrlKey = this.ctrlKey || this.keyCode === KeyCode.Ctrl;
|
|
152
|
+
this.altKey = this.altKey || this.keyCode === KeyCode.Alt;
|
|
153
|
+
this.shiftKey = this.shiftKey || this.keyCode === KeyCode.Shift;
|
|
154
|
+
this.metaKey = this.metaKey || this.keyCode === KeyCode.Meta;
|
|
155
|
+
|
|
156
|
+
this._asKeybinding = this._computeKeybinding();
|
|
157
|
+
this._asKeyCodeChord = this._computeKeyCodeChord();
|
|
158
|
+
|
|
159
|
+
// console.log(`code: ${e.code}, keyCode: ${e.keyCode}, key: ${e.key}`);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
public preventDefault(): void {
|
|
163
|
+
if (this.browserEvent && this.browserEvent.preventDefault) {
|
|
164
|
+
this.browserEvent.preventDefault();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
public stopPropagation(): void {
|
|
169
|
+
if (this.browserEvent && this.browserEvent.stopPropagation) {
|
|
170
|
+
this.browserEvent.stopPropagation();
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
public toKeyCodeChord(): KeyCodeChord {
|
|
175
|
+
return this._asKeyCodeChord;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
public equals(other: number): boolean {
|
|
179
|
+
return this._asKeybinding === other;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
private _computeKeybinding(): number {
|
|
183
|
+
let key = KeyCode.Unknown;
|
|
184
|
+
if (this.keyCode !== KeyCode.Ctrl && this.keyCode !== KeyCode.Shift && this.keyCode !== KeyCode.Alt && this.keyCode !== KeyCode.Meta) {
|
|
185
|
+
key = this.keyCode;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
let result = 0;
|
|
189
|
+
if (this.ctrlKey) {
|
|
190
|
+
result |= ctrlKeyMod;
|
|
191
|
+
}
|
|
192
|
+
if (this.altKey) {
|
|
193
|
+
result |= altKeyMod;
|
|
194
|
+
}
|
|
195
|
+
if (this.shiftKey) {
|
|
196
|
+
result |= shiftKeyMod;
|
|
197
|
+
}
|
|
198
|
+
if (this.metaKey) {
|
|
199
|
+
result |= metaKeyMod;
|
|
200
|
+
}
|
|
201
|
+
result |= key;
|
|
202
|
+
|
|
203
|
+
return result;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
private _computeKeyCodeChord(): KeyCodeChord {
|
|
207
|
+
let key = KeyCode.Unknown;
|
|
208
|
+
if (this.keyCode !== KeyCode.Ctrl && this.keyCode !== KeyCode.Shift && this.keyCode !== KeyCode.Alt && this.keyCode !== KeyCode.Meta) {
|
|
209
|
+
key = this.keyCode;
|
|
210
|
+
}
|
|
211
|
+
return new KeyCodeChord(this.ctrlKey, this.shiftKey, this.altKey, this.metaKey, key);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
|
|
6
|
+
import * as browser from 'vs/base/browser/browser';
|
|
7
|
+
import { IframeUtils } from 'vs/base/browser/iframe';
|
|
8
|
+
import * as platform from 'vs/base/common/platform';
|
|
9
|
+
|
|
10
|
+
export interface IMouseEvent {
|
|
11
|
+
readonly browserEvent: MouseEvent;
|
|
12
|
+
readonly leftButton: boolean;
|
|
13
|
+
readonly middleButton: boolean;
|
|
14
|
+
readonly rightButton: boolean;
|
|
15
|
+
readonly buttons: number;
|
|
16
|
+
readonly target: HTMLElement;
|
|
17
|
+
readonly detail: number;
|
|
18
|
+
readonly posx: number;
|
|
19
|
+
readonly posy: number;
|
|
20
|
+
readonly ctrlKey: boolean;
|
|
21
|
+
readonly shiftKey: boolean;
|
|
22
|
+
readonly altKey: boolean;
|
|
23
|
+
readonly metaKey: boolean;
|
|
24
|
+
readonly timestamp: number;
|
|
25
|
+
|
|
26
|
+
preventDefault(): void;
|
|
27
|
+
stopPropagation(): void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export class StandardMouseEvent implements IMouseEvent {
|
|
31
|
+
|
|
32
|
+
public readonly browserEvent: MouseEvent;
|
|
33
|
+
|
|
34
|
+
public readonly leftButton: boolean;
|
|
35
|
+
public readonly middleButton: boolean;
|
|
36
|
+
public readonly rightButton: boolean;
|
|
37
|
+
public readonly buttons: number;
|
|
38
|
+
public readonly target: HTMLElement;
|
|
39
|
+
public detail: number;
|
|
40
|
+
public readonly posx: number;
|
|
41
|
+
public readonly posy: number;
|
|
42
|
+
public readonly ctrlKey: boolean;
|
|
43
|
+
public readonly shiftKey: boolean;
|
|
44
|
+
public readonly altKey: boolean;
|
|
45
|
+
public readonly metaKey: boolean;
|
|
46
|
+
public readonly timestamp: number;
|
|
47
|
+
|
|
48
|
+
constructor(targetWindow: Window, e: MouseEvent) {
|
|
49
|
+
this.timestamp = Date.now();
|
|
50
|
+
this.browserEvent = e;
|
|
51
|
+
this.leftButton = e.button === 0;
|
|
52
|
+
this.middleButton = e.button === 1;
|
|
53
|
+
this.rightButton = e.button === 2;
|
|
54
|
+
this.buttons = e.buttons;
|
|
55
|
+
|
|
56
|
+
this.target = <HTMLElement>e.target;
|
|
57
|
+
|
|
58
|
+
this.detail = e.detail || 1;
|
|
59
|
+
if (e.type === 'dblclick') {
|
|
60
|
+
this.detail = 2;
|
|
61
|
+
}
|
|
62
|
+
this.ctrlKey = e.ctrlKey;
|
|
63
|
+
this.shiftKey = e.shiftKey;
|
|
64
|
+
this.altKey = e.altKey;
|
|
65
|
+
this.metaKey = e.metaKey;
|
|
66
|
+
|
|
67
|
+
if (typeof e.pageX === 'number') {
|
|
68
|
+
this.posx = e.pageX;
|
|
69
|
+
this.posy = e.pageY;
|
|
70
|
+
} else {
|
|
71
|
+
// Probably hit by MSGestureEvent
|
|
72
|
+
this.posx = e.clientX + this.target.ownerDocument.body.scrollLeft + this.target.ownerDocument.documentElement.scrollLeft;
|
|
73
|
+
this.posy = e.clientY + this.target.ownerDocument.body.scrollTop + this.target.ownerDocument.documentElement.scrollTop;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Find the position of the iframe this code is executing in relative to the iframe where the event was captured.
|
|
77
|
+
const iframeOffsets = IframeUtils.getPositionOfChildWindowRelativeToAncestorWindow(targetWindow, e.view);
|
|
78
|
+
this.posx -= iframeOffsets.left;
|
|
79
|
+
this.posy -= iframeOffsets.top;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public preventDefault(): void {
|
|
83
|
+
this.browserEvent.preventDefault();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public stopPropagation(): void {
|
|
87
|
+
this.browserEvent.stopPropagation();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export class DragMouseEvent extends StandardMouseEvent {
|
|
92
|
+
|
|
93
|
+
public readonly dataTransfer: DataTransfer;
|
|
94
|
+
|
|
95
|
+
constructor(targetWindow: Window, e: MouseEvent) {
|
|
96
|
+
super(targetWindow, e);
|
|
97
|
+
this.dataTransfer = (<any>e).dataTransfer;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface IMouseWheelEvent extends MouseEvent {
|
|
102
|
+
readonly wheelDelta: number;
|
|
103
|
+
readonly wheelDeltaX: number;
|
|
104
|
+
readonly wheelDeltaY: number;
|
|
105
|
+
|
|
106
|
+
readonly deltaX: number;
|
|
107
|
+
readonly deltaY: number;
|
|
108
|
+
readonly deltaZ: number;
|
|
109
|
+
readonly deltaMode: number;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
interface IWebKitMouseWheelEvent {
|
|
113
|
+
wheelDeltaY: number;
|
|
114
|
+
wheelDeltaX: number;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
interface IGeckoMouseWheelEvent {
|
|
118
|
+
HORIZONTAL_AXIS: number;
|
|
119
|
+
VERTICAL_AXIS: number;
|
|
120
|
+
axis: number;
|
|
121
|
+
detail: number;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export class StandardWheelEvent {
|
|
125
|
+
|
|
126
|
+
public readonly browserEvent: IMouseWheelEvent | null;
|
|
127
|
+
public readonly deltaY: number;
|
|
128
|
+
public readonly deltaX: number;
|
|
129
|
+
public readonly target: Node;
|
|
130
|
+
|
|
131
|
+
constructor(e: IMouseWheelEvent | null, deltaX: number = 0, deltaY: number = 0) {
|
|
132
|
+
|
|
133
|
+
this.browserEvent = e || null;
|
|
134
|
+
this.target = e ? (e.target || (<any>e).targetNode || e.srcElement) : null;
|
|
135
|
+
|
|
136
|
+
this.deltaY = deltaY;
|
|
137
|
+
this.deltaX = deltaX;
|
|
138
|
+
|
|
139
|
+
let shouldFactorDPR: boolean = false;
|
|
140
|
+
if (browser.isChrome) {
|
|
141
|
+
// Chrome version >= 123 contains the fix to factor devicePixelRatio into the wheel event.
|
|
142
|
+
// See https://chromium.googlesource.com/chromium/src.git/+/be51b448441ff0c9d1f17e0f25c4bf1ab3f11f61
|
|
143
|
+
const chromeVersionMatch = navigator.userAgent.match(/Chrome\/(\d+)/);
|
|
144
|
+
const chromeMajorVersion = chromeVersionMatch ? parseInt(chromeVersionMatch[1]) : 123;
|
|
145
|
+
shouldFactorDPR = chromeMajorVersion <= 122;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (e) {
|
|
149
|
+
// Old (deprecated) wheel events
|
|
150
|
+
const e1 = <IWebKitMouseWheelEvent><any>e;
|
|
151
|
+
const e2 = <IGeckoMouseWheelEvent><any>e;
|
|
152
|
+
const devicePixelRatio = e.view?.devicePixelRatio || 1;
|
|
153
|
+
|
|
154
|
+
// vertical delta scroll
|
|
155
|
+
if (typeof e1.wheelDeltaY !== 'undefined') {
|
|
156
|
+
if (shouldFactorDPR) {
|
|
157
|
+
// Refs https://github.com/microsoft/vscode/issues/146403#issuecomment-1854538928
|
|
158
|
+
this.deltaY = e1.wheelDeltaY / (120 * devicePixelRatio);
|
|
159
|
+
} else {
|
|
160
|
+
this.deltaY = e1.wheelDeltaY / 120;
|
|
161
|
+
}
|
|
162
|
+
} else if (typeof e2.VERTICAL_AXIS !== 'undefined' && e2.axis === e2.VERTICAL_AXIS) {
|
|
163
|
+
this.deltaY = -e2.detail / 3;
|
|
164
|
+
} else if (e.type === 'wheel') {
|
|
165
|
+
// Modern wheel event
|
|
166
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent
|
|
167
|
+
const ev = <WheelEvent><unknown>e;
|
|
168
|
+
|
|
169
|
+
if (ev.deltaMode === ev.DOM_DELTA_LINE) {
|
|
170
|
+
// the deltas are expressed in lines
|
|
171
|
+
if (browser.isFirefox && !platform.isMacintosh) {
|
|
172
|
+
this.deltaY = -e.deltaY / 3;
|
|
173
|
+
} else {
|
|
174
|
+
this.deltaY = -e.deltaY;
|
|
175
|
+
}
|
|
176
|
+
} else {
|
|
177
|
+
this.deltaY = -e.deltaY / 40;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// horizontal delta scroll
|
|
182
|
+
if (typeof e1.wheelDeltaX !== 'undefined') {
|
|
183
|
+
if (browser.isSafari && platform.isWindows) {
|
|
184
|
+
this.deltaX = - (e1.wheelDeltaX / 120);
|
|
185
|
+
} else if (shouldFactorDPR) {
|
|
186
|
+
// Refs https://github.com/microsoft/vscode/issues/146403#issuecomment-1854538928
|
|
187
|
+
this.deltaX = e1.wheelDeltaX / (120 * devicePixelRatio);
|
|
188
|
+
} else {
|
|
189
|
+
this.deltaX = e1.wheelDeltaX / 120;
|
|
190
|
+
}
|
|
191
|
+
} else if (typeof e2.HORIZONTAL_AXIS !== 'undefined' && e2.axis === e2.HORIZONTAL_AXIS) {
|
|
192
|
+
this.deltaX = -e.detail / 3;
|
|
193
|
+
} else if (e.type === 'wheel') {
|
|
194
|
+
// Modern wheel event
|
|
195
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent
|
|
196
|
+
const ev = <WheelEvent><unknown>e;
|
|
197
|
+
|
|
198
|
+
if (ev.deltaMode === ev.DOM_DELTA_LINE) {
|
|
199
|
+
// the deltas are expressed in lines
|
|
200
|
+
if (browser.isFirefox && !platform.isMacintosh) {
|
|
201
|
+
this.deltaX = -e.deltaX / 3;
|
|
202
|
+
} else {
|
|
203
|
+
this.deltaX = -e.deltaX;
|
|
204
|
+
}
|
|
205
|
+
} else {
|
|
206
|
+
this.deltaX = -e.deltaX / 40;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Assume a vertical scroll if nothing else worked
|
|
211
|
+
if (this.deltaY === 0 && this.deltaX === 0 && e.wheelDelta) {
|
|
212
|
+
if (shouldFactorDPR) {
|
|
213
|
+
// Refs https://github.com/microsoft/vscode/issues/146403#issuecomment-1854538928
|
|
214
|
+
this.deltaY = e.wheelDelta / (120 * devicePixelRatio);
|
|
215
|
+
} else {
|
|
216
|
+
this.deltaY = e.wheelDelta / 120;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
public preventDefault(): void {
|
|
223
|
+
this.browserEvent?.preventDefault();
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
public stopPropagation(): void {
|
|
227
|
+
this.browserEvent?.stopPropagation();
|
|
228
|
+
}
|
|
229
|
+
}
|