@xterm/xterm 6.1.0-beta.18 → 6.1.0-beta.180

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 (156) 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 +142 -62
  11. package/src/browser/Dom.ts +178 -0
  12. package/src/browser/Linkifier.ts +3 -3
  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 +40 -17
  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 +16 -1
  21. package/src/browser/public/Terminal.ts +24 -27
  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 +481 -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/MouseService.ts +2 -1
  47. package/src/browser/services/RenderService.ts +22 -15
  48. package/src/browser/services/SelectionService.ts +12 -4
  49. package/src/browser/services/Services.ts +24 -15
  50. package/src/browser/services/ThemeService.ts +2 -2
  51. package/src/common/Async.ts +105 -0
  52. package/src/common/CircularList.ts +2 -2
  53. package/src/common/Color.ts +8 -0
  54. package/src/common/CoreTerminal.ts +21 -11
  55. package/src/common/Event.ts +118 -0
  56. package/src/common/InputHandler.ts +244 -24
  57. package/src/common/Lifecycle.ts +113 -0
  58. package/src/common/Platform.ts +13 -3
  59. package/src/common/SortedList.ts +7 -3
  60. package/src/common/TaskQueue.ts +9 -3
  61. package/src/common/Types.ts +29 -9
  62. package/src/common/Version.ts +9 -0
  63. package/src/common/buffer/Buffer.ts +20 -14
  64. package/src/common/buffer/BufferLine.ts +4 -5
  65. package/src/common/buffer/BufferSet.ts +7 -6
  66. package/src/common/buffer/CellData.ts +57 -0
  67. package/src/common/buffer/Marker.ts +2 -2
  68. package/src/common/buffer/Types.ts +6 -2
  69. package/src/common/data/EscapeSequences.ts +71 -70
  70. package/src/common/input/Keyboard.ts +14 -7
  71. package/src/common/input/KittyKeyboard.ts +491 -0
  72. package/src/common/input/Win32InputMode.ts +297 -0
  73. package/src/common/input/WriteBuffer.ts +34 -2
  74. package/src/common/input/XParseColor.ts +2 -2
  75. package/src/common/parser/ApcParser.ts +245 -0
  76. package/src/common/parser/Constants.ts +22 -4
  77. package/src/common/parser/DcsParser.ts +5 -5
  78. package/src/common/parser/EscapeSequenceParser.ts +75 -22
  79. package/src/common/parser/OscParser.ts +5 -5
  80. package/src/common/parser/Types.ts +34 -1
  81. package/src/common/public/BufferLineApiView.ts +2 -2
  82. package/src/common/public/BufferNamespaceApi.ts +2 -2
  83. package/src/common/public/ParserApi.ts +3 -0
  84. package/src/common/services/BufferService.ts +8 -5
  85. package/src/common/services/CharsetService.ts +4 -0
  86. package/src/common/services/CoreMouseService.ts +2 -2
  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/OptionsService.ts +13 -4
  91. package/src/common/services/Services.ts +39 -16
  92. package/src/common/services/UnicodeService.ts +1 -1
  93. package/typings/xterm.d.ts +319 -35
  94. package/src/common/TypedArrayUtils.ts +0 -17
  95. package/src/vs/base/browser/browser.ts +0 -141
  96. package/src/vs/base/browser/canIUse.ts +0 -49
  97. package/src/vs/base/browser/dom.ts +0 -2369
  98. package/src/vs/base/browser/fastDomNode.ts +0 -316
  99. package/src/vs/base/browser/globalPointerMoveMonitor.ts +0 -112
  100. package/src/vs/base/browser/iframe.ts +0 -135
  101. package/src/vs/base/browser/keyboardEvent.ts +0 -213
  102. package/src/vs/base/browser/mouseEvent.ts +0 -229
  103. package/src/vs/base/browser/touch.ts +0 -372
  104. package/src/vs/base/browser/ui/scrollbar/abstractScrollbar.ts +0 -303
  105. package/src/vs/base/browser/ui/scrollbar/horizontalScrollbar.ts +0 -114
  106. package/src/vs/base/browser/ui/scrollbar/scrollableElement.ts +0 -720
  107. package/src/vs/base/browser/ui/scrollbar/scrollableElementOptions.ts +0 -165
  108. package/src/vs/base/browser/ui/scrollbar/scrollbarArrow.ts +0 -114
  109. package/src/vs/base/browser/ui/scrollbar/scrollbarState.ts +0 -243
  110. package/src/vs/base/browser/ui/scrollbar/scrollbarVisibilityController.ts +0 -118
  111. package/src/vs/base/browser/ui/scrollbar/verticalScrollbar.ts +0 -116
  112. package/src/vs/base/browser/ui/widget.ts +0 -57
  113. package/src/vs/base/browser/window.ts +0 -14
  114. package/src/vs/base/common/arrays.ts +0 -887
  115. package/src/vs/base/common/arraysFind.ts +0 -202
  116. package/src/vs/base/common/assert.ts +0 -71
  117. package/src/vs/base/common/async.ts +0 -1992
  118. package/src/vs/base/common/cancellation.ts +0 -148
  119. package/src/vs/base/common/charCode.ts +0 -450
  120. package/src/vs/base/common/collections.ts +0 -140
  121. package/src/vs/base/common/decorators.ts +0 -130
  122. package/src/vs/base/common/equals.ts +0 -146
  123. package/src/vs/base/common/errors.ts +0 -303
  124. package/src/vs/base/common/event.ts +0 -1778
  125. package/src/vs/base/common/functional.ts +0 -32
  126. package/src/vs/base/common/hash.ts +0 -316
  127. package/src/vs/base/common/iterator.ts +0 -159
  128. package/src/vs/base/common/keyCodes.ts +0 -526
  129. package/src/vs/base/common/keybindings.ts +0 -284
  130. package/src/vs/base/common/lazy.ts +0 -47
  131. package/src/vs/base/common/lifecycle.ts +0 -801
  132. package/src/vs/base/common/linkedList.ts +0 -142
  133. package/src/vs/base/common/map.ts +0 -202
  134. package/src/vs/base/common/numbers.ts +0 -98
  135. package/src/vs/base/common/observable.ts +0 -76
  136. package/src/vs/base/common/observableInternal/api.ts +0 -31
  137. package/src/vs/base/common/observableInternal/autorun.ts +0 -281
  138. package/src/vs/base/common/observableInternal/base.ts +0 -489
  139. package/src/vs/base/common/observableInternal/debugName.ts +0 -145
  140. package/src/vs/base/common/observableInternal/derived.ts +0 -428
  141. package/src/vs/base/common/observableInternal/lazyObservableValue.ts +0 -146
  142. package/src/vs/base/common/observableInternal/logging.ts +0 -328
  143. package/src/vs/base/common/observableInternal/promise.ts +0 -209
  144. package/src/vs/base/common/observableInternal/utils.ts +0 -610
  145. package/src/vs/base/common/platform.ts +0 -281
  146. package/src/vs/base/common/scrollable.ts +0 -522
  147. package/src/vs/base/common/sequence.ts +0 -34
  148. package/src/vs/base/common/stopwatch.ts +0 -43
  149. package/src/vs/base/common/strings.ts +0 -557
  150. package/src/vs/base/common/symbols.ts +0 -9
  151. package/src/vs/base/common/uint.ts +0 -59
  152. package/src/vs/patches/nls.ts +0 -90
  153. package/src/vs/typings/base-common.d.ts +0 -20
  154. package/src/vs/typings/require.d.ts +0 -42
  155. package/src/vs/typings/vscode-globals-nls.d.ts +0 -36
  156. 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
10
  import { ILinkProviderService, IMouseService, IRenderService } from './services/Services';
11
- import { Emitter } from 'vs/base/common/event';
12
- import { addDisposableListener } from 'vs/base/browser/dom';
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; }
@@ -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,15 @@
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';
8
+ import { Disposable, toDisposable } from 'common/Lifecycle';
9
9
  import { IBufferService, ICoreMouseService, 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 { addDisposableListener, 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
+ import { Gesture, EventType as GestureEventType, type IGestureEvent } from 'browser/scrollable/touch';
16
17
 
17
18
  export class Viewport extends Disposable {
18
19
 
@@ -51,16 +52,17 @@ export class Viewport extends Disposable {
51
52
  }));
52
53
 
53
54
  this._scrollableElement = this._register(new SmoothScrollableElement(screenElement, {
54
- vertical: ScrollbarVisibility.Auto,
55
- horizontal: ScrollbarVisibility.Hidden,
55
+ vertical: ScrollbarVisibility.AUTO,
56
+ horizontal: ScrollbarVisibility.HIDDEN,
56
57
  useShadows: false,
57
58
  mouseWheelSmoothScroll: true,
59
+ verticalHasArrows: this._optionsService.rawOptions.scrollbar?.showArrows ?? false,
58
60
  ...this._getChangeOptions()
59
61
  }, scrollable));
60
62
  this._register(this._optionsService.onMultipleOptionChange([
61
63
  'scrollSensitivity',
62
64
  'fastScrollSensitivity',
63
- 'overviewRuler'
65
+ 'scrollbar'
64
66
  ], () => this._scrollableElement.updateOptions(this._getChangeOptions())));
65
67
  // Don't handle mouse wheel if wheel events are supported by the current mouse prototcol
66
68
  this._register(coreMouseService.onProtocolChange(type => {
@@ -70,7 +72,8 @@ export class Viewport extends Disposable {
70
72
  }));
71
73
 
72
74
  this._scrollableElement.setScrollDimensions({ height: 0, scrollHeight: 0 });
73
- this._register(Event.runAndSubscribe(themeService.onChangeColors, () => {
75
+ this._register(EventUtils.runAndSubscribe(themeService.onChangeColors, () => {
76
+ element.style.backgroundColor = themeService.colors.background.css;
74
77
  this._scrollableElement.getDomNode().style.backgroundColor = themeService.colors.background.css;
75
78
  }));
76
79
  element.appendChild(this._scrollableElement.getDomNode());
@@ -79,15 +82,15 @@ export class Viewport extends Disposable {
79
82
  this._styleElement = coreBrowserService.mainDocument.createElement('style');
80
83
  screenElement.appendChild(this._styleElement);
81
84
  this._register(toDisposable(() => this._styleElement.remove()));
82
- this._register(Event.runAndSubscribe(themeService.onChangeColors, () => {
85
+ this._register(EventUtils.runAndSubscribe(themeService.onChangeColors, () => {
83
86
  this._styleElement.textContent = [
84
- `.xterm .xterm-scrollable-element > .scrollbar > .slider {`,
87
+ `.xterm .xterm-scrollable-element > .xterm-scrollbar > .xterm-slider {`,
85
88
  ` background: ${themeService.colors.scrollbarSliderBackground.css};`,
86
89
  `}`,
87
- `.xterm .xterm-scrollable-element > .scrollbar > .slider:hover {`,
90
+ `.xterm .xterm-scrollable-element > .xterm-scrollbar > .xterm-slider:hover {`,
88
91
  ` background: ${themeService.colors.scrollbarSliderHoverBackground.css};`,
89
92
  `}`,
90
- `.xterm .xterm-scrollable-element > .scrollbar > .slider.active {`,
93
+ `.xterm .xterm-scrollable-element > .xterm-scrollbar > .xterm-slider.xterm-active {`,
91
94
  ` background: ${themeService.colors.scrollbarSliderActiveBackground.css};`,
92
95
  `}`
93
96
  ].join('\n');
@@ -103,6 +106,10 @@ export class Viewport extends Disposable {
103
106
  this._register(this._bufferService.onScroll(() => this._sync()));
104
107
 
105
108
  this._register(this._scrollableElement.onScroll(e => this._handleScroll(e)));
109
+
110
+ // Touch/gesture scrolling support
111
+ this._register(Gesture.addTarget(screenElement));
112
+ this._register(addDisposableListener(screenElement, GestureEventType.CHANGE, (e: IGestureEvent) => this._handleGestureChange(e)));
106
113
  }
107
114
 
108
115
  public scrollLines(disp: number): void {
@@ -123,11 +130,18 @@ export class Viewport extends Disposable {
123
130
  });
124
131
  }
125
132
 
126
- private _getChangeOptions(): ScrollableElementChangeOptions {
133
+ private _getChangeOptions(): IScrollableElementChangeOptions {
134
+ const showScrollbar = this._optionsService.rawOptions.scrollbar?.showScrollbar ?? true;
135
+ const showArrows = this._optionsService.rawOptions.scrollbar?.showArrows ?? false;
136
+ const verticalScrollbarSize = showScrollbar
137
+ ? (this._optionsService.rawOptions.scrollbar?.width ?? ViewportConstants.DEFAULT_SCROLL_BAR_WIDTH)
138
+ : 0;
127
139
  return {
128
140
  mouseWheelScrollSensitivity: this._optionsService.rawOptions.scrollSensitivity,
129
141
  fastScrollSensitivity: this._optionsService.rawOptions.fastScrollSensitivity,
130
- verticalScrollbarSize: this._optionsService.rawOptions.overviewRuler?.width || ViewportConstants.DEFAULT_SCROLL_BAR_WIDTH
142
+ vertical: showScrollbar ? ScrollbarVisibility.AUTO : ScrollbarVisibility.HIDDEN,
143
+ verticalScrollbarSize,
144
+ verticalHasArrows: showArrows
131
145
  };
132
146
  }
133
147
 
@@ -173,7 +187,7 @@ export class Viewport extends Disposable {
173
187
  this._isSyncing = false;
174
188
  }
175
189
 
176
- private _handleScroll(e: ScrollEvent): void {
190
+ private _handleScroll(e: IScrollEvent): void {
177
191
  if (!this._renderService) {
178
192
  return;
179
193
  }
@@ -189,4 +203,13 @@ export class Viewport extends Disposable {
189
203
  }
190
204
  this._isHandlingScroll = false;
191
205
  }
206
+
207
+ private _handleGestureChange(e: IGestureEvent): void {
208
+ e.preventDefault();
209
+ e.stopPropagation();
210
+ const pos = this._scrollableElement.getScrollPosition();
211
+ this._scrollableElement.setScrollPosition({
212
+ scrollTop: pos.scrollTop - e.translationY
213
+ });
214
+ }
192
215
  }
@@ -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
  }
@@ -41,6 +41,11 @@ export class CompositionHelper {
41
41
  */
42
42
  private _dataAlreadySent: string;
43
43
 
44
+ /**
45
+ * The pending textarea change timer, if any.
46
+ */
47
+ private _textareaChangeTimer?: number;
48
+
44
49
  constructor(
45
50
  private readonly _textarea: HTMLTextAreaElement,
46
51
  private readonly _compositionView: HTMLElement,
@@ -184,8 +189,12 @@ export class CompositionHelper {
184
189
  * IME is active.
185
190
  */
186
191
  private _handleAnyTextareaChanges(): void {
192
+ if (this._textareaChangeTimer) {
193
+ return;
194
+ }
187
195
  const oldValue = this._textarea.value;
188
- setTimeout(() => {
196
+ this._textareaChangeTimer = window.setTimeout(() => {
197
+ this._textareaChangeTimer = undefined;
189
198
  // Ignore if a composition has started since the timeout
190
199
  if (!this._isComposing) {
191
200
  const newValue = this._textarea.value;
@@ -230,6 +239,12 @@ export class CompositionHelper {
230
239
  this._compositionView.style.lineHeight = cellHeight + 'px';
231
240
  this._compositionView.style.fontFamily = this._optionsService.rawOptions.fontFamily;
232
241
  this._compositionView.style.fontSize = this._optionsService.rawOptions.fontSize + 'px';
242
+ // Limit the composition view width to the space between the cursor and
243
+ // the terminal's right edge, preventing it from overflowing the terminal.
244
+ const maxWidth = this._bufferService.cols * this._renderService.dimensions.css.cell.width - cursorLeft;
245
+ this._compositionView.style.maxWidth = maxWidth + 'px';
246
+ this._compositionView.style.overflow = 'hidden';
247
+ this._compositionView.style.direction = 'rtl';
233
248
  // Sync the textarea to the exact position of the composition view so the IME knows where the
234
249
  // text is.
235
250
  const compositionViewBounds = this._compositionView.getBoundingClientRect();
@@ -6,14 +6,14 @@
6
6
  import * as Strings from 'browser/LocalizableStrings';
7
7
  import { CoreBrowserTerminal as TerminalCore } from 'browser/CoreBrowserTerminal';
8
8
  import { IBufferRange, ITerminal } from 'browser/Types';
9
- import { Disposable } from 'vs/base/common/lifecycle';
9
+ import { Disposable } from 'common/Lifecycle';
10
10
  import { ITerminalOptions } from 'common/Types';
11
11
  import { AddonManager } from 'common/public/AddonManager';
12
12
  import { BufferNamespaceApi } from 'common/public/BufferNamespaceApi';
13
13
  import { ParserApi } from 'common/public/ParserApi';
14
14
  import { UnicodeApi } from 'common/public/UnicodeApi';
15
- import { IBufferNamespace as IBufferNamespaceApi, IDecoration, IDecorationOptions, IDisposable, ILinkProvider, ILocalizableStrings, IMarker, IModes, IParser, ITerminalAddon, Terminal as ITerminalApi, ITerminalInitOnlyOptions, IUnicodeHandling } from '@xterm/xterm';
16
- import type { Event } from 'vs/base/common/event';
15
+ import { IBufferNamespace as IBufferNamespaceApi, IDecoration, IDecorationOptions, IDisposable, ILinkProvider, ILocalizableStrings, IMarker, IModes, IParser, IRenderDimensions, ITerminalAddon, Terminal as ITerminalApi, ITerminalInitOnlyOptions, IUnicodeHandling } from '@xterm/xterm';
16
+ import type { IEvent } from 'common/Event';
17
17
 
18
18
  /**
19
19
  * The set of options that only have an effect when set in the Terminal constructor.
@@ -68,25 +68,24 @@ export class Terminal extends Disposable implements ITerminalApi {
68
68
  }
69
69
  }
70
70
 
71
- public get onBell(): Event<void> { return this._core.onBell; }
72
- public get onBinary(): Event<string> { return this._core.onBinary; }
73
- public get onCursorMove(): Event<void> { return this._core.onCursorMove; }
74
- public get onData(): Event<string> { return this._core.onData; }
75
- public get onKey(): Event<{ key: string, domEvent: KeyboardEvent }> { return this._core.onKey; }
76
- public get onLineFeed(): Event<void> { return this._core.onLineFeed; }
77
- public get onRender(): Event<{ start: number, end: number }> { return this._core.onRender; }
78
- public get onResize(): Event<{ cols: number, rows: number }> { return this._core.onResize; }
79
- public get onScroll(): Event<number> { return this._core.onScroll; }
80
- public get onSelectionChange(): Event<void> { return this._core.onSelectionChange; }
81
- public get onTitleChange(): Event<string> { return this._core.onTitleChange; }
82
- public get onWriteParsed(): Event<void> { return this._core.onWriteParsed; }
71
+ public get onBell(): IEvent<void> { return this._core.onBell; }
72
+ public get onBinary(): IEvent<string> { return this._core.onBinary; }
73
+ public get onCursorMove(): IEvent<void> { return this._core.onCursorMove; }
74
+ public get onData(): IEvent<string> { return this._core.onData; }
75
+ public get onKey(): IEvent<{ key: string, domEvent: KeyboardEvent }> { return this._core.onKey; }
76
+ public get onLineFeed(): IEvent<void> { return this._core.onLineFeed; }
77
+ public get onRender(): IEvent<{ start: number, end: number }> { return this._core.onRender; }
78
+ public get onResize(): IEvent<{ cols: number, rows: number }> { return this._core.onResize; }
79
+ public get onScroll(): IEvent<number> { return this._core.onScroll; }
80
+ public get onSelectionChange(): IEvent<void> { return this._core.onSelectionChange; }
81
+ public get onTitleChange(): IEvent<string> { return this._core.onTitleChange; }
82
+ public get onWriteParsed(): IEvent<void> { return this._core.onWriteParsed; }
83
+ public get onDimensionsChange(): IEvent<IRenderDimensions> { return this._core.onDimensionsChange; }
83
84
 
84
85
  public get element(): HTMLElement | undefined { return this._core.element; }
86
+ public get screenElement(): HTMLElement | undefined { return this._core.screenElement; }
85
87
  public get parser(): IParser {
86
- if (!this._parser) {
87
- this._parser = new ParserApi(this._core);
88
- }
89
- return this._parser;
88
+ return this._parser ??= new ParserApi(this._core);
90
89
  }
91
90
  public get unicode(): IUnicodeHandling {
92
91
  this._checkProposedApi();
@@ -96,13 +95,9 @@ export class Terminal extends Disposable implements ITerminalApi {
96
95
  public get rows(): number { return this._core.rows; }
97
96
  public get cols(): number { return this._core.cols; }
98
97
  public get buffer(): IBufferNamespaceApi {
99
- if (!this._buffer) {
100
- this._buffer = this._register(new BufferNamespaceApi(this._core));
101
- }
102
- return this._buffer;
98
+ return this._buffer ??= this._register(new BufferNamespaceApi(this._core));
103
99
  }
104
100
  public get markers(): ReadonlyArray<IMarker> {
105
- this._checkProposedApi();
106
101
  return this._core.markers;
107
102
  }
108
103
  public get modes(): IModes {
@@ -123,10 +118,15 @@ export class Terminal extends Disposable implements ITerminalApi {
123
118
  originMode: m.origin,
124
119
  reverseWraparoundMode: m.reverseWraparound,
125
120
  sendFocusMode: m.sendFocus,
121
+ showCursor: !this._core.coreService.isCursorHidden,
126
122
  synchronizedOutputMode: m.synchronizedOutput,
123
+ win32InputMode: m.win32InputMode,
127
124
  wraparoundMode: m.wraparound
128
125
  };
129
126
  }
127
+ public get dimensions(): IRenderDimensions | undefined {
128
+ return this._core.dimensions;
129
+ }
130
130
  public get options(): Required<ITerminalOptions> {
131
131
  return this._publicOptions;
132
132
  }
@@ -161,11 +161,9 @@ export class Terminal extends Disposable implements ITerminalApi {
161
161
  return this._core.registerLinkProvider(linkProvider);
162
162
  }
163
163
  public registerCharacterJoiner(handler: (text: string) => [number, number][]): number {
164
- this._checkProposedApi();
165
164
  return this._core.registerCharacterJoiner(handler);
166
165
  }
167
166
  public deregisterCharacterJoiner(joinerId: number): void {
168
- this._checkProposedApi();
169
167
  this._core.deregisterCharacterJoiner(joinerId);
170
168
  }
171
169
  public registerMarker(cursorYOffset: number = 0): IMarker {
@@ -173,7 +171,6 @@ export class Terminal extends Disposable implements ITerminalApi {
173
171
  return this._core.registerMarker(cursorYOffset);
174
172
  }
175
173
  public registerDecoration(decorationOptions: IDecorationOptions): IDecoration | undefined {
176
- this._checkProposedApi();
177
174
  this._verifyPositiveIntegers(decorationOptions.x ?? 0, decorationOptions.width ?? 0, decorationOptions.height ?? 0);
178
175
  return this._core.registerDecoration(decorationOptions);
179
176
  }