@xterm/xterm 6.1.0-beta.22 → 6.1.0-beta.220

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 (160) hide show
  1. package/README.md +62 -38
  2. package/css/xterm.css +29 -22
  3. package/lib/xterm.js +1 -1
  4. package/lib/xterm.js.map +1 -1
  5. package/lib/xterm.mjs +8 -34
  6. package/lib/xterm.mjs.map +4 -4
  7. package/package.json +25 -22
  8. package/src/browser/AccessibilityManager.ts +11 -6
  9. package/src/browser/Clipboard.ts +6 -3
  10. package/src/browser/CoreBrowserTerminal.ts +147 -318
  11. package/src/browser/Dom.ts +178 -0
  12. package/src/browser/Linkifier.ts +11 -11
  13. package/src/browser/OscLinkProvider.ts +3 -1
  14. package/src/browser/RenderDebouncer.ts +2 -2
  15. package/src/browser/TimeBasedDebouncer.ts +2 -2
  16. package/src/browser/Types.ts +12 -11
  17. package/src/browser/Viewport.ts +55 -20
  18. package/src/browser/decorations/BufferDecorationRenderer.ts +1 -1
  19. package/src/browser/decorations/OverviewRulerRenderer.ts +33 -17
  20. package/src/browser/input/CompositionHelper.ts +44 -8
  21. package/src/browser/public/Terminal.ts +25 -28
  22. package/src/browser/renderer/dom/DomRenderer.ts +242 -76
  23. package/src/browser/renderer/dom/DomRendererRowFactory.ts +19 -13
  24. package/src/browser/renderer/dom/WidthCache.ts +54 -52
  25. package/src/browser/renderer/shared/Constants.ts +7 -0
  26. package/src/browser/renderer/shared/TextBlinkStateManager.ts +97 -0
  27. package/src/browser/renderer/shared/Types.ts +8 -2
  28. package/src/browser/scrollable/abstractScrollbar.ts +300 -0
  29. package/src/browser/scrollable/fastDomNode.ts +126 -0
  30. package/src/browser/scrollable/globalPointerMoveMonitor.ts +90 -0
  31. package/src/browser/scrollable/horizontalScrollbar.ts +85 -0
  32. package/src/browser/scrollable/mouseEvent.ts +292 -0
  33. package/src/browser/scrollable/scrollable.ts +486 -0
  34. package/src/browser/scrollable/scrollableElement.ts +581 -0
  35. package/src/browser/scrollable/scrollableElementOptions.ts +161 -0
  36. package/src/browser/scrollable/scrollbarArrow.ts +110 -0
  37. package/src/browser/scrollable/scrollbarState.ts +246 -0
  38. package/src/browser/scrollable/scrollbarVisibilityController.ts +113 -0
  39. package/src/browser/scrollable/touch.ts +485 -0
  40. package/src/browser/scrollable/verticalScrollbar.ts +143 -0
  41. package/src/browser/scrollable/widget.ts +23 -0
  42. package/src/browser/services/CharSizeService.ts +2 -2
  43. package/src/browser/services/CoreBrowserService.ts +7 -5
  44. package/src/browser/services/KeyboardService.ts +67 -0
  45. package/src/browser/services/LinkProviderService.ts +1 -1
  46. package/src/browser/services/MouseCoordsService.ts +47 -0
  47. package/src/browser/services/MouseService.ts +518 -25
  48. package/src/browser/services/RenderService.ts +22 -15
  49. package/src/browser/services/SelectionService.ts +42 -35
  50. package/src/browser/services/Services.ts +40 -17
  51. package/src/browser/services/ThemeService.ts +2 -2
  52. package/src/common/Async.ts +105 -0
  53. package/src/common/CircularList.ts +2 -2
  54. package/src/common/Color.ts +8 -0
  55. package/src/common/CoreTerminal.ts +31 -21
  56. package/src/common/Event.ts +118 -0
  57. package/src/common/InputHandler.ts +283 -81
  58. package/src/common/Lifecycle.ts +113 -0
  59. package/src/common/Platform.ts +13 -3
  60. package/src/common/SortedList.ts +7 -3
  61. package/src/common/TaskQueue.ts +14 -5
  62. package/src/common/Types.ts +35 -15
  63. package/src/common/Version.ts +9 -0
  64. package/src/common/buffer/Buffer.ts +34 -19
  65. package/src/common/buffer/BufferLine.ts +133 -65
  66. package/src/common/buffer/BufferLineStringCache.ts +69 -0
  67. package/src/common/buffer/BufferSet.ts +11 -6
  68. package/src/common/buffer/CellData.ts +57 -0
  69. package/src/common/buffer/Marker.ts +2 -2
  70. package/src/common/buffer/Types.ts +6 -2
  71. package/src/common/data/EscapeSequences.ts +71 -70
  72. package/src/common/input/Keyboard.ts +14 -7
  73. package/src/common/input/KittyKeyboard.ts +526 -0
  74. package/src/common/input/Win32InputMode.ts +297 -0
  75. package/src/common/input/WriteBuffer.ts +64 -32
  76. package/src/common/input/XParseColor.ts +2 -2
  77. package/src/common/parser/ApcParser.ts +197 -0
  78. package/src/common/parser/Constants.ts +14 -4
  79. package/src/common/parser/DcsParser.ts +5 -5
  80. package/src/common/parser/EscapeSequenceParser.ts +205 -63
  81. package/src/common/parser/OscParser.ts +5 -5
  82. package/src/common/parser/Params.ts +27 -8
  83. package/src/common/parser/Types.ts +36 -2
  84. package/src/common/public/BufferLineApiView.ts +2 -2
  85. package/src/common/public/BufferNamespaceApi.ts +2 -2
  86. package/src/common/public/ParserApi.ts +3 -0
  87. package/src/common/services/BufferService.ts +14 -9
  88. package/src/common/services/CharsetService.ts +4 -0
  89. package/src/common/services/CoreService.ts +18 -4
  90. package/src/common/services/DecorationService.ts +24 -8
  91. package/src/common/services/LogService.ts +1 -31
  92. package/src/common/services/{CoreMouseService.ts → MouseStateService.ts} +21 -132
  93. package/src/common/services/OptionsService.ts +13 -4
  94. package/src/common/services/ServiceRegistry.ts +9 -7
  95. package/src/common/services/Services.ts +47 -40
  96. package/src/common/services/UnicodeService.ts +1 -1
  97. package/typings/xterm.d.ts +318 -34
  98. package/src/common/TypedArrayUtils.ts +0 -17
  99. package/src/vs/base/browser/browser.ts +0 -141
  100. package/src/vs/base/browser/canIUse.ts +0 -49
  101. package/src/vs/base/browser/dom.ts +0 -2369
  102. package/src/vs/base/browser/fastDomNode.ts +0 -316
  103. package/src/vs/base/browser/globalPointerMoveMonitor.ts +0 -112
  104. package/src/vs/base/browser/iframe.ts +0 -135
  105. package/src/vs/base/browser/keyboardEvent.ts +0 -213
  106. package/src/vs/base/browser/mouseEvent.ts +0 -229
  107. package/src/vs/base/browser/touch.ts +0 -372
  108. package/src/vs/base/browser/ui/scrollbar/abstractScrollbar.ts +0 -303
  109. package/src/vs/base/browser/ui/scrollbar/horizontalScrollbar.ts +0 -114
  110. package/src/vs/base/browser/ui/scrollbar/scrollableElement.ts +0 -720
  111. package/src/vs/base/browser/ui/scrollbar/scrollableElementOptions.ts +0 -165
  112. package/src/vs/base/browser/ui/scrollbar/scrollbarArrow.ts +0 -114
  113. package/src/vs/base/browser/ui/scrollbar/scrollbarState.ts +0 -243
  114. package/src/vs/base/browser/ui/scrollbar/scrollbarVisibilityController.ts +0 -118
  115. package/src/vs/base/browser/ui/scrollbar/verticalScrollbar.ts +0 -116
  116. package/src/vs/base/browser/ui/widget.ts +0 -57
  117. package/src/vs/base/browser/window.ts +0 -14
  118. package/src/vs/base/common/arrays.ts +0 -887
  119. package/src/vs/base/common/arraysFind.ts +0 -202
  120. package/src/vs/base/common/assert.ts +0 -71
  121. package/src/vs/base/common/async.ts +0 -1992
  122. package/src/vs/base/common/cancellation.ts +0 -148
  123. package/src/vs/base/common/charCode.ts +0 -450
  124. package/src/vs/base/common/collections.ts +0 -140
  125. package/src/vs/base/common/decorators.ts +0 -130
  126. package/src/vs/base/common/equals.ts +0 -146
  127. package/src/vs/base/common/errors.ts +0 -303
  128. package/src/vs/base/common/event.ts +0 -1778
  129. package/src/vs/base/common/functional.ts +0 -32
  130. package/src/vs/base/common/hash.ts +0 -316
  131. package/src/vs/base/common/iterator.ts +0 -159
  132. package/src/vs/base/common/keyCodes.ts +0 -526
  133. package/src/vs/base/common/keybindings.ts +0 -284
  134. package/src/vs/base/common/lazy.ts +0 -47
  135. package/src/vs/base/common/lifecycle.ts +0 -801
  136. package/src/vs/base/common/linkedList.ts +0 -142
  137. package/src/vs/base/common/map.ts +0 -202
  138. package/src/vs/base/common/numbers.ts +0 -98
  139. package/src/vs/base/common/observable.ts +0 -76
  140. package/src/vs/base/common/observableInternal/api.ts +0 -31
  141. package/src/vs/base/common/observableInternal/autorun.ts +0 -281
  142. package/src/vs/base/common/observableInternal/base.ts +0 -489
  143. package/src/vs/base/common/observableInternal/debugName.ts +0 -145
  144. package/src/vs/base/common/observableInternal/derived.ts +0 -428
  145. package/src/vs/base/common/observableInternal/lazyObservableValue.ts +0 -146
  146. package/src/vs/base/common/observableInternal/logging.ts +0 -328
  147. package/src/vs/base/common/observableInternal/promise.ts +0 -209
  148. package/src/vs/base/common/observableInternal/utils.ts +0 -610
  149. package/src/vs/base/common/platform.ts +0 -281
  150. package/src/vs/base/common/scrollable.ts +0 -522
  151. package/src/vs/base/common/sequence.ts +0 -34
  152. package/src/vs/base/common/stopwatch.ts +0 -43
  153. package/src/vs/base/common/strings.ts +0 -557
  154. package/src/vs/base/common/symbols.ts +0 -9
  155. package/src/vs/base/common/uint.ts +0 -59
  156. package/src/vs/patches/nls.ts +0 -90
  157. package/src/vs/typings/base-common.d.ts +0 -20
  158. package/src/vs/typings/require.d.ts +0 -42
  159. package/src/vs/typings/vscode-globals-nls.d.ts +0 -36
  160. package/src/vs/typings/vscode-globals-product.d.ts +0 -33
@@ -32,6 +32,7 @@ export interface IParams {
32
32
  clone(): IParams;
33
33
  toArray(): ParamsArray;
34
34
  reset(): void;
35
+ resetZdm(): void;
35
36
  addParam(value: number): void;
36
37
  addSubParam(value: number): void;
37
38
  hasSubParams(idx: number): boolean;
@@ -107,7 +108,7 @@ export type EscFallbackHandlerType = (identifier: number) => void;
107
108
  /**
108
109
  * EXECUTE handler types.
109
110
  */
110
- export type ExecuteHandlerType = () => boolean;
111
+ export type ExecuteHandlerType = (ident?: number) => boolean;
111
112
  export type ExecuteFallbackHandlerType = (ident: number) => void;
112
113
 
113
114
  /**
@@ -134,6 +135,29 @@ export interface IOscHandler {
134
135
  }
135
136
  export type OscFallbackHandlerType = (ident: number, action: 'START' | 'PUT' | 'END', payload?: any) => void;
136
137
 
138
+ /**
139
+ * APC handler types.
140
+ */
141
+ export interface IApcHandler {
142
+ /**
143
+ * Announces start of this APC command.
144
+ * Prepare needed data structures here.
145
+ */
146
+ start(): void;
147
+ /**
148
+ * Incoming data chunk.
149
+ */
150
+ put(data: Uint32Array, start: number, end: number): void;
151
+ /**
152
+ * End of APC command. `success` indicates whether the
153
+ * command finished normally or got aborted, thus final
154
+ * execution of the command should depend on `success`.
155
+ * To save memory also cleanup data structures here.
156
+ */
157
+ end(success: boolean): boolean | Promise<boolean>;
158
+ }
159
+ export type ApcFallbackHandlerType = (ident: number, action: 'START' | 'PUT' | 'END', payload?: any) => void;
160
+
137
161
  /**
138
162
  * PRINT handler types.
139
163
  */
@@ -196,6 +220,10 @@ export interface IEscapeSequenceParser extends IDisposable {
196
220
  clearOscHandler(ident: number): void;
197
221
  setOscHandlerFallback(handler: OscFallbackHandlerType): void;
198
222
 
223
+ registerApcHandler(id: IFunctionIdentifier, handler: IApcHandler): IDisposable;
224
+ clearApcHandler(id: IFunctionIdentifier): void;
225
+ setApcHandlerFallback(handler: ApcFallbackHandlerType): void;
226
+
199
227
  setErrorHandler(handler: (state: IParsingState) => IParsingState): void;
200
228
  clearErrorHandler(): void;
201
229
  }
@@ -223,6 +251,11 @@ export interface IDcsParser extends ISubParser<IDcsHandler, DcsFallbackHandlerTy
223
251
  unhook(success: boolean, promiseResult?: boolean): void | Promise<boolean>;
224
252
  }
225
253
 
254
+ export interface IApcParser extends ISubParser<IApcHandler, ApcFallbackHandlerType> {
255
+ start(ident: number): void;
256
+ end(success: boolean, promiseResult?: boolean): void | Promise<boolean>;
257
+ }
258
+
226
259
  /**
227
260
  * Interface to denote a specific ESC, CSI or DCS handler slot.
228
261
  * The values are used to create an integer respresentation during handler
@@ -252,7 +285,8 @@ export const enum ParserStackType {
252
285
  CSI,
253
286
  ESC,
254
287
  OSC,
255
- DCS
288
+ DCS,
289
+ APC
256
290
  }
257
291
 
258
292
  // aggregate of resumable handler lists
@@ -18,10 +18,10 @@ export class BufferLineApiView implements IBufferLineApi {
18
18
  }
19
19
 
20
20
  if (cell) {
21
- this._line.loadCell(x, cell as ICellData);
21
+ this._line.loadCell(x, cell as unknown as ICellData);
22
22
  return cell;
23
23
  }
24
- return this._line.loadCell(x, new CellData());
24
+ return this._line.loadCell(x, new CellData()) as unknown as IBufferCellApi;
25
25
  }
26
26
  public translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string {
27
27
  return this._line.translateToString(trimRight, startColumn, endColumn);
@@ -6,8 +6,8 @@
6
6
  import { IBuffer as IBufferApi, IBufferNamespace as IBufferNamespaceApi } from '@xterm/xterm';
7
7
  import { BufferApiView } from 'common/public/BufferApiView';
8
8
  import { ICoreTerminal } from 'common/Types';
9
- import { Disposable } from 'vs/base/common/lifecycle';
10
- import { Emitter } from 'vs/base/common/event';
9
+ import { Disposable } from 'common/Lifecycle';
10
+ import { Emitter } from 'common/Event';
11
11
 
12
12
  export class BufferNamespaceApi extends Disposable implements IBufferNamespaceApi {
13
13
  private _normal: BufferApiView;
@@ -34,4 +34,7 @@ export class ParserApi implements IParser {
34
34
  public addOscHandler(ident: number, callback: (data: string) => boolean | Promise<boolean>): IDisposable {
35
35
  return this.registerOscHandler(ident, callback);
36
36
  }
37
+ public registerApcHandler(id: IFunctionIdentifier, callback: (data: string) => boolean | Promise<boolean>): IDisposable {
38
+ return this._core.registerApcHandler(id, callback);
39
+ }
37
40
  }
@@ -3,15 +3,17 @@
3
3
  * @license MIT
4
4
  */
5
5
 
6
- import { Disposable } from 'vs/base/common/lifecycle';
6
+ import { Disposable } from 'common/Lifecycle';
7
7
  import { IAttributeData, IBufferLine } from 'common/Types';
8
8
  import { BufferSet } from 'common/buffer/BufferSet';
9
9
  import { IBuffer, IBufferSet } from 'common/buffer/Types';
10
- import { IBufferService, IOptionsService, type IBufferResizeEvent } from 'common/services/Services';
11
- import { Emitter } from 'vs/base/common/event';
10
+ import { IBufferService, ILogService, IOptionsService, type IBufferResizeEvent } from 'common/services/Services';
11
+ import { Emitter } from 'common/Event';
12
12
 
13
- export const MINIMUM_COLS = 2; // Less than 2 can mess with wide chars
14
- export const MINIMUM_ROWS = 1;
13
+ export const enum BufferServiceConstants {
14
+ MINIMUM_COLS = 2, // Less than 2 can mess with wide chars
15
+ MINIMUM_ROWS = 1
16
+ }
15
17
 
16
18
  export class BufferService extends Disposable implements IBufferService {
17
19
  public serviceBrand: any;
@@ -32,11 +34,14 @@ export class BufferService extends Disposable implements IBufferService {
32
34
  /** An IBufferline to clone/copy from for new blank lines */
33
35
  private _cachedBlankLine: IBufferLine | undefined;
34
36
 
35
- constructor(@IOptionsService optionsService: IOptionsService) {
37
+ constructor(
38
+ @IOptionsService optionsService: IOptionsService,
39
+ @ILogService logService: ILogService
40
+ ) {
36
41
  super();
37
- this.cols = Math.max(optionsService.rawOptions.cols || 0, MINIMUM_COLS);
38
- this.rows = Math.max(optionsService.rawOptions.rows || 0, MINIMUM_ROWS);
39
- this.buffers = this._register(new BufferSet(optionsService, this));
42
+ this.cols = Math.max(optionsService.rawOptions.cols || 0, BufferServiceConstants.MINIMUM_COLS);
43
+ this.rows = Math.max(optionsService.rawOptions.rows || 0, BufferServiceConstants.MINIMUM_ROWS);
44
+ this.buffers = this._register(new BufferSet(optionsService, this, logService));
40
45
  this._register(this.buffers.onBufferActivate(e => {
41
46
  this._onScroll.fire(e.activeBuffer.ydisp);
42
47
  }));
@@ -14,6 +14,10 @@ export class CharsetService implements ICharsetService {
14
14
 
15
15
  private _charsets: (ICharset | undefined)[] = [];
16
16
 
17
+ public get charsets(): (ICharset | undefined)[] {
18
+ return this._charsets;
19
+ }
20
+
17
21
  public reset(): void {
18
22
  this.charset = undefined;
19
23
  this._charsets = [];
@@ -4,10 +4,10 @@
4
4
  */
5
5
 
6
6
  import { clone } from 'common/Clone';
7
- import { Disposable } from 'vs/base/common/lifecycle';
8
- import { IDecPrivateModes, IModes } from 'common/Types';
7
+ import { Disposable } from 'common/Lifecycle';
8
+ import { IDecPrivateModes, IKittyKeyboardState, IModes } from 'common/Types';
9
9
  import { IBufferService, ICoreService, ILogService, IOptionsService } from 'common/services/Services';
10
- import { Emitter } from 'vs/base/common/event';
10
+ import { Emitter } from 'common/Event';
11
11
 
12
12
  const DEFAULT_MODES: IModes = Object.freeze({
13
13
  insertMode: false
@@ -17,22 +17,33 @@ const DEFAULT_DEC_PRIVATE_MODES: IDecPrivateModes = Object.freeze({
17
17
  applicationCursorKeys: false,
18
18
  applicationKeypad: false,
19
19
  bracketedPasteMode: false,
20
+ colorSchemeUpdates: false,
20
21
  cursorBlink: undefined,
21
22
  cursorStyle: undefined,
22
23
  origin: false,
23
24
  reverseWraparound: false,
24
25
  sendFocus: false,
25
26
  synchronizedOutput: false,
27
+ win32InputMode: false,
26
28
  wraparound: true // defaults: xterm - true, vt100 - false
27
29
  });
28
30
 
31
+ const DEFAULT_KITTY_KEYBOARD_STATE = (): IKittyKeyboardState => ({
32
+ flags: 0,
33
+ mainFlags: 0,
34
+ altFlags: 0,
35
+ mainStack: [],
36
+ altStack: []
37
+ });
38
+
29
39
  export class CoreService extends Disposable implements ICoreService {
30
40
  public serviceBrand: any;
31
41
 
32
- public isCursorInitialized: boolean = false;
42
+ public isCursorInitialized: boolean;
33
43
  public isCursorHidden: boolean = false;
34
44
  public modes: IModes;
35
45
  public decPrivateModes: IDecPrivateModes;
46
+ public kittyKeyboard: IKittyKeyboardState;
36
47
 
37
48
  private readonly _onData = this._register(new Emitter<string>());
38
49
  public readonly onData = this._onData.event;
@@ -49,13 +60,16 @@ export class CoreService extends Disposable implements ICoreService {
49
60
  @IOptionsService private readonly _optionsService: IOptionsService
50
61
  ) {
51
62
  super();
63
+ this.isCursorInitialized = _optionsService.rawOptions.showCursorImmediately ?? false;
52
64
  this.modes = clone(DEFAULT_MODES);
53
65
  this.decPrivateModes = clone(DEFAULT_DEC_PRIVATE_MODES);
66
+ this.kittyKeyboard = DEFAULT_KITTY_KEYBOARD_STATE();
54
67
  }
55
68
 
56
69
  public reset(): void {
57
70
  this.modes = clone(DEFAULT_MODES);
58
71
  this.decPrivateModes = clone(DEFAULT_DEC_PRIVATE_MODES);
72
+ this.kittyKeyboard = DEFAULT_KITTY_KEYBOARD_STATE();
59
73
  }
60
74
 
61
75
  public triggerDataEvent(data: string, wasUserInput: boolean = false): void {
@@ -4,16 +4,18 @@
4
4
  */
5
5
 
6
6
  import { css } from 'common/Color';
7
- import { Disposable, DisposableStore, toDisposable } from 'vs/base/common/lifecycle';
8
- import { IDecorationService, IInternalDecoration } from 'common/services/Services';
7
+ import { Disposable, DisposableStore, toDisposable } from 'common/Lifecycle';
8
+ import { IDecorationService, IInternalDecoration, ILogService } from 'common/services/Services';
9
9
  import { SortedList } from 'common/SortedList';
10
10
  import { IColor } from 'common/Types';
11
11
  import { IDecoration, IDecorationOptions, IMarker } from '@xterm/xterm';
12
- import { Emitter } from 'vs/base/common/event';
12
+ import { Emitter } from 'common/Event';
13
13
 
14
14
  // Work variables to avoid garbage collection
15
15
  let $xmin = 0;
16
16
  let $xmax = 0;
17
+ let $ymin = 0;
18
+ let $ymax = 0;
17
19
 
18
20
  export class DecorationService extends Disposable implements IDecorationService {
19
21
  public serviceBrand: any;
@@ -23,7 +25,7 @@ export class DecorationService extends Disposable implements IDecorationService
23
25
  * while marker line values do change, they should all change by the same amount so this should
24
26
  * never become out of order.
25
27
  */
26
- private readonly _decorations: SortedList<IInternalDecoration> = new SortedList(e => e?.marker.line);
28
+ private readonly _decorations: SortedList<IInternalDecoration>;
27
29
 
28
30
  private readonly _onDecorationRegistered = this._register(new Emitter<IInternalDecoration>());
29
31
  public readonly onDecorationRegistered = this._onDecorationRegistered.event;
@@ -32,9 +34,11 @@ export class DecorationService extends Disposable implements IDecorationService
32
34
 
33
35
  public get decorations(): IterableIterator<IInternalDecoration> { return this._decorations.values(); }
34
36
 
35
- constructor() {
37
+ constructor(@ILogService private readonly _logService: ILogService) {
36
38
  super();
37
39
 
40
+ this._decorations = new SortedList(e => e?.marker.line, this._logService);
41
+
38
42
  this._register(toDisposable(() => this.reset()));
39
43
  }
40
44
 
@@ -70,7 +74,14 @@ export class DecorationService extends Disposable implements IDecorationService
70
74
  public *getDecorationsAtCell(x: number, line: number, layer?: 'bottom' | 'top'): IterableIterator<IInternalDecoration> {
71
75
  let xmin = 0;
72
76
  let xmax = 0;
73
- for (const d of this._decorations.getKeyIterator(line)) {
77
+ let ymin = 0;
78
+ let ymax = 0;
79
+ for (const d of this._decorations.values()) {
80
+ ymin = d.marker.line;
81
+ ymax = ymin + (d.options.height ?? 1);
82
+ if (line < ymin || line >= ymax) {
83
+ continue;
84
+ }
74
85
  xmin = d.options.x ?? 0;
75
86
  xmax = xmin + (d.options.width ?? 1);
76
87
  if (x >= xmin && x < xmax && (!layer || (d.options.layer ?? 'bottom') === layer)) {
@@ -80,13 +91,18 @@ export class DecorationService extends Disposable implements IDecorationService
80
91
  }
81
92
 
82
93
  public forEachDecorationAtCell(x: number, line: number, layer: 'bottom' | 'top' | undefined, callback: (decoration: IInternalDecoration) => void): void {
83
- this._decorations.forEachByKey(line, d => {
94
+ for (const d of this._decorations.values()) {
95
+ $ymin = d.marker.line;
96
+ $ymax = $ymin + (d.options.height ?? 1);
97
+ if (line < $ymin || line >= $ymax) {
98
+ continue;
99
+ }
84
100
  $xmin = d.options.x ?? 0;
85
101
  $xmax = $xmin + (d.options.width ?? 1);
86
102
  if (x >= $xmin && x < $xmax && (!layer || (d.options.layer ?? 'bottom') === layer)) {
87
103
  callback(d);
88
104
  }
89
- });
105
+ }
90
106
  }
91
107
  }
92
108
 
@@ -3,7 +3,7 @@
3
3
  * @license MIT
4
4
  */
5
5
 
6
- import { Disposable } from 'vs/base/common/lifecycle';
6
+ import { Disposable } from 'common/Lifecycle';
7
7
  import { ILogService, IOptionsService, LogLevelEnum } from 'common/services/Services';
8
8
 
9
9
  type LogType = (message?: any, ...optionalParams: any[]) => void;
@@ -43,9 +43,6 @@ export class LogService extends Disposable implements ILogService {
43
43
  super();
44
44
  this._updateLogLevel();
45
45
  this._register(this._optionsService.onSpecificOptionChange('logLevel', () => this._updateLogLevel()));
46
-
47
- // For trace logging, assume the latest created log service is valid
48
- traceLogger = this;
49
46
  }
50
47
 
51
48
  private _updateLogLevel(): void {
@@ -95,30 +92,3 @@ export class LogService extends Disposable implements ILogService {
95
92
  }
96
93
  }
97
94
  }
98
-
99
- let traceLogger: ILogService;
100
- export function setTraceLogger(logger: ILogService): void {
101
- traceLogger = logger;
102
- }
103
-
104
- /**
105
- * A decorator that can be used to automatically log trace calls to the decorated function.
106
- */
107
- export function traceCall(_target: any, key: string, descriptor: any): any {
108
- if (typeof descriptor.value !== 'function') {
109
- throw new Error('not supported');
110
- }
111
- const fnKey = 'value';
112
- const fn = descriptor.value;
113
- descriptor[fnKey] = function (...args: any[]) {
114
- // Early exit
115
- if (traceLogger.logLevel !== LogLevelEnum.TRACE) {
116
- return fn.apply(this, args);
117
- }
118
-
119
- traceLogger.trace(`GlyphRenderer#${fn.name}(${args.map(e => JSON.stringify(e)).join(', ')})`);
120
- const result = fn.apply(this, args);
121
- traceLogger.trace(`GlyphRenderer#${fn.name} return`, result);
122
- return result;
123
- };
124
- }
@@ -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, IOptionsService } from 'common/services/Services';
5
+ import { IMouseStateService } from 'common/services/Services';
6
6
  import { ICoreMouseProtocol, ICoreMouseEvent, CoreMouseEncoding, CoreMouseEventType, CoreMouseButton, CoreMouseAction } from 'common/Types';
7
- import { Disposable } from 'vs/base/common/lifecycle';
8
- import { Emitter } from 'vs/base/common/event';
7
+ import { Disposable } from 'common/Lifecycle';
8
+ import { Emitter } from 'common/Event';
9
9
 
10
10
  /**
11
11
  * Supported default protocols.
@@ -151,7 +151,7 @@ const DEFAULT_ENCODINGS: { [key: string]: CoreMouseEncoding } = {
151
151
  };
152
152
 
153
153
  /**
154
- * CoreMouseService
154
+ * MouseStateService
155
155
  *
156
156
  * Provides mouse tracking reports with different protocols and encodings.
157
157
  * - protocols: NONE (default), X10, VT200, DRAG, ANY
@@ -166,25 +166,21 @@ const DEFAULT_ENCODINGS: { [key: string]: CoreMouseEncoding } = {
166
166
  * a tracking report to the backend based on protocol and encoding limitations.
167
167
  * To send a mouse event call `triggerMouseEvent`.
168
168
  */
169
- export class CoreMouseService extends Disposable implements ICoreMouseService {
169
+ export class MouseStateService extends Disposable implements IMouseStateService {
170
170
  public serviceBrand: any;
171
171
 
172
172
  private _protocols: { [name: string]: ICoreMouseProtocol } = {};
173
173
  private _encodings: { [name: string]: CoreMouseEncoding } = {};
174
174
  private _activeProtocol: string = '';
175
175
  private _activeEncoding: string = '';
176
- private _lastEvent: ICoreMouseEvent | null = null;
177
- private _wheelPartialScroll: number = 0;
176
+ private _customWheelEventHandler: ((event: WheelEvent) => boolean) | undefined;
178
177
 
179
178
  private readonly _onProtocolChange = this._register(new Emitter<CoreMouseEventType>());
180
179
  public readonly onProtocolChange = this._onProtocolChange.event;
181
180
 
182
- constructor(
183
- @IBufferService private readonly _bufferService: IBufferService,
184
- @ICoreService private readonly _coreService: ICoreService,
185
- @IOptionsService private readonly _optionsService: IOptionsService
186
- ) {
181
+ constructor() {
187
182
  super();
183
+
188
184
  // register default protocols and encodings
189
185
  for (const name of Object.keys(DEFAULT_PROTOCOLS)) this.addProtocol(name, DEFAULT_PROTOCOLS[name]);
190
186
  for (const name of Object.keys(DEFAULT_ENCODINGS)) this.addEncoding(name, DEFAULT_ENCODINGS[name]);
@@ -230,136 +226,29 @@ export class CoreMouseService extends Disposable implements ICoreMouseService {
230
226
  public reset(): void {
231
227
  this.activeProtocol = 'NONE';
232
228
  this.activeEncoding = 'DEFAULT';
233
- this._lastEvent = null;
234
- this._wheelPartialScroll = 0;
235
229
  }
236
230
 
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;
231
+ public setCustomWheelEventHandler(customWheelEventHandler: ((event: WheelEvent) => boolean) | undefined): void {
232
+ this._customWheelEventHandler = customWheelEventHandler;
269
233
  }
270
234
 
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;
235
+ public allowCustomWheelEvent(ev: WheelEvent): boolean {
236
+ return this._customWheelEventHandler ? this._customWheelEventHandler(ev) !== false : true;
277
237
  }
278
238
 
279
- /**
280
- * Triggers a mouse event to be sent.
281
- *
282
- * Returns true if the event passed all protocol restrictions and a report
283
- * was sent, otherwise false. The return value may be used to decide whether
284
- * the default event action in the bowser component should be omitted.
285
- *
286
- * Note: The method will change values of the given event object
287
- * to fullfill protocol and encoding restrictions.
288
- */
289
- public triggerMouseEvent(e: ICoreMouseEvent): boolean {
290
- // range check for col/row
291
- if (e.col < 0 || e.col >= this._bufferService.cols
292
- || e.row < 0 || e.row >= this._bufferService.rows) {
293
- return false;
294
- }
295
-
296
- // filter nonsense combinations of button + action
297
- if (e.button === CoreMouseButton.WHEEL && e.action === CoreMouseAction.MOVE) {
298
- return false;
299
- }
300
- if (e.button === CoreMouseButton.NONE && e.action !== CoreMouseAction.MOVE) {
301
- return false;
302
- }
303
- if (e.button !== CoreMouseButton.WHEEL && (e.action === CoreMouseAction.LEFT || e.action === CoreMouseAction.RIGHT)) {
304
- return false;
305
- }
306
-
307
- // report 1-based coords
308
- e.col++;
309
- e.row++;
310
-
311
- // debounce move events at grid or pixel level
312
- if (e.action === CoreMouseAction.MOVE
313
- && this._lastEvent
314
- && this._equalEvents(this._lastEvent, e, this._activeEncoding === 'SGR_PIXELS')
315
- ) {
316
- return false;
317
- }
318
-
319
- // apply protocol restrictions
320
- if (!this._protocols[this._activeProtocol].restrict(e)) {
321
- return false;
322
- }
323
-
324
- // encode report and send
325
- const report = this._encodings[this._activeEncoding](e);
326
- if (report) {
327
- // always send DEFAULT as binary data
328
- if (this._activeEncoding === 'DEFAULT') {
329
- this._coreService.triggerBinaryEvent(report);
330
- } else {
331
- this._coreService.triggerDataEvent(report, true);
332
- }
333
- }
334
-
335
- this._lastEvent = e;
239
+ public restrictMouseEvent(e: ICoreMouseEvent): boolean {
240
+ return this._protocols[this._activeProtocol].restrict(e);
241
+ }
336
242
 
337
- return true;
243
+ public encodeMouseEvent(e: ICoreMouseEvent): string {
244
+ return this._encodings[this._activeEncoding](e);
338
245
  }
339
246
 
340
- public explainEvents(events: CoreMouseEventType): { [event: string]: boolean } {
341
- return {
342
- down: !!(events & CoreMouseEventType.DOWN),
343
- up: !!(events & CoreMouseEventType.UP),
344
- drag: !!(events & CoreMouseEventType.DRAG),
345
- move: !!(events & CoreMouseEventType.MOVE),
346
- wheel: !!(events & CoreMouseEventType.WHEEL)
347
- };
247
+ public get isDefaultEncoding(): boolean {
248
+ return this._activeEncoding === 'DEFAULT';
348
249
  }
349
250
 
350
- private _equalEvents(e1: ICoreMouseEvent, e2: ICoreMouseEvent, pixels: boolean): boolean {
351
- if (pixels) {
352
- if (e1.x !== e2.x) return false;
353
- if (e1.y !== e2.y) return false;
354
- } else {
355
- if (e1.col !== e2.col) return false;
356
- if (e1.row !== e2.row) return false;
357
- }
358
- if (e1.button !== e2.button) return false;
359
- if (e1.action !== e2.action) return false;
360
- if (e1.ctrl !== e2.ctrl) return false;
361
- if (e1.alt !== e2.alt) return false;
362
- if (e1.shift !== e2.shift) return false;
363
- return true;
251
+ public get isPixelEncoding(): boolean {
252
+ return this._activeEncoding === 'SGR_PIXELS';
364
253
  }
365
254
  }
@@ -3,16 +3,18 @@
3
3
  * @license MIT
4
4
  */
5
5
 
6
- import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
6
+ import { Disposable, toDisposable } from 'common/Lifecycle';
7
7
  import { isMac } from 'common/Platform';
8
8
  import { CursorStyle, IDisposable } from 'common/Types';
9
9
  import { FontWeight, IOptionsService, ITerminalOptions } from 'common/services/Services';
10
- import { Emitter } from 'vs/base/common/event';
10
+ import { Emitter } from 'common/Event';
11
11
 
12
12
  export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
13
13
  cols: 80,
14
14
  rows: 24,
15
+ showCursorImmediately: false,
15
16
  cursorBlink: false,
17
+ blinkIntervalDuration: 0,
16
18
  cursorStyle: 'block',
17
19
  cursorWidth: 1,
18
20
  cursorInactiveStyle: 'outline',
@@ -30,6 +32,7 @@ export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
30
32
  logLevel: 'info',
31
33
  logger: null,
32
34
  scrollback: 1000,
35
+ scrollbar: { showScrollbar: true },
33
36
  scrollOnEraseInDisplay: false,
34
37
  scrollOnUserInput: true,
35
38
  scrollSensitivity: 1,
@@ -52,8 +55,8 @@ export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
52
55
  altClickMovesCursor: true,
53
56
  convertEol: false,
54
57
  termName: 'xterm',
55
- cancelEvents: false,
56
- overviewRuler: {}
58
+ quirks: {},
59
+ vtExtensions: {}
57
60
  };
58
61
 
59
62
  const FONT_WEIGHT_OPTIONS: Extract<FontWeight, string>[] = ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'];
@@ -166,6 +169,12 @@ export class OptionsService extends Disposable implements IOptionsService {
166
169
  }
167
170
  value = FONT_WEIGHT_OPTIONS.includes(value) ? value : DEFAULT_OPTIONS[key];
168
171
  break;
172
+ case 'blinkIntervalDuration':
173
+ value = Math.floor(value);
174
+ if (value < 0) {
175
+ throw new Error(`${key} cannot be less than 0, value: ${value}`);
176
+ }
177
+ break;
169
178
  case 'cursorWidth':
170
179
  value = Math.floor(value);
171
180
  // Fall through for bounds check
@@ -11,13 +11,15 @@
11
11
 
12
12
  import { IServiceIdentifier } from 'common/services/Services';
13
13
 
14
- const DI_TARGET = 'di$target';
15
- const DI_DEPENDENCIES = 'di$dependencies';
14
+ const enum Constants {
15
+ DI_TARGET = 'di$target',
16
+ DI_DEPENDENCIES = 'di$dependencies'
17
+ }
16
18
 
17
19
  export const serviceRegistry: Map<string, IServiceIdentifier<any>> = new Map();
18
20
 
19
21
  export function getServiceDependencies(ctor: any): { id: IServiceIdentifier<any>, index: number, optional: boolean }[] {
20
- return ctor[DI_DEPENDENCIES] || [];
22
+ return ctor[Constants.DI_DEPENDENCIES] || [];
21
23
  }
22
24
 
23
25
  export function createDecorator<T>(id: string): IServiceIdentifier<T> {
@@ -40,10 +42,10 @@ export function createDecorator<T>(id: string): IServiceIdentifier<T> {
40
42
  }
41
43
 
42
44
  function storeServiceDependency(id: Function, target: Function, index: number): void {
43
- if ((target as any)[DI_TARGET] === target) {
44
- (target as any)[DI_DEPENDENCIES].push({ id, index });
45
+ if ((target as any)[Constants.DI_TARGET] === target) {
46
+ (target as any)[Constants.DI_DEPENDENCIES].push({ id, index });
45
47
  } else {
46
- (target as any)[DI_DEPENDENCIES] = [{ id, index }];
47
- (target as any)[DI_TARGET] = target;
48
+ (target as any)[Constants.DI_DEPENDENCIES] = [{ id, index }];
49
+ (target as any)[Constants.DI_TARGET] = target;
48
50
  }
49
51
  }