@xterm/xterm 5.6.0-beta.8 → 5.6.0-beta.80

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 (122) hide show
  1. package/README.md +6 -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 +43 -33
  8. package/src/browser/AccessibilityManager.ts +53 -25
  9. package/src/browser/{Terminal.ts → CoreBrowserTerminal.ts} +139 -148
  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 +143 -370
  14. package/src/browser/decorations/BufferDecorationRenderer.ts +14 -9
  15. package/src/browser/decorations/OverviewRulerRenderer.ts +40 -44
  16. package/src/browser/public/Terminal.ts +25 -19
  17. package/src/browser/renderer/dom/DomRenderer.ts +22 -19
  18. package/src/browser/renderer/dom/DomRendererRowFactory.ts +35 -15
  19. package/src/browser/renderer/shared/CharAtlasUtils.ts +4 -0
  20. package/src/browser/renderer/shared/CustomGlyphs.ts +6 -0
  21. package/src/browser/renderer/shared/DevicePixelObserver.ts +1 -2
  22. package/src/browser/renderer/shared/TextureAtlas.ts +3 -3
  23. package/src/browser/renderer/shared/{Types.d.ts → Types.ts} +4 -4
  24. package/src/browser/services/CharSizeService.ts +6 -6
  25. package/src/browser/services/CoreBrowserService.ts +15 -15
  26. package/src/browser/services/LinkProviderService.ts +2 -2
  27. package/src/browser/services/RenderService.ts +20 -20
  28. package/src/browser/services/SelectionService.ts +8 -8
  29. package/src/browser/services/Services.ts +13 -13
  30. package/src/browser/services/ThemeService.ts +19 -58
  31. package/src/browser/shared/Constants.ts +8 -0
  32. package/src/common/CircularList.ts +5 -5
  33. package/src/common/CoreTerminal.ts +35 -41
  34. package/src/common/InputHandler.ts +63 -51
  35. package/src/common/{Types.d.ts → Types.ts} +13 -17
  36. package/src/common/buffer/Buffer.ts +15 -7
  37. package/src/common/buffer/BufferReflow.ts +9 -6
  38. package/src/common/buffer/BufferSet.ts +5 -5
  39. package/src/common/buffer/Marker.ts +4 -4
  40. package/src/common/buffer/{Types.d.ts → Types.ts} +2 -2
  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 +7 -7
  45. package/src/common/services/CoreMouseService.ts +5 -3
  46. package/src/common/services/CoreService.ts +8 -6
  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 +6 -5
  51. package/src/common/services/ServiceRegistry.ts +1 -1
  52. package/src/common/services/Services.ts +26 -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/thenable.d.ts +12 -0
  115. package/src/vs/typings/vscode-globals-nls.d.ts +36 -0
  116. package/src/vs/typings/vscode-globals-product.d.ts +33 -0
  117. package/typings/xterm.d.ts +66 -15
  118. package/src/browser/Lifecycle.ts +0 -33
  119. package/src/common/EventEmitter.ts +0 -78
  120. package/src/common/Lifecycle.ts +0 -108
  121. /package/src/browser/selection/{Types.d.ts → Types.ts} +0 -0
  122. /package/src/common/parser/{Types.d.ts → Types.ts} +0 -0
@@ -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(
@@ -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,
@@ -44,6 +44,7 @@ export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
44
44
  allowTransparency: false,
45
45
  tabStopWidth: 8,
46
46
  theme: {},
47
+ reflowCursorLine: false,
47
48
  rescaleOverlappingGlyphs: false,
48
49
  rightClickSelectsWord: isMac,
49
50
  windowOptions: {},
@@ -54,7 +55,7 @@ export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
54
55
  convertEol: false,
55
56
  termName: 'xterm',
56
57
  cancelEvents: false,
57
- overviewRulerWidth: 0
58
+ overviewRuler: {}
58
59
  };
59
60
 
60
61
  const FONT_WEIGHT_OPTIONS: Extract<FontWeight, string>[] = ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'];
@@ -65,7 +66,7 @@ export class OptionsService extends Disposable implements IOptionsService {
65
66
  public readonly rawOptions: Required<ITerminalOptions>;
66
67
  public options: Required<ITerminalOptions>;
67
68
 
68
- private readonly _onOptionChange = this.register(new EventEmitter<keyof ITerminalOptions>());
69
+ private readonly _onOptionChange = this._register(new Emitter<keyof ITerminalOptions>());
69
70
  public readonly onOptionChange = this._onOptionChange.event;
70
71
 
71
72
  constructor(options: Partial<ITerminalOptions>) {
@@ -90,7 +91,7 @@ export class OptionsService extends Disposable implements IOptionsService {
90
91
 
91
92
  // Clear out options that could link outside xterm.js as they could easily cause an embedder
92
93
  // memory leak
93
- this.register(toDisposable(() => {
94
+ this._register(toDisposable(() => {
94
95
  this.rawOptions.linkHandler = null;
95
96
  this.rawOptions.documentOverride = null;
96
97
  }));
@@ -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,7 +52,7 @@ 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.
@@ -72,10 +74,10 @@ export interface ICoreService {
72
74
  readonly modes: IModes;
73
75
  readonly decPrivateModes: IDecPrivateModes;
74
76
 
75
- readonly onData: IEvent<string>;
76
- readonly onUserInput: IEvent<void>;
77
- readonly onBinary: IEvent<string>;
78
- readonly onRequestScrollToBottom: IEvent<void>;
77
+ readonly onData: Event<string>;
78
+ readonly onUserInput: Event<void>;
79
+ readonly onBinary: Event<string>;
80
+ readonly onRequestScrollToBottom: Event<void>;
79
81
 
80
82
  reset(): void;
81
83
 
@@ -122,6 +124,7 @@ export interface ICharsetService {
122
124
  export interface IServiceIdentifier<T> {
123
125
  (...args: any[]): void;
124
126
  type: T;
127
+ _id: string;
125
128
  }
126
129
 
127
130
  export interface IBrandedService {
@@ -184,7 +187,7 @@ export interface IOptionsService {
184
187
  /**
185
188
  * Adds an event listener for when any option changes.
186
189
  */
187
- readonly onOptionChange: IEvent<keyof ITerminalOptions>;
190
+ readonly onOptionChange: Event<keyof ITerminalOptions>;
188
191
 
189
192
  /**
190
193
  * Adds an event listener for when a specific option changes, this is a convenience method that is
@@ -219,6 +222,7 @@ export interface ITerminalOptions {
219
222
  disableStdin?: boolean;
220
223
  documentOverride?: any | null;
221
224
  drawBoldTextInBrightColors?: boolean;
225
+ /** @deprecated No longer supported */
222
226
  fastScrollModifier?: 'none' | 'alt' | 'ctrl' | 'shift';
223
227
  fastScrollSensitivity?: number;
224
228
  fontSize?: number;
@@ -234,6 +238,7 @@ export interface ITerminalOptions {
234
238
  macOptionIsMeta?: boolean;
235
239
  macOptionClickForcesSelection?: boolean;
236
240
  minimumContrastRatio?: number;
241
+ reflowCursorLine?: boolean;
237
242
  rescaleOverlappingGlyphs?: boolean;
238
243
  rightClickSelectsWord?: boolean;
239
244
  rows?: number;
@@ -248,7 +253,7 @@ export interface ITerminalOptions {
248
253
  windowsPty?: IWindowsPty;
249
254
  windowOptions?: IWindowOptions;
250
255
  wordSeparator?: string;
251
- overviewRulerWidth?: number;
256
+ overviewRuler?: IOverviewRulerOptions;
252
257
 
253
258
  [key: string]: any;
254
259
  cancelEvents: boolean;
@@ -263,6 +268,10 @@ export interface ITheme {
263
268
  selectionForeground?: string;
264
269
  selectionBackground?: string;
265
270
  selectionInactiveBackground?: string;
271
+ scrollbarSliderBackground?: string;
272
+ scrollbarSliderHoverBackground?: string;
273
+ scrollbarSliderActiveBackground?: string;
274
+ overviewRulerBorder?: string;
266
275
  black?: string;
267
276
  red?: string;
268
277
  green?: string;
@@ -331,7 +340,7 @@ export interface IUnicodeService {
331
340
  /** Currently active version. */
332
341
  activeVersion: string;
333
342
  /** Event triggered, when activate version changed. */
334
- readonly onChange: IEvent<string>;
343
+ readonly onChange: Event<string>;
335
344
 
336
345
  /**
337
346
  * Unicode version dependent
@@ -356,8 +365,8 @@ export const IDecorationService = createDecorator<IDecorationService>('Decoratio
356
365
  export interface IDecorationService extends IDisposable {
357
366
  serviceBrand: undefined;
358
367
  readonly decorations: IterableIterator<IInternalDecoration>;
359
- readonly onDecorationRegistered: IEvent<IInternalDecoration>;
360
- readonly onDecorationRemoved: IEvent<IInternalDecoration>;
368
+ readonly onDecorationRegistered: Event<IInternalDecoration>;
369
+ readonly onDecorationRemoved: Event<IInternalDecoration>;
361
370
  registerDecoration(decorationOptions: IDecorationOptions): IDecoration | undefined;
362
371
  reset(): void;
363
372
  /**
@@ -370,5 +379,5 @@ export interface IInternalDecoration extends IDecoration {
370
379
  readonly options: IDecorationOptions;
371
380
  readonly backgroundColorRGB: IColor | undefined;
372
381
  readonly foregroundColorRGB: IColor | undefined;
373
- readonly onRenderEmitter: IEventEmitter<HTMLElement>;
382
+ readonly onRenderEmitter: Emitter<HTMLElement>;
374
383
  }
@@ -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
+ }
@@ -0,0 +1,49 @@
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 { mainWindow } from 'vs/base/browser/window';
8
+ import * as platform from 'vs/base/common/platform';
9
+
10
+ export const enum KeyboardSupport {
11
+ Always,
12
+ FullScreen,
13
+ None
14
+ }
15
+
16
+ const safeNavigator = typeof navigator === 'object' ? navigator : {} as { [key: string]: any };
17
+
18
+ /**
19
+ * Browser feature we can support in current platform, browser and environment.
20
+ */
21
+ export const BrowserFeatures = {
22
+ clipboard: {
23
+ writeText: (
24
+ platform.isNative
25
+ || (document.queryCommandSupported && document.queryCommandSupported('copy'))
26
+ || !!(safeNavigator && safeNavigator.clipboard && safeNavigator.clipboard.writeText)
27
+ ),
28
+ readText: (
29
+ platform.isNative
30
+ || !!(safeNavigator && safeNavigator.clipboard && safeNavigator.clipboard.readText)
31
+ )
32
+ },
33
+ keyboard: (() => {
34
+ if (platform.isNative || browser.isStandalone()) {
35
+ return KeyboardSupport.Always;
36
+ }
37
+
38
+ if ((<any>safeNavigator).keyboard || browser.isSafari) {
39
+ return KeyboardSupport.FullScreen;
40
+ }
41
+
42
+ return KeyboardSupport.None;
43
+ })(),
44
+
45
+ // 'ontouchstart' in window always evaluates to true with typescript's modern typings. This causes `window` to be
46
+ // `never` later in `window.navigator`. That's why we need the explicit `window as Window` cast
47
+ touch: 'ontouchstart' in mainWindow || safeNavigator.maxTouchPoints > 0,
48
+ pointerEvents: mainWindow.PointerEvent && ('ontouchstart' in mainWindow || navigator.maxTouchPoints > 0)
49
+ };