@xterm/xterm 6.1.0-beta.184 → 6.1.0-beta.185
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/lib/xterm.js +1 -1
- package/lib/xterm.js.map +1 -1
- package/lib/xterm.mjs +8 -8
- package/lib/xterm.mjs.map +4 -4
- package/package.json +2 -2
- package/src/browser/CoreBrowserTerminal.ts +3 -5
- package/src/browser/Viewport.ts +3 -3
- package/src/browser/public/Terminal.ts +1 -1
- package/src/browser/services/MouseService.ts +146 -17
- package/src/browser/services/Services.ts +2 -2
- package/src/common/CoreTerminal.ts +7 -7
- package/src/common/InputHandler.ts +12 -12
- package/src/common/Types.ts +6 -6
- package/src/common/Version.ts +1 -1
- package/src/common/services/{CoreMouseService.ts → MouseStateService.ts} +19 -130
- package/src/common/services/Services.ts +8 -24
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": "6.1.0-beta.
|
|
4
|
+
"version": "6.1.0-beta.185",
|
|
5
5
|
"main": "lib/xterm.js",
|
|
6
6
|
"module": "lib/xterm.mjs",
|
|
7
7
|
"style": "css/xterm.css",
|
|
@@ -119,5 +119,5 @@
|
|
|
119
119
|
"ws": "^8.2.3",
|
|
120
120
|
"xterm-benchmark": "^0.3.1"
|
|
121
121
|
},
|
|
122
|
-
"commit": "
|
|
122
|
+
"commit": "89980fc565c178d13588e135f8eb975f44a47712"
|
|
123
123
|
}
|
|
@@ -78,7 +78,6 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
|
|
|
78
78
|
public browser: IBrowser = Browser as any;
|
|
79
79
|
|
|
80
80
|
private _customKeyEventHandler: CustomKeyEventHandler | undefined;
|
|
81
|
-
private _customWheelEventHandler: CustomWheelEventHandler | undefined;
|
|
82
81
|
|
|
83
82
|
// Browser services
|
|
84
83
|
private readonly _decorationService: DecorationService;
|
|
@@ -582,7 +581,6 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
|
|
|
582
581
|
));
|
|
583
582
|
this._instantiationService.setService(ISelectionService, this._selectionService);
|
|
584
583
|
this._mouseService = this._instantiationService.createInstance(MouseService);
|
|
585
|
-
this._mouseService.setCustomWheelEventHandler(this._customWheelEventHandler);
|
|
586
584
|
this._instantiationService.setService(IMouseService, this._mouseService);
|
|
587
585
|
this._register(this._selectionService.onRequestScrollLines(e => this.scrollLines(e.amount, e.suppressScrollEvent)));
|
|
588
586
|
this._register(this._selectionService.onSelectionChange(() => this._onSelectionChange.fire()));
|
|
@@ -607,7 +605,7 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
|
|
|
607
605
|
this._register(addDisposableListener(this.element, 'mousedown', (e: MouseEvent) => this._selectionService!.handleMouseDown(e)));
|
|
608
606
|
|
|
609
607
|
// apply mouse event classes set by escape codes before terminal was attached
|
|
610
|
-
if (this.
|
|
608
|
+
if (this.mouseStateService.areMouseEventsActive) {
|
|
611
609
|
this._selectionService.disable();
|
|
612
610
|
this.element.classList.add('enable-mouse-events');
|
|
613
611
|
} else {
|
|
@@ -727,8 +725,7 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
|
|
|
727
725
|
}
|
|
728
726
|
|
|
729
727
|
public attachCustomWheelEventHandler(customWheelEventHandler: CustomWheelEventHandler): void {
|
|
730
|
-
this.
|
|
731
|
-
this._mouseService?.setCustomWheelEventHandler(customWheelEventHandler);
|
|
728
|
+
this.mouseStateService.setCustomWheelEventHandler(customWheelEventHandler);
|
|
732
729
|
}
|
|
733
730
|
|
|
734
731
|
public registerLinkProvider(linkProvider: ILinkProvider): IDisposable {
|
|
@@ -1098,6 +1095,7 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
|
|
|
1098
1095
|
|
|
1099
1096
|
this._setup();
|
|
1100
1097
|
super.reset();
|
|
1098
|
+
this._mouseService?.reset();
|
|
1101
1099
|
this._selectionService?.reset();
|
|
1102
1100
|
this._decorationService.reset();
|
|
1103
1101
|
|
package/src/browser/Viewport.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { ICoreBrowserService, IRenderService, IThemeService } from 'browser/services/Services';
|
|
7
7
|
import { ViewportConstants } from 'browser/shared/Constants';
|
|
8
8
|
import { Disposable, toDisposable } from 'common/Lifecycle';
|
|
9
|
-
import { IBufferService,
|
|
9
|
+
import { IBufferService, IMouseStateService, IOptionsService } from 'common/services/Services';
|
|
10
10
|
import { CoreMouseEventType } from 'common/Types';
|
|
11
11
|
import { addDisposableListener, scheduleAtNextAnimationFrame } from 'browser/Dom';
|
|
12
12
|
import { SmoothScrollableElement } from 'browser/scrollable/scrollableElement';
|
|
@@ -34,7 +34,7 @@ export class Viewport extends Disposable {
|
|
|
34
34
|
screenElement: HTMLElement,
|
|
35
35
|
@IBufferService private readonly _bufferService: IBufferService,
|
|
36
36
|
@ICoreBrowserService coreBrowserService: ICoreBrowserService,
|
|
37
|
-
@
|
|
37
|
+
@IMouseStateService mouseStateService: IMouseStateService,
|
|
38
38
|
@IThemeService themeService: IThemeService,
|
|
39
39
|
@IOptionsService private readonly _optionsService: IOptionsService,
|
|
40
40
|
@IRenderService private readonly _renderService: IRenderService
|
|
@@ -65,7 +65,7 @@ export class Viewport extends Disposable {
|
|
|
65
65
|
'scrollbar'
|
|
66
66
|
], () => this._scrollableElement.updateOptions(this._getChangeOptions())));
|
|
67
67
|
// Don't handle mouse wheel if wheel events are supported by the current mouse prototcol
|
|
68
|
-
this._register(
|
|
68
|
+
this._register(mouseStateService.onProtocolChange(type => {
|
|
69
69
|
this._scrollableElement.updateOptions({
|
|
70
70
|
handleMouseWheel: !(type & CoreMouseEventType.WHEEL)
|
|
71
71
|
});
|
|
@@ -103,7 +103,7 @@ export class Terminal extends Disposable implements ITerminalApi {
|
|
|
103
103
|
public get modes(): IModes {
|
|
104
104
|
const m = this._core.coreService.decPrivateModes;
|
|
105
105
|
let mouseTrackingMode: 'none' | 'x10' | 'vt200' | 'drag' | 'any' = 'none';
|
|
106
|
-
switch (this._core.
|
|
106
|
+
switch (this._core.mouseStateService.activeProtocol) {
|
|
107
107
|
case 'X10': mouseTrackingMode = 'x10'; break;
|
|
108
108
|
case 'VT200': mouseTrackingMode = 'vt200'; break;
|
|
109
109
|
case 'DRAG': mouseTrackingMode = 'drag'; break;
|
|
@@ -4,11 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { addDisposableListener } from 'browser/Dom';
|
|
7
|
-
import { IBufferService,
|
|
8
|
-
import { CoreMouseAction, CoreMouseButton, CoreMouseEventType, IDisposable } from 'common/Types';
|
|
7
|
+
import { IBufferService, IMouseStateService, ICoreService, ILogService, IOptionsService } from 'common/services/Services';
|
|
8
|
+
import { CoreMouseAction, CoreMouseButton, CoreMouseEventType, ICoreMouseEvent, IDisposable } from 'common/Types';
|
|
9
9
|
import { C0 } from 'common/data/EscapeSequences';
|
|
10
10
|
import { toDisposable } from 'common/Lifecycle';
|
|
11
|
-
import { CustomWheelEventHandler } from 'browser/Types';
|
|
12
11
|
import { ICoreBrowserService, IMouseCoordsService, IMouseService, IMouseServiceTarget, IRenderService, ISelectionService } from './Services';
|
|
13
12
|
|
|
14
13
|
type RequestedMouseEvents = Record<'mouseup' | 'wheel' | 'mousedrag' | 'mousemove', EventListener | null>;
|
|
@@ -22,12 +21,13 @@ interface IMouseBindContext {
|
|
|
22
21
|
export class MouseService implements IMouseService {
|
|
23
22
|
public serviceBrand: undefined;
|
|
24
23
|
|
|
25
|
-
private
|
|
24
|
+
private _lastEvent: ICoreMouseEvent | null = null;
|
|
25
|
+
private _wheelPartialScroll: number = 0;
|
|
26
26
|
|
|
27
27
|
constructor(
|
|
28
28
|
@IRenderService private readonly _renderService: IRenderService,
|
|
29
29
|
@IMouseCoordsService private readonly _mouseCoordsService: IMouseCoordsService,
|
|
30
|
-
@
|
|
30
|
+
@IMouseStateService private readonly _mouseStateService: IMouseStateService,
|
|
31
31
|
@ICoreService private readonly _coreService: ICoreService,
|
|
32
32
|
@IBufferService private readonly _bufferService: IBufferService,
|
|
33
33
|
@IOptionsService private readonly _optionsService: IOptionsService,
|
|
@@ -42,7 +42,7 @@ export class MouseService implements IMouseService {
|
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* Event listener state handling.
|
|
45
|
-
* We listen to the onProtocolChange event of
|
|
45
|
+
* We listen to the onProtocolChange event of MouseStateService and put
|
|
46
46
|
* requested listeners in `requestedEvents`. With this the listeners
|
|
47
47
|
* have all bits to do the event listener juggling.
|
|
48
48
|
* Note: 'mousedown' currently is "always on" and not managed
|
|
@@ -61,11 +61,11 @@ export class MouseService implements IMouseService {
|
|
|
61
61
|
mousedrag: (ev: Event) => this._handleMouseDrag(ctx, ev as MouseEvent),
|
|
62
62
|
mousemove: (ev: Event) => this._handleMouseMove(ctx, ev as MouseEvent)
|
|
63
63
|
};
|
|
64
|
-
register(this.
|
|
64
|
+
register(this._mouseStateService.onProtocolChange(events => {
|
|
65
65
|
this._handleProtocolChange(ctx, eventListeners, events);
|
|
66
66
|
}));
|
|
67
67
|
// force initial onProtocolChange so we dont miss early mouse requests
|
|
68
|
-
this.
|
|
68
|
+
this._mouseStateService.activeProtocol = this._mouseStateService.activeProtocol;
|
|
69
69
|
|
|
70
70
|
// Ensure document-level listeners are removed on dispose
|
|
71
71
|
register(toDisposable(() => {
|
|
@@ -119,14 +119,14 @@ export class MouseService implements IMouseService {
|
|
|
119
119
|
but = ev.button < 3 ? ev.button : CoreMouseButton.NONE;
|
|
120
120
|
break;
|
|
121
121
|
case 'wheel':
|
|
122
|
-
if (this.
|
|
122
|
+
if (!this._mouseStateService.allowCustomWheelEvent(ev as WheelEvent)) {
|
|
123
123
|
return false;
|
|
124
124
|
}
|
|
125
125
|
const deltaY = (ev as WheelEvent).deltaY;
|
|
126
126
|
if (deltaY === 0) {
|
|
127
127
|
return false;
|
|
128
128
|
}
|
|
129
|
-
const lines = this.
|
|
129
|
+
const lines = this._consumeWheelEvent(
|
|
130
130
|
ev as WheelEvent,
|
|
131
131
|
this._renderService?.dimensions?.device?.cell?.height,
|
|
132
132
|
this._coreBrowserService?.dpr
|
|
@@ -148,7 +148,7 @@ export class MouseService implements IMouseService {
|
|
|
148
148
|
return false;
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
return this.
|
|
151
|
+
return this._triggerMouseEvent({
|
|
152
152
|
col: pos.col,
|
|
153
153
|
row: pos.row,
|
|
154
154
|
x: pos.x,
|
|
@@ -202,7 +202,7 @@ export class MouseService implements IMouseService {
|
|
|
202
202
|
// Don't send the mouse button to the pty if mouse events are disabled or
|
|
203
203
|
// if the selection manager is having selection forced (ie. a modifier is
|
|
204
204
|
// held).
|
|
205
|
-
if (!this.
|
|
205
|
+
if (!this._mouseStateService.areMouseEventsActive || this._selectionService.shouldForceSelection(ev)) {
|
|
206
206
|
return;
|
|
207
207
|
}
|
|
208
208
|
|
|
@@ -226,7 +226,7 @@ export class MouseService implements IMouseService {
|
|
|
226
226
|
return;
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
if (this.
|
|
229
|
+
if (!this._mouseStateService.allowCustomWheelEvent(ev)) {
|
|
230
230
|
return false;
|
|
231
231
|
}
|
|
232
232
|
|
|
@@ -244,7 +244,7 @@ export class MouseService implements IMouseService {
|
|
|
244
244
|
return false;
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
const lines = this.
|
|
247
|
+
const lines = this._consumeWheelEvent(
|
|
248
248
|
ev,
|
|
249
249
|
this._renderService?.dimensions?.device?.cell?.height,
|
|
250
250
|
this._coreBrowserService?.dpr
|
|
@@ -264,13 +264,18 @@ export class MouseService implements IMouseService {
|
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
+
public reset(): void {
|
|
268
|
+
this._lastEvent = null;
|
|
269
|
+
this._wheelPartialScroll = 0;
|
|
270
|
+
}
|
|
271
|
+
|
|
267
272
|
private _handleProtocolChange(ctx: IMouseBindContext, eventListeners: Record<'mouseup' | 'wheel' | 'mousedrag' | 'mousemove', EventListener>, events: CoreMouseEventType): void {
|
|
268
273
|
const { element, document } = ctx.target;
|
|
269
274
|
const { requestedEvents } = ctx;
|
|
270
275
|
// apply global changes on events
|
|
271
276
|
if (events) {
|
|
272
277
|
if (this._optionsService.rawOptions.logLevel === 'debug') {
|
|
273
|
-
this._logService.debug('Binding to mouse events:', this.
|
|
278
|
+
this._logService.debug('Binding to mouse events:', this._explainEvents(events));
|
|
274
279
|
}
|
|
275
280
|
element.classList.add('enable-mouse-events');
|
|
276
281
|
this._selectionService.disable();
|
|
@@ -320,7 +325,131 @@ export class MouseService implements IMouseService {
|
|
|
320
325
|
}
|
|
321
326
|
}
|
|
322
327
|
|
|
323
|
-
|
|
324
|
-
|
|
328
|
+
private _applyScrollModifier(amount: number, ev: WheelEvent): number {
|
|
329
|
+
// Multiply the scroll speed when the modifier key is pressed
|
|
330
|
+
if (ev.altKey || ev.ctrlKey || ev.shiftKey) {
|
|
331
|
+
return amount * this._optionsService.rawOptions.fastScrollSensitivity * this._optionsService.rawOptions.scrollSensitivity;
|
|
332
|
+
}
|
|
333
|
+
return amount * this._optionsService.rawOptions.scrollSensitivity;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Processes a wheel event, accounting for partial scrolls for trackpad, mouse scrolls.
|
|
338
|
+
* This prevents hyper-sensitive scrolling in alt buffer.
|
|
339
|
+
*/
|
|
340
|
+
private _consumeWheelEvent(ev: WheelEvent, cellHeight?: number, dpr?: number): number {
|
|
341
|
+
// Do nothing if it's not a vertical scroll event
|
|
342
|
+
if (ev.deltaY === 0 || ev.shiftKey) {
|
|
343
|
+
return 0;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
if (cellHeight === undefined || dpr === undefined) {
|
|
347
|
+
return 0;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const targetWheelEventPixels = cellHeight / dpr;
|
|
351
|
+
let amount = this._applyScrollModifier(ev.deltaY, ev);
|
|
352
|
+
|
|
353
|
+
if (ev.deltaMode === WheelEvent.DOM_DELTA_PIXEL) {
|
|
354
|
+
amount /= (targetWheelEventPixels + 0.0); // Prevent integer division
|
|
355
|
+
|
|
356
|
+
const isLikelyTrackpad = Math.abs(ev.deltaY) < 50;
|
|
357
|
+
if (isLikelyTrackpad) {
|
|
358
|
+
amount *= 0.3;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
this._wheelPartialScroll += amount;
|
|
362
|
+
amount = Math.floor(Math.abs(this._wheelPartialScroll)) * (this._wheelPartialScroll > 0 ? 1 : -1);
|
|
363
|
+
this._wheelPartialScroll %= 1;
|
|
364
|
+
} else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
|
|
365
|
+
amount *= this._bufferService.rows;
|
|
366
|
+
}
|
|
367
|
+
return amount;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Triggers a mouse event to be sent.
|
|
372
|
+
*
|
|
373
|
+
* Returns true if the event passed all protocol restrictions and a report
|
|
374
|
+
* was sent, otherwise false. The return value may be used to decide whether
|
|
375
|
+
* the default event action in the browser component should be omitted.
|
|
376
|
+
*
|
|
377
|
+
* Note: The method will change values of the given event object
|
|
378
|
+
* to fulfill protocol and encoding restrictions.
|
|
379
|
+
*/
|
|
380
|
+
private _triggerMouseEvent(e: ICoreMouseEvent): boolean {
|
|
381
|
+
// range check for col/row
|
|
382
|
+
if (e.col < 0 || e.col >= this._bufferService.cols
|
|
383
|
+
|| e.row < 0 || e.row >= this._bufferService.rows) {
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// filter nonsense combinations of button + action
|
|
388
|
+
if (e.button === CoreMouseButton.WHEEL && e.action === CoreMouseAction.MOVE) {
|
|
389
|
+
return false;
|
|
390
|
+
}
|
|
391
|
+
if (e.button === CoreMouseButton.NONE && e.action !== CoreMouseAction.MOVE) {
|
|
392
|
+
return false;
|
|
393
|
+
}
|
|
394
|
+
if (e.button !== CoreMouseButton.WHEEL && (e.action === CoreMouseAction.LEFT || e.action === CoreMouseAction.RIGHT)) {
|
|
395
|
+
return false;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// report 1-based coords
|
|
399
|
+
e.col++;
|
|
400
|
+
e.row++;
|
|
401
|
+
|
|
402
|
+
// debounce move events at grid or pixel level
|
|
403
|
+
if (e.action === CoreMouseAction.MOVE
|
|
404
|
+
&& this._lastEvent
|
|
405
|
+
&& this._equalEvents(this._lastEvent, e, this._mouseStateService.isPixelEncoding)
|
|
406
|
+
) {
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// apply protocol restrictions
|
|
411
|
+
if (!this._mouseStateService.restrictMouseEvent(e)) {
|
|
412
|
+
return false;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// encode report and send
|
|
416
|
+
const report = this._mouseStateService.encodeMouseEvent(e);
|
|
417
|
+
if (report) {
|
|
418
|
+
if (this._mouseStateService.isDefaultEncoding) {
|
|
419
|
+
this._coreService.triggerBinaryEvent(report);
|
|
420
|
+
} else {
|
|
421
|
+
this._coreService.triggerDataEvent(report, true);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
this._lastEvent = e;
|
|
426
|
+
return true;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
private _explainEvents(events: CoreMouseEventType): { [event: string]: boolean } {
|
|
430
|
+
return {
|
|
431
|
+
down: !!(events & CoreMouseEventType.DOWN),
|
|
432
|
+
up: !!(events & CoreMouseEventType.UP),
|
|
433
|
+
drag: !!(events & CoreMouseEventType.DRAG),
|
|
434
|
+
move: !!(events & CoreMouseEventType.MOVE),
|
|
435
|
+
wheel: !!(events & CoreMouseEventType.WHEEL)
|
|
436
|
+
};
|
|
325
437
|
}
|
|
438
|
+
|
|
439
|
+
private _equalEvents(e1: ICoreMouseEvent, e2: ICoreMouseEvent, pixels: boolean): boolean {
|
|
440
|
+
if (pixels) {
|
|
441
|
+
if (e1.x !== e2.x) return false;
|
|
442
|
+
if (e1.y !== e2.y) return false;
|
|
443
|
+
} else {
|
|
444
|
+
if (e1.col !== e2.col) return false;
|
|
445
|
+
if (e1.row !== e2.row) return false;
|
|
446
|
+
}
|
|
447
|
+
if (e1.button !== e2.button) return false;
|
|
448
|
+
if (e1.action !== e2.action) return false;
|
|
449
|
+
if (e1.ctrl !== e2.ctrl) return false;
|
|
450
|
+
if (e1.alt !== e2.alt) return false;
|
|
451
|
+
if (e1.shift !== e2.shift) return false;
|
|
452
|
+
return true;
|
|
453
|
+
}
|
|
454
|
+
|
|
326
455
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { IRenderDimensions, IRenderer } from 'browser/renderer/shared/Types';
|
|
7
|
-
import {
|
|
7
|
+
import { IColorSet, ILink, ReadonlyColorSet } from 'browser/Types';
|
|
8
8
|
import { ISelectionRedrawRequestEvent as ISelectionRequestRedrawEvent, ISelectionRequestScrollLinesEvent } from 'browser/selection/Types';
|
|
9
9
|
import { createDecorator } from 'common/services/ServiceRegistry';
|
|
10
10
|
import { AllColorIndex, IDisposable, IKeyboardResult } from 'common/Types';
|
|
@@ -61,8 +61,8 @@ export const IMouseService = createDecorator<IMouseService>('MouseService');
|
|
|
61
61
|
export interface IMouseService {
|
|
62
62
|
serviceBrand: undefined;
|
|
63
63
|
|
|
64
|
-
setCustomWheelEventHandler(customWheelEventHandler: CustomWheelEventHandler | undefined): void;
|
|
65
64
|
bindMouse(target: IMouseServiceTarget, register: (disposable: IDisposable) => void, focus: () => void): void;
|
|
65
|
+
reset(): void;
|
|
66
66
|
}
|
|
67
67
|
export interface IMouseServiceTarget {
|
|
68
68
|
element: HTMLElement;
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
* http://linux.die.net/man/7/urxvt
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
import { IInstantiationService, IOptionsService, IBufferService, ILogService, ICharsetService, ICoreService,
|
|
24
|
+
import { IInstantiationService, IOptionsService, IBufferService, ILogService, ICharsetService, ICoreService, IMouseStateService, IUnicodeService, LogLevelEnum, ITerminalOptions, IOscLinkService } from 'common/services/Services';
|
|
25
25
|
import { InstantiationService } from 'common/services/InstantiationService';
|
|
26
26
|
import { LogService } from 'common/services/LogService';
|
|
27
27
|
import { BufferService, MINIMUM_COLS, MINIMUM_ROWS } from 'common/services/BufferService';
|
|
28
28
|
import { OptionsService } from 'common/services/OptionsService';
|
|
29
29
|
import { IDisposable, IAttributeData, ICoreTerminal, IScrollEvent } from 'common/Types';
|
|
30
30
|
import { CoreService } from 'common/services/CoreService';
|
|
31
|
-
import {
|
|
31
|
+
import { MouseStateService } from 'common/services/MouseStateService';
|
|
32
32
|
import { UnicodeService } from 'common/services/UnicodeService';
|
|
33
33
|
import { CharsetService } from 'common/services/CharsetService';
|
|
34
34
|
import { updateWindowsModeWrappedState } from 'common/WindowsMode';
|
|
@@ -50,7 +50,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
|
|
|
50
50
|
protected readonly _charsetService: ICharsetService;
|
|
51
51
|
protected readonly _oscLinkService: IOscLinkService;
|
|
52
52
|
|
|
53
|
-
public readonly
|
|
53
|
+
public readonly mouseStateService: IMouseStateService;
|
|
54
54
|
public readonly coreService: ICoreService;
|
|
55
55
|
public readonly unicodeService: IUnicodeService;
|
|
56
56
|
public readonly optionsService: IOptionsService;
|
|
@@ -113,8 +113,8 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
|
|
|
113
113
|
this._instantiationService.setService(IBufferService, this._bufferService);
|
|
114
114
|
this.coreService = this._register(this._instantiationService.createInstance(CoreService));
|
|
115
115
|
this._instantiationService.setService(ICoreService, this.coreService);
|
|
116
|
-
this.
|
|
117
|
-
this._instantiationService.setService(
|
|
116
|
+
this.mouseStateService = this._register(this._instantiationService.createInstance(MouseStateService));
|
|
117
|
+
this._instantiationService.setService(IMouseStateService, this.mouseStateService);
|
|
118
118
|
this.unicodeService = this._register(this._instantiationService.createInstance(UnicodeService));
|
|
119
119
|
this._instantiationService.setService(IUnicodeService, this.unicodeService);
|
|
120
120
|
this._charsetService = this._instantiationService.createInstance(CharsetService);
|
|
@@ -124,7 +124,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
|
|
|
124
124
|
|
|
125
125
|
|
|
126
126
|
// Register input handler and handle/forward events
|
|
127
|
-
this._inputHandler = this._register(new InputHandler(this._bufferService, this._charsetService, this.coreService, this._logService, this.optionsService, this._oscLinkService, this.
|
|
127
|
+
this._inputHandler = this._register(new InputHandler(this._bufferService, this._charsetService, this.coreService, this._logService, this.optionsService, this._oscLinkService, this.mouseStateService, this.unicodeService));
|
|
128
128
|
this._register(EventUtils.forward(this._inputHandler.onLineFeed, this._onLineFeed));
|
|
129
129
|
|
|
130
130
|
// Setup listeners
|
|
@@ -256,7 +256,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
|
|
|
256
256
|
this._bufferService.reset();
|
|
257
257
|
this._charsetService.reset();
|
|
258
258
|
this.coreService.reset();
|
|
259
|
-
this.
|
|
259
|
+
this.mouseStateService.reset();
|
|
260
260
|
}
|
|
261
261
|
|
|
262
262
|
|
|
@@ -15,7 +15,7 @@ import { IParsingState, IEscapeSequenceParser, IParams, IFunctionIdentifier } fr
|
|
|
15
15
|
import { NULL_CELL_CODE, NULL_CELL_WIDTH, Attributes, FgFlags, BgFlags, Content, UnderlineStyle } from 'common/buffer/Constants';
|
|
16
16
|
import { CellData } from 'common/buffer/CellData';
|
|
17
17
|
import { AttributeData } from 'common/buffer/AttributeData';
|
|
18
|
-
import { ICoreService, IBufferService, IOptionsService, ILogService,
|
|
18
|
+
import { ICoreService, IBufferService, IOptionsService, ILogService, IMouseStateService, ICharsetService, IUnicodeService, LogLevelEnum, IOscLinkService } from 'common/services/Services';
|
|
19
19
|
import { UnicodeService } from 'common/services/UnicodeService';
|
|
20
20
|
import { OscHandler } from 'common/parser/OscParser';
|
|
21
21
|
import { DcsHandler } from 'common/parser/DcsParser';
|
|
@@ -178,7 +178,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
|
|
178
178
|
private readonly _logService: ILogService,
|
|
179
179
|
private readonly _optionsService: IOptionsService,
|
|
180
180
|
private readonly _oscLinkService: IOscLinkService,
|
|
181
|
-
private readonly
|
|
181
|
+
private readonly _mouseStateService: IMouseStateService,
|
|
182
182
|
private readonly _unicodeService: IUnicodeService,
|
|
183
183
|
private readonly _parser: IEscapeSequenceParser = new EscapeSequenceParser()
|
|
184
184
|
) {
|
|
@@ -1987,19 +1987,19 @@ export class InputHandler extends Disposable implements IInputHandler {
|
|
|
1987
1987
|
break;
|
|
1988
1988
|
case 9: // X10 Mouse
|
|
1989
1989
|
// no release, no motion, no wheel, no modifiers.
|
|
1990
|
-
this.
|
|
1990
|
+
this._mouseStateService.activeProtocol = 'X10';
|
|
1991
1991
|
break;
|
|
1992
1992
|
case 1000: // vt200 mouse
|
|
1993
1993
|
// no motion.
|
|
1994
|
-
this.
|
|
1994
|
+
this._mouseStateService.activeProtocol = 'VT200';
|
|
1995
1995
|
break;
|
|
1996
1996
|
case 1002: // button event mouse
|
|
1997
|
-
this.
|
|
1997
|
+
this._mouseStateService.activeProtocol = 'DRAG';
|
|
1998
1998
|
break;
|
|
1999
1999
|
case 1003: // any event mouse
|
|
2000
2000
|
// any event - sends motion events,
|
|
2001
2001
|
// even if there is no button held down.
|
|
2002
|
-
this.
|
|
2002
|
+
this._mouseStateService.activeProtocol = 'ANY';
|
|
2003
2003
|
break;
|
|
2004
2004
|
case 1004: // send focusin/focusout events
|
|
2005
2005
|
// focusin: ^[[I
|
|
@@ -2011,13 +2011,13 @@ export class InputHandler extends Disposable implements IInputHandler {
|
|
|
2011
2011
|
this._logService.debug('DECSET 1005 not supported (see #2507)');
|
|
2012
2012
|
break;
|
|
2013
2013
|
case 1006: // sgr ext mode mouse
|
|
2014
|
-
this.
|
|
2014
|
+
this._mouseStateService.activeEncoding = 'SGR';
|
|
2015
2015
|
break;
|
|
2016
2016
|
case 1015: // urxvt ext mode mouse - removed in #2507
|
|
2017
2017
|
this._logService.debug('DECSET 1015 not supported (see #2507)');
|
|
2018
2018
|
break;
|
|
2019
2019
|
case 1016: // sgr pixels mode mouse
|
|
2020
|
-
this.
|
|
2020
|
+
this._mouseStateService.activeEncoding = 'SGR_PIXELS';
|
|
2021
2021
|
break;
|
|
2022
2022
|
case 25: // show cursor
|
|
2023
2023
|
this._coreService.isCursorHidden = false;
|
|
@@ -2248,7 +2248,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
|
|
2248
2248
|
case 1000: // vt200 mouse
|
|
2249
2249
|
case 1002: // button event mouse
|
|
2250
2250
|
case 1003: // any event mouse
|
|
2251
|
-
this.
|
|
2251
|
+
this._mouseStateService.activeProtocol = 'NONE';
|
|
2252
2252
|
break;
|
|
2253
2253
|
case 1004: // send focusin/focusout events
|
|
2254
2254
|
this._coreService.decPrivateModes.sendFocus = false;
|
|
@@ -2257,13 +2257,13 @@ export class InputHandler extends Disposable implements IInputHandler {
|
|
|
2257
2257
|
this._logService.debug('DECRST 1005 not supported (see #2507)');
|
|
2258
2258
|
break;
|
|
2259
2259
|
case 1006: // sgr ext mode mouse
|
|
2260
|
-
this.
|
|
2260
|
+
this._mouseStateService.activeEncoding = 'DEFAULT';
|
|
2261
2261
|
break;
|
|
2262
2262
|
case 1015: // urxvt ext mode mouse - removed in #2507
|
|
2263
2263
|
this._logService.debug('DECRST 1015 not supported (see #2507)');
|
|
2264
2264
|
break;
|
|
2265
2265
|
case 1016: // sgr pixels mode mouse
|
|
2266
|
-
this.
|
|
2266
|
+
this._mouseStateService.activeEncoding = 'DEFAULT';
|
|
2267
2267
|
break;
|
|
2268
2268
|
case 25: // hide cursor
|
|
2269
2269
|
this._coreService.isCursorHidden = true;
|
|
@@ -2357,7 +2357,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
|
|
2357
2357
|
|
|
2358
2358
|
// access helpers
|
|
2359
2359
|
const dm = this._coreService.decPrivateModes;
|
|
2360
|
-
const { activeProtocol: mouseProtocol, activeEncoding: mouseEncoding } = this.
|
|
2360
|
+
const { activeProtocol: mouseProtocol, activeEncoding: mouseEncoding } = this._mouseStateService;
|
|
2361
2361
|
const cs = this._coreService;
|
|
2362
2362
|
const { buffers, cols } = this._bufferService;
|
|
2363
2363
|
const { active, alt } = buffers;
|
package/src/common/Types.ts
CHANGED
|
@@ -7,12 +7,12 @@ import { IDeleteEvent, IInsertEvent } from 'common/CircularList';
|
|
|
7
7
|
import { UnderlineStyle } from 'common/buffer/Constants';
|
|
8
8
|
import { IBufferSet } from 'common/buffer/Types';
|
|
9
9
|
import { IParams } from 'common/parser/Types';
|
|
10
|
-
import {
|
|
10
|
+
import { IMouseStateService, ICoreService, IOptionsService, IUnicodeService } from 'common/services/Services';
|
|
11
11
|
import { IFunctionIdentifier, ITerminalOptions as IPublicTerminalOptions } from '@xterm/xterm';
|
|
12
12
|
import type { Emitter, IEvent } from 'common/Event';
|
|
13
13
|
|
|
14
14
|
export interface ICoreTerminal {
|
|
15
|
-
|
|
15
|
+
mouseStateService: IMouseStateService;
|
|
16
16
|
coreService: ICoreService;
|
|
17
17
|
optionsService: IOptionsService;
|
|
18
18
|
unicodeService: IUnicodeService;
|
|
@@ -343,7 +343,7 @@ export interface ICoreMouseEvent {
|
|
|
343
343
|
* it is not possible to report multiple buttons at once.
|
|
344
344
|
* Wheel is treated as a button.
|
|
345
345
|
* There are invalid combinations of buttons and actions possible
|
|
346
|
-
* (like move + wheel), those are silently ignored by the
|
|
346
|
+
* (like move + wheel), those are silently ignored by the MouseStateService.
|
|
347
347
|
*/
|
|
348
348
|
button: CoreMouseButton;
|
|
349
349
|
action: CoreMouseAction;
|
|
@@ -360,7 +360,7 @@ export interface ICoreMouseEvent {
|
|
|
360
360
|
* CoreMouseEventType
|
|
361
361
|
* To be reported to the browser component which events a mouse
|
|
362
362
|
* protocol wants to be catched and forwarded as an ICoreMouseEvent
|
|
363
|
-
* to
|
|
363
|
+
* to MouseStateService.
|
|
364
364
|
*/
|
|
365
365
|
export const enum CoreMouseEventType {
|
|
366
366
|
NONE = 0,
|
|
@@ -378,7 +378,7 @@ export const enum CoreMouseEventType {
|
|
|
378
378
|
|
|
379
379
|
/**
|
|
380
380
|
* Mouse protocol interface.
|
|
381
|
-
* A mouse protocol can be registered and activated at the
|
|
381
|
+
* A mouse protocol can be registered and activated at the MouseStateService.
|
|
382
382
|
* `events` should contain a list of needed events as a hint for the browser component
|
|
383
383
|
* to install/remove the appropriate event handlers.
|
|
384
384
|
* `restrict` applies further protocol specific restrictions like not allowed
|
|
@@ -391,7 +391,7 @@ export interface ICoreMouseProtocol {
|
|
|
391
391
|
|
|
392
392
|
/**
|
|
393
393
|
* CoreMouseEncoding
|
|
394
|
-
* The tracking encoding can be registered and activated at the
|
|
394
|
+
* The tracking encoding can be registered and activated at the MouseStateService.
|
|
395
395
|
* If a ICoreMouseEvent passes all procotol restrictions it will be encoded
|
|
396
396
|
* with the active encoding and sent out.
|
|
397
397
|
* Note: Returning an empty string will supress sending a mouse report,
|
package/src/common/Version.ts
CHANGED