@xterm/xterm 6.1.0-beta.28 → 6.1.0-beta.281

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 (181) 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 +56 -45
  8. package/src/browser/AccessibilityManager.ts +18 -13
  9. package/src/browser/Clipboard.ts +8 -5
  10. package/src/browser/ColorContrastCache.ts +3 -3
  11. package/src/browser/CoreBrowserTerminal.ts +179 -348
  12. package/src/browser/Dom.ts +178 -0
  13. package/src/browser/Linkifier.ts +14 -14
  14. package/src/browser/OscLinkProvider.ts +86 -18
  15. package/src/browser/RenderDebouncer.ts +7 -9
  16. package/src/browser/TimeBasedDebouncer.ts +12 -5
  17. package/src/browser/Types.ts +16 -14
  18. package/src/browser/Viewport.ts +58 -23
  19. package/src/browser/decorations/BufferDecorationRenderer.ts +3 -3
  20. package/src/browser/decorations/ColorZoneStore.ts +1 -1
  21. package/src/browser/decorations/OverviewRulerRenderer.ts +36 -20
  22. package/src/browser/input/CompositionHelper.ts +47 -11
  23. package/src/browser/input/Mouse.ts +5 -9
  24. package/src/browser/input/MoveToCell.ts +3 -3
  25. package/src/browser/public/Terminal.ts +33 -36
  26. package/src/browser/renderer/dom/DomRenderer.ts +265 -89
  27. package/src/browser/renderer/dom/DomRendererRowFactory.ts +34 -27
  28. package/src/browser/renderer/dom/WidthCache.ts +57 -55
  29. package/src/browser/renderer/shared/Constants.ts +7 -0
  30. package/src/browser/renderer/shared/RendererUtils.ts +1 -1
  31. package/src/browser/renderer/shared/SelectionRenderModel.ts +2 -2
  32. package/src/browser/renderer/shared/TextBlinkStateManager.ts +97 -0
  33. package/src/browser/renderer/shared/Types.ts +10 -4
  34. package/src/browser/scrollable/abstractScrollbar.ts +300 -0
  35. package/src/browser/scrollable/fastDomNode.ts +126 -0
  36. package/src/browser/scrollable/globalPointerMoveMonitor.ts +90 -0
  37. package/src/browser/scrollable/horizontalScrollbar.ts +85 -0
  38. package/src/browser/scrollable/mouseEvent.ts +292 -0
  39. package/src/browser/scrollable/scrollable.ts +486 -0
  40. package/src/browser/scrollable/scrollableElement.ts +581 -0
  41. package/src/browser/scrollable/scrollableElementOptions.ts +161 -0
  42. package/src/browser/scrollable/scrollbarArrow.ts +110 -0
  43. package/src/browser/scrollable/scrollbarState.ts +246 -0
  44. package/src/browser/scrollable/scrollbarVisibilityController.ts +113 -0
  45. package/src/browser/scrollable/touch.ts +485 -0
  46. package/src/browser/scrollable/verticalScrollbar.ts +143 -0
  47. package/src/browser/scrollable/widget.ts +23 -0
  48. package/src/browser/selection/SelectionModel.ts +1 -1
  49. package/src/browser/services/CharSizeService.ts +4 -4
  50. package/src/browser/services/CharacterJoinerService.ts +13 -11
  51. package/src/browser/services/CoreBrowserService.ts +7 -5
  52. package/src/browser/services/KeyboardService.ts +67 -0
  53. package/src/browser/services/LinkProviderService.ts +3 -3
  54. package/src/browser/services/MouseCoordsService.ts +47 -0
  55. package/src/browser/services/MouseService.ts +619 -23
  56. package/src/browser/services/RenderService.ts +33 -21
  57. package/src/browser/services/SelectionService.ts +72 -54
  58. package/src/browser/services/Services.ts +44 -21
  59. package/src/browser/services/ThemeService.ts +9 -9
  60. package/src/common/Async.ts +141 -0
  61. package/src/common/CircularList.ts +24 -3
  62. package/src/common/Color.ts +13 -5
  63. package/src/common/CoreTerminal.ts +61 -35
  64. package/src/common/Event.ts +118 -0
  65. package/src/common/InputHandler.ts +286 -105
  66. package/src/common/Lifecycle.ts +113 -0
  67. package/src/common/Platform.ts +15 -5
  68. package/src/common/SortedList.ts +8 -4
  69. package/src/common/StringBuilder.ts +67 -0
  70. package/src/common/TaskQueue.ts +17 -8
  71. package/src/common/Types.ts +68 -206
  72. package/src/common/Version.ts +1 -1
  73. package/src/common/WindowsMode.ts +2 -2
  74. package/src/common/buffer/AttributeData.ts +3 -2
  75. package/src/common/buffer/Buffer.ts +47 -32
  76. package/src/common/buffer/BufferLine.ts +175 -100
  77. package/src/common/buffer/BufferLineStringCache.ts +69 -0
  78. package/src/common/buffer/BufferReflow.ts +7 -4
  79. package/src/common/buffer/BufferSet.ts +13 -9
  80. package/src/common/buffer/CellData.ts +61 -4
  81. package/src/common/buffer/Constants.ts +13 -13
  82. package/src/common/buffer/Marker.ts +4 -4
  83. package/src/common/buffer/Types.ts +153 -3
  84. package/src/common/data/Charsets.ts +4 -7
  85. package/src/common/data/EscapeSequences.ts +71 -70
  86. package/src/common/input/Keyboard.ts +17 -10
  87. package/src/common/input/KittyKeyboard.ts +526 -0
  88. package/src/common/input/TextDecoder.ts +3 -3
  89. package/src/common/input/UnicodeV6.ts +3 -2
  90. package/src/common/input/Win32InputMode.ts +297 -0
  91. package/src/common/input/WriteBuffer.ts +108 -39
  92. package/src/common/input/XParseColor.ts +2 -2
  93. package/src/common/parser/ApcParser.ts +196 -0
  94. package/src/common/parser/Constants.ts +14 -4
  95. package/src/common/parser/DcsParser.ts +15 -16
  96. package/src/common/parser/EscapeSequenceParser.ts +214 -72
  97. package/src/common/parser/OscParser.ts +14 -15
  98. package/src/common/parser/Params.ts +31 -12
  99. package/src/common/parser/Types.ts +40 -30
  100. package/src/common/public/BufferApiView.ts +3 -3
  101. package/src/common/public/BufferLineApiView.ts +4 -4
  102. package/src/common/public/BufferNamespaceApi.ts +5 -5
  103. package/src/common/public/ParserApi.ts +5 -2
  104. package/src/common/public/UnicodeApi.ts +1 -1
  105. package/src/common/services/BufferService.ts +17 -13
  106. package/src/common/services/CharsetService.ts +6 -2
  107. package/src/common/services/CoreService.ts +23 -10
  108. package/src/common/services/DecorationService.ts +260 -15
  109. package/src/common/services/InstantiationService.ts +2 -2
  110. package/src/common/services/LogService.ts +2 -32
  111. package/src/common/services/{CoreMouseService.ts → MouseStateService.ts} +22 -133
  112. package/src/common/services/OptionsService.ts +17 -7
  113. package/src/common/services/OscLinkService.ts +3 -2
  114. package/src/common/services/ServiceRegistry.ts +14 -8
  115. package/src/common/services/Services.ts +54 -50
  116. package/src/common/services/UnicodeService.ts +6 -11
  117. package/typings/xterm.d.ts +329 -34
  118. package/src/common/Clone.ts +0 -23
  119. package/src/common/TypedArrayUtils.ts +0 -17
  120. package/src/vs/base/browser/browser.ts +0 -141
  121. package/src/vs/base/browser/canIUse.ts +0 -49
  122. package/src/vs/base/browser/dom.ts +0 -2369
  123. package/src/vs/base/browser/fastDomNode.ts +0 -316
  124. package/src/vs/base/browser/globalPointerMoveMonitor.ts +0 -112
  125. package/src/vs/base/browser/iframe.ts +0 -135
  126. package/src/vs/base/browser/keyboardEvent.ts +0 -213
  127. package/src/vs/base/browser/mouseEvent.ts +0 -229
  128. package/src/vs/base/browser/touch.ts +0 -372
  129. package/src/vs/base/browser/ui/scrollbar/abstractScrollbar.ts +0 -303
  130. package/src/vs/base/browser/ui/scrollbar/horizontalScrollbar.ts +0 -114
  131. package/src/vs/base/browser/ui/scrollbar/scrollableElement.ts +0 -720
  132. package/src/vs/base/browser/ui/scrollbar/scrollableElementOptions.ts +0 -165
  133. package/src/vs/base/browser/ui/scrollbar/scrollbarArrow.ts +0 -114
  134. package/src/vs/base/browser/ui/scrollbar/scrollbarState.ts +0 -243
  135. package/src/vs/base/browser/ui/scrollbar/scrollbarVisibilityController.ts +0 -118
  136. package/src/vs/base/browser/ui/scrollbar/verticalScrollbar.ts +0 -116
  137. package/src/vs/base/browser/ui/widget.ts +0 -57
  138. package/src/vs/base/browser/window.ts +0 -14
  139. package/src/vs/base/common/arrays.ts +0 -887
  140. package/src/vs/base/common/arraysFind.ts +0 -202
  141. package/src/vs/base/common/assert.ts +0 -71
  142. package/src/vs/base/common/async.ts +0 -1992
  143. package/src/vs/base/common/cancellation.ts +0 -148
  144. package/src/vs/base/common/charCode.ts +0 -450
  145. package/src/vs/base/common/collections.ts +0 -140
  146. package/src/vs/base/common/decorators.ts +0 -130
  147. package/src/vs/base/common/equals.ts +0 -146
  148. package/src/vs/base/common/errors.ts +0 -303
  149. package/src/vs/base/common/event.ts +0 -1778
  150. package/src/vs/base/common/functional.ts +0 -32
  151. package/src/vs/base/common/hash.ts +0 -316
  152. package/src/vs/base/common/iterator.ts +0 -159
  153. package/src/vs/base/common/keyCodes.ts +0 -526
  154. package/src/vs/base/common/keybindings.ts +0 -284
  155. package/src/vs/base/common/lazy.ts +0 -47
  156. package/src/vs/base/common/lifecycle.ts +0 -801
  157. package/src/vs/base/common/linkedList.ts +0 -142
  158. package/src/vs/base/common/map.ts +0 -202
  159. package/src/vs/base/common/numbers.ts +0 -98
  160. package/src/vs/base/common/observable.ts +0 -76
  161. package/src/vs/base/common/observableInternal/api.ts +0 -31
  162. package/src/vs/base/common/observableInternal/autorun.ts +0 -281
  163. package/src/vs/base/common/observableInternal/base.ts +0 -489
  164. package/src/vs/base/common/observableInternal/debugName.ts +0 -145
  165. package/src/vs/base/common/observableInternal/derived.ts +0 -428
  166. package/src/vs/base/common/observableInternal/lazyObservableValue.ts +0 -146
  167. package/src/vs/base/common/observableInternal/logging.ts +0 -328
  168. package/src/vs/base/common/observableInternal/promise.ts +0 -209
  169. package/src/vs/base/common/observableInternal/utils.ts +0 -610
  170. package/src/vs/base/common/platform.ts +0 -281
  171. package/src/vs/base/common/scrollable.ts +0 -522
  172. package/src/vs/base/common/sequence.ts +0 -34
  173. package/src/vs/base/common/stopwatch.ts +0 -43
  174. package/src/vs/base/common/strings.ts +0 -557
  175. package/src/vs/base/common/symbols.ts +0 -9
  176. package/src/vs/base/common/uint.ts +0 -59
  177. package/src/vs/patches/nls.ts +0 -90
  178. package/src/vs/typings/base-common.d.ts +0 -20
  179. package/src/vs/typings/require.d.ts +0 -42
  180. package/src/vs/typings/vscode-globals-nls.d.ts +0 -36
  181. package/src/vs/typings/vscode-globals-product.d.ts +0 -33
@@ -3,25 +3,32 @@
3
3
  * @license MIT
4
4
  */
5
5
 
6
- import { IDeleteEvent, IInsertEvent } from 'common/CircularList';
7
- import { UnderlineStyle } from 'common/buffer/Constants';
8
- import { IBufferSet } from 'common/buffer/Types';
9
- import { IParams } from 'common/parser/Types';
10
- import { ICoreMouseService, ICoreService, IOptionsService, IUnicodeService } from 'common/services/Services';
11
6
  import { IFunctionIdentifier, ITerminalOptions as IPublicTerminalOptions } from '@xterm/xterm';
12
- import type { Emitter, Event } from 'vs/base/common/event';
13
-
14
- export interface ICoreTerminal {
15
- coreMouseService: ICoreMouseService;
16
- coreService: ICoreService;
17
- optionsService: IOptionsService;
18
- unicodeService: IUnicodeService;
19
- buffers: IBufferSet;
20
- options: Required<ITerminalOptions>;
21
- registerCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean | Promise<boolean>): IDisposable;
22
- registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean | Promise<boolean>): IDisposable;
23
- registerEscHandler(id: IFunctionIdentifier, callback: () => boolean | Promise<boolean>): IDisposable;
24
- registerOscHandler(ident: number, callback: (data: string) => boolean | Promise<boolean>): IDisposable;
7
+ import type { IEvent } from './Event';
8
+
9
+ /** sequence params serialized to js arrays */
10
+ export type ParamsArray = (number | number[])[];
11
+
12
+ /** Interface of Params storage class. */
13
+ export interface IParams {
14
+ /** from ctor */
15
+ maxLength: number;
16
+ maxSubParamsLength: number;
17
+
18
+ /** param values and its length */
19
+ params: Int32Array;
20
+ length: number;
21
+
22
+ /** methods */
23
+ clone(): IParams;
24
+ toArray(): ParamsArray;
25
+ reset(): void;
26
+ resetZdm(): void;
27
+ addParam(value: number): void;
28
+ addSubParam(value: number): void;
29
+ hasSubParams(idx: number): boolean;
30
+ getSubParams(idx: number): Int32Array | null;
31
+ getSubParamsAll(): {[idx: number]: Int32Array};
25
32
  }
26
33
 
27
34
  export interface IDisposable {
@@ -31,7 +38,6 @@ export interface IDisposable {
31
38
  // TODO: The options that are not in the public API should be reviewed
32
39
  export interface ITerminalOptions extends IPublicTerminalOptions {
33
40
  [key: string]: any;
34
- cancelEvents?: boolean;
35
41
  convertEol?: boolean;
36
42
  termName?: string;
37
43
  }
@@ -62,28 +68,6 @@ export interface IScrollEvent {
62
68
  position: number;
63
69
  }
64
70
 
65
- export interface ICircularList<T> {
66
- length: number;
67
- maxLength: number;
68
- isFull: boolean;
69
-
70
- onDeleteEmitter: Emitter<IDeleteEvent>;
71
- onDelete: Event<IDeleteEvent>;
72
- onInsertEmitter: Emitter<IInsertEvent>;
73
- onInsert: Event<IInsertEvent>;
74
- onTrimEmitter: Emitter<number>;
75
- onTrim: Event<number>;
76
-
77
- get(index: number): T | undefined;
78
- set(index: number, value: T): void;
79
- push(value: T): void;
80
- recycle(): T;
81
- pop(): T | undefined;
82
- splice(start: number, deleteCount: number, ...items: T[]): void;
83
- trimStart(count: number): void;
84
- shiftElements(start: number, count: number, offset: number): void;
85
- }
86
-
87
71
  export const enum KeyboardResultType {
88
72
  SEND_KEY,
89
73
  SELECT_ALL,
@@ -101,23 +85,11 @@ export interface ICharset {
101
85
  [key: string]: string | undefined;
102
86
  }
103
87
 
104
- export type CharData = [number, string, number, number];
105
-
106
88
  export interface IColor {
107
89
  readonly css: string;
108
90
  readonly rgba: number; // 32-bit int with rgba in each byte
109
91
  }
110
- export type IColorRGB = [number, number, number];
111
-
112
- export interface IExtendedAttrs {
113
- ext: number;
114
- underlineStyle: UnderlineStyle;
115
- underlineColor: number;
116
- underlineVariantOffset: number;
117
- urlId: number;
118
- clone(): IExtendedAttrs;
119
- isEmpty(): boolean;
120
- }
92
+ export type IColorRGB = [red: number, green: number, blue: number];
121
93
 
122
94
  /**
123
95
  * Tracks the current hyperlink. Since these are treated as extended attirbutes, these get passed on
@@ -130,136 +102,6 @@ export interface IOscLinkData {
130
102
  uri: string;
131
103
  }
132
104
 
133
- /**
134
- * An object that represents all attributes of a cell.
135
- */
136
- export interface IAttributeData {
137
- /**
138
- * "fg" is a 32-bit unsigned integer that stores the foreground color of the cell in the 24 least
139
- * significant bits and additional flags in the remaining 8 bits.
140
- */
141
- fg: number;
142
- /**
143
- * "bg" is a 32-bit unsigned integer that stores the background color of the cell in the 24 least
144
- * significant bits and additional flags in the remaining 8 bits.
145
- */
146
- bg: number;
147
- /**
148
- * "extended", aka "ext", stores extended attributes beyond those available in fg and bg. This
149
- * data is optional on a cell and encodes less common data.
150
- */
151
- extended: IExtendedAttrs;
152
-
153
- clone(): IAttributeData;
154
-
155
- // flags
156
- isInverse(): number;
157
- isBold(): number;
158
- isUnderline(): number;
159
- isBlink(): number;
160
- isInvisible(): number;
161
- isItalic(): number;
162
- isDim(): number;
163
- isStrikethrough(): number;
164
- isProtected(): number;
165
- isOverline(): number;
166
-
167
- /**
168
- * The color mode of the foreground color which determines how to decode {@link getFgColor},
169
- * possible values include {@link Attributes.CM_DEFAULT}, {@link Attributes.CM_P16},
170
- * {@link Attributes.CM_P256} and {@link Attributes.CM_RGB}.
171
- */
172
- getFgColorMode(): number;
173
- /**
174
- * The color mode of the background color which determines how to decode {@link getBgColor},
175
- * possible values include {@link Attributes.CM_DEFAULT}, {@link Attributes.CM_P16},
176
- * {@link Attributes.CM_P256} and {@link Attributes.CM_RGB}.
177
- */
178
- getBgColorMode(): number;
179
- isFgRGB(): boolean;
180
- isBgRGB(): boolean;
181
- isFgPalette(): boolean;
182
- isBgPalette(): boolean;
183
- isFgDefault(): boolean;
184
- isBgDefault(): boolean;
185
- isAttributeDefault(): boolean;
186
-
187
- /**
188
- * Gets an integer representation of the foreground color, how to decode the color depends on the
189
- * color mode {@link getFgColorMode}.
190
- */
191
- getFgColor(): number;
192
- /**
193
- * Gets an integer representation of the background color, how to decode the color depends on the
194
- * color mode {@link getBgColorMode}.
195
- */
196
- getBgColor(): number;
197
-
198
- // extended attrs
199
- hasExtendedAttrs(): number;
200
- updateExtended(): void;
201
- getUnderlineColor(): number;
202
- getUnderlineColorMode(): number;
203
- isUnderlineColorRGB(): boolean;
204
- isUnderlineColorPalette(): boolean;
205
- isUnderlineColorDefault(): boolean;
206
- getUnderlineStyle(): number;
207
- getUnderlineVariantOffset(): number;
208
- }
209
-
210
- /** Cell data */
211
- export interface ICellData extends IAttributeData {
212
- content: number;
213
- combinedData: string;
214
- isCombined(): number;
215
- getWidth(): number;
216
- getChars(): string;
217
- getCode(): number;
218
- setFromCharData(value: CharData): void;
219
- getAsCharData(): CharData;
220
- }
221
-
222
- /**
223
- * Interface for a line in the terminal buffer.
224
- */
225
- export interface IBufferLine {
226
- length: number;
227
- isWrapped: boolean;
228
- get(index: number): CharData;
229
- set(index: number, value: CharData): void;
230
- loadCell(index: number, cell: ICellData): ICellData;
231
- setCell(index: number, cell: ICellData): void;
232
- setCellFromCodepoint(index: number, codePoint: number, width: number, attrs: IAttributeData): void;
233
- addCodepointToCell(index: number, codePoint: number, width: number): void;
234
- insertCells(pos: number, n: number, ch: ICellData): void;
235
- deleteCells(pos: number, n: number, fill: ICellData): void;
236
- replaceCells(start: number, end: number, fill: ICellData, respectProtect?: boolean): void;
237
- resize(cols: number, fill: ICellData): boolean;
238
- cleanupMemory(): number;
239
- fill(fillCellData: ICellData, respectProtect?: boolean): void;
240
- copyFrom(line: IBufferLine): void;
241
- clone(): IBufferLine;
242
- getTrimmedLength(): number;
243
- getNoBgTrimmedLength(): number;
244
- translateToString(trimRight?: boolean, startCol?: number, endCol?: number, outColumns?: number[]): string;
245
-
246
- /* direct access to cell attrs */
247
- getWidth(index: number): number;
248
- hasWidth(index: number): number;
249
- getFg(index: number): number;
250
- getBg(index: number): number;
251
- hasContent(index: number): number;
252
- getCodePoint(index: number): number;
253
- isCombined(index: number): number;
254
- getString(index: number): string;
255
- }
256
-
257
- export interface IMarker extends IDisposable {
258
- readonly id: number;
259
- readonly isDisposed: boolean;
260
- readonly line: number;
261
- onDispose: Event<void>;
262
- }
263
105
  export interface IModes {
264
106
  insertMode: boolean;
265
107
  }
@@ -268,15 +110,34 @@ export interface IDecPrivateModes {
268
110
  applicationCursorKeys: boolean;
269
111
  applicationKeypad: boolean;
270
112
  bracketedPasteMode: boolean;
113
+ colorSchemeUpdates: boolean;
271
114
  cursorBlink: boolean | undefined;
272
115
  cursorStyle: CursorStyle | undefined;
273
116
  origin: boolean;
274
117
  reverseWraparound: boolean;
275
118
  sendFocus: boolean;
276
119
  synchronizedOutput: boolean;
120
+ win32InputMode: boolean;
277
121
  wraparound: boolean; // defaults: xterm - true, vt100 - false
278
122
  }
279
123
 
124
+ /**
125
+ * Kitty keyboard protocol state.
126
+ * Maintains per-screen stacks of enhancement flags.
127
+ */
128
+ export interface IKittyKeyboardState {
129
+ /** Current active enhancement flags (for current screen) */
130
+ flags: number;
131
+ /** Saved flags for main screen when alt is active */
132
+ mainFlags: number;
133
+ /** Saved flags for alternate screen when main is active */
134
+ altFlags: number;
135
+ /** Stack of flags for main screen */
136
+ mainStack: number[];
137
+ /** Stack of flags for alternate screen */
138
+ altStack: number[];
139
+ }
140
+
280
141
  export interface IRowRange {
281
142
  start: number;
282
143
  end: number;
@@ -320,11 +181,11 @@ export interface ICoreMouseEvent {
320
181
  x: number;
321
182
  y: number;
322
183
  /**
323
- * Button the action occured. Due to restrictions of the tracking protocols
184
+ * Button the action occurred. Due to restrictions of the tracking protocols
324
185
  * it is not possible to report multiple buttons at once.
325
186
  * Wheel is treated as a button.
326
187
  * There are invalid combinations of buttons and actions possible
327
- * (like move + wheel), those are silently ignored by the CoreMouseService.
188
+ * (like move + wheel), those are silently ignored by the MouseStateService.
328
189
  */
329
190
  button: CoreMouseButton;
330
191
  action: CoreMouseAction;
@@ -341,7 +202,7 @@ export interface ICoreMouseEvent {
341
202
  * CoreMouseEventType
342
203
  * To be reported to the browser component which events a mouse
343
204
  * protocol wants to be catched and forwarded as an ICoreMouseEvent
344
- * to CoreMouseService.
205
+ * to MouseStateService.
345
206
  */
346
207
  export const enum CoreMouseEventType {
347
208
  NONE = 0,
@@ -359,7 +220,7 @@ export const enum CoreMouseEventType {
359
220
 
360
221
  /**
361
222
  * Mouse protocol interface.
362
- * A mouse protocol can be registered and activated at the CoreMouseService.
223
+ * A mouse protocol can be registered and activated at the MouseStateService.
363
224
  * `events` should contain a list of needed events as a hint for the browser component
364
225
  * to install/remove the appropriate event handlers.
365
226
  * `restrict` applies further protocol specific restrictions like not allowed
@@ -372,7 +233,7 @@ export interface ICoreMouseProtocol {
372
233
 
373
234
  /**
374
235
  * CoreMouseEncoding
375
- * The tracking encoding can be registered and activated at the CoreMouseService.
236
+ * The tracking encoding can be registered and activated at the MouseStateService.
376
237
  * If a ICoreMouseEvent passes all procotol restrictions it will be encoded
377
238
  * with the active encoding and sent out.
378
239
  * Note: Returning an empty string will supress sending a mouse report,
@@ -449,7 +310,7 @@ export type IColorEvent = (IColorReportRequest | IColorSetRequest | IColorRestor
449
310
  * Calls the parser and handles actions generated by the parser.
450
311
  */
451
312
  export interface IInputHandler {
452
- onTitleChange: Event<string>;
313
+ onTitleChange: IEvent<string>;
453
314
 
454
315
  parse(data: string | Uint8Array, promiseResult?: boolean): void | Promise<boolean>;
455
316
  print(data: Uint32Array, start: number, end: number): void;
@@ -457,6 +318,7 @@ export interface IInputHandler {
457
318
  registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean | Promise<boolean>): IDisposable;
458
319
  registerEscHandler(id: IFunctionIdentifier, callback: () => boolean | Promise<boolean>): IDisposable;
459
320
  registerOscHandler(ident: number, callback: (data: string) => boolean | Promise<boolean>): IDisposable;
321
+ registerApcHandler(id: IFunctionIdentifier, callback: (data: string) => boolean | Promise<boolean>): IDisposable;
460
322
 
461
323
  /** C0 BEL */ bell(): boolean;
462
324
  /** C0 LF */ lineFeed(): boolean;
@@ -508,8 +370,8 @@ export interface IInputHandler {
508
370
  /** CSI ' } */ insertColumns(params: IParams): boolean;
509
371
  /** CSI ' ~ */ deleteColumns(params: IParams): boolean;
510
372
 
511
- /** OSC 0
512
- OSC 2 */ setTitle(data: string): boolean;
373
+ /** OSC 0 */
374
+ /** OSC 2 */ setTitle(data: string): boolean;
513
375
  /** OSC 4 */ setOrReportIndexedColor(data: string): boolean;
514
376
  /** OSC 10 */ setOrReportFgColor(data: string): boolean;
515
377
  /** OSC 11 */ setOrReportBgColor(data: string): boolean;
@@ -522,24 +384,24 @@ export interface IInputHandler {
522
384
  /** ESC E */ nextLine(): boolean;
523
385
  /** ESC = */ keypadApplicationMode(): boolean;
524
386
  /** ESC > */ keypadNumericMode(): boolean;
525
- /** ESC % G
526
- ESC % @ */ selectDefaultCharset(): boolean;
527
- /** ESC ( C
528
- ESC ) C
529
- ESC * C
530
- ESC + C
531
- ESC - C
532
- ESC . C
533
- ESC / C */ selectCharset(collectAndFlag: string): boolean;
387
+ /** ESC % G */
388
+ /** ESC % @ */ selectDefaultCharset(): boolean;
389
+ /** ESC ( C */
390
+ /** ESC ) C */
391
+ /** ESC * C */
392
+ /** ESC + C */
393
+ /** ESC - C */
394
+ /** ESC . C */
395
+ /** ESC / C */ selectCharset(collectAndFlag: string): boolean;
534
396
  /** ESC D */ index(): boolean;
535
397
  /** ESC H */ tabSet(): boolean;
536
398
  /** ESC M */ reverseIndex(): boolean;
537
399
  /** ESC c */ fullReset(): boolean;
538
- /** ESC n
539
- ESC o
540
- ESC |
541
- ESC }
542
- ESC ~ */ setgLevel(level: number): boolean;
400
+ /** ESC n */
401
+ /** ESC o */
402
+ /** ESC | */
403
+ /** ESC } */
404
+ /** ESC ~ */ setgLevel(level: number): boolean;
543
405
  /** ESC # 8 */ screenAlignmentPattern(): boolean;
544
406
  }
545
407
 
@@ -6,4 +6,4 @@
6
6
  /**
7
7
  * The xterm.js version. This is updated by the publish script from package.json.
8
8
  */
9
- export const XTERM_VERSION = '6.1.0-beta.28';
9
+ export const XTERM_VERSION = '6.1.0-beta.281';
@@ -3,8 +3,8 @@
3
3
  * @license MIT
4
4
  */
5
5
 
6
- import { CHAR_DATA_CODE_INDEX, NULL_CELL_CODE, WHITESPACE_CELL_CODE } from 'common/buffer/Constants';
7
- import { IBufferService } from 'common/services/Services';
6
+ import { CHAR_DATA_CODE_INDEX, NULL_CELL_CODE, WHITESPACE_CELL_CODE } from './buffer/Constants';
7
+ import { IBufferService } from './services/Services';
8
8
 
9
9
  export function updateWindowsModeWrappedState(bufferService: IBufferService): void {
10
10
  // Winpty does not support wraparound mode which means that lines will never
@@ -3,8 +3,9 @@
3
3
  * @license MIT
4
4
  */
5
5
 
6
- import { IAttributeData, IColorRGB, IExtendedAttrs } from 'common/Types';
7
- import { Attributes, FgFlags, BgFlags, UnderlineStyle, ExtFlags } from 'common/buffer/Constants';
6
+ import { IColorRGB } from '../Types';
7
+ import { IAttributeData, IExtendedAttrs } from './Types';
8
+ import { Attributes, FgFlags, BgFlags, UnderlineStyle, ExtFlags } from './Constants';
8
9
 
9
10
  export class AttributeData implements IAttributeData {
10
11
  public static toColorRGB(value: number): IColorRGB {
@@ -3,18 +3,20 @@
3
3
  * @license MIT
4
4
  */
5
5
 
6
- import { CircularList, IInsertEvent } from 'common/CircularList';
7
- import { IdleTaskQueue } from 'common/TaskQueue';
8
- import { IAttributeData, IBufferLine, ICellData, ICharset } from 'common/Types';
9
- import { ExtendedAttrs } from 'common/buffer/AttributeData';
10
- import { BufferLine, DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';
11
- import { getWrappedLineTrimmedLength, reflowLargerApplyNewLayout, reflowLargerCreateNewLayout, reflowLargerGetLinesToRemove, reflowSmallerGetNewLineLengths } from 'common/buffer/BufferReflow';
12
- import { CellData } from 'common/buffer/CellData';
13
- import { NULL_CELL_CHAR, NULL_CELL_CODE, NULL_CELL_WIDTH, WHITESPACE_CELL_CHAR, WHITESPACE_CELL_CODE, WHITESPACE_CELL_WIDTH } from 'common/buffer/Constants';
14
- import { Marker } from 'common/buffer/Marker';
15
- import { IBuffer } from 'common/buffer/Types';
16
- import { DEFAULT_CHARSET } from 'common/data/Charsets';
17
- import { IBufferService, IOptionsService } from 'common/services/Services';
6
+ import { CircularList, IInsertEvent } from '../CircularList';
7
+ import { Disposable, toDisposable } from '../Lifecycle';
8
+ import { IdleTaskQueue } from '../TaskQueue';
9
+ import { ICharset } from '../Types';
10
+ import { IAttributeData, IBuffer, IBufferLine, ICellData } from './Types';
11
+ import { ExtendedAttrs } from './AttributeData';
12
+ import { BufferLine, DEFAULT_ATTR_DATA } from './BufferLine';
13
+ import { BufferLineStringCache } from './BufferLineStringCache';
14
+ import { getWrappedLineTrimmedLength, reflowLargerApplyNewLayout, reflowLargerCreateNewLayout, reflowLargerGetLinesToRemove, reflowSmallerGetNewLineLengths } from './BufferReflow';
15
+ import { CellData } from './CellData';
16
+ import { NULL_CELL_CHAR, NULL_CELL_CODE, NULL_CELL_WIDTH, WHITESPACE_CELL_CHAR, WHITESPACE_CELL_CODE, WHITESPACE_CELL_WIDTH } from './Constants';
17
+ import { Marker } from './Marker';
18
+ import { DEFAULT_CHARSET } from '../data/Charsets';
19
+ import { IBufferService, ILogService, IOptionsService } from '../services/Services';
18
20
 
19
21
  export const MAX_BUFFER_SIZE = 4294967295; // 2^32 - 1
20
22
 
@@ -25,7 +27,7 @@ export const MAX_BUFFER_SIZE = 4294967295; // 2^32 - 1
25
27
  * - cursor position
26
28
  * - scroll position
27
29
  */
28
- export class Buffer implements IBuffer {
30
+ export class Buffer extends Disposable implements IBuffer {
29
31
  public lines: CircularList<IBufferLine>;
30
32
  public ydisp: number = 0;
31
33
  public ybase: number = 0;
@@ -38,24 +40,37 @@ export class Buffer implements IBuffer {
38
40
  public savedX: number = 0;
39
41
  public savedCurAttrData = DEFAULT_ATTR_DATA.clone();
40
42
  public savedCharset: ICharset | undefined = DEFAULT_CHARSET;
43
+ public savedCharsets: (ICharset | undefined)[] = [];
44
+ public savedGlevel: number = 0;
45
+ public savedOriginMode: boolean = false;
46
+ public savedWraparoundMode: boolean = true;
41
47
  public markers: Marker[] = [];
42
48
  private _nullCell: ICellData = CellData.fromCharData([0, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]);
43
49
  private _whitespaceCell: ICellData = CellData.fromCharData([0, WHITESPACE_CELL_CHAR, WHITESPACE_CELL_WIDTH, WHITESPACE_CELL_CODE]);
44
50
  private _cols: number;
45
51
  private _rows: number;
46
52
  private _isClearing: boolean = false;
53
+ private _memoryCleanupQueue: InstanceType<typeof IdleTaskQueue>;
54
+ private _memoryCleanupPosition = 0;
55
+ private readonly _stringCache: BufferLineStringCache;
47
56
 
48
57
  constructor(
49
58
  private _hasScrollback: boolean,
50
59
  private _optionsService: IOptionsService,
51
- private _bufferService: IBufferService
60
+ private _bufferService: IBufferService,
61
+ private readonly _logService: ILogService
52
62
  ) {
63
+ super();
53
64
  this._cols = this._bufferService.cols;
54
65
  this._rows = this._bufferService.rows;
55
66
  this.lines = new CircularList<IBufferLine>(this._getCorrectBufferLength(this._rows));
56
67
  this.scrollTop = 0;
57
68
  this.scrollBottom = this._rows - 1;
58
69
  this.setupTabStops();
70
+ this._memoryCleanupQueue = new IdleTaskQueue(this._logService);
71
+ this._register(toDisposable(() => this._memoryCleanupQueue.clear()));
72
+ this._register(toDisposable(() => this.clearAllMarkers()));
73
+ this._stringCache = this._register(new BufferLineStringCache());
59
74
  }
60
75
 
61
76
  public getNullCell(attr?: IAttributeData): ICellData {
@@ -85,7 +100,7 @@ export class Buffer implements IBuffer {
85
100
  }
86
101
 
87
102
  public getBlankLine(attr: IAttributeData, isWrapped?: boolean): IBufferLine {
88
- return new BufferLine(this._bufferService.cols, this.getNullCell(attr), isWrapped);
103
+ return new BufferLine(this._stringCache, this._bufferService.cols, this.getNullCell(attr), isWrapped);
89
104
  }
90
105
 
91
106
  public get hasScrollback(): boolean {
@@ -118,9 +133,7 @@ export class Buffer implements IBuffer {
118
133
  */
119
134
  public fillViewportRows(fillAttr?: IAttributeData): void {
120
135
  if (this.lines.length === 0) {
121
- if (fillAttr === undefined) {
122
- fillAttr = DEFAULT_ATTR_DATA;
123
- }
136
+ fillAttr ??= DEFAULT_ATTR_DATA;
124
137
  let i = this._rows;
125
138
  while (i--) {
126
139
  this.lines.push(this.getBlankLine(fillAttr));
@@ -129,9 +142,10 @@ export class Buffer implements IBuffer {
129
142
  }
130
143
 
131
144
  /**
132
- * Clears the buffer to it's initial state, discarding all previous data.
145
+ * Clears the buffer to its initial state, discarding all previous data.
133
146
  */
134
147
  public clear(): void {
148
+ this._stringCache.clear();
135
149
  this.ydisp = 0;
136
150
  this.ybase = 0;
137
151
  this.y = 0;
@@ -150,6 +164,7 @@ export class Buffer implements IBuffer {
150
164
  public resize(newCols: number, newRows: number): void {
151
165
  // store reference to null cell with default attrs
152
166
  const nullCell = this.getNullCell(DEFAULT_ATTR_DATA);
167
+ this._stringCache.clear();
153
168
 
154
169
  // count bufferlines with overly big memory to be cleaned afterwards
155
170
  let dirtyMemoryLines = 0;
@@ -182,9 +197,9 @@ export class Buffer implements IBuffer {
182
197
  for (let y = this._rows; y < newRows; y++) {
183
198
  if (this.lines.length < newRows + this.ybase) {
184
199
  if (this._optionsService.rawOptions.windowsPty.backend !== undefined || this._optionsService.rawOptions.windowsPty.buildNumber !== undefined) {
185
- // Just add the new missing rows on Windows as conpty reprints the screen with it's
200
+ // Just add the new missing rows on Windows as conpty reprints the screen with its
186
201
  // view of the world. Once a line enters scrollback for conpty it remains there
187
- this.lines.push(new BufferLine(newCols, nullCell));
202
+ this.lines.push(new BufferLine(this._stringCache, newCols, nullCell, false));
188
203
  } else {
189
204
  if (this.ybase > 0 && this.lines.length <= this.ybase + this.y + addToY + 1) {
190
205
  // There is room above the buffer and there are no empty elements below the line,
@@ -198,7 +213,7 @@ export class Buffer implements IBuffer {
198
213
  } else {
199
214
  // Add a blank line if there is no buffer left at the top to scroll to, or if there
200
215
  // are blank lines after the cursor
201
- this.lines.push(new BufferLine(newCols, nullCell));
216
+ this.lines.push(new BufferLine(this._stringCache, newCols, nullCell, false));
202
217
  }
203
218
  }
204
219
  }
@@ -260,6 +275,13 @@ export class Buffer implements IBuffer {
260
275
  this._cols = newCols;
261
276
  this._rows = newRows;
262
277
 
278
+ // Ensure the cursor position invariant: ybase + y must be within buffer bounds
279
+ // This can be violated during reflow or when shrinking rows
280
+ if (this.lines.length > 0) {
281
+ const maxY = Math.max(0, this.lines.length - this.ybase - 1);
282
+ this.y = Math.min(this.y, maxY);
283
+ }
284
+
263
285
  this._memoryCleanupQueue.clear();
264
286
  // schedule memory cleanup only, if more than 10% of the lines are affected
265
287
  if (dirtyMemoryLines > 0.1 * this.lines.length) {
@@ -268,9 +290,6 @@ export class Buffer implements IBuffer {
268
290
  }
269
291
  }
270
292
 
271
- private _memoryCleanupQueue = new IdleTaskQueue();
272
- private _memoryCleanupPosition = 0;
273
-
274
293
  private _batchedMemoryCleanup(): boolean {
275
294
  let normalRun = true;
276
295
  if (this._memoryCleanupPosition >= this.lines.length) {
@@ -335,7 +354,7 @@ export class Buffer implements IBuffer {
335
354
  }
336
355
  if (this.lines.length < newRows) {
337
356
  // Add an extra row at the bottom of the viewport
338
- this.lines.push(new BufferLine(newCols, nullCell));
357
+ this.lines.push(new BufferLine(this._stringCache, newCols, nullCell, false));
339
358
  }
340
359
  } else {
341
360
  if (this.ydisp === this.ybase) {
@@ -578,9 +597,7 @@ export class Buffer implements IBuffer {
578
597
  * @param x The position to move the cursor to the previous tab stop.
579
598
  */
580
599
  public prevStop(x?: number): number {
581
- if (x === null || x === undefined) {
582
- x = this.x;
583
- }
600
+ x ??= this.x;
584
601
  while (!this.tabs[--x] && x > 0);
585
602
  return x >= this._cols ? this._cols - 1 : x < 0 ? 0 : x;
586
603
  }
@@ -590,9 +607,7 @@ export class Buffer implements IBuffer {
590
607
  * @param x The position to move the cursor one tab stop forward.
591
608
  */
592
609
  public nextStop(x?: number): number {
593
- if (x === null || x === undefined) {
594
- x = this.x;
595
- }
610
+ x ??= this.x;
596
611
  while (!this.tabs[++x] && x < this._cols);
597
612
  return x >= this._cols ? this._cols - 1 : x < 0 ? 0 : x;
598
613
  }