@xterm/xterm 5.6.0-beta.118 → 5.6.0-beta.119
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xterm/xterm",
|
|
3
3
|
"description": "Full xterm terminal, in your browser",
|
|
4
|
-
"version": "5.6.0-beta.
|
|
4
|
+
"version": "5.6.0-beta.119",
|
|
5
5
|
"main": "lib/xterm.js",
|
|
6
6
|
"module": "lib/xterm.mjs",
|
|
7
7
|
"style": "css/xterm.css",
|
|
@@ -107,5 +107,5 @@
|
|
|
107
107
|
"ws": "^8.2.3",
|
|
108
108
|
"xterm-benchmark": "^0.3.1"
|
|
109
109
|
},
|
|
110
|
-
"commit": "
|
|
110
|
+
"commit": "d7d7f1b0236aaaac17bd707c5e008d4d8701d366"
|
|
111
111
|
}
|
|
@@ -646,6 +646,14 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
|
|
|
646
646
|
if (deltaY === 0) {
|
|
647
647
|
return false;
|
|
648
648
|
}
|
|
649
|
+
const lines = self.coreMouseService.consumeWheelEvent(
|
|
650
|
+
ev as WheelEvent,
|
|
651
|
+
self._renderService?.dimensions?.device?.cell?.height,
|
|
652
|
+
self._coreBrowserService?.dpr
|
|
653
|
+
);
|
|
654
|
+
if (lines === 0) {
|
|
655
|
+
return false;
|
|
656
|
+
}
|
|
649
657
|
action = deltaY < 0 ? CoreMouseAction.UP : CoreMouseAction.DOWN;
|
|
650
658
|
but = CoreMouseButton.WHEEL;
|
|
651
659
|
break;
|
|
@@ -817,6 +825,15 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
|
|
|
817
825
|
return false;
|
|
818
826
|
}
|
|
819
827
|
|
|
828
|
+
const lines = self.coreMouseService.consumeWheelEvent(
|
|
829
|
+
ev as WheelEvent,
|
|
830
|
+
self._renderService?.dimensions?.device?.cell?.height,
|
|
831
|
+
self._coreBrowserService?.dpr
|
|
832
|
+
);
|
|
833
|
+
if (lines === 0) {
|
|
834
|
+
return false;
|
|
835
|
+
}
|
|
836
|
+
|
|
820
837
|
// Construct and send sequences
|
|
821
838
|
const sequence = C0.ESC + (this.coreService.decPrivateModes.applicationCursorKeys ? 'O' : '[') + (ev.deltaY < 0 ? 'A' : 'B');
|
|
822
839
|
this.coreService.triggerDataEvent(sequence, true);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
|
|
3
3
|
* @license MIT
|
|
4
4
|
*/
|
|
5
|
-
import { IBufferService, ICoreService, ICoreMouseService } from 'common/services/Services';
|
|
5
|
+
import { IBufferService, ICoreService, ICoreMouseService, IOptionsService } from 'common/services/Services';
|
|
6
6
|
import { ICoreMouseProtocol, ICoreMouseEvent, CoreMouseEncoding, CoreMouseEventType, CoreMouseButton, CoreMouseAction } from 'common/Types';
|
|
7
7
|
import { Disposable } from 'vs/base/common/lifecycle';
|
|
8
8
|
import { Emitter } from 'vs/base/common/event';
|
|
@@ -174,13 +174,15 @@ export class CoreMouseService extends Disposable implements ICoreMouseService {
|
|
|
174
174
|
private _activeProtocol: string = '';
|
|
175
175
|
private _activeEncoding: string = '';
|
|
176
176
|
private _lastEvent: ICoreMouseEvent | null = null;
|
|
177
|
+
private _wheelPartialScroll: number = 0;
|
|
177
178
|
|
|
178
179
|
private readonly _onProtocolChange = this._register(new Emitter<CoreMouseEventType>());
|
|
179
|
-
public readonly onProtocolChange =
|
|
180
|
+
public readonly onProtocolChange = this._onProtocolChange.event;
|
|
180
181
|
|
|
181
182
|
constructor(
|
|
182
183
|
@IBufferService private readonly _bufferService: IBufferService,
|
|
183
|
-
@ICoreService private readonly _coreService: ICoreService
|
|
184
|
+
@ICoreService private readonly _coreService: ICoreService,
|
|
185
|
+
@IOptionsService private readonly _optionsService: IOptionsService
|
|
184
186
|
) {
|
|
185
187
|
super();
|
|
186
188
|
// register default protocols and encodings
|
|
@@ -229,6 +231,49 @@ export class CoreMouseService extends Disposable implements ICoreMouseService {
|
|
|
229
231
|
this.activeProtocol = 'NONE';
|
|
230
232
|
this.activeEncoding = 'DEFAULT';
|
|
231
233
|
this._lastEvent = null;
|
|
234
|
+
this._wheelPartialScroll = 0;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Processes a wheel event, accounting for partial scrolls for trackpad, mouse scrolls.
|
|
239
|
+
* This prevents hyper-sensitive scrolling in alt buffer.
|
|
240
|
+
*/
|
|
241
|
+
public consumeWheelEvent(ev: WheelEvent, cellHeight?: number, dpr?: number): number {
|
|
242
|
+
// Do nothing if it's not a vertical scroll event
|
|
243
|
+
if (ev.deltaY === 0 || ev.shiftKey) {
|
|
244
|
+
return 0;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (cellHeight === undefined || dpr === undefined) {
|
|
248
|
+
return 0;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const targetWheelEventPixels = cellHeight / dpr;
|
|
252
|
+
let amount = this._applyScrollModifier(ev.deltaY, ev);
|
|
253
|
+
|
|
254
|
+
if (ev.deltaMode === WheelEvent.DOM_DELTA_PIXEL) {
|
|
255
|
+
amount /= (targetWheelEventPixels + 0.0); // Prevent integer division
|
|
256
|
+
|
|
257
|
+
const isLikelyTrackpad = Math.abs(ev.deltaY) < 50;
|
|
258
|
+
if (isLikelyTrackpad) {
|
|
259
|
+
amount *= 0.3;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
this._wheelPartialScroll += amount;
|
|
263
|
+
amount = Math.floor(Math.abs(this._wheelPartialScroll)) * (this._wheelPartialScroll > 0 ? 1 : -1);
|
|
264
|
+
this._wheelPartialScroll %= 1;
|
|
265
|
+
} else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
|
|
266
|
+
amount *= this._bufferService.rows;
|
|
267
|
+
}
|
|
268
|
+
return amount;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
private _applyScrollModifier(amount: number, ev: WheelEvent): number {
|
|
272
|
+
// Multiply the scroll speed when the modifier key is pressed
|
|
273
|
+
if (ev.altKey || ev.ctrlKey || ev.shiftKey) {
|
|
274
|
+
return amount * this._optionsService.rawOptions.fastScrollSensitivity * this._optionsService.rawOptions.scrollSensitivity;
|
|
275
|
+
}
|
|
276
|
+
return amount * this._optionsService.rawOptions.scrollSensitivity;
|
|
232
277
|
}
|
|
233
278
|
|
|
234
279
|
/**
|
|
@@ -58,6 +58,11 @@ export interface ICoreMouseService {
|
|
|
58
58
|
* Human readable version of mouse events.
|
|
59
59
|
*/
|
|
60
60
|
explainEvents(events: CoreMouseEventType): { [event: string]: boolean };
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Process wheel event taking partial scroll into account.
|
|
64
|
+
*/
|
|
65
|
+
consumeWheelEvent(ev: WheelEvent, cellHeight?: number, dpr?: number): number;
|
|
61
66
|
}
|
|
62
67
|
|
|
63
68
|
export const ICoreService = createDecorator<ICoreService>('CoreService');
|