@xterm/xterm 5.6.0-beta.13 → 5.6.0-beta.131

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.
Files changed (129) hide show
  1. package/README.md +9 -3
  2. package/css/xterm.css +71 -4
  3. package/lib/xterm.js +1 -1
  4. package/lib/xterm.js.map +1 -1
  5. package/lib/xterm.mjs +53 -0
  6. package/lib/xterm.mjs.map +7 -0
  7. package/package.json +44 -33
  8. package/src/browser/AccessibilityManager.ts +54 -26
  9. package/src/browser/{Terminal.ts → CoreBrowserTerminal.ts} +159 -145
  10. package/src/browser/Linkifier.ts +26 -14
  11. package/src/browser/LocalizableStrings.ts +15 -4
  12. package/src/browser/{Types.d.ts → Types.ts} +67 -15
  13. package/src/browser/Viewport.ts +148 -370
  14. package/src/browser/decorations/BufferDecorationRenderer.ts +14 -9
  15. package/src/browser/decorations/OverviewRulerRenderer.ts +40 -44
  16. package/src/browser/input/CompositionHelper.ts +2 -1
  17. package/src/browser/input/MoveToCell.ts +3 -1
  18. package/src/browser/public/Terminal.ts +25 -19
  19. package/src/browser/renderer/dom/DomRenderer.ts +19 -14
  20. package/src/browser/renderer/dom/DomRendererRowFactory.ts +35 -15
  21. package/src/browser/renderer/shared/Constants.ts +0 -8
  22. package/src/browser/renderer/shared/Types.ts +84 -0
  23. package/src/browser/services/CharSizeService.ts +6 -6
  24. package/src/browser/services/CoreBrowserService.ts +15 -15
  25. package/src/browser/services/LinkProviderService.ts +2 -2
  26. package/src/browser/services/RenderService.ts +20 -20
  27. package/src/browser/services/SelectionService.ts +8 -8
  28. package/src/browser/services/Services.ts +13 -13
  29. package/src/browser/services/ThemeService.ts +19 -58
  30. package/src/browser/shared/Constants.ts +8 -0
  31. package/src/common/CircularList.ts +5 -5
  32. package/src/common/CoreTerminal.ts +35 -41
  33. package/src/common/InputHandler.ts +83 -56
  34. package/src/common/{Types.d.ts → Types.ts} +13 -17
  35. package/src/common/buffer/Buffer.ts +15 -7
  36. package/src/common/buffer/BufferReflow.ts +9 -6
  37. package/src/common/buffer/BufferSet.ts +5 -5
  38. package/src/common/buffer/Marker.ts +4 -4
  39. package/src/common/buffer/{Types.d.ts → Types.ts} +2 -2
  40. package/src/common/input/Keyboard.ts +0 -24
  41. package/src/common/input/WriteBuffer.ts +3 -3
  42. package/src/common/parser/EscapeSequenceParser.ts +4 -4
  43. package/src/common/public/BufferNamespaceApi.ts +3 -3
  44. package/src/common/services/BufferService.ts +10 -7
  45. package/src/common/services/CoreMouseService.ts +53 -6
  46. package/src/common/services/CoreService.ts +12 -8
  47. package/src/common/services/DecorationService.ts +8 -9
  48. package/src/common/services/InstantiationService.ts +1 -1
  49. package/src/common/services/LogService.ts +2 -2
  50. package/src/common/services/OptionsService.ts +8 -6
  51. package/src/common/services/ServiceRegistry.ts +1 -1
  52. package/src/common/services/Services.ts +32 -17
  53. package/src/common/services/UnicodeService.ts +2 -2
  54. package/src/vs/base/browser/browser.ts +141 -0
  55. package/src/vs/base/browser/canIUse.ts +49 -0
  56. package/src/vs/base/browser/dom.ts +2369 -0
  57. package/src/vs/base/browser/fastDomNode.ts +316 -0
  58. package/src/vs/base/browser/globalPointerMoveMonitor.ts +112 -0
  59. package/src/vs/base/browser/iframe.ts +135 -0
  60. package/src/vs/base/browser/keyboardEvent.ts +213 -0
  61. package/src/vs/base/browser/mouseEvent.ts +229 -0
  62. package/src/vs/base/browser/touch.ts +372 -0
  63. package/src/vs/base/browser/ui/scrollbar/abstractScrollbar.ts +303 -0
  64. package/src/vs/base/browser/ui/scrollbar/horizontalScrollbar.ts +114 -0
  65. package/src/vs/base/browser/ui/scrollbar/scrollableElement.ts +720 -0
  66. package/src/vs/base/browser/ui/scrollbar/scrollableElementOptions.ts +165 -0
  67. package/src/vs/base/browser/ui/scrollbar/scrollbarArrow.ts +114 -0
  68. package/src/vs/base/browser/ui/scrollbar/scrollbarState.ts +243 -0
  69. package/src/vs/base/browser/ui/scrollbar/scrollbarVisibilityController.ts +118 -0
  70. package/src/vs/base/browser/ui/scrollbar/verticalScrollbar.ts +116 -0
  71. package/src/vs/base/browser/ui/widget.ts +57 -0
  72. package/src/vs/base/browser/window.ts +14 -0
  73. package/src/vs/base/common/arrays.ts +887 -0
  74. package/src/vs/base/common/arraysFind.ts +202 -0
  75. package/src/vs/base/common/assert.ts +71 -0
  76. package/src/vs/base/common/async.ts +1992 -0
  77. package/src/vs/base/common/cancellation.ts +148 -0
  78. package/src/vs/base/common/charCode.ts +450 -0
  79. package/src/vs/base/common/collections.ts +140 -0
  80. package/src/vs/base/common/decorators.ts +130 -0
  81. package/src/vs/base/common/equals.ts +146 -0
  82. package/src/vs/base/common/errors.ts +303 -0
  83. package/src/vs/base/common/event.ts +1778 -0
  84. package/src/vs/base/common/functional.ts +32 -0
  85. package/src/vs/base/common/hash.ts +316 -0
  86. package/src/vs/base/common/iterator.ts +159 -0
  87. package/src/vs/base/common/keyCodes.ts +526 -0
  88. package/src/vs/base/common/keybindings.ts +284 -0
  89. package/src/vs/base/common/lazy.ts +47 -0
  90. package/src/vs/base/common/lifecycle.ts +801 -0
  91. package/src/vs/base/common/linkedList.ts +142 -0
  92. package/src/vs/base/common/map.ts +202 -0
  93. package/src/vs/base/common/numbers.ts +98 -0
  94. package/src/vs/base/common/observable.ts +76 -0
  95. package/src/vs/base/common/observableInternal/api.ts +31 -0
  96. package/src/vs/base/common/observableInternal/autorun.ts +281 -0
  97. package/src/vs/base/common/observableInternal/base.ts +489 -0
  98. package/src/vs/base/common/observableInternal/debugName.ts +145 -0
  99. package/src/vs/base/common/observableInternal/derived.ts +428 -0
  100. package/src/vs/base/common/observableInternal/lazyObservableValue.ts +146 -0
  101. package/src/vs/base/common/observableInternal/logging.ts +328 -0
  102. package/src/vs/base/common/observableInternal/promise.ts +209 -0
  103. package/src/vs/base/common/observableInternal/utils.ts +610 -0
  104. package/src/vs/base/common/platform.ts +281 -0
  105. package/src/vs/base/common/scrollable.ts +522 -0
  106. package/src/vs/base/common/sequence.ts +34 -0
  107. package/src/vs/base/common/stopwatch.ts +43 -0
  108. package/src/vs/base/common/strings.ts +557 -0
  109. package/src/vs/base/common/symbols.ts +9 -0
  110. package/src/vs/base/common/uint.ts +59 -0
  111. package/src/vs/patches/nls.ts +90 -0
  112. package/src/vs/typings/base-common.d.ts +20 -0
  113. package/src/vs/typings/require.d.ts +42 -0
  114. package/src/vs/typings/vscode-globals-nls.d.ts +36 -0
  115. package/src/vs/typings/vscode-globals-product.d.ts +33 -0
  116. package/typings/xterm.d.ts +80 -14
  117. package/src/browser/Lifecycle.ts +0 -33
  118. package/src/browser/renderer/shared/CellColorResolver.ts +0 -236
  119. package/src/browser/renderer/shared/CharAtlasCache.ts +0 -96
  120. package/src/browser/renderer/shared/CharAtlasUtils.ts +0 -75
  121. package/src/browser/renderer/shared/CursorBlinkStateManager.ts +0 -146
  122. package/src/browser/renderer/shared/CustomGlyphs.ts +0 -687
  123. package/src/browser/renderer/shared/DevicePixelObserver.ts +0 -41
  124. package/src/browser/renderer/shared/TextureAtlas.ts +0 -1100
  125. package/src/browser/renderer/shared/Types.d.ts +0 -173
  126. package/src/common/EventEmitter.ts +0 -78
  127. package/src/common/Lifecycle.ts +0 -108
  128. /package/src/browser/selection/{Types.d.ts → Types.ts} +0 -0
  129. /package/src/common/parser/{Types.d.ts → Types.ts} +0 -0
@@ -3,12 +3,12 @@
3
3
  * @license MIT
4
4
  */
5
5
 
6
- import { EventEmitter } from 'common/EventEmitter';
7
- import { Disposable } from 'common/Lifecycle';
8
- import { IAttributeData, IBufferLine, ScrollSource } from 'common/Types';
6
+ import { Disposable } from 'vs/base/common/lifecycle';
7
+ import { IAttributeData, IBufferLine } from 'common/Types';
9
8
  import { BufferSet } from 'common/buffer/BufferSet';
10
9
  import { IBuffer, IBufferSet } from 'common/buffer/Types';
11
10
  import { IBufferService, IOptionsService } from 'common/services/Services';
11
+ import { Emitter } from 'vs/base/common/event';
12
12
 
13
13
  export const MINIMUM_COLS = 2; // Less than 2 can mess with wide chars
14
14
  export const MINIMUM_ROWS = 1;
@@ -22,9 +22,9 @@ export class BufferService extends Disposable implements IBufferService {
22
22
  /** Whether the user is scrolling (locks the scroll position) */
23
23
  public isUserScrolling: boolean = false;
24
24
 
25
- private readonly _onResize = this.register(new EventEmitter<{ cols: number, rows: number }>());
25
+ private readonly _onResize = this._register(new Emitter<{ cols: number, rows: number }>());
26
26
  public readonly onResize = this._onResize.event;
27
- private readonly _onScroll = this.register(new EventEmitter<number>());
27
+ private readonly _onScroll = this._register(new Emitter<number>());
28
28
  public readonly onScroll = this._onScroll.event;
29
29
 
30
30
  public get buffer(): IBuffer { return this.buffers.active; }
@@ -36,7 +36,10 @@ export class BufferService extends Disposable implements IBufferService {
36
36
  super();
37
37
  this.cols = Math.max(optionsService.rawOptions.cols || 0, MINIMUM_COLS);
38
38
  this.rows = Math.max(optionsService.rawOptions.rows || 0, MINIMUM_ROWS);
39
- this.buffers = this.register(new BufferSet(optionsService, this));
39
+ this.buffers = this._register(new BufferSet(optionsService, this));
40
+ this._register(this.buffers.onBufferActivate(e => {
41
+ this._onScroll.fire(e.activeBuffer.ydisp);
42
+ }));
40
43
  }
41
44
 
42
45
  public resize(cols: number, rows: number): void {
@@ -125,7 +128,7 @@ export class BufferService extends Disposable implements IBufferService {
125
128
  * to avoid unwanted events being handled by the viewport when the event was triggered from the
126
129
  * viewport originally.
127
130
  */
128
- public scrollLines(disp: number, suppressScrollEvent?: boolean, source?: ScrollSource): void {
131
+ public scrollLines(disp: number, suppressScrollEvent?: boolean): void {
129
132
  const buffer = this.buffer;
130
133
  if (disp < 0) {
131
134
  if (buffer.ydisp === 0) {
@@ -2,10 +2,10 @@
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';
6
- import { EventEmitter } from 'common/EventEmitter';
5
+ import { IBufferService, ICoreService, ICoreMouseService, IOptionsService } from 'common/services/Services';
7
6
  import { ICoreMouseProtocol, ICoreMouseEvent, CoreMouseEncoding, CoreMouseEventType, CoreMouseButton, CoreMouseAction } from 'common/Types';
8
- import { Disposable } from 'common/Lifecycle';
7
+ import { Disposable } from 'vs/base/common/lifecycle';
8
+ import { Emitter } from 'vs/base/common/event';
9
9
 
10
10
  /**
11
11
  * Supported default protocols.
@@ -167,18 +167,22 @@ const DEFAULT_ENCODINGS: { [key: string]: CoreMouseEncoding } = {
167
167
  * To send a mouse event call `triggerMouseEvent`.
168
168
  */
169
169
  export class CoreMouseService extends Disposable implements ICoreMouseService {
170
+ public serviceBrand: any;
171
+
170
172
  private _protocols: { [name: string]: ICoreMouseProtocol } = {};
171
173
  private _encodings: { [name: string]: CoreMouseEncoding } = {};
172
174
  private _activeProtocol: string = '';
173
175
  private _activeEncoding: string = '';
174
176
  private _lastEvent: ICoreMouseEvent | null = null;
177
+ private _wheelPartialScroll: number = 0;
175
178
 
176
- private readonly _onProtocolChange = this.register(new EventEmitter<CoreMouseEventType>());
177
- public readonly onProtocolChange = this._onProtocolChange.event;
179
+ private readonly _onProtocolChange = this._register(new Emitter<CoreMouseEventType>());
180
+ public readonly onProtocolChange = this._onProtocolChange.event;
178
181
 
179
182
  constructor(
180
183
  @IBufferService private readonly _bufferService: IBufferService,
181
- @ICoreService private readonly _coreService: ICoreService
184
+ @ICoreService private readonly _coreService: ICoreService,
185
+ @IOptionsService private readonly _optionsService: IOptionsService
182
186
  ) {
183
187
  super();
184
188
  // register default protocols and encodings
@@ -227,6 +231,49 @@ export class CoreMouseService extends Disposable implements ICoreMouseService {
227
231
  this.activeProtocol = 'NONE';
228
232
  this.activeEncoding = 'DEFAULT';
229
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;
230
277
  }
231
278
 
232
279
  /**
@@ -4,10 +4,10 @@
4
4
  */
5
5
 
6
6
  import { clone } from 'common/Clone';
7
- import { EventEmitter } from 'common/EventEmitter';
8
- import { Disposable } from 'common/Lifecycle';
7
+ import { Disposable } from 'vs/base/common/lifecycle';
9
8
  import { IDecPrivateModes, IModes } from 'common/Types';
10
9
  import { IBufferService, ICoreService, ILogService, IOptionsService } from 'common/services/Services';
10
+ import { Emitter } from 'vs/base/common/event';
11
11
 
12
12
  const DEFAULT_MODES: IModes = Object.freeze({
13
13
  insertMode: false
@@ -17,6 +17,8 @@ const DEFAULT_DEC_PRIVATE_MODES: IDecPrivateModes = Object.freeze({
17
17
  applicationCursorKeys: false,
18
18
  applicationKeypad: false,
19
19
  bracketedPasteMode: false,
20
+ cursorBlink: undefined,
21
+ cursorStyle: undefined,
20
22
  origin: false,
21
23
  reverseWraparound: false,
22
24
  sendFocus: false,
@@ -31,13 +33,13 @@ export class CoreService extends Disposable implements ICoreService {
31
33
  public modes: IModes;
32
34
  public decPrivateModes: IDecPrivateModes;
33
35
 
34
- private readonly _onData = this.register(new EventEmitter<string>());
36
+ private readonly _onData = this._register(new Emitter<string>());
35
37
  public readonly onData = this._onData.event;
36
- private readonly _onUserInput = this.register(new EventEmitter<void>());
38
+ private readonly _onUserInput = this._register(new Emitter<void>());
37
39
  public readonly onUserInput = this._onUserInput.event;
38
- private readonly _onBinary = this.register(new EventEmitter<string>());
40
+ private readonly _onBinary = this._register(new Emitter<string>());
39
41
  public readonly onBinary = this._onBinary.event;
40
- private readonly _onRequestScrollToBottom = this.register(new EventEmitter<void>());
42
+ private readonly _onRequestScrollToBottom = this._register(new Emitter<void>());
41
43
  public readonly onRequestScrollToBottom = this._onRequestScrollToBottom.event;
42
44
 
43
45
  constructor(
@@ -73,7 +75,8 @@ export class CoreService extends Disposable implements ICoreService {
73
75
  }
74
76
 
75
77
  // Fire onData API
76
- this._logService.debug(`sending data "${data}"`, () => data.split('').map(e => e.charCodeAt(0)));
78
+ this._logService.debug(`sending data "${data}"`);
79
+ this._logService.trace(`sending data (codes)`, () => data.split('').map(e => e.charCodeAt(0)));
77
80
  this._onData.fire(data);
78
81
  }
79
82
 
@@ -81,7 +84,8 @@ export class CoreService extends Disposable implements ICoreService {
81
84
  if (this._optionsService.rawOptions.disableStdin) {
82
85
  return;
83
86
  }
84
- this._logService.debug(`sending binary "${data}"`, () => data.split('').map(e => e.charCodeAt(0)));
87
+ this._logService.debug(`sending binary "${data}"`);
88
+ this._logService.trace(`sending binary (codes)`, () => data.split('').map(e => e.charCodeAt(0)));
85
89
  this._onBinary.fire(data);
86
90
  }
87
91
  }
@@ -4,12 +4,12 @@
4
4
  */
5
5
 
6
6
  import { css } from 'common/Color';
7
- import { EventEmitter } from 'common/EventEmitter';
8
- import { Disposable, toDisposable } from 'common/Lifecycle';
7
+ import { Disposable, DisposableStore, toDisposable } from 'vs/base/common/lifecycle';
9
8
  import { IDecorationService, IInternalDecoration } from 'common/services/Services';
10
9
  import { SortedList } from 'common/SortedList';
11
10
  import { IColor } from 'common/Types';
12
11
  import { IDecoration, IDecorationOptions, IMarker } from '@xterm/xterm';
12
+ import { Emitter } from 'vs/base/common/event';
13
13
 
14
14
  // Work variables to avoid garbage collection
15
15
  let $xmin = 0;
@@ -25,9 +25,9 @@ export class DecorationService extends Disposable implements IDecorationService
25
25
  */
26
26
  private readonly _decorations: SortedList<IInternalDecoration> = new SortedList(e => e?.marker.line);
27
27
 
28
- private readonly _onDecorationRegistered = this.register(new EventEmitter<IInternalDecoration>());
28
+ private readonly _onDecorationRegistered = this._register(new Emitter<IInternalDecoration>());
29
29
  public readonly onDecorationRegistered = this._onDecorationRegistered.event;
30
- private readonly _onDecorationRemoved = this.register(new EventEmitter<IInternalDecoration>());
30
+ private readonly _onDecorationRemoved = this._register(new Emitter<IInternalDecoration>());
31
31
  public readonly onDecorationRemoved = this._onDecorationRemoved.event;
32
32
 
33
33
  public get decorations(): IterableIterator<IInternalDecoration> { return this._decorations.values(); }
@@ -35,7 +35,7 @@ export class DecorationService extends Disposable implements IDecorationService
35
35
  constructor() {
36
36
  super();
37
37
 
38
- this.register(toDisposable(() => this.reset()));
38
+ this._register(toDisposable(() => this.reset()));
39
39
  }
40
40
 
41
41
  public registerDecoration(options: IDecorationOptions): IDecoration | undefined {
@@ -90,14 +90,13 @@ export class DecorationService extends Disposable implements IDecorationService
90
90
  }
91
91
  }
92
92
 
93
- class Decoration extends Disposable implements IInternalDecoration {
93
+ class Decoration extends DisposableStore implements IInternalDecoration {
94
94
  public readonly marker: IMarker;
95
95
  public element: HTMLElement | undefined;
96
- public get isDisposed(): boolean { return this._isDisposed; }
97
96
 
98
- public readonly onRenderEmitter = this.register(new EventEmitter<HTMLElement>());
97
+ public readonly onRenderEmitter = this.add(new Emitter<HTMLElement>());
99
98
  public readonly onRender = this.onRenderEmitter.event;
100
- private readonly _onDispose = this.register(new EventEmitter<void>());
99
+ private readonly _onDispose = this.add(new Emitter<void>());
101
100
  public readonly onDispose = this._onDispose.event;
102
101
 
103
102
  private _cachedBg: IColor | undefined | null = null;
@@ -67,7 +67,7 @@ export class InstantiationService implements IInstantiationService {
67
67
  for (const dependency of serviceDependencies) {
68
68
  const service = this._services.get(dependency.id);
69
69
  if (!service) {
70
- throw new Error(`[createInstance] ${ctor.name} depends on UNKNOWN service ${dependency.id}.`);
70
+ throw new Error(`[createInstance] ${ctor.name} depends on UNKNOWN service ${dependency.id._id}.`);
71
71
  }
72
72
  serviceArgs.push(service);
73
73
  }
@@ -3,7 +3,7 @@
3
3
  * @license MIT
4
4
  */
5
5
 
6
- import { Disposable } from 'common/Lifecycle';
6
+ import { Disposable } from 'vs/base/common/lifecycle';
7
7
  import { ILogService, IOptionsService, LogLevelEnum } from 'common/services/Services';
8
8
 
9
9
  type LogType = (message?: any, ...optionalParams: any[]) => void;
@@ -42,7 +42,7 @@ export class LogService extends Disposable implements ILogService {
42
42
  ) {
43
43
  super();
44
44
  this._updateLogLevel();
45
- this.register(this._optionsService.onSpecificOptionChange('logLevel', () => this._updateLogLevel()));
45
+ this._register(this._optionsService.onSpecificOptionChange('logLevel', () => this._updateLogLevel()));
46
46
 
47
47
  // For trace logging, assume the latest created log service is valid
48
48
  traceLogger = this;
@@ -3,11 +3,11 @@
3
3
  * @license MIT
4
4
  */
5
5
 
6
- import { EventEmitter } from 'common/EventEmitter';
7
- import { Disposable, toDisposable } from 'common/Lifecycle';
6
+ import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
8
7
  import { isMac } from 'common/Platform';
9
8
  import { CursorStyle, IDisposable } from 'common/Types';
10
9
  import { FontWeight, IOptionsService, ITerminalOptions } from 'common/services/Services';
10
+ import { Emitter } from 'vs/base/common/event';
11
11
 
12
12
  export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
13
13
  cols: 80,
@@ -21,7 +21,7 @@ export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
21
21
  documentOverride: null,
22
22
  fastScrollModifier: 'alt',
23
23
  fastScrollSensitivity: 5,
24
- fontFamily: 'courier-new, courier, monospace',
24
+ fontFamily: 'monospace',
25
25
  fontSize: 15,
26
26
  fontWeight: 'normal',
27
27
  fontWeightBold: 'bold',
@@ -32,6 +32,7 @@ export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
32
32
  logLevel: 'info',
33
33
  logger: null,
34
34
  scrollback: 1000,
35
+ scrollOnEraseInDisplay: false,
35
36
  scrollOnUserInput: true,
36
37
  scrollSensitivity: 1,
37
38
  screenReaderMode: false,
@@ -44,6 +45,7 @@ export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
44
45
  allowTransparency: false,
45
46
  tabStopWidth: 8,
46
47
  theme: {},
48
+ reflowCursorLine: false,
47
49
  rescaleOverlappingGlyphs: false,
48
50
  rightClickSelectsWord: isMac,
49
51
  windowOptions: {},
@@ -54,7 +56,7 @@ export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
54
56
  convertEol: false,
55
57
  termName: 'xterm',
56
58
  cancelEvents: false,
57
- overviewRulerWidth: 0
59
+ overviewRuler: {}
58
60
  };
59
61
 
60
62
  const FONT_WEIGHT_OPTIONS: Extract<FontWeight, string>[] = ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'];
@@ -65,7 +67,7 @@ export class OptionsService extends Disposable implements IOptionsService {
65
67
  public readonly rawOptions: Required<ITerminalOptions>;
66
68
  public options: Required<ITerminalOptions>;
67
69
 
68
- private readonly _onOptionChange = this.register(new EventEmitter<keyof ITerminalOptions>());
70
+ private readonly _onOptionChange = this._register(new Emitter<keyof ITerminalOptions>());
69
71
  public readonly onOptionChange = this._onOptionChange.event;
70
72
 
71
73
  constructor(options: Partial<ITerminalOptions>) {
@@ -90,7 +92,7 @@ export class OptionsService extends Disposable implements IOptionsService {
90
92
 
91
93
  // Clear out options that could link outside xterm.js as they could easily cause an embedder
92
94
  // memory leak
93
- this.register(toDisposable(() => {
95
+ this._register(toDisposable(() => {
94
96
  this.rawOptions.linkHandler = null;
95
97
  this.rawOptions.documentOverride = null;
96
98
  }));
@@ -33,7 +33,7 @@ export function createDecorator<T>(id: string): IServiceIdentifier<T> {
33
33
  storeServiceDependency(decorator, target, index);
34
34
  };
35
35
 
36
- decorator.toString = () => id;
36
+ decorator._id = id;
37
37
 
38
38
  serviceRegistry.set(id, decorator);
39
39
  return decorator;
@@ -3,11 +3,11 @@
3
3
  * @license MIT
4
4
  */
5
5
 
6
- import { IEvent, IEventEmitter } from 'common/EventEmitter';
6
+ import { IDecoration, IDecorationOptions, ILinkHandler, ILogger, IWindowsPty, type IOverviewRulerOptions } from '@xterm/xterm';
7
+ import { CoreMouseEncoding, CoreMouseEventType, CursorInactiveStyle, CursorStyle, IAttributeData, ICharset, IColor, ICoreMouseEvent, ICoreMouseProtocol, IDecPrivateModes, IDisposable, IModes, IOscLinkData, IWindowOptions } from 'common/Types';
7
8
  import { IBuffer, IBufferSet } from 'common/buffer/Types';
8
- import { IDecPrivateModes, ICoreMouseEvent, CoreMouseEncoding, ICoreMouseProtocol, CoreMouseEventType, ICharset, IWindowOptions, IModes, IAttributeData, ScrollSource, IDisposable, IColor, CursorStyle, CursorInactiveStyle, IOscLinkData } from 'common/Types';
9
9
  import { createDecorator } from 'common/services/ServiceRegistry';
10
- import { IDecorationOptions, IDecoration, ILinkHandler, IWindowsPty, ILogger } from '@xterm/xterm';
10
+ import type { Emitter, Event } from 'vs/base/common/event';
11
11
 
12
12
  export const IBufferService = createDecorator<IBufferService>('BufferService');
13
13
  export interface IBufferService {
@@ -18,16 +18,18 @@ export interface IBufferService {
18
18
  readonly buffer: IBuffer;
19
19
  readonly buffers: IBufferSet;
20
20
  isUserScrolling: boolean;
21
- onResize: IEvent<{ cols: number, rows: number }>;
22
- onScroll: IEvent<number>;
21
+ onResize: Event<{ cols: number, rows: number }>;
22
+ onScroll: Event<number>;
23
23
  scroll(eraseAttr: IAttributeData, isWrapped?: boolean): void;
24
- scrollLines(disp: number, suppressScrollEvent?: boolean, source?: ScrollSource): void;
24
+ scrollLines(disp: number, suppressScrollEvent?: boolean): void;
25
25
  resize(cols: number, rows: number): void;
26
26
  reset(): void;
27
27
  }
28
28
 
29
29
  export const ICoreMouseService = createDecorator<ICoreMouseService>('CoreMouseService');
30
30
  export interface ICoreMouseService {
31
+ serviceBrand: undefined;
32
+
31
33
  activeProtocol: string;
32
34
  activeEncoding: string;
33
35
  areMouseEventsActive: boolean;
@@ -50,12 +52,17 @@ export interface ICoreMouseService {
50
52
  /**
51
53
  * Event to announce changes in mouse tracking.
52
54
  */
53
- onProtocolChange: IEvent<CoreMouseEventType>;
55
+ onProtocolChange: Event<CoreMouseEventType>;
54
56
 
55
57
  /**
56
58
  * Human readable version of mouse events.
57
59
  */
58
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;
59
66
  }
60
67
 
61
68
  export const ICoreService = createDecorator<ICoreService>('CoreService');
@@ -72,10 +79,10 @@ export interface ICoreService {
72
79
  readonly modes: IModes;
73
80
  readonly decPrivateModes: IDecPrivateModes;
74
81
 
75
- readonly onData: IEvent<string>;
76
- readonly onUserInput: IEvent<void>;
77
- readonly onBinary: IEvent<string>;
78
- readonly onRequestScrollToBottom: IEvent<void>;
82
+ readonly onData: Event<string>;
83
+ readonly onUserInput: Event<void>;
84
+ readonly onBinary: Event<string>;
85
+ readonly onRequestScrollToBottom: Event<void>;
79
86
 
80
87
  reset(): void;
81
88
 
@@ -122,6 +129,7 @@ export interface ICharsetService {
122
129
  export interface IServiceIdentifier<T> {
123
130
  (...args: any[]): void;
124
131
  type: T;
132
+ _id: string;
125
133
  }
126
134
 
127
135
  export interface IBrandedService {
@@ -184,7 +192,7 @@ export interface IOptionsService {
184
192
  /**
185
193
  * Adds an event listener for when any option changes.
186
194
  */
187
- readonly onOptionChange: IEvent<keyof ITerminalOptions>;
195
+ readonly onOptionChange: Event<keyof ITerminalOptions>;
188
196
 
189
197
  /**
190
198
  * Adds an event listener for when a specific option changes, this is a convenience method that is
@@ -219,6 +227,7 @@ export interface ITerminalOptions {
219
227
  disableStdin?: boolean;
220
228
  documentOverride?: any | null;
221
229
  drawBoldTextInBrightColors?: boolean;
230
+ /** @deprecated No longer supported */
222
231
  fastScrollModifier?: 'none' | 'alt' | 'ctrl' | 'shift';
223
232
  fastScrollSensitivity?: number;
224
233
  fontSize?: number;
@@ -234,6 +243,7 @@ export interface ITerminalOptions {
234
243
  macOptionIsMeta?: boolean;
235
244
  macOptionClickForcesSelection?: boolean;
236
245
  minimumContrastRatio?: number;
246
+ reflowCursorLine?: boolean;
237
247
  rescaleOverlappingGlyphs?: boolean;
238
248
  rightClickSelectsWord?: boolean;
239
249
  rows?: number;
@@ -248,7 +258,8 @@ export interface ITerminalOptions {
248
258
  windowsPty?: IWindowsPty;
249
259
  windowOptions?: IWindowOptions;
250
260
  wordSeparator?: string;
251
- overviewRulerWidth?: number;
261
+ overviewRuler?: IOverviewRulerOptions;
262
+ scrollOnEraseInDisplay?: boolean;
252
263
 
253
264
  [key: string]: any;
254
265
  cancelEvents: boolean;
@@ -263,6 +274,10 @@ export interface ITheme {
263
274
  selectionForeground?: string;
264
275
  selectionBackground?: string;
265
276
  selectionInactiveBackground?: string;
277
+ scrollbarSliderBackground?: string;
278
+ scrollbarSliderHoverBackground?: string;
279
+ scrollbarSliderActiveBackground?: string;
280
+ overviewRulerBorder?: string;
266
281
  black?: string;
267
282
  red?: string;
268
283
  green?: string;
@@ -331,7 +346,7 @@ export interface IUnicodeService {
331
346
  /** Currently active version. */
332
347
  activeVersion: string;
333
348
  /** Event triggered, when activate version changed. */
334
- readonly onChange: IEvent<string>;
349
+ readonly onChange: Event<string>;
335
350
 
336
351
  /**
337
352
  * Unicode version dependent
@@ -356,8 +371,8 @@ export const IDecorationService = createDecorator<IDecorationService>('Decoratio
356
371
  export interface IDecorationService extends IDisposable {
357
372
  serviceBrand: undefined;
358
373
  readonly decorations: IterableIterator<IInternalDecoration>;
359
- readonly onDecorationRegistered: IEvent<IInternalDecoration>;
360
- readonly onDecorationRemoved: IEvent<IInternalDecoration>;
374
+ readonly onDecorationRegistered: Event<IInternalDecoration>;
375
+ readonly onDecorationRemoved: Event<IInternalDecoration>;
361
376
  registerDecoration(decorationOptions: IDecorationOptions): IDecoration | undefined;
362
377
  reset(): void;
363
378
  /**
@@ -370,5 +385,5 @@ export interface IInternalDecoration extends IDecoration {
370
385
  readonly options: IDecorationOptions;
371
386
  readonly backgroundColorRGB: IColor | undefined;
372
387
  readonly foregroundColorRGB: IColor | undefined;
373
- readonly onRenderEmitter: IEventEmitter<HTMLElement>;
388
+ readonly onRenderEmitter: Emitter<HTMLElement>;
374
389
  }
@@ -3,9 +3,9 @@
3
3
  * @license MIT
4
4
  */
5
5
 
6
- import { EventEmitter } from 'common/EventEmitter';
7
6
  import { UnicodeV6 } from 'common/input/UnicodeV6';
8
7
  import { IUnicodeService, IUnicodeVersionProvider, UnicodeCharProperties, UnicodeCharWidth } from 'common/services/Services';
8
+ import { Emitter } from 'vs/base/common/event';
9
9
 
10
10
  export class UnicodeService implements IUnicodeService {
11
11
  public serviceBrand: any;
@@ -14,7 +14,7 @@ export class UnicodeService implements IUnicodeService {
14
14
  private _active: string = '';
15
15
  private _activeProvider: IUnicodeVersionProvider;
16
16
 
17
- private readonly _onChange = new EventEmitter<string>();
17
+ private readonly _onChange = new Emitter<string>();
18
18
  public readonly onChange = this._onChange.event;
19
19
 
20
20
  public static extractShouldJoin(value: UnicodeCharProperties): boolean {
@@ -0,0 +1,141 @@
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 { CodeWindow, mainWindow } from 'vs/base/browser/window';
7
+ import { Emitter } from 'vs/base/common/event';
8
+
9
+ class WindowManager {
10
+
11
+ static readonly INSTANCE = new WindowManager();
12
+
13
+ // --- Zoom Level
14
+
15
+ private readonly mapWindowIdToZoomLevel = new Map<number, number>();
16
+
17
+ private readonly _onDidChangeZoomLevel = new Emitter<number>();
18
+ readonly onDidChangeZoomLevel = this._onDidChangeZoomLevel.event;
19
+
20
+ getZoomLevel(targetWindow: Window): number {
21
+ return this.mapWindowIdToZoomLevel.get(this.getWindowId(targetWindow)) ?? 0;
22
+ }
23
+ setZoomLevel(zoomLevel: number, targetWindow: Window): void {
24
+ if (this.getZoomLevel(targetWindow) === zoomLevel) {
25
+ return;
26
+ }
27
+
28
+ const targetWindowId = this.getWindowId(targetWindow);
29
+ this.mapWindowIdToZoomLevel.set(targetWindowId, zoomLevel);
30
+ this._onDidChangeZoomLevel.fire(targetWindowId);
31
+ }
32
+
33
+ // --- Zoom Factor
34
+
35
+ private readonly mapWindowIdToZoomFactor = new Map<number, number>();
36
+
37
+ getZoomFactor(targetWindow: Window): number {
38
+ return this.mapWindowIdToZoomFactor.get(this.getWindowId(targetWindow)) ?? 1;
39
+ }
40
+ setZoomFactor(zoomFactor: number, targetWindow: Window): void {
41
+ this.mapWindowIdToZoomFactor.set(this.getWindowId(targetWindow), zoomFactor);
42
+ }
43
+
44
+ // --- Fullscreen
45
+
46
+ private readonly _onDidChangeFullscreen = new Emitter<number>();
47
+ readonly onDidChangeFullscreen = this._onDidChangeFullscreen.event;
48
+
49
+ private readonly mapWindowIdToFullScreen = new Map<number, boolean>();
50
+
51
+ setFullscreen(fullscreen: boolean, targetWindow: Window): void {
52
+ if (this.isFullscreen(targetWindow) === fullscreen) {
53
+ return;
54
+ }
55
+
56
+ const windowId = this.getWindowId(targetWindow);
57
+ this.mapWindowIdToFullScreen.set(windowId, fullscreen);
58
+ this._onDidChangeFullscreen.fire(windowId);
59
+ }
60
+ isFullscreen(targetWindow: Window): boolean {
61
+ return !!this.mapWindowIdToFullScreen.get(this.getWindowId(targetWindow));
62
+ }
63
+
64
+ private getWindowId(targetWindow: Window): number {
65
+ return (targetWindow as CodeWindow).vscodeWindowId;
66
+ }
67
+ }
68
+
69
+ export function addMatchMediaChangeListener(targetWindow: Window, query: string | MediaQueryList, callback: (this: MediaQueryList, ev: MediaQueryListEvent) => any): void {
70
+ if (typeof query === 'string') {
71
+ query = targetWindow.matchMedia(query);
72
+ }
73
+ query.addEventListener('change', callback);
74
+ }
75
+
76
+ /** A zoom index, e.g. 1, 2, 3 */
77
+ export function setZoomLevel(zoomLevel: number, targetWindow: Window): void {
78
+ WindowManager.INSTANCE.setZoomLevel(zoomLevel, targetWindow);
79
+ }
80
+ export function getZoomLevel(targetWindow: Window): number {
81
+ return WindowManager.INSTANCE.getZoomLevel(targetWindow);
82
+ }
83
+ export const onDidChangeZoomLevel = WindowManager.INSTANCE.onDidChangeZoomLevel;
84
+
85
+ /** The zoom scale for an index, e.g. 1, 1.2, 1.4 */
86
+ export function getZoomFactor(targetWindow: Window): number {
87
+ return WindowManager.INSTANCE.getZoomFactor(targetWindow);
88
+ }
89
+ export function setZoomFactor(zoomFactor: number, targetWindow: Window): void {
90
+ WindowManager.INSTANCE.setZoomFactor(zoomFactor, targetWindow);
91
+ }
92
+
93
+ export function setFullscreen(fullscreen: boolean, targetWindow: Window): void {
94
+ WindowManager.INSTANCE.setFullscreen(fullscreen, targetWindow);
95
+ }
96
+ export function isFullscreen(targetWindow: Window): boolean {
97
+ return WindowManager.INSTANCE.isFullscreen(targetWindow);
98
+ }
99
+ export const onDidChangeFullscreen = WindowManager.INSTANCE.onDidChangeFullscreen;
100
+
101
+ const userAgent = typeof navigator === 'object' ? navigator.userAgent : '';
102
+
103
+ export const isFirefox = (userAgent.indexOf('Firefox') >= 0);
104
+ export const isWebKit = (userAgent.indexOf('AppleWebKit') >= 0);
105
+ export const isChrome = (userAgent.indexOf('Chrome') >= 0);
106
+ export const isSafari = (!isChrome && (userAgent.indexOf('Safari') >= 0));
107
+ export const isWebkitWebView = (!isChrome && !isSafari && isWebKit);
108
+ export const isElectron = (userAgent.indexOf('Electron/') >= 0);
109
+ export const isAndroid = (userAgent.indexOf('Android') >= 0);
110
+
111
+ let standalone = false;
112
+ if (typeof mainWindow.matchMedia === 'function') {
113
+ const standaloneMatchMedia = mainWindow.matchMedia('(display-mode: standalone) or (display-mode: window-controls-overlay)');
114
+ const fullScreenMatchMedia = mainWindow.matchMedia('(display-mode: fullscreen)');
115
+ standalone = standaloneMatchMedia.matches;
116
+ addMatchMediaChangeListener(mainWindow, standaloneMatchMedia, ({ matches }) => {
117
+ // entering fullscreen would change standaloneMatchMedia.matches to false
118
+ // if standalone is true (running as PWA) and entering fullscreen, skip this change
119
+ if (standalone && fullScreenMatchMedia.matches) {
120
+ return;
121
+ }
122
+ // otherwise update standalone (browser to PWA or PWA to browser)
123
+ standalone = matches;
124
+ });
125
+ }
126
+ export function isStandalone(): boolean {
127
+ return standalone;
128
+ }
129
+
130
+ // Visible means that the feature is enabled, not necessarily being rendered
131
+ // e.g. visible is true even in fullscreen mode where the controls are hidden
132
+ // See docs at https://developer.mozilla.org/en-US/docs/Web/API/WindowControlsOverlay/visible
133
+ export function isWCOEnabled(): boolean {
134
+ return (navigator as any)?.windowControlsOverlay?.visible;
135
+ }
136
+
137
+ // Returns the bounding rect of the titlebar area if it is supported and defined
138
+ // See docs at https://developer.mozilla.org/en-US/docs/Web/API/WindowControlsOverlay/getTitlebarAreaRect
139
+ export function getWCOBoundingRect(): DOMRect | undefined {
140
+ return (navigator as any)?.windowControlsOverlay?.getTitlebarAreaRect();
141
+ }