@xterm/xterm 6.1.0-beta.23 → 6.1.0-beta.230

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 +82 -14
  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 +28 -16
  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 +141 -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 +51 -31
  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 +69 -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 +3 -3
  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 +258 -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 +49 -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
@@ -21,14 +21,14 @@
21
21
  * http://linux.die.net/man/7/urxvt
22
22
  */
23
23
 
24
- import { IInstantiationService, IOptionsService, IBufferService, ILogService, ICharsetService, ICoreService, ICoreMouseService, IUnicodeService, LogLevelEnum, ITerminalOptions, IOscLinkService } from 'common/services/Services';
24
+ import { IInstantiationService, IOptionsService, IBufferService, ILogService, ICharsetService, ICoreService, IMouseStateService, IUnicodeService, LogLevelEnum, ITerminalOptions, IOscLinkService } from 'common/services/Services';
25
25
  import { InstantiationService } from 'common/services/InstantiationService';
26
26
  import { LogService } from 'common/services/LogService';
27
- import { BufferService, MINIMUM_COLS, MINIMUM_ROWS } from 'common/services/BufferService';
27
+ import { BufferService, BufferServiceConstants } from 'common/services/BufferService';
28
28
  import { OptionsService } from 'common/services/OptionsService';
29
29
  import { IDisposable, IAttributeData, ICoreTerminal, IScrollEvent } from 'common/Types';
30
30
  import { CoreService } from 'common/services/CoreService';
31
- import { CoreMouseService } from 'common/services/CoreMouseService';
31
+ import { MouseStateService } from 'common/services/MouseStateService';
32
32
  import { UnicodeService } from 'common/services/UnicodeService';
33
33
  import { CharsetService } from 'common/services/CharsetService';
34
34
  import { updateWindowsModeWrappedState } from 'common/WindowsMode';
@@ -37,8 +37,8 @@ import { IBufferSet } from 'common/buffer/Types';
37
37
  import { InputHandler } from 'common/InputHandler';
38
38
  import { WriteBuffer } from 'common/input/WriteBuffer';
39
39
  import { OscLinkService } from 'common/services/OscLinkService';
40
- import { Emitter, Event } from 'vs/base/common/event';
41
- import { Disposable, MutableDisposable, toDisposable } from 'vs/base/common/lifecycle';
40
+ import { Emitter, EventUtils, type IEvent } from 'common/Event';
41
+ import { Disposable, MutableDisposable, toDisposable } from 'common/Lifecycle';
42
42
 
43
43
  // Only trigger this warning a single time per session
44
44
  let hasWriteSyncWarnHappened = false;
@@ -50,7 +50,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
50
50
  protected readonly _charsetService: ICharsetService;
51
51
  protected readonly _oscLinkService: IOscLinkService;
52
52
 
53
- public readonly coreMouseService: ICoreMouseService;
53
+ public readonly mouseStateService: IMouseStateService;
54
54
  public readonly coreService: ICoreService;
55
55
  public readonly unicodeService: IUnicodeService;
56
56
  public readonly optionsService: IOptionsService;
@@ -65,6 +65,8 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
65
65
  public readonly onData = this._onData.event;
66
66
  protected _onLineFeed = this._register(new Emitter<void>());
67
67
  public readonly onLineFeed = this._onLineFeed.event;
68
+ protected readonly _onRender = this._register(new Emitter<{ start: number, end: number }>());
69
+ public readonly onRender = this._onRender.event;
68
70
  private readonly _onResize = this._register(new Emitter<{ cols: number, rows: number }>());
69
71
  public readonly onResize = this._onResize.event;
70
72
  protected readonly _onWriteParsed = this._register(new Emitter<void>());
@@ -76,7 +78,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
76
78
  */
77
79
  protected _onScrollApi?: Emitter<number>;
78
80
  protected _onScroll = this._register(new Emitter<IScrollEvent>());
79
- public get onScroll(): Event<number> {
81
+ public get onScroll(): IEvent<number> {
80
82
  if (!this._onScrollApi) {
81
83
  this._onScrollApi = this._register(new Emitter<number>());
82
84
  this._onScroll.event(ev => {
@@ -105,14 +107,14 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
105
107
  this._instantiationService = new InstantiationService();
106
108
  this.optionsService = this._register(new OptionsService(options));
107
109
  this._instantiationService.setService(IOptionsService, this.optionsService);
108
- this._bufferService = this._register(this._instantiationService.createInstance(BufferService));
109
- this._instantiationService.setService(IBufferService, this._bufferService);
110
110
  this._logService = this._register(this._instantiationService.createInstance(LogService));
111
111
  this._instantiationService.setService(ILogService, this._logService);
112
+ this._bufferService = this._register(this._instantiationService.createInstance(BufferService));
113
+ this._instantiationService.setService(IBufferService, this._bufferService);
112
114
  this.coreService = this._register(this._instantiationService.createInstance(CoreService));
113
115
  this._instantiationService.setService(ICoreService, this.coreService);
114
- this.coreMouseService = this._register(this._instantiationService.createInstance(CoreMouseService));
115
- this._instantiationService.setService(ICoreMouseService, this.coreMouseService);
116
+ this.mouseStateService = this._register(this._instantiationService.createInstance(MouseStateService));
117
+ this._instantiationService.setService(IMouseStateService, this.mouseStateService);
116
118
  this.unicodeService = this._register(this._instantiationService.createInstance(UnicodeService));
117
119
  this._instantiationService.setService(IUnicodeService, this.unicodeService);
118
120
  this._charsetService = this._instantiationService.createInstance(CharsetService);
@@ -122,14 +124,13 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
122
124
 
123
125
 
124
126
  // Register input handler and handle/forward events
125
- this._inputHandler = this._register(new InputHandler(this._bufferService, this._charsetService, this.coreService, this._logService, this.optionsService, this._oscLinkService, this.coreMouseService, this.unicodeService));
126
- this._register(Event.forward(this._inputHandler.onLineFeed, this._onLineFeed));
127
- this._register(this._inputHandler);
127
+ this._inputHandler = this._register(new InputHandler(this._bufferService, this._charsetService, this.coreService, this._logService, this.optionsService, this._oscLinkService, this.mouseStateService, this.unicodeService));
128
+ this._register(EventUtils.forward(this._inputHandler.onLineFeed, this._onLineFeed));
128
129
 
129
130
  // Setup listeners
130
- this._register(Event.forward(this._bufferService.onResize, this._onResize));
131
- this._register(Event.forward(this.coreService.onData, this._onData));
132
- this._register(Event.forward(this.coreService.onBinary, this._onBinary));
131
+ this._register(EventUtils.forward(this._bufferService.onResize, this._onResize));
132
+ this._register(EventUtils.forward(this.coreService.onData, this._onData));
133
+ this._register(EventUtils.forward(this.coreService.onBinary, this._onBinary));
133
134
  this._register(this.coreService.onRequestScrollToBottom(() => this.scrollToBottom(true)));
134
135
  this._register(this.coreService.onUserInput(() => this._writeBuffer.handleUserInput()));
135
136
  this._register(this.optionsService.onMultipleOptionChange(['windowsPty'], () => this._handleWindowsPtyOptionChange()));
@@ -139,7 +140,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
139
140
  }));
140
141
  // Setup WriteBuffer
141
142
  this._writeBuffer = this._register(new WriteBuffer((data, promiseResult) => this._inputHandler.parse(data, promiseResult)));
142
- this._register(Event.forward(this._writeBuffer.onWriteParsed, this._onWriteParsed));
143
+ this._register(EventUtils.forward(this._writeBuffer.onWriteParsed, this._onWriteParsed));
143
144
  }
144
145
 
145
146
  public write(data: string | Uint8Array, callback?: () => void): void {
@@ -172,8 +173,12 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
172
173
  return;
173
174
  }
174
175
 
175
- x = Math.max(x, MINIMUM_COLS);
176
- y = Math.max(y, MINIMUM_ROWS);
176
+ x = Math.max(x, BufferServiceConstants.MINIMUM_COLS);
177
+ y = Math.max(y, BufferServiceConstants.MINIMUM_ROWS);
178
+
179
+ // Flush pending writes before resize to avoid race conditions where async
180
+ // writes are processed with incorrect dimensions
181
+ this._writeBuffer.flushSync();
177
182
 
178
183
  this._bufferService.resize(x, y);
179
184
  }
@@ -237,6 +242,11 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
237
242
  return this._inputHandler.registerOscHandler(ident, callback);
238
243
  }
239
244
 
245
+ /** Add handler for APC escape sequence. See xterm.d.ts for details. */
246
+ public registerApcHandler(id: IFunctionIdentifier, callback: (data: string) => boolean | Promise<boolean>): IDisposable {
247
+ return this._inputHandler.registerApcHandler(id, callback);
248
+ }
249
+
240
250
  protected _setup(): void {
241
251
  this._handleWindowsPtyOptionChange();
242
252
  }
@@ -246,7 +256,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
246
256
  this._bufferService.reset();
247
257
  this._charsetService.reset();
248
258
  this.coreService.reset();
249
- this.coreMouseService.reset();
259
+ this.mouseStateService.reset();
250
260
  }
251
261
 
252
262
 
@@ -0,0 +1,118 @@
1
+ /**
2
+ * Copyright (c) 2024-2026 The xterm.js authors. All rights reserved.
3
+ * @license MIT
4
+ *
5
+ * Minimal event utilities for xterm.js core.
6
+ * Simplified from VS Code's event.ts - no leak detection/profiling.
7
+ */
8
+
9
+ import { IDisposable, DisposableStore, toDisposable } from 'common/Lifecycle';
10
+
11
+ export interface IEvent<T> {
12
+ (listener: (e: T) => any, thisArgs?: any, disposables?: IDisposable[] | DisposableStore): IDisposable;
13
+ }
14
+
15
+ export class Emitter<T> {
16
+ private _listeners: { fn: (e: T) => any, thisArgs: any }[] = [];
17
+ private _disposed = false;
18
+ private _event: IEvent<T> | undefined;
19
+
20
+ public get event(): IEvent<T> {
21
+ if (this._event) {
22
+ return this._event;
23
+ }
24
+ this._event = (listener: (e: T) => any, thisArgs?: any, disposables?: IDisposable[] | DisposableStore) => {
25
+ if (this._disposed) {
26
+ return toDisposable(() => {});
27
+ }
28
+
29
+ const entry = { fn: listener, thisArgs };
30
+ this._listeners.push(entry);
31
+
32
+ const result = toDisposable(() => {
33
+ const idx = this._listeners.indexOf(entry);
34
+ if (idx !== -1) {
35
+ this._listeners.splice(idx, 1);
36
+ }
37
+ });
38
+
39
+ if (disposables) {
40
+ if (Array.isArray(disposables)) {
41
+ disposables.push(result);
42
+ } else {
43
+ disposables.add(result);
44
+ }
45
+ }
46
+
47
+ return result;
48
+ };
49
+ return this._event;
50
+ }
51
+
52
+ public fire(event: T): void {
53
+ if (this._disposed) {
54
+ return;
55
+ }
56
+ switch (this._listeners.length) {
57
+ case 0: return;
58
+ case 1: {
59
+ const { fn, thisArgs } = this._listeners[0];
60
+ fn.call(thisArgs, event);
61
+ return;
62
+ }
63
+ default: {
64
+ // Snapshot listeners to allow modifications during iteration (2+ listeners)
65
+ const listeners = this._listeners.slice();
66
+ for (const { fn, thisArgs } of listeners) {
67
+ fn.call(thisArgs, event);
68
+ }
69
+ }
70
+ }
71
+ }
72
+
73
+ public dispose(): void {
74
+ if (this._disposed) {
75
+ return;
76
+ }
77
+ this._disposed = true;
78
+ this._listeners.length = 0;
79
+ }
80
+ }
81
+
82
+ export namespace EventUtils {
83
+ export function forward<T>(from: IEvent<T>, to: Emitter<T>): IDisposable {
84
+ return from(e => to.fire(e));
85
+ }
86
+
87
+ export function map<I, O>(event: IEvent<I>, map: (i: I) => O): IEvent<O> {
88
+ return (listener: (e: O) => any, thisArgs?: any, disposables?: IDisposable[] | DisposableStore) => {
89
+ return event(i => listener.call(thisArgs, map(i)), undefined, disposables);
90
+ };
91
+ }
92
+
93
+ export function any<T>(...events: IEvent<T>[]): IEvent<T>;
94
+ export function any(...events: IEvent<any>[]): IEvent<void>;
95
+ export function any<T>(...events: IEvent<T>[]): IEvent<T> {
96
+ return (listener: (e: T) => any, thisArgs?: any, disposables?: IDisposable[] | DisposableStore) => {
97
+ const store = new DisposableStore();
98
+ for (const event of events) {
99
+ store.add(event(e => listener.call(thisArgs, e)));
100
+ }
101
+ if (disposables) {
102
+ if (Array.isArray(disposables)) {
103
+ disposables.push(store);
104
+ } else {
105
+ disposables.add(store);
106
+ }
107
+ }
108
+ return store;
109
+ };
110
+ }
111
+
112
+ export function runAndSubscribe<T>(event: IEvent<T>, handler: (e: T) => void, initial: T): IDisposable;
113
+ export function runAndSubscribe<T>(event: IEvent<T>, handler: (e: T | undefined) => void): IDisposable;
114
+ export function runAndSubscribe<T>(event: IEvent<T>, handler: (e: T | undefined) => void, initial?: T): IDisposable {
115
+ handler(initial);
116
+ return event(e => handler(e));
117
+ }
118
+ }