@xterm/xterm 6.1.0-beta.19 → 6.1.0-beta.190

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 (157) hide show
  1. package/README.md +60 -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 -14
  8. package/src/browser/AccessibilityManager.ts +6 -3
  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 +37 -20
  18. package/src/browser/decorations/BufferDecorationRenderer.ts +1 -1
  19. package/src/browser/decorations/OverviewRulerRenderer.ts +15 -16
  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 +128 -8
  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 +579 -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 +16 -8
  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 +28 -18
  56. package/src/common/Event.ts +118 -0
  57. package/src/common/InputHandler.ts +256 -36
  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 +9 -3
  62. package/src/common/Types.ts +35 -15
  63. package/src/common/Version.ts +9 -0
  64. package/src/common/buffer/Buffer.ts +20 -14
  65. package/src/common/buffer/BufferLine.ts +4 -5
  66. package/src/common/buffer/BufferSet.ts +7 -6
  67. package/src/common/buffer/CellData.ts +57 -0
  68. package/src/common/buffer/Marker.ts +2 -2
  69. package/src/common/buffer/Types.ts +6 -2
  70. package/src/common/data/EscapeSequences.ts +71 -70
  71. package/src/common/input/Keyboard.ts +14 -7
  72. package/src/common/input/KittyKeyboard.ts +496 -0
  73. package/src/common/input/Win32InputMode.ts +297 -0
  74. package/src/common/input/WriteBuffer.ts +34 -2
  75. package/src/common/input/XParseColor.ts +2 -2
  76. package/src/common/parser/ApcParser.ts +245 -0
  77. package/src/common/parser/Constants.ts +22 -4
  78. package/src/common/parser/DcsParser.ts +5 -5
  79. package/src/common/parser/EscapeSequenceParser.ts +75 -22
  80. package/src/common/parser/OscParser.ts +5 -5
  81. package/src/common/parser/Types.ts +34 -1
  82. package/src/common/public/BufferLineApiView.ts +2 -2
  83. package/src/common/public/BufferNamespaceApi.ts +2 -2
  84. package/src/common/public/ParserApi.ts +3 -0
  85. package/src/common/services/BufferService.ts +8 -5
  86. package/src/common/services/CharsetService.ts +4 -0
  87. package/src/common/services/CoreService.ts +18 -4
  88. package/src/common/services/DecorationService.ts +24 -8
  89. package/src/common/services/LogService.ts +1 -31
  90. package/src/common/services/{CoreMouseService.ts → MouseStateService.ts} +21 -132
  91. package/src/common/services/OptionsService.ts +13 -4
  92. package/src/common/services/Services.ts +47 -40
  93. package/src/common/services/UnicodeService.ts +1 -1
  94. package/typings/xterm.d.ts +319 -35
  95. package/src/common/TypedArrayUtils.ts +0 -17
  96. package/src/vs/base/browser/browser.ts +0 -141
  97. package/src/vs/base/browser/canIUse.ts +0 -49
  98. package/src/vs/base/browser/dom.ts +0 -2369
  99. package/src/vs/base/browser/fastDomNode.ts +0 -316
  100. package/src/vs/base/browser/globalPointerMoveMonitor.ts +0 -112
  101. package/src/vs/base/browser/iframe.ts +0 -135
  102. package/src/vs/base/browser/keyboardEvent.ts +0 -213
  103. package/src/vs/base/browser/mouseEvent.ts +0 -229
  104. package/src/vs/base/browser/touch.ts +0 -372
  105. package/src/vs/base/browser/ui/scrollbar/abstractScrollbar.ts +0 -303
  106. package/src/vs/base/browser/ui/scrollbar/horizontalScrollbar.ts +0 -114
  107. package/src/vs/base/browser/ui/scrollbar/scrollableElement.ts +0 -720
  108. package/src/vs/base/browser/ui/scrollbar/scrollableElementOptions.ts +0 -165
  109. package/src/vs/base/browser/ui/scrollbar/scrollbarArrow.ts +0 -114
  110. package/src/vs/base/browser/ui/scrollbar/scrollbarState.ts +0 -243
  111. package/src/vs/base/browser/ui/scrollbar/scrollbarVisibilityController.ts +0 -118
  112. package/src/vs/base/browser/ui/scrollbar/verticalScrollbar.ts +0 -116
  113. package/src/vs/base/browser/ui/widget.ts +0 -57
  114. package/src/vs/base/browser/window.ts +0 -14
  115. package/src/vs/base/common/arrays.ts +0 -887
  116. package/src/vs/base/common/arraysFind.ts +0 -202
  117. package/src/vs/base/common/assert.ts +0 -71
  118. package/src/vs/base/common/async.ts +0 -1992
  119. package/src/vs/base/common/cancellation.ts +0 -148
  120. package/src/vs/base/common/charCode.ts +0 -450
  121. package/src/vs/base/common/collections.ts +0 -140
  122. package/src/vs/base/common/decorators.ts +0 -130
  123. package/src/vs/base/common/equals.ts +0 -146
  124. package/src/vs/base/common/errors.ts +0 -303
  125. package/src/vs/base/common/event.ts +0 -1778
  126. package/src/vs/base/common/functional.ts +0 -32
  127. package/src/vs/base/common/hash.ts +0 -316
  128. package/src/vs/base/common/iterator.ts +0 -159
  129. package/src/vs/base/common/keyCodes.ts +0 -526
  130. package/src/vs/base/common/keybindings.ts +0 -284
  131. package/src/vs/base/common/lazy.ts +0 -47
  132. package/src/vs/base/common/lifecycle.ts +0 -801
  133. package/src/vs/base/common/linkedList.ts +0 -142
  134. package/src/vs/base/common/map.ts +0 -202
  135. package/src/vs/base/common/numbers.ts +0 -98
  136. package/src/vs/base/common/observable.ts +0 -76
  137. package/src/vs/base/common/observableInternal/api.ts +0 -31
  138. package/src/vs/base/common/observableInternal/autorun.ts +0 -281
  139. package/src/vs/base/common/observableInternal/base.ts +0 -489
  140. package/src/vs/base/common/observableInternal/debugName.ts +0 -145
  141. package/src/vs/base/common/observableInternal/derived.ts +0 -428
  142. package/src/vs/base/common/observableInternal/lazyObservableValue.ts +0 -146
  143. package/src/vs/base/common/observableInternal/logging.ts +0 -328
  144. package/src/vs/base/common/observableInternal/promise.ts +0 -209
  145. package/src/vs/base/common/observableInternal/utils.ts +0 -610
  146. package/src/vs/base/common/platform.ts +0 -281
  147. package/src/vs/base/common/scrollable.ts +0 -522
  148. package/src/vs/base/common/sequence.ts +0 -34
  149. package/src/vs/base/common/stopwatch.ts +0 -43
  150. package/src/vs/base/common/strings.ts +0 -557
  151. package/src/vs/base/common/symbols.ts +0 -9
  152. package/src/vs/base/common/uint.ts +0 -59
  153. package/src/vs/patches/nls.ts +0 -90
  154. package/src/vs/typings/base-common.d.ts +0 -20
  155. package/src/vs/typings/require.d.ts +0 -42
  156. package/src/vs/typings/vscode-globals-nls.d.ts +0 -36
  157. package/src/vs/typings/vscode-globals-product.d.ts +0 -33
@@ -0,0 +1,178 @@
1
+ /**
2
+ * Copyright (c) 2026 The xterm.js authors. All rights reserved.
3
+ * @license MIT
4
+ *
5
+ * Minimal DOM helpers for xterm.js browser code.
6
+ */
7
+
8
+ import { IntervalTimer } from 'common/Async';
9
+ import { IDisposable } from 'common/Lifecycle';
10
+
11
+ export function getWindow(e: Node | UIEvent | undefined | null): Window {
12
+ const candidateNode = e as Node | undefined | null;
13
+ if (candidateNode?.ownerDocument?.defaultView) {
14
+ return candidateNode.ownerDocument.defaultView;
15
+ }
16
+
17
+ const candidateEvent = e as UIEvent | undefined | null;
18
+ if (candidateEvent?.view) {
19
+ return candidateEvent.view;
20
+ }
21
+
22
+ return window;
23
+ }
24
+
25
+ class DomListener implements IDisposable {
26
+ private _handler: ((e: any) => void) | null;
27
+ private _node: EventTarget | null;
28
+ private readonly _type: string;
29
+ private readonly _options: boolean | AddEventListenerOptions | undefined;
30
+
31
+ constructor(node: EventTarget, type: string, handler: (e: any) => void, options?: boolean | AddEventListenerOptions) {
32
+ this._node = node;
33
+ this._type = type;
34
+ this._handler = handler;
35
+ this._options = options;
36
+ node.addEventListener(type, handler, options);
37
+ }
38
+
39
+ public dispose(): void {
40
+ if (!this._node || !this._handler) {
41
+ return;
42
+ }
43
+ this._node.removeEventListener(this._type, this._handler, this._options);
44
+ this._node = null;
45
+ this._handler = null;
46
+ }
47
+ }
48
+
49
+ export function addDisposableListener<K extends keyof GlobalEventHandlersEventMap>(node: EventTarget, type: K, handler: (event: GlobalEventHandlersEventMap[K]) => void, useCapture?: boolean): IDisposable;
50
+ export function addDisposableListener(node: EventTarget, type: string, handler: (event: any) => void, useCapture?: boolean): IDisposable;
51
+ export function addDisposableListener(node: EventTarget, type: string, handler: (event: any) => void, options: AddEventListenerOptions): IDisposable;
52
+ export function addDisposableListener(node: EventTarget, type: string, handler: (event: any) => void, useCaptureOrOptions?: boolean | AddEventListenerOptions): IDisposable {
53
+ return new DomListener(node, type, handler, useCaptureOrOptions);
54
+ }
55
+
56
+ export function addStandardDisposableListener(node: HTMLElement, type: string, handler: (event: any) => void, useCapture?: boolean): IDisposable {
57
+ return addDisposableListener(node, type, handler, useCapture);
58
+ }
59
+
60
+ export const eventType = {
61
+ CLICK: 'click',
62
+ MOUSE_DOWN: 'mousedown',
63
+ MOUSE_OVER: 'mouseover',
64
+ MOUSE_LEAVE: 'mouseleave',
65
+ KEY_DOWN: 'keydown',
66
+ KEY_UP: 'keyup',
67
+ INPUT: 'input',
68
+ BLUR: 'blur',
69
+ FOCUS: 'focus',
70
+ CHANGE: 'change',
71
+ POINTER_DOWN: 'pointerdown',
72
+ POINTER_MOVE: 'pointermove',
73
+ POINTER_UP: 'pointerup',
74
+ MOUSE_WHEEL: 'wheel',
75
+ WHEEL: 'wheel'
76
+ } as const;
77
+
78
+ export function getDomNodePagePosition(domNode: HTMLElement): { left: number, top: number, width: number, height: number } {
79
+ const bb = domNode.getBoundingClientRect();
80
+ const win = getWindow(domNode);
81
+ return {
82
+ left: bb.left + win.scrollX,
83
+ top: bb.top + win.scrollY,
84
+ width: bb.width,
85
+ height: bb.height
86
+ };
87
+ }
88
+
89
+ class AnimationFrameQueueItem implements IDisposable {
90
+ private _canceled = false;
91
+
92
+ constructor(private readonly _runner: () => void, public priority: number) {
93
+ }
94
+
95
+ public dispose(): void {
96
+ this._canceled = true;
97
+ }
98
+
99
+ public execute(): void {
100
+ if (this._canceled) {
101
+ return;
102
+ }
103
+ try {
104
+ this._runner();
105
+ } catch (e) {
106
+ console.error(e);
107
+ }
108
+ }
109
+
110
+ public static sort(a: AnimationFrameQueueItem, b: AnimationFrameQueueItem): number {
111
+ return b.priority - a.priority;
112
+ }
113
+ }
114
+
115
+ interface IWindowAnimationFrameState {
116
+ next: AnimationFrameQueueItem[];
117
+ current: AnimationFrameQueueItem[];
118
+ animFrameRequested: boolean;
119
+ inAnimationFrameRunner: boolean;
120
+ }
121
+
122
+ const animationFrameState = new Map<Window, IWindowAnimationFrameState>();
123
+
124
+ function getAnimationFrameState(targetWindow: Window): IWindowAnimationFrameState {
125
+ let state = animationFrameState.get(targetWindow);
126
+ if (!state) {
127
+ state = {
128
+ next: [],
129
+ current: [],
130
+ animFrameRequested: false,
131
+ inAnimationFrameRunner: false
132
+ };
133
+ animationFrameState.set(targetWindow, state);
134
+ }
135
+ return state;
136
+ }
137
+
138
+ function animationFrameRunner(targetWindow: Window): void {
139
+ const state = getAnimationFrameState(targetWindow);
140
+ state.animFrameRequested = false;
141
+
142
+ state.current = state.next;
143
+ state.next = [];
144
+
145
+ state.inAnimationFrameRunner = true;
146
+ while (state.current.length > 0) {
147
+ state.current.sort(AnimationFrameQueueItem.sort);
148
+ const top = state.current.shift()!;
149
+ top.execute();
150
+ }
151
+ state.inAnimationFrameRunner = false;
152
+ }
153
+
154
+ export function scheduleAtNextAnimationFrame(targetWindow: Window, runner: () => void, priority: number = 0): IDisposable {
155
+ const state = getAnimationFrameState(targetWindow);
156
+ const item = new AnimationFrameQueueItem(runner, priority);
157
+ state.next.push(item);
158
+
159
+ if (!state.animFrameRequested) {
160
+ state.animFrameRequested = true;
161
+ targetWindow.requestAnimationFrame(() => animationFrameRunner(targetWindow));
162
+ }
163
+
164
+ return item;
165
+ }
166
+
167
+ export class WindowIntervalTimer extends IntervalTimer {
168
+ private readonly _defaultTarget?: Window;
169
+
170
+ constructor(node?: Node) {
171
+ super();
172
+ this._defaultTarget = node ? getWindow(node) : undefined;
173
+ }
174
+
175
+ public cancelAndSet(runner: () => void, interval: number, targetWindow?: Window): void {
176
+ super.cancelAndSet(runner, interval, targetWindow ?? this._defaultTarget ?? window);
177
+ }
178
+ }
@@ -4,12 +4,12 @@
4
4
  */
5
5
 
6
6
  import { IBufferCellPosition, ILink, ILinkDecorations, ILinkWithState, ILinkifier2, ILinkifierEvent } from 'browser/Types';
7
- import { Disposable, dispose, toDisposable } from 'vs/base/common/lifecycle';
7
+ import { Disposable, dispose, toDisposable } from 'common/Lifecycle';
8
8
  import { IDisposable } from 'common/Types';
9
9
  import { IBufferService } from 'common/services/Services';
10
- import { ILinkProviderService, IMouseService, IRenderService } from './services/Services';
11
- import { Emitter } from 'vs/base/common/event';
12
- import { addDisposableListener } from 'vs/base/browser/dom';
10
+ import { ILinkProviderService, IMouseCoordsService, IRenderService } from './services/Services';
11
+ import { Emitter } from 'common/Event';
12
+ import { addDisposableListener } from 'browser/Dom';
13
13
 
14
14
  export class Linkifier extends Disposable implements ILinkifier2 {
15
15
  public get currentLink(): ILinkWithState | undefined { return this._currentLink; }
@@ -30,7 +30,7 @@ export class Linkifier extends Disposable implements ILinkifier2 {
30
30
 
31
31
  constructor(
32
32
  private readonly _element: HTMLElement,
33
- @IMouseService private readonly _mouseService: IMouseService,
33
+ @IMouseCoordsService private readonly _mouseCoordsService: IMouseCoordsService,
34
34
  @IRenderService private readonly _renderService: IRenderService,
35
35
  @IBufferService private readonly _bufferService: IBufferService,
36
36
  @ILinkProviderService private readonly _linkProviderService: ILinkProviderService
@@ -60,7 +60,7 @@ export class Linkifier extends Disposable implements ILinkifier2 {
60
60
  private _handleMouseMove(event: MouseEvent): void {
61
61
  this._lastMouseEvent = event;
62
62
 
63
- const position = this._positionFromMouseEvent(event, this._element, this._mouseService);
63
+ const position = this._positionFromMouseEvent(event, this._element);
64
64
  if (!position) {
65
65
  return;
66
66
  }
@@ -222,7 +222,7 @@ export class Linkifier extends Disposable implements ILinkifier2 {
222
222
  return;
223
223
  }
224
224
 
225
- const position = this._positionFromMouseEvent(event, this._element, this._mouseService);
225
+ const position = this._positionFromMouseEvent(event, this._element);
226
226
  if (!position) {
227
227
  return;
228
228
  }
@@ -251,7 +251,7 @@ export class Linkifier extends Disposable implements ILinkifier2 {
251
251
  return;
252
252
  }
253
253
 
254
- const position = this._positionFromMouseEvent(this._lastMouseEvent, this._element, this._mouseService);
254
+ const position = this._positionFromMouseEvent(this._lastMouseEvent, this._element);
255
255
 
256
256
  if (!position) {
257
257
  return;
@@ -312,7 +312,7 @@ export class Linkifier extends Disposable implements ILinkifier2 {
312
312
  this._clearCurrentLink(start, end);
313
313
  if (this._lastMouseEvent) {
314
314
  // re-eval previously active link after changes
315
- const position = this._positionFromMouseEvent(this._lastMouseEvent, this._element, this._mouseService!);
315
+ const position = this._positionFromMouseEvent(this._lastMouseEvent, this._element);
316
316
  if (position) {
317
317
  this._askForLink(position, false);
318
318
  }
@@ -378,8 +378,8 @@ export class Linkifier extends Disposable implements ILinkifier2 {
378
378
  * Get the buffer position from a mouse event
379
379
  * @param event
380
380
  */
381
- private _positionFromMouseEvent(event: MouseEvent, element: HTMLElement, mouseService: IMouseService): IBufferCellPosition | undefined {
382
- const coords = mouseService.getCoords(event, element, this._bufferService.cols, this._bufferService.rows);
381
+ private _positionFromMouseEvent(event: MouseEvent, element: HTMLElement): IBufferCellPosition | undefined {
382
+ const coords = this._mouseCoordsService.getCoords(event, element, this._bufferService.cols, this._bufferService.rows);
383
383
  if (!coords) {
384
384
  return;
385
385
  }
@@ -9,6 +9,8 @@ import { CellData } from 'common/buffer/CellData';
9
9
  import { IBufferService, IOptionsService, IOscLinkService } from 'common/services/Services';
10
10
 
11
11
  export class OscLinkProvider implements ILinkProvider {
12
+ private readonly _workCell = new CellData();
13
+
12
14
  constructor(
13
15
  @IBufferService private readonly _bufferService: IBufferService,
14
16
  @IOptionsService private readonly _optionsService: IOptionsService,
@@ -25,7 +27,7 @@ export class OscLinkProvider implements ILinkProvider {
25
27
 
26
28
  const result: ILink[] = [];
27
29
  const linkHandler = this._optionsService.rawOptions.linkHandler;
28
- const cell = new CellData();
30
+ const cell = this._workCell;
29
31
  const lineLength = line.getTrimmedLength();
30
32
  let currentLinkId = -1;
31
33
  let currentStart = -1;
@@ -40,8 +40,8 @@ export class RenderDebouncer implements IRenderDebouncerWithCallback {
40
40
  public refresh(rowStart: number | undefined, rowEnd: number | undefined, rowCount: number): void {
41
41
  this._rowCount = rowCount;
42
42
  // Get the min/max row start/end for the arg values
43
- rowStart = rowStart !== undefined ? rowStart : 0;
44
- rowEnd = rowEnd !== undefined ? rowEnd : this._rowCount - 1;
43
+ rowStart = rowStart ?? 0;
44
+ rowEnd = rowEnd ?? this._rowCount - 1;
45
45
  // Set the properties to the updated values
46
46
  this._rowStart = this._rowStart !== undefined ? Math.min(this._rowStart, rowStart) : rowStart;
47
47
  this._rowEnd = this._rowEnd !== undefined ? Math.max(this._rowEnd, rowEnd) : rowEnd;
@@ -37,8 +37,8 @@ export class TimeBasedDebouncer implements IRenderDebouncer {
37
37
  public refresh(rowStart: number | undefined, rowEnd: number | undefined, rowCount: number): void {
38
38
  this._rowCount = rowCount;
39
39
  // Get the min/max row start/end for the arg values
40
- rowStart = rowStart !== undefined ? rowStart : 0;
41
- rowEnd = rowEnd !== undefined ? rowEnd : this._rowCount - 1;
40
+ rowStart = rowStart ?? 0;
41
+ rowEnd = rowEnd ?? this._rowCount - 1;
42
42
  // Set the properties to the updated values
43
43
  this._rowStart = this._rowStart !== undefined ? Math.min(this._rowStart, rowStart) : rowStart;
44
44
  this._rowEnd = this._rowEnd !== undefined ? Math.max(this._rowEnd, rowEnd) : rowEnd;
@@ -5,9 +5,9 @@
5
5
 
6
6
  import { CharData, IColor, ICoreTerminal, ITerminalOptions } from 'common/Types';
7
7
  import { IBuffer } from 'common/buffer/Types';
8
- import { IDisposable, Terminal as ITerminalApi } from '@xterm/xterm';
8
+ import { IDisposable, IRenderDimensions as IRenderDimensionsApi, Terminal as ITerminalApi } from '@xterm/xterm';
9
9
  import { channels, css } from 'common/Color';
10
- import type { Event } from 'vs/base/common/event';
10
+ import type { IEvent } from 'common/Event';
11
11
 
12
12
  /**
13
13
  * A portion of the public API that are implemented identially internally and simply passed through.
@@ -21,13 +21,14 @@ export interface ITerminal extends InternalPassthroughApis, ICoreTerminal {
21
21
  linkifier: ILinkifier2 | undefined;
22
22
  options: Required<ITerminalOptions>;
23
23
 
24
- onBlur: Event<void>;
25
- onFocus: Event<void>;
26
- onA11yChar: Event<string>;
27
- onA11yTab: Event<number>;
28
- onWillOpen: Event<HTMLElement>;
24
+ readonly dimensions: IRenderDimensionsApi | undefined;
29
25
 
30
- cancel(ev: MouseEvent | WheelEvent | KeyboardEvent | InputEvent, force?: boolean): boolean | void;
26
+ onBlur: IEvent<void>;
27
+ onFocus: IEvent<void>;
28
+ onDimensionsChange: IEvent<IRenderDimensionsApi>;
29
+ onA11yChar: IEvent<string>;
30
+ onA11yTab: IEvent<number>;
31
+ onWillOpen: IEvent<HTMLElement>;
31
32
  }
32
33
 
33
34
  export type CustomKeyEventHandler = (event: KeyboardEvent) => boolean;
@@ -98,7 +99,7 @@ export interface IPartialColorSet {
98
99
 
99
100
  export interface IViewport extends IDisposable {
100
101
  scrollBarWidth: number;
101
- readonly onRequestScrollLines: Event<{ amount: number, suppressScrollEvent: boolean }>;
102
+ readonly onRequestScrollLines: IEvent<{ amount: number, suppressScrollEvent: boolean }>;
102
103
  syncScrollArea(immediate?: boolean, force?: boolean): void;
103
104
  getLinesScrolled(ev: WheelEvent): number;
104
105
  getBufferElements(startLine: number, endLine?: number): { bufferElements: HTMLElement[], cursorElement?: HTMLElement };
@@ -128,8 +129,8 @@ export interface ILinkWithState {
128
129
  }
129
130
 
130
131
  export interface ILinkifier2 extends IDisposable {
131
- onShowLinkUnderline: Event<ILinkifierEvent>;
132
- onHideLinkUnderline: Event<ILinkifierEvent>;
132
+ onShowLinkUnderline: IEvent<ILinkifierEvent>;
133
+ onHideLinkUnderline: IEvent<ILinkifierEvent>;
133
134
  readonly currentLink: ILinkWithState | undefined;
134
135
  }
135
136
 
@@ -5,14 +5,14 @@
5
5
 
6
6
  import { ICoreBrowserService, IRenderService, IThemeService } from 'browser/services/Services';
7
7
  import { ViewportConstants } from 'browser/shared/Constants';
8
- import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
9
- import { IBufferService, ICoreMouseService, IOptionsService } from 'common/services/Services';
8
+ import { Disposable, toDisposable } from 'common/Lifecycle';
9
+ import { IBufferService, IMouseStateService, IOptionsService } from 'common/services/Services';
10
10
  import { CoreMouseEventType } from 'common/Types';
11
- import { scheduleAtNextAnimationFrame } from 'vs/base/browser/dom';
12
- import { SmoothScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement';
13
- import type { ScrollableElementChangeOptions } from 'vs/base/browser/ui/scrollbar/scrollableElementOptions';
14
- import { Emitter, Event } from 'vs/base/common/event';
15
- import { Scrollable, ScrollbarVisibility, type ScrollEvent } from 'vs/base/common/scrollable';
11
+ import { scheduleAtNextAnimationFrame } from 'browser/Dom';
12
+ import { SmoothScrollableElement } from 'browser/scrollable/scrollableElement';
13
+ import type { IScrollableElementChangeOptions } from 'browser/scrollable/scrollableElementOptions';
14
+ import { Emitter, EventUtils } from 'common/Event';
15
+ import { Scrollable, ScrollbarVisibility, type IScrollEvent } from 'browser/scrollable/scrollable';
16
16
 
17
17
  export class Viewport extends Disposable {
18
18
 
@@ -33,7 +33,7 @@ export class Viewport extends Disposable {
33
33
  screenElement: HTMLElement,
34
34
  @IBufferService private readonly _bufferService: IBufferService,
35
35
  @ICoreBrowserService coreBrowserService: ICoreBrowserService,
36
- @ICoreMouseService coreMouseService: ICoreMouseService,
36
+ @IMouseStateService mouseStateService: IMouseStateService,
37
37
  @IThemeService themeService: IThemeService,
38
38
  @IOptionsService private readonly _optionsService: IOptionsService,
39
39
  @IRenderService private readonly _renderService: IRenderService
@@ -51,26 +51,28 @@ export class Viewport extends Disposable {
51
51
  }));
52
52
 
53
53
  this._scrollableElement = this._register(new SmoothScrollableElement(screenElement, {
54
- vertical: ScrollbarVisibility.Auto,
55
- horizontal: ScrollbarVisibility.Hidden,
54
+ vertical: ScrollbarVisibility.AUTO,
55
+ horizontal: ScrollbarVisibility.HIDDEN,
56
56
  useShadows: false,
57
57
  mouseWheelSmoothScroll: true,
58
+ verticalHasArrows: this._optionsService.rawOptions.scrollbar?.showArrows ?? false,
58
59
  ...this._getChangeOptions()
59
60
  }, scrollable));
60
61
  this._register(this._optionsService.onMultipleOptionChange([
61
62
  'scrollSensitivity',
62
63
  'fastScrollSensitivity',
63
- 'overviewRuler'
64
+ 'scrollbar'
64
65
  ], () => this._scrollableElement.updateOptions(this._getChangeOptions())));
65
66
  // Don't handle mouse wheel if wheel events are supported by the current mouse prototcol
66
- this._register(coreMouseService.onProtocolChange(type => {
67
+ this._register(mouseStateService.onProtocolChange(type => {
67
68
  this._scrollableElement.updateOptions({
68
69
  handleMouseWheel: !(type & CoreMouseEventType.WHEEL)
69
70
  });
70
71
  }));
71
72
 
72
73
  this._scrollableElement.setScrollDimensions({ height: 0, scrollHeight: 0 });
73
- this._register(Event.runAndSubscribe(themeService.onChangeColors, () => {
74
+ this._register(EventUtils.runAndSubscribe(themeService.onChangeColors, () => {
75
+ element.style.backgroundColor = themeService.colors.background.css;
74
76
  this._scrollableElement.getDomNode().style.backgroundColor = themeService.colors.background.css;
75
77
  }));
76
78
  element.appendChild(this._scrollableElement.getDomNode());
@@ -79,15 +81,15 @@ export class Viewport extends Disposable {
79
81
  this._styleElement = coreBrowserService.mainDocument.createElement('style');
80
82
  screenElement.appendChild(this._styleElement);
81
83
  this._register(toDisposable(() => this._styleElement.remove()));
82
- this._register(Event.runAndSubscribe(themeService.onChangeColors, () => {
84
+ this._register(EventUtils.runAndSubscribe(themeService.onChangeColors, () => {
83
85
  this._styleElement.textContent = [
84
- `.xterm .xterm-scrollable-element > .scrollbar > .slider {`,
86
+ `.xterm .xterm-scrollable-element > .xterm-scrollbar > .xterm-slider {`,
85
87
  ` background: ${themeService.colors.scrollbarSliderBackground.css};`,
86
88
  `}`,
87
- `.xterm .xterm-scrollable-element > .scrollbar > .slider:hover {`,
89
+ `.xterm .xterm-scrollable-element > .xterm-scrollbar > .xterm-slider:hover {`,
88
90
  ` background: ${themeService.colors.scrollbarSliderHoverBackground.css};`,
89
91
  `}`,
90
- `.xterm .xterm-scrollable-element > .scrollbar > .slider.active {`,
92
+ `.xterm .xterm-scrollable-element > .xterm-scrollbar > .xterm-slider.xterm-active {`,
91
93
  ` background: ${themeService.colors.scrollbarSliderActiveBackground.css};`,
92
94
  `}`
93
95
  ].join('\n');
@@ -103,6 +105,7 @@ export class Viewport extends Disposable {
103
105
  this._register(this._bufferService.onScroll(() => this._sync()));
104
106
 
105
107
  this._register(this._scrollableElement.onScroll(e => this._handleScroll(e)));
108
+
106
109
  }
107
110
 
108
111
  public scrollLines(disp: number): void {
@@ -123,11 +126,18 @@ export class Viewport extends Disposable {
123
126
  });
124
127
  }
125
128
 
126
- private _getChangeOptions(): ScrollableElementChangeOptions {
129
+ private _getChangeOptions(): IScrollableElementChangeOptions {
130
+ const showScrollbar = this._optionsService.rawOptions.scrollbar?.showScrollbar ?? true;
131
+ const showArrows = this._optionsService.rawOptions.scrollbar?.showArrows ?? false;
132
+ const verticalScrollbarSize = showScrollbar
133
+ ? (this._optionsService.rawOptions.scrollbar?.width ?? ViewportConstants.DEFAULT_SCROLL_BAR_WIDTH)
134
+ : 0;
127
135
  return {
128
136
  mouseWheelScrollSensitivity: this._optionsService.rawOptions.scrollSensitivity,
129
137
  fastScrollSensitivity: this._optionsService.rawOptions.fastScrollSensitivity,
130
- verticalScrollbarSize: this._optionsService.rawOptions.overviewRuler?.width || ViewportConstants.DEFAULT_SCROLL_BAR_WIDTH
138
+ vertical: showScrollbar ? ScrollbarVisibility.AUTO : ScrollbarVisibility.HIDDEN,
139
+ verticalScrollbarSize,
140
+ verticalHasArrows: showArrows
131
141
  };
132
142
  }
133
143
 
@@ -173,7 +183,7 @@ export class Viewport extends Disposable {
173
183
  this._isSyncing = false;
174
184
  }
175
185
 
176
- private _handleScroll(e: ScrollEvent): void {
186
+ private _handleScroll(e: IScrollEvent): void {
177
187
  if (!this._renderService) {
178
188
  return;
179
189
  }
@@ -189,4 +199,11 @@ export class Viewport extends Disposable {
189
199
  }
190
200
  this._isHandlingScroll = false;
191
201
  }
202
+
203
+ public handleTouchScroll(translationY: number): void {
204
+ const pos = this._scrollableElement.getScrollPosition();
205
+ this._scrollableElement.setScrollPosition({
206
+ scrollTop: pos.scrollTop - translationY
207
+ });
208
+ }
192
209
  }
@@ -4,7 +4,7 @@
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
 
6
6
  import { ICoreBrowserService, IRenderService } from 'browser/services/Services';
7
- import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
7
+ import { Disposable, toDisposable } from 'common/Lifecycle';
8
8
  import { IBufferService, IDecorationService, IInternalDecoration } from 'common/services/Services';
9
9
 
10
10
  export class BufferDecorationRenderer extends Disposable {
@@ -5,7 +5,7 @@
5
5
 
6
6
  import { ColorZoneStore, IColorZone, IColorZoneStore } from 'browser/decorations/ColorZoneStore';
7
7
  import { ICoreBrowserService, IRenderService, IThemeService } from 'browser/services/Services';
8
- import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
8
+ import { Disposable, toDisposable } from 'common/Lifecycle';
9
9
  import { IBufferService, IDecorationService, IOptionsService } from 'common/services/Services';
10
10
 
11
11
  const enum Constants {
@@ -38,7 +38,12 @@ export class OverviewRulerRenderer extends Disposable {
38
38
  private readonly _ctx: CanvasRenderingContext2D;
39
39
  private readonly _colorZoneStore: IColorZoneStore = new ColorZoneStore();
40
40
  private get _width(): number {
41
- return this._optionsService.options.overviewRuler?.width || 0;
41
+ const scrollbar = this._optionsService.rawOptions.scrollbar;
42
+ const showScrollbar = scrollbar?.showScrollbar ?? true;
43
+ if (!showScrollbar) {
44
+ return 0;
45
+ }
46
+ return scrollbar?.width ?? 0;
42
47
  }
43
48
  private _animationFrame: number | undefined;
44
49
 
@@ -46,8 +51,6 @@ export class OverviewRulerRenderer extends Disposable {
46
51
  private _shouldUpdateAnchor: boolean | undefined = true;
47
52
  private _lastKnownBufferLength: number = 0;
48
53
 
49
- private _containerHeight: number | undefined;
50
-
51
54
  constructor(
52
55
  private readonly _viewportElement: HTMLElement,
53
56
  private readonly _screenElement: HTMLElement,
@@ -86,16 +89,10 @@ export class OverviewRulerRenderer extends Disposable {
86
89
  }
87
90
  }));
88
91
 
89
- // Container height changed
90
- this._register(this._renderService.onRender((): void => {
91
- if (!this._containerHeight || this._containerHeight !== this._screenElement.clientHeight) {
92
- this._queueRefresh(true);
93
- this._containerHeight = this._screenElement.clientHeight;
94
- }
95
- }));
92
+ this._register(this._renderService.onDimensionsChange(() => this._queueRefresh(true)));
96
93
 
97
94
  this._register(this._coreBrowserService.onDprChange(() => this._queueRefresh(true)));
98
- this._register(this._optionsService.onSpecificOptionChange('overviewRuler', () => this._queueRefresh(true)));
95
+ this._register(this._optionsService.onSpecificOptionChange('scrollbar', () => this._queueRefresh(true)));
99
96
  this._register(this._themeService.onChangeColors(() => this._queueRefresh()));
100
97
  this._queueRefresh(true);
101
98
  }
@@ -139,10 +136,12 @@ export class OverviewRulerRenderer extends Disposable {
139
136
  }
140
137
 
141
138
  private _refreshCanvasDimensions(): void {
139
+ const cssCanvasHeight = this._renderService.dimensions.css.canvas.height;
140
+ const deviceCanvasHeight = this._renderService.dimensions.device.canvas.height;
142
141
  this._canvas.style.width = `${this._width}px`;
143
142
  this._canvas.width = Math.round(this._width * this._coreBrowserService.dpr);
144
- this._canvas.style.height = `${this._screenElement.clientHeight}px`;
145
- this._canvas.height = Math.round(this._screenElement.clientHeight * this._coreBrowserService.dpr);
143
+ this._canvas.style.height = `${cssCanvasHeight}px`;
144
+ this._canvas.height = deviceCanvasHeight;
146
145
  this._refreshDrawConstants();
147
146
  this._refreshColorZonePadding();
148
147
  }
@@ -176,10 +175,10 @@ export class OverviewRulerRenderer extends Disposable {
176
175
  private _renderRulerOutline(): void {
177
176
  this._ctx.fillStyle = this._themeService.colors.overviewRulerBorder.css;
178
177
  this._ctx.fillRect(0, 0, Constants.OVERVIEW_RULER_BORDER_WIDTH, this._canvas.height);
179
- if (this._optionsService.rawOptions.overviewRuler.showTopBorder) {
178
+ if (this._optionsService.rawOptions.scrollbar?.overviewRuler?.showTopBorder) {
180
179
  this._ctx.fillRect(Constants.OVERVIEW_RULER_BORDER_WIDTH, 0, this._canvas.width - Constants.OVERVIEW_RULER_BORDER_WIDTH, Constants.OVERVIEW_RULER_BORDER_WIDTH);
181
180
  }
182
- if (this._optionsService.rawOptions.overviewRuler.showBottomBorder) {
181
+ if (this._optionsService.rawOptions.scrollbar?.overviewRuler?.showBottomBorder) {
183
182
  this._ctx.fillRect(Constants.OVERVIEW_RULER_BORDER_WIDTH, this._canvas.height - Constants.OVERVIEW_RULER_BORDER_WIDTH, this._canvas.width - Constants.OVERVIEW_RULER_BORDER_WIDTH, this._canvas.height);
184
183
  }
185
184
  }