@xterm/xterm 5.4.0-beta.1

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 (108) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +235 -0
  3. package/css/xterm.css +209 -0
  4. package/lib/xterm.js +2 -0
  5. package/lib/xterm.js.map +1 -0
  6. package/package.json +101 -0
  7. package/src/browser/AccessibilityManager.ts +278 -0
  8. package/src/browser/Clipboard.ts +93 -0
  9. package/src/browser/ColorContrastCache.ts +34 -0
  10. package/src/browser/Lifecycle.ts +33 -0
  11. package/src/browser/Linkifier2.ts +416 -0
  12. package/src/browser/LocalizableStrings.ts +12 -0
  13. package/src/browser/OscLinkProvider.ts +128 -0
  14. package/src/browser/RenderDebouncer.ts +83 -0
  15. package/src/browser/Terminal.ts +1317 -0
  16. package/src/browser/TimeBasedDebouncer.ts +86 -0
  17. package/src/browser/Types.d.ts +181 -0
  18. package/src/browser/Viewport.ts +401 -0
  19. package/src/browser/decorations/BufferDecorationRenderer.ts +134 -0
  20. package/src/browser/decorations/ColorZoneStore.ts +117 -0
  21. package/src/browser/decorations/OverviewRulerRenderer.ts +218 -0
  22. package/src/browser/input/CompositionHelper.ts +246 -0
  23. package/src/browser/input/Mouse.ts +54 -0
  24. package/src/browser/input/MoveToCell.ts +249 -0
  25. package/src/browser/public/Terminal.ts +260 -0
  26. package/src/browser/renderer/dom/DomRenderer.ts +509 -0
  27. package/src/browser/renderer/dom/DomRendererRowFactory.ts +526 -0
  28. package/src/browser/renderer/dom/WidthCache.ts +160 -0
  29. package/src/browser/renderer/shared/CellColorResolver.ts +137 -0
  30. package/src/browser/renderer/shared/CharAtlasCache.ts +96 -0
  31. package/src/browser/renderer/shared/CharAtlasUtils.ts +75 -0
  32. package/src/browser/renderer/shared/Constants.ts +14 -0
  33. package/src/browser/renderer/shared/CursorBlinkStateManager.ts +146 -0
  34. package/src/browser/renderer/shared/CustomGlyphs.ts +687 -0
  35. package/src/browser/renderer/shared/DevicePixelObserver.ts +41 -0
  36. package/src/browser/renderer/shared/README.md +1 -0
  37. package/src/browser/renderer/shared/RendererUtils.ts +58 -0
  38. package/src/browser/renderer/shared/SelectionRenderModel.ts +91 -0
  39. package/src/browser/renderer/shared/TextureAtlas.ts +1082 -0
  40. package/src/browser/renderer/shared/Types.d.ts +173 -0
  41. package/src/browser/selection/SelectionModel.ts +144 -0
  42. package/src/browser/selection/Types.d.ts +15 -0
  43. package/src/browser/services/CharSizeService.ts +102 -0
  44. package/src/browser/services/CharacterJoinerService.ts +339 -0
  45. package/src/browser/services/CoreBrowserService.ts +137 -0
  46. package/src/browser/services/MouseService.ts +46 -0
  47. package/src/browser/services/RenderService.ts +279 -0
  48. package/src/browser/services/SelectionService.ts +1031 -0
  49. package/src/browser/services/Services.ts +147 -0
  50. package/src/browser/services/ThemeService.ts +237 -0
  51. package/src/common/CircularList.ts +241 -0
  52. package/src/common/Clone.ts +23 -0
  53. package/src/common/Color.ts +357 -0
  54. package/src/common/CoreTerminal.ts +284 -0
  55. package/src/common/EventEmitter.ts +78 -0
  56. package/src/common/InputHandler.ts +3461 -0
  57. package/src/common/Lifecycle.ts +108 -0
  58. package/src/common/MultiKeyMap.ts +42 -0
  59. package/src/common/Platform.ts +44 -0
  60. package/src/common/SortedList.ts +118 -0
  61. package/src/common/TaskQueue.ts +166 -0
  62. package/src/common/TypedArrayUtils.ts +17 -0
  63. package/src/common/Types.d.ts +553 -0
  64. package/src/common/WindowsMode.ts +27 -0
  65. package/src/common/buffer/AttributeData.ts +196 -0
  66. package/src/common/buffer/Buffer.ts +654 -0
  67. package/src/common/buffer/BufferLine.ts +524 -0
  68. package/src/common/buffer/BufferRange.ts +13 -0
  69. package/src/common/buffer/BufferReflow.ts +223 -0
  70. package/src/common/buffer/BufferSet.ts +134 -0
  71. package/src/common/buffer/CellData.ts +94 -0
  72. package/src/common/buffer/Constants.ts +149 -0
  73. package/src/common/buffer/Marker.ts +43 -0
  74. package/src/common/buffer/Types.d.ts +52 -0
  75. package/src/common/data/Charsets.ts +256 -0
  76. package/src/common/data/EscapeSequences.ts +153 -0
  77. package/src/common/input/Keyboard.ts +398 -0
  78. package/src/common/input/TextDecoder.ts +346 -0
  79. package/src/common/input/UnicodeV6.ts +145 -0
  80. package/src/common/input/WriteBuffer.ts +246 -0
  81. package/src/common/input/XParseColor.ts +80 -0
  82. package/src/common/parser/Constants.ts +58 -0
  83. package/src/common/parser/DcsParser.ts +192 -0
  84. package/src/common/parser/EscapeSequenceParser.ts +792 -0
  85. package/src/common/parser/OscParser.ts +238 -0
  86. package/src/common/parser/Params.ts +229 -0
  87. package/src/common/parser/Types.d.ts +275 -0
  88. package/src/common/public/AddonManager.ts +53 -0
  89. package/src/common/public/BufferApiView.ts +35 -0
  90. package/src/common/public/BufferLineApiView.ts +29 -0
  91. package/src/common/public/BufferNamespaceApi.ts +36 -0
  92. package/src/common/public/ParserApi.ts +37 -0
  93. package/src/common/public/UnicodeApi.ts +27 -0
  94. package/src/common/services/BufferService.ts +151 -0
  95. package/src/common/services/CharsetService.ts +34 -0
  96. package/src/common/services/CoreMouseService.ts +318 -0
  97. package/src/common/services/CoreService.ts +87 -0
  98. package/src/common/services/DecorationService.ts +140 -0
  99. package/src/common/services/InstantiationService.ts +85 -0
  100. package/src/common/services/LogService.ts +124 -0
  101. package/src/common/services/OptionsService.ts +202 -0
  102. package/src/common/services/OscLinkService.ts +115 -0
  103. package/src/common/services/ServiceRegistry.ts +49 -0
  104. package/src/common/services/Services.ts +373 -0
  105. package/src/common/services/UnicodeService.ts +111 -0
  106. package/src/headless/Terminal.ts +136 -0
  107. package/src/headless/public/Terminal.ts +195 -0
  108. package/typings/xterm.d.ts +1857 -0
@@ -0,0 +1,1857 @@
1
+ /**
2
+ * @license MIT
3
+ *
4
+ * This contains the type declarations for the xterm.js library. Note that
5
+ * some interfaces differ between this file and the actual implementation in
6
+ * src/, that's because this file declares the *public* API which is intended
7
+ * to be stable and consumed by external programs.
8
+ */
9
+
10
+ /// <reference lib="dom"/>
11
+
12
+ declare module '@xterm/xterm' {
13
+ /**
14
+ * A string or number representing text font weight.
15
+ */
16
+ export type FontWeight = 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number;
17
+
18
+ /**
19
+ * A string representing log level.
20
+ */
21
+ export type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'off';
22
+
23
+ /**
24
+ * An object containing options for the terminal.
25
+ */
26
+ export interface ITerminalOptions {
27
+ /**
28
+ * Whether to allow the use of proposed API. When false, any usage of APIs
29
+ * marked as experimental/proposed will throw an error. The default is
30
+ * false.
31
+ */
32
+ allowProposedApi?: boolean;
33
+
34
+ /**
35
+ * Whether background should support non-opaque color. It must be set before
36
+ * executing the `Terminal.open()` method and can't be changed later without
37
+ * executing it again. Note that enabling this can negatively impact
38
+ * performance.
39
+ */
40
+ allowTransparency?: boolean;
41
+
42
+ /**
43
+ * If enabled, alt + click will move the prompt cursor to position
44
+ * underneath the mouse. The default is true.
45
+ */
46
+ altClickMovesCursor?: boolean;
47
+
48
+ /**
49
+ * When enabled the cursor will be set to the beginning of the next line
50
+ * with every new line. This is equivalent to sending '\r\n' for each '\n'.
51
+ * Normally the termios settings of the underlying PTY deals with the
52
+ * translation of '\n' to '\r\n' and this setting should not be used. If you
53
+ * deal with data from a non-PTY related source, this settings might be
54
+ * useful.
55
+ */
56
+ convertEol?: boolean;
57
+
58
+ /**
59
+ * Whether the cursor blinks.
60
+ */
61
+ cursorBlink?: boolean;
62
+
63
+ /**
64
+ * The style of the cursor when the terminal is focused.
65
+ */
66
+ cursorStyle?: 'block' | 'underline' | 'bar';
67
+
68
+ /**
69
+ * The width of the cursor in CSS pixels when `cursorStyle` is set to 'bar'.
70
+ */
71
+ cursorWidth?: number;
72
+
73
+ /**
74
+ * The style of the cursor when the terminal is not focused.
75
+ */
76
+ cursorInactiveStyle?: 'outline' | 'block' | 'bar' | 'underline' | 'none';
77
+
78
+ /**
79
+ * Whether to draw custom glyphs for block element and box drawing
80
+ * characters instead of using the font. This should typically result in
81
+ * better rendering with continuous lines, even when line height and letter
82
+ * spacing is used. Note that this doesn't work with the DOM renderer which
83
+ * renders all characters using the font. The default is true.
84
+ */
85
+ customGlyphs?: boolean;
86
+
87
+ /**
88
+ * Whether input should be disabled.
89
+ */
90
+ disableStdin?: boolean;
91
+
92
+ /**
93
+ * A {@link Document} to use instead of the one that xterm.js was attached
94
+ * to. The purpose of this is to improve support in multi-window
95
+ * applications where HTML elements may be references across multiple
96
+ * windows which can cause problems with `instanceof`.
97
+ *
98
+ * The type is `any` because using `Document` can cause TS to have
99
+ * performance/compiler problems.
100
+ */
101
+ documentOverride?: any | null;
102
+
103
+ /**
104
+ * Whether to draw bold text in bright colors. The default is true.
105
+ */
106
+ drawBoldTextInBrightColors?: boolean;
107
+
108
+ /**
109
+ * The modifier key hold to multiply scroll speed.
110
+ */
111
+ fastScrollModifier?: 'none' | 'alt' | 'ctrl' | 'shift';
112
+
113
+ /**
114
+ * The scroll speed multiplier used for fast scrolling.
115
+ */
116
+ fastScrollSensitivity?: number;
117
+
118
+ /**
119
+ * The font size used to render text.
120
+ */
121
+ fontSize?: number;
122
+
123
+ /**
124
+ * The font family used to render text.
125
+ */
126
+ fontFamily?: string;
127
+
128
+ /**
129
+ * The font weight used to render non-bold text.
130
+ */
131
+ fontWeight?: FontWeight;
132
+
133
+ /**
134
+ * The font weight used to render bold text.
135
+ */
136
+ fontWeightBold?: FontWeight;
137
+
138
+ /**
139
+ * Whether to ignore the bracketed paste mode. When true, this will always
140
+ * paste without the `\x1b[200~` and `\x1b[201~` sequences, even when the
141
+ * shell enables bracketed mode.
142
+ */
143
+ ignoreBracketedPasteMode?: boolean;
144
+
145
+ /**
146
+ * The spacing in whole pixels between characters.
147
+ */
148
+ letterSpacing?: number;
149
+
150
+ /**
151
+ * The line height used to render text.
152
+ */
153
+ lineHeight?: number;
154
+
155
+ /**
156
+ * The handler for OSC 8 hyperlinks. Links will use the `confirm` browser
157
+ * API with a strongly worded warning if no link handler is set.
158
+ *
159
+ * When setting this, consider the security of users opening these links,
160
+ * at a minimum there should be a tooltip or a prompt when hovering or
161
+ * activating the link respectively. An example of what might be possible is
162
+ * a terminal app writing link in the form `javascript:...` that runs some
163
+ * javascript, a safe approach to prevent that is to validate the link
164
+ * starts with http(s)://.
165
+ */
166
+ linkHandler?: ILinkHandler | null;
167
+
168
+ /**
169
+ * What log level to use, this will log for all levels below and including
170
+ * what is set:
171
+ *
172
+ * 1. trace
173
+ * 2. debug
174
+ * 3. info (default)
175
+ * 4. warn
176
+ * 5. error
177
+ * 6. off
178
+ */
179
+ logLevel?: LogLevel;
180
+
181
+ /**
182
+ * A logger to use instead of `console`.
183
+ */
184
+ logger?: ILogger | null;
185
+
186
+ /**
187
+ * Whether to treat option as the meta key.
188
+ */
189
+ macOptionIsMeta?: boolean;
190
+
191
+ /**
192
+ * Whether holding a modifier key will force normal selection behavior,
193
+ * regardless of whether the terminal is in mouse events mode. This will
194
+ * also prevent mouse events from being emitted by the terminal. For
195
+ * example, this allows you to use xterm.js' regular selection inside tmux
196
+ * with mouse mode enabled.
197
+ */
198
+ macOptionClickForcesSelection?: boolean;
199
+
200
+ /**
201
+ * The minimum contrast ratio for text in the terminal, setting this will
202
+ * change the foreground color dynamically depending on whether the contrast
203
+ * ratio is met. Example values:
204
+ *
205
+ * - 1: The default, do nothing.
206
+ * - 4.5: Minimum for WCAG AA compliance.
207
+ * - 7: Minimum for WCAG AAA compliance.
208
+ * - 21: White on black or black on white.
209
+ */
210
+ minimumContrastRatio?: number;
211
+
212
+ /**
213
+ * Whether to select the word under the cursor on right click, this is
214
+ * standard behavior in a lot of macOS applications.
215
+ */
216
+ rightClickSelectsWord?: boolean;
217
+
218
+ /**
219
+ * Whether screen reader support is enabled. When on this will expose
220
+ * supporting elements in the DOM to support NVDA on Windows and VoiceOver
221
+ * on macOS.
222
+ */
223
+ screenReaderMode?: boolean;
224
+
225
+ /**
226
+ * The amount of scrollback in the terminal. Scrollback is the amount of
227
+ * rows that are retained when lines are scrolled beyond the initial
228
+ * viewport.
229
+ */
230
+ scrollback?: number;
231
+
232
+ /**
233
+ * Whether to scroll to the bottom whenever there is some user input. The
234
+ * default is true.
235
+ */
236
+ scrollOnUserInput?: boolean;
237
+
238
+ /**
239
+ * The scrolling speed multiplier used for adjusting normal scrolling speed.
240
+ */
241
+ scrollSensitivity?: number;
242
+
243
+ /**
244
+ * The duration to smoothly scroll between the origin and the target in
245
+ * milliseconds. Set to 0 to disable smooth scrolling and scroll instantly.
246
+ */
247
+ smoothScrollDuration?: number;
248
+
249
+ /**
250
+ * The size of tab stops in the terminal.
251
+ */
252
+ tabStopWidth?: number;
253
+
254
+ /**
255
+ * The color theme of the terminal.
256
+ */
257
+ theme?: ITheme;
258
+
259
+ /**
260
+ * Whether "Windows mode" is enabled. Because Windows backends winpty and
261
+ * conpty operate by doing line wrapping on their side, xterm.js does not
262
+ * have access to wrapped lines. When Windows mode is enabled the following
263
+ * changes will be in effect:
264
+ *
265
+ * - Reflow is disabled.
266
+ * - Lines are assumed to be wrapped if the last character of the line is
267
+ * not whitespace.
268
+ *
269
+ * When using conpty on Windows 11 version >= 21376, it is recommended to
270
+ * disable this because native text wrapping sequences are output correctly
271
+ * thanks to https://github.com/microsoft/terminal/issues/405
272
+ *
273
+ * @deprecated Use {@link windowsPty}. This value will be ignored if
274
+ * windowsPty is set.
275
+ */
276
+ windowsMode?: boolean;
277
+
278
+ /**
279
+ * Compatibility information when the pty is known to be hosted on Windows.
280
+ * Setting this will turn on certain heuristics/workarounds depending on the
281
+ * values:
282
+ *
283
+ * - `if (backend !== undefined || buildNumber !== undefined)`
284
+ * - When increasing the rows in the terminal, the amount increased into
285
+ * the scrollback. This is done because ConPTY does not behave like
286
+ * expect scrollback to come back into the viewport, instead it makes
287
+ * empty rows at of the viewport. Not having this behavior can result in
288
+ * missing data as the rows get replaced.
289
+ * - `if !(backend === 'conpty' && buildNumber >= 21376)`
290
+ * - Reflow is disabled
291
+ * - Lines are assumed to be wrapped if the last character of the line is
292
+ * not whitespace.
293
+ */
294
+ windowsPty?: IWindowsPty;
295
+
296
+ /**
297
+ * A string containing all characters that are considered word separated by
298
+ * the double click to select work logic.
299
+ */
300
+ wordSeparator?: string;
301
+
302
+ /**
303
+ * Enable various window manipulation and report features.
304
+ * All features are disabled by default for security reasons.
305
+ */
306
+ windowOptions?: IWindowOptions;
307
+
308
+ /**
309
+ * The width, in pixels, of the canvas for the overview ruler. The overview
310
+ * ruler will be hidden when not set.
311
+ */
312
+ overviewRulerWidth?: number;
313
+ }
314
+
315
+ /**
316
+ * An object containing additional options for the terminal that can only be
317
+ * set on start up.
318
+ */
319
+ export interface ITerminalInitOnlyOptions {
320
+ /**
321
+ * The number of columns in the terminal.
322
+ */
323
+ cols?: number;
324
+
325
+ /**
326
+ * The number of rows in the terminal.
327
+ */
328
+ rows?: number;
329
+ }
330
+
331
+ /**
332
+ * Contains colors to theme the terminal with.
333
+ */
334
+ export interface ITheme {
335
+ /** The default foreground color */
336
+ foreground?: string;
337
+ /** The default background color */
338
+ background?: string;
339
+ /** The cursor color */
340
+ cursor?: string;
341
+ /** The accent color of the cursor (fg color for a block cursor) */
342
+ cursorAccent?: string;
343
+ /** The selection background color (can be transparent) */
344
+ selectionBackground?: string;
345
+ /** The selection foreground color */
346
+ selectionForeground?: string;
347
+ /**
348
+ * The selection background color when the terminal does not have focus (can
349
+ * be transparent)
350
+ */
351
+ selectionInactiveBackground?: string;
352
+ /** ANSI black (eg. `\x1b[30m`) */
353
+ black?: string;
354
+ /** ANSI red (eg. `\x1b[31m`) */
355
+ red?: string;
356
+ /** ANSI green (eg. `\x1b[32m`) */
357
+ green?: string;
358
+ /** ANSI yellow (eg. `\x1b[33m`) */
359
+ yellow?: string;
360
+ /** ANSI blue (eg. `\x1b[34m`) */
361
+ blue?: string;
362
+ /** ANSI magenta (eg. `\x1b[35m`) */
363
+ magenta?: string;
364
+ /** ANSI cyan (eg. `\x1b[36m`) */
365
+ cyan?: string;
366
+ /** ANSI white (eg. `\x1b[37m`) */
367
+ white?: string;
368
+ /** ANSI bright black (eg. `\x1b[1;30m`) */
369
+ brightBlack?: string;
370
+ /** ANSI bright red (eg. `\x1b[1;31m`) */
371
+ brightRed?: string;
372
+ /** ANSI bright green (eg. `\x1b[1;32m`) */
373
+ brightGreen?: string;
374
+ /** ANSI bright yellow (eg. `\x1b[1;33m`) */
375
+ brightYellow?: string;
376
+ /** ANSI bright blue (eg. `\x1b[1;34m`) */
377
+ brightBlue?: string;
378
+ /** ANSI bright magenta (eg. `\x1b[1;35m`) */
379
+ brightMagenta?: string;
380
+ /** ANSI bright cyan (eg. `\x1b[1;36m`) */
381
+ brightCyan?: string;
382
+ /** ANSI bright white (eg. `\x1b[1;37m`) */
383
+ brightWhite?: string;
384
+ /** ANSI extended colors (16-255) */
385
+ extendedAnsi?: string[];
386
+ }
387
+
388
+ /**
389
+ * Pty information for Windows.
390
+ */
391
+ export interface IWindowsPty {
392
+ /**
393
+ * What pty emulation backend is being used.
394
+ */
395
+ backend?: 'conpty' | 'winpty';
396
+ /**
397
+ * The Windows build version (eg. 19045)
398
+ */
399
+ buildNumber?: number;
400
+ }
401
+
402
+ /**
403
+ * A replacement logger for `console`.
404
+ */
405
+ export interface ILogger {
406
+ /**
407
+ * Log a trace message, this will only be called if
408
+ * {@link ITerminalOptions.logLevel} is set to trace.
409
+ */
410
+ trace(message: string, ...args: any[]): void;
411
+ /**
412
+ * Log a debug message, this will only be called if
413
+ * {@link ITerminalOptions.logLevel} is set to debug or below.
414
+ */
415
+ debug(message: string, ...args: any[]): void;
416
+ /**
417
+ * Log a debug message, this will only be called if
418
+ * {@link ITerminalOptions.logLevel} is set to info or below.
419
+ */
420
+ info(message: string, ...args: any[]): void;
421
+ /**
422
+ * Log a debug message, this will only be called if
423
+ * {@link ITerminalOptions.logLevel} is set to warn or below.
424
+ */
425
+ warn(message: string, ...args: any[]): void;
426
+ /**
427
+ * Log a debug message, this will only be called if
428
+ * {@link ITerminalOptions.logLevel} is set to error or below.
429
+ */
430
+ error(message: string | Error, ...args: any[]): void;
431
+ }
432
+
433
+ /**
434
+ * An object that can be disposed via a dispose function.
435
+ */
436
+ export interface IDisposable {
437
+ dispose(): void;
438
+ }
439
+
440
+ /**
441
+ * An event that can be listened to.
442
+ * @returns an `IDisposable` to stop listening.
443
+ */
444
+ export interface IEvent<T, U = void> {
445
+ (listener: (arg1: T, arg2: U) => any): IDisposable;
446
+ }
447
+
448
+ /**
449
+ * Represents a specific line in the terminal that is tracked when scrollback
450
+ * is trimmed and lines are added or removed. This is a single line that may
451
+ * be part of a larger wrapped line.
452
+ */
453
+ export interface IMarker extends IDisposableWithEvent {
454
+ /**
455
+ * A unique identifier for this marker.
456
+ */
457
+ readonly id: number;
458
+
459
+ /**
460
+ * The actual line index in the buffer at this point in time. This is set to
461
+ * -1 if the marker has been disposed.
462
+ */
463
+ readonly line: number;
464
+ }
465
+
466
+ /**
467
+ * Represents a disposable that tracks is disposed state.
468
+ */
469
+ export interface IDisposableWithEvent extends IDisposable {
470
+ /**
471
+ * Event listener to get notified when this gets disposed.
472
+ */
473
+ onDispose: IEvent<void>;
474
+
475
+ /**
476
+ * Whether this is disposed.
477
+ */
478
+ readonly isDisposed: boolean;
479
+ }
480
+
481
+ /**
482
+ * Represents a decoration in the terminal that is associated with a
483
+ * particular marker and DOM element.
484
+ */
485
+ export interface IDecoration extends IDisposableWithEvent {
486
+ /*
487
+ * The marker for the decoration in the terminal.
488
+ */
489
+ readonly marker: IMarker;
490
+
491
+ /**
492
+ * An event fired when the decoration
493
+ * is rendered, returns the dom element
494
+ * associated with the decoration.
495
+ */
496
+ readonly onRender: IEvent<HTMLElement>;
497
+
498
+ /**
499
+ * The element that the decoration is rendered to. This will be undefined
500
+ * until it is rendered for the first time by {@link IDecoration.onRender}.
501
+ * that.
502
+ */
503
+ element: HTMLElement | undefined;
504
+
505
+ /**
506
+ * The options for the overview ruler that can be updated. This will only
507
+ * take effect when {@link IDecorationOptions.overviewRulerOptions} were
508
+ * provided initially.
509
+ */
510
+ options: Pick<IDecorationOptions, 'overviewRulerOptions'>;
511
+ }
512
+
513
+
514
+ /**
515
+ * Overview ruler decoration options
516
+ */
517
+ interface IDecorationOverviewRulerOptions {
518
+ color: string;
519
+ position?: 'left' | 'center' | 'right' | 'full';
520
+ }
521
+
522
+ /*
523
+ * Options that define the presentation of the decoration.
524
+ */
525
+ export interface IDecorationOptions {
526
+ /**
527
+ * The line in the terminal where
528
+ * the decoration will be displayed
529
+ */
530
+ readonly marker: IMarker;
531
+
532
+ /*
533
+ * Where the decoration will be anchored -
534
+ * defaults to the left edge
535
+ */
536
+ readonly anchor?: 'right' | 'left';
537
+
538
+ /**
539
+ * The x position offset relative to the anchor
540
+ */
541
+ readonly x?: number;
542
+
543
+
544
+ /**
545
+ * The width of the decoration in cells, defaults to 1.
546
+ */
547
+ readonly width?: number;
548
+
549
+ /**
550
+ * The height of the decoration in cells, defaults to 1.
551
+ */
552
+ readonly height?: number;
553
+
554
+ /**
555
+ * The background color of the cell(s). When 2 decorations both set the
556
+ * foreground color the last registered decoration will be used. Only the
557
+ * `#RRGGBB` format is supported.
558
+ */
559
+ readonly backgroundColor?: string;
560
+
561
+ /**
562
+ * The foreground color of the cell(s). When 2 decorations both set the
563
+ * foreground color the last registered decoration will be used. Only the
564
+ * `#RRGGBB` format is supported.
565
+ */
566
+ readonly foregroundColor?: string;
567
+
568
+ /**
569
+ * What layer to render the decoration at when {@link backgroundColor} or
570
+ * {@link foregroundColor} are used. `'bottom'` will render under the
571
+ * selection, `'top`' will render above the selection\*.
572
+ *
573
+ * *\* The selection will render on top regardless of layer on the canvas
574
+ * renderer due to how it renders selection separately.*
575
+ */
576
+ readonly layer?: 'bottom' | 'top';
577
+
578
+ /**
579
+ * When defined, renders the decoration in the overview ruler to the right
580
+ * of the terminal. {@link ITerminalOptions.overviewRulerWidth} must be set
581
+ * in order to see the overview ruler.
582
+ * @param color The color of the decoration.
583
+ * @param position The position of the decoration.
584
+ */
585
+ overviewRulerOptions?: IDecorationOverviewRulerOptions;
586
+ }
587
+
588
+ /**
589
+ * The set of localizable strings.
590
+ */
591
+ export interface ILocalizableStrings {
592
+ /**
593
+ * The aria label for the underlying input textarea for the terminal.
594
+ */
595
+ promptLabel: string;
596
+
597
+ /**
598
+ * Announcement for when line reading is suppressed due to too many lines
599
+ * being printed to the terminal when `screenReaderMode` is enabled.
600
+ */
601
+ tooMuchOutput: string;
602
+ }
603
+
604
+ /**
605
+ * Enable various window manipulation and report features
606
+ * (`CSI Ps ; Ps ; Ps t`).
607
+ *
608
+ * Most settings have no default implementation, as they heavily rely on
609
+ * the embedding environment.
610
+ *
611
+ * To implement a feature, create a custom CSI hook like this:
612
+ * ```ts
613
+ * term.parser.addCsiHandler({final: 't'}, params => {
614
+ * const ps = params[0];
615
+ * switch (ps) {
616
+ * case XY:
617
+ * ... // your implementation for option XY
618
+ * return true; // signal Ps=XY was handled
619
+ * }
620
+ * return false; // any Ps that was not handled
621
+ * });
622
+ * ```
623
+ *
624
+ * Note on security:
625
+ * Most features are meant to deal with some information of the host machine
626
+ * where the terminal runs on. This is seen as a security risk possibly
627
+ * leaking sensitive data of the host to the program in the terminal.
628
+ * Therefore all options (even those without a default implementation) are
629
+ * guarded by the boolean flag and disabled by default.
630
+ */
631
+ export interface IWindowOptions {
632
+ /**
633
+ * Ps=1 De-iconify window.
634
+ * No default implementation.
635
+ */
636
+ restoreWin?: boolean;
637
+ /**
638
+ * Ps=2 Iconify window.
639
+ * No default implementation.
640
+ */
641
+ minimizeWin?: boolean;
642
+ /**
643
+ * Ps=3 ; x ; y
644
+ * Move window to [x, y].
645
+ * No default implementation.
646
+ */
647
+ setWinPosition?: boolean;
648
+ /**
649
+ * Ps = 4 ; height ; width
650
+ * Resize the window to given `height` and `width` in pixels.
651
+ * Omitted parameters should reuse the current height or width.
652
+ * Zero parameters should use the display's height or width.
653
+ * No default implementation.
654
+ */
655
+ setWinSizePixels?: boolean;
656
+ /**
657
+ * Ps=5 Raise the window to the front of the stacking order.
658
+ * No default implementation.
659
+ */
660
+ raiseWin?: boolean;
661
+ /**
662
+ * Ps=6 Lower the xterm window to the bottom of the stacking order.
663
+ * No default implementation.
664
+ */
665
+ lowerWin?: boolean;
666
+ /** Ps=7 Refresh the window. */
667
+ refreshWin?: boolean;
668
+ /**
669
+ * Ps = 8 ; height ; width
670
+ * Resize the text area to given height and width in characters.
671
+ * Omitted parameters should reuse the current height or width.
672
+ * Zero parameters use the display's height or width.
673
+ * No default implementation.
674
+ */
675
+ setWinSizeChars?: boolean;
676
+ /**
677
+ * Ps=9 ; 0 Restore maximized window.
678
+ * Ps=9 ; 1 Maximize window (i.e., resize to screen size).
679
+ * Ps=9 ; 2 Maximize window vertically.
680
+ * Ps=9 ; 3 Maximize window horizontally.
681
+ * No default implementation.
682
+ */
683
+ maximizeWin?: boolean;
684
+ /**
685
+ * Ps=10 ; 0 Undo full-screen mode.
686
+ * Ps=10 ; 1 Change to full-screen.
687
+ * Ps=10 ; 2 Toggle full-screen.
688
+ * No default implementation.
689
+ */
690
+ fullscreenWin?: boolean;
691
+ /** Ps=11 Report xterm window state.
692
+ * If the xterm window is non-iconified, it returns "CSI 1 t".
693
+ * If the xterm window is iconified, it returns "CSI 2 t".
694
+ * No default implementation.
695
+ */
696
+ getWinState?: boolean;
697
+ /**
698
+ * Ps=13 Report xterm window position. Result is "CSI 3 ; x ; y t".
699
+ * Ps=13 ; 2 Report xterm text-area position. Result is "CSI 3 ; x ; y t".
700
+ * No default implementation.
701
+ */
702
+ getWinPosition?: boolean;
703
+ /**
704
+ * Ps=14 Report xterm text area size in pixels. Result is "CSI 4 ; height ; width t".
705
+ * Ps=14 ; 2 Report xterm window size in pixels. Result is "CSI 4 ; height ; width t".
706
+ * Has a default implementation.
707
+ */
708
+ getWinSizePixels?: boolean;
709
+ /**
710
+ * Ps=15 Report size of the screen in pixels. Result is "CSI 5 ; height ; width t".
711
+ * No default implementation.
712
+ */
713
+ getScreenSizePixels?: boolean;
714
+ /**
715
+ * Ps=16 Report xterm character cell size in pixels. Result is "CSI 6 ; height ; width t".
716
+ * Has a default implementation.
717
+ */
718
+ getCellSizePixels?: boolean;
719
+ /**
720
+ * Ps=18 Report the size of the text area in characters. Result is "CSI 8 ; height ; width t".
721
+ * Has a default implementation.
722
+ */
723
+ getWinSizeChars?: boolean;
724
+ /**
725
+ * Ps=19 Report the size of the screen in characters. Result is "CSI 9 ; height ; width t".
726
+ * No default implementation.
727
+ */
728
+ getScreenSizeChars?: boolean;
729
+ /**
730
+ * Ps=20 Report xterm window's icon label. Result is "OSC L label ST".
731
+ * No default implementation.
732
+ */
733
+ getIconTitle?: boolean;
734
+ /**
735
+ * Ps=21 Report xterm window's title. Result is "OSC l label ST".
736
+ * No default implementation.
737
+ */
738
+ getWinTitle?: boolean;
739
+ /**
740
+ * Ps=22 ; 0 Save xterm icon and window title on stack.
741
+ * Ps=22 ; 1 Save xterm icon title on stack.
742
+ * Ps=22 ; 2 Save xterm window title on stack.
743
+ * All variants have a default implementation.
744
+ */
745
+ pushTitle?: boolean;
746
+ /**
747
+ * Ps=23 ; 0 Restore xterm icon and window title from stack.
748
+ * Ps=23 ; 1 Restore xterm icon title from stack.
749
+ * Ps=23 ; 2 Restore xterm window title from stack.
750
+ * All variants have a default implementation.
751
+ */
752
+ popTitle?: boolean;
753
+ /**
754
+ * Ps>=24 Resize to Ps lines (DECSLPP).
755
+ * DECSLPP is not implemented. This settings is also used to
756
+ * enable / disable DECCOLM (earlier variant of DECSLPP).
757
+ */
758
+ setWinLines?: boolean;
759
+ }
760
+
761
+ /**
762
+ * The class that represents an xterm.js terminal.
763
+ */
764
+ export class Terminal implements IDisposable {
765
+ /**
766
+ * The element containing the terminal.
767
+ */
768
+ readonly element: HTMLElement | undefined;
769
+
770
+ /**
771
+ * The textarea that accepts input for the terminal.
772
+ */
773
+ readonly textarea: HTMLTextAreaElement | undefined;
774
+
775
+ /**
776
+ * The number of rows in the terminal's viewport. Use
777
+ * `ITerminalOptions.rows` to set this in the constructor and
778
+ * `Terminal.resize` for when the terminal exists.
779
+ */
780
+ readonly rows: number;
781
+
782
+ /**
783
+ * The number of columns in the terminal's viewport. Use
784
+ * `ITerminalOptions.cols` to set this in the constructor and
785
+ * `Terminal.resize` for when the terminal exists.
786
+ */
787
+ readonly cols: number;
788
+
789
+ /**
790
+ * Access to the terminal's normal and alt buffer.
791
+ */
792
+ readonly buffer: IBufferNamespace;
793
+
794
+ /**
795
+ * (EXPERIMENTAL) Get all markers registered against the buffer. If the alt
796
+ * buffer is active this will always return [].
797
+ */
798
+ readonly markers: ReadonlyArray<IMarker>;
799
+
800
+ /**
801
+ * Get the parser interface to register custom escape sequence handlers.
802
+ */
803
+ readonly parser: IParser;
804
+
805
+ /**
806
+ * (EXPERIMENTAL) Get the Unicode handling interface
807
+ * to register and switch Unicode version.
808
+ */
809
+ readonly unicode: IUnicodeHandling;
810
+
811
+ /**
812
+ * Gets the terminal modes as set by SM/DECSET.
813
+ */
814
+ readonly modes: IModes;
815
+
816
+ /**
817
+ * Gets or sets the terminal options. This supports setting multiple
818
+ * options.
819
+ *
820
+ * @example Get a single option
821
+ * ```ts
822
+ * console.log(terminal.options.fontSize);
823
+ * ```
824
+ *
825
+ * @example Set a single option:
826
+ * ```ts
827
+ * terminal.options.fontSize = 12;
828
+ * ```
829
+ * Note that for options that are object, a new object must be used in order
830
+ * to take effect as a reference comparison will be done:
831
+ * ```ts
832
+ * const newValue = terminal.options.theme;
833
+ * newValue.background = '#000000';
834
+ *
835
+ * // This won't work
836
+ * terminal.options.theme = newValue;
837
+ *
838
+ * // This will work
839
+ * terminal.options.theme = { ...newValue };
840
+ * ```
841
+ *
842
+ * @example Set multiple options
843
+ * ```ts
844
+ * terminal.options = {
845
+ * fontSize: 12,
846
+ * fontFamily: 'Courier New'
847
+ * };
848
+ * ```
849
+ */
850
+ options: ITerminalOptions;
851
+
852
+ /**
853
+ * Natural language strings that can be localized.
854
+ */
855
+ static strings: ILocalizableStrings;
856
+
857
+ /**
858
+ * Creates a new `Terminal` object.
859
+ *
860
+ * @param options An object containing a set of options.
861
+ */
862
+ constructor(options?: ITerminalOptions & ITerminalInitOnlyOptions);
863
+
864
+ /**
865
+ * Adds an event listener for when the bell is triggered.
866
+ * @returns an `IDisposable` to stop listening.
867
+ */
868
+ onBell: IEvent<void>;
869
+
870
+ /**
871
+ * Adds an event listener for when a binary event fires. This is used to
872
+ * enable non UTF-8 conformant binary messages to be sent to the backend.
873
+ * Currently this is only used for a certain type of mouse reports that
874
+ * happen to be not UTF-8 compatible.
875
+ * The event value is a JS string, pass it to the underlying pty as
876
+ * binary data, e.g. `pty.write(Buffer.from(data, 'binary'))`.
877
+ * @returns an `IDisposable` to stop listening.
878
+ */
879
+ onBinary: IEvent<string>;
880
+
881
+ /**
882
+ * Adds an event listener for the cursor moves.
883
+ * @returns an `IDisposable` to stop listening.
884
+ */
885
+ onCursorMove: IEvent<void>;
886
+
887
+ /**
888
+ * Adds an event listener for when a data event fires. This happens for
889
+ * example when the user types or pastes into the terminal. The event value
890
+ * is whatever `string` results, in a typical setup, this should be passed
891
+ * on to the backing pty.
892
+ * @returns an `IDisposable` to stop listening.
893
+ */
894
+ onData: IEvent<string>;
895
+
896
+ /**
897
+ * Adds an event listener for when a key is pressed. The event value
898
+ * contains the string that will be sent in the data event as well as the
899
+ * DOM event that triggered it.
900
+ * @returns an `IDisposable` to stop listening.
901
+ */
902
+ onKey: IEvent<{ key: string, domEvent: KeyboardEvent }>;
903
+
904
+ /**
905
+ * Adds an event listener for when a line feed is added.
906
+ * @returns an `IDisposable` to stop listening.
907
+ */
908
+ onLineFeed: IEvent<void>;
909
+
910
+ /**
911
+ * Adds an event listener for when rows are rendered. The event value
912
+ * contains the start row and end rows of the rendered area (ranges from `0`
913
+ * to `Terminal.rows - 1`).
914
+ * @returns an `IDisposable` to stop listening.
915
+ */
916
+ onRender: IEvent<{ start: number, end: number }>;
917
+
918
+ /**
919
+ * Adds an event listener for when data has been parsed by the terminal,
920
+ * after {@link write} is called. This event is useful to listen for any
921
+ * changes in the buffer.
922
+ *
923
+ * This fires at most once per frame, after data parsing completes. Note
924
+ * that this can fire when there are still writes pending if there is a lot
925
+ * of data.
926
+ */
927
+ onWriteParsed: IEvent<void>;
928
+
929
+ /**
930
+ * Adds an event listener for when the terminal is resized. The event value
931
+ * contains the new size.
932
+ * @returns an `IDisposable` to stop listening.
933
+ */
934
+ onResize: IEvent<{ cols: number, rows: number }>;
935
+
936
+ /**
937
+ * Adds an event listener for when a scroll occurs. The event value is the
938
+ * new position of the viewport.
939
+ * @returns an `IDisposable` to stop listening.
940
+ */
941
+ onScroll: IEvent<number>;
942
+
943
+ /**
944
+ * Adds an event listener for when a selection change occurs.
945
+ * @returns an `IDisposable` to stop listening.
946
+ */
947
+ onSelectionChange: IEvent<void>;
948
+
949
+ /**
950
+ * Adds an event listener for when an OSC 0 or OSC 2 title change occurs.
951
+ * The event value is the new title.
952
+ * @returns an `IDisposable` to stop listening.
953
+ */
954
+ onTitleChange: IEvent<string>;
955
+
956
+ /**
957
+ * Unfocus the terminal.
958
+ */
959
+ blur(): void;
960
+
961
+ /**
962
+ * Focus the terminal.
963
+ */
964
+ focus(): void;
965
+
966
+ /**
967
+ * Resizes the terminal. It's best practice to debounce calls to resize,
968
+ * this will help ensure that the pty can respond to the resize event
969
+ * before another one occurs.
970
+ * @param x The number of columns to resize to.
971
+ * @param y The number of rows to resize to.
972
+ */
973
+ resize(columns: number, rows: number): void;
974
+
975
+ /**
976
+ * Opens the terminal within an element. This should also be called if the
977
+ * xterm.js element ever changes browser window.
978
+ * @param parent The element to create the terminal within. This element
979
+ * must be visible (have dimensions) when `open` is called as several DOM-
980
+ * based measurements need to be performed when this function is called.
981
+ */
982
+ open(parent: HTMLElement): void;
983
+
984
+ /**
985
+ * Attaches a custom key event handler which is run before keys are
986
+ * processed, giving consumers of xterm.js ultimate control as to what keys
987
+ * should be processed by the terminal and what keys should not.
988
+ * @param customKeyEventHandler The custom KeyboardEvent handler to attach.
989
+ * This is a function that takes a KeyboardEvent, allowing consumers to stop
990
+ * propagation and/or prevent the default action. The function returns
991
+ * whether the event should be processed by xterm.js.
992
+ *
993
+ * @example A custom keymap that overrides the backspace key
994
+ * ```ts
995
+ * const keymap = [
996
+ * { "key": "Backspace", "shiftKey": false, "mapCode": 8 },
997
+ * { "key": "Backspace", "shiftKey": true, "mapCode": 127 }
998
+ * ];
999
+ * term.attachCustomKeyEventHandler(ev => {
1000
+ * if (ev.type === 'keydown') {
1001
+ * for (let i in keymap) {
1002
+ * if (keymap[i].key == ev.key && keymap[i].shiftKey == ev.shiftKey) {
1003
+ * socket.send(String.fromCharCode(keymap[i].mapCode));
1004
+ * return false;
1005
+ * }
1006
+ * }
1007
+ * }
1008
+ * });
1009
+ * ```
1010
+ */
1011
+ attachCustomKeyEventHandler(customKeyEventHandler: (event: KeyboardEvent) => boolean): void;
1012
+
1013
+ /**
1014
+ * Registers a link provider, allowing a custom parser to be used to match
1015
+ * and handle links. Multiple link providers can be used, they will be asked
1016
+ * in the order in which they are registered.
1017
+ * @param linkProvider The link provider to use to detect links.
1018
+ */
1019
+ registerLinkProvider(linkProvider: ILinkProvider): IDisposable;
1020
+
1021
+ /**
1022
+ * (EXPERIMENTAL) Registers a character joiner, allowing custom sequences of
1023
+ * characters to be rendered as a single unit. This is useful in particular
1024
+ * for rendering ligatures and graphemes, among other things.
1025
+ *
1026
+ * Each registered character joiner is called with a string of text
1027
+ * representing a portion of a line in the terminal that can be rendered as
1028
+ * a single unit. The joiner must return a sorted array, where each entry is
1029
+ * itself an array of length two, containing the start (inclusive) and end
1030
+ * (exclusive) index of a substring of the input that should be rendered as
1031
+ * a single unit. When multiple joiners are provided, the results of each
1032
+ * are collected. If there are any overlapping substrings between them, they
1033
+ * are combined into one larger unit that is drawn together.
1034
+ *
1035
+ * All character joiners that are registered get called every time a line is
1036
+ * rendered in the terminal, so it is essential for the handler function to
1037
+ * run as quickly as possible to avoid slowdowns when rendering. Similarly,
1038
+ * joiners should strive to return the smallest possible substrings to
1039
+ * render together, since they aren't drawn as optimally as individual
1040
+ * characters.
1041
+ *
1042
+ * NOTE: character joiners are only used by the canvas renderer.
1043
+ *
1044
+ * @param handler The function that determines character joins. It is called
1045
+ * with a string of text that is eligible for joining and returns an array
1046
+ * where each entry is an array containing the start (inclusive) and end
1047
+ * (exclusive) indexes of ranges that should be rendered as a single unit.
1048
+ * @returns The ID of the new joiner, this can be used to deregister
1049
+ */
1050
+ registerCharacterJoiner(handler: (text: string) => [number, number][]): number;
1051
+
1052
+ /**
1053
+ * (EXPERIMENTAL) Deregisters the character joiner if one was registered.
1054
+ * NOTE: character joiners are only used by the canvas renderer.
1055
+ * @param joinerId The character joiner's ID (returned after register)
1056
+ */
1057
+ deregisterCharacterJoiner(joinerId: number): void;
1058
+
1059
+ /**
1060
+ * Adds a marker to the normal buffer and returns it.
1061
+ * @param cursorYOffset The y position offset of the marker from the cursor.
1062
+ * @returns The new marker or undefined.
1063
+ */
1064
+ registerMarker(cursorYOffset?: number): IMarker;
1065
+
1066
+ /**
1067
+ * (EXPERIMENTAL) Adds a decoration to the terminal using
1068
+ * @param decorationOptions, which takes a marker and an optional anchor,
1069
+ * width, height, and x offset from the anchor. Returns the decoration or
1070
+ * undefined if the alt buffer is active or the marker has already been
1071
+ * disposed of.
1072
+ * @throws when options include a negative x offset.
1073
+ */
1074
+ registerDecoration(decorationOptions: IDecorationOptions): IDecoration | undefined;
1075
+
1076
+ /**
1077
+ * Gets whether the terminal has an active selection.
1078
+ */
1079
+ hasSelection(): boolean;
1080
+
1081
+ /**
1082
+ * Gets the terminal's current selection, this is useful for implementing
1083
+ * copy behavior outside of xterm.js.
1084
+ */
1085
+ getSelection(): string;
1086
+
1087
+ /**
1088
+ * Gets the selection position or undefined if there is no selection.
1089
+ */
1090
+ getSelectionPosition(): IBufferRange | undefined;
1091
+
1092
+ /**
1093
+ * Clears the current terminal selection.
1094
+ */
1095
+ clearSelection(): void;
1096
+
1097
+ /**
1098
+ * Selects text within the terminal.
1099
+ * @param column The column the selection starts at.
1100
+ * @param row The row the selection starts at.
1101
+ * @param length The length of the selection.
1102
+ */
1103
+ select(column: number, row: number, length: number): void;
1104
+
1105
+ /**
1106
+ * Selects all text within the terminal.
1107
+ */
1108
+ selectAll(): void;
1109
+
1110
+ /**
1111
+ * Selects text in the buffer between 2 lines.
1112
+ * @param start The 0-based line index to select from (inclusive).
1113
+ * @param end The 0-based line index to select to (inclusive).
1114
+ */
1115
+ selectLines(start: number, end: number): void;
1116
+
1117
+ /*
1118
+ * Disposes of the terminal, detaching it from the DOM and removing any
1119
+ * active listeners. Once the terminal is disposed it should not be used
1120
+ * again.
1121
+ */
1122
+ dispose(): void;
1123
+
1124
+ /**
1125
+ * Scroll the display of the terminal
1126
+ * @param amount The number of lines to scroll down (negative scroll up).
1127
+ */
1128
+ scrollLines(amount: number): void;
1129
+
1130
+ /**
1131
+ * Scroll the display of the terminal by a number of pages.
1132
+ * @param pageCount The number of pages to scroll (negative scrolls up).
1133
+ */
1134
+ scrollPages(pageCount: number): void;
1135
+
1136
+ /**
1137
+ * Scrolls the display of the terminal to the top.
1138
+ */
1139
+ scrollToTop(): void;
1140
+
1141
+ /**
1142
+ * Scrolls the display of the terminal to the bottom.
1143
+ */
1144
+ scrollToBottom(): void;
1145
+
1146
+ /**
1147
+ * Scrolls to a line within the buffer.
1148
+ * @param line The 0-based line index to scroll to.
1149
+ */
1150
+ scrollToLine(line: number): void;
1151
+
1152
+ /**
1153
+ * Clear the entire buffer, making the prompt line the new first line.
1154
+ */
1155
+ clear(): void;
1156
+
1157
+ /**
1158
+ * Write data to the terminal.
1159
+ * @param data The data to write to the terminal. This can either be raw
1160
+ * bytes given as Uint8Array from the pty or a string. Raw bytes will always
1161
+ * be treated as UTF-8 encoded, string data as UTF-16.
1162
+ * @param callback Optional callback that fires when the data was processed
1163
+ * by the parser.
1164
+ */
1165
+ write(data: string | Uint8Array, callback?: () => void): void;
1166
+
1167
+ /**
1168
+ * Writes data to the terminal, followed by a break line character (\n).
1169
+ * @param data The data to write to the terminal. This can either be raw
1170
+ * bytes given as Uint8Array from the pty or a string. Raw bytes will always
1171
+ * be treated as UTF-8 encoded, string data as UTF-16.
1172
+ * @param callback Optional callback that fires when the data was processed
1173
+ * by the parser.
1174
+ */
1175
+ writeln(data: string | Uint8Array, callback?: () => void): void;
1176
+
1177
+ /**
1178
+ * Writes text to the terminal, performing the necessary transformations for
1179
+ * pasted text.
1180
+ * @param data The text to write to the terminal.
1181
+ */
1182
+ paste(data: string): void;
1183
+
1184
+ /**
1185
+ * Tells the renderer to refresh terminal content between two rows
1186
+ * (inclusive) at the next opportunity.
1187
+ * @param start The row to start from (between 0 and this.rows - 1).
1188
+ * @param end The row to end at (between start and this.rows - 1).
1189
+ */
1190
+ refresh(start: number, end: number): void;
1191
+
1192
+ /**
1193
+ * Clears the texture atlas of the canvas renderer if it's active. Doing
1194
+ * this will force a redraw of all glyphs which can workaround issues
1195
+ * causing the texture to become corrupt, for example Chromium/Nvidia has an
1196
+ * issue where the texture gets messed up when resuming the OS from sleep.
1197
+ */
1198
+ clearTextureAtlas(): void;
1199
+
1200
+ /**
1201
+ * Perform a full reset (RIS, aka '\x1bc').
1202
+ */
1203
+ reset(): void;
1204
+
1205
+ /**
1206
+ * Loads an addon into this instance of xterm.js.
1207
+ * @param addon The addon to load.
1208
+ */
1209
+ loadAddon(addon: ITerminalAddon): void;
1210
+ }
1211
+
1212
+ /**
1213
+ * An addon that can provide additional functionality to the terminal.
1214
+ */
1215
+ export interface ITerminalAddon extends IDisposable {
1216
+ /**
1217
+ * This is called when the addon is activated.
1218
+ */
1219
+ activate(terminal: Terminal): void;
1220
+ }
1221
+
1222
+ /**
1223
+ * An object representing a range within the viewport of the terminal.
1224
+ */
1225
+ export interface IViewportRange {
1226
+ /**
1227
+ * The start of the range.
1228
+ */
1229
+ start: IViewportRangePosition;
1230
+
1231
+ /**
1232
+ * The end of the range.
1233
+ */
1234
+ end: IViewportRangePosition;
1235
+ }
1236
+
1237
+ /**
1238
+ * An object representing a cell position within the viewport of the terminal.
1239
+ */
1240
+ interface IViewportRangePosition {
1241
+ /**
1242
+ * The x position of the cell. This is a 0-based index that refers to the
1243
+ * space in between columns, not the column itself. Index 0 refers to the
1244
+ * left side of the viewport, index `Terminal.cols` refers to the right side
1245
+ * of the viewport. This can be thought of as how a cursor is positioned in
1246
+ * a text editor.
1247
+ */
1248
+ x: number;
1249
+
1250
+ /**
1251
+ * The y position of the cell. This is a 0-based index that refers to a
1252
+ * specific row.
1253
+ */
1254
+ y: number;
1255
+ }
1256
+
1257
+ /**
1258
+ * A link handler for OSC 8 hyperlinks.
1259
+ */
1260
+ interface ILinkHandler {
1261
+ /**
1262
+ * Calls when the link is activated.
1263
+ * @param event The mouse event triggering the callback.
1264
+ * @param text The text of the link.
1265
+ * @param range The buffer range of the link.
1266
+ */
1267
+ activate(event: MouseEvent, text: string, range: IBufferRange): void;
1268
+
1269
+ /**
1270
+ * Called when the mouse hovers the link. To use this to create a DOM-based
1271
+ * hover tooltip, create the hover element within `Terminal.element` and
1272
+ * add the `xterm-hover` class to it, that will cause mouse events to not
1273
+ * fall through and activate other links.
1274
+ * @param event The mouse event triggering the callback.
1275
+ * @param text The text of the link.
1276
+ * @param range The buffer range of the link.
1277
+ */
1278
+ hover?(event: MouseEvent, text: string, range: IBufferRange): void;
1279
+
1280
+ /**
1281
+ * Called when the mouse leaves the link.
1282
+ * @param event The mouse event triggering the callback.
1283
+ * @param text The text of the link.
1284
+ * @param range The buffer range of the link.
1285
+ */
1286
+ leave?(event: MouseEvent, text: string, range: IBufferRange): void;
1287
+
1288
+ /**
1289
+ * Whether to receive non-HTTP URLs from LinkProvider. When false, any
1290
+ * usage of non-HTTP URLs will be ignored. Enabling this option without
1291
+ * proper protection in `activate` function may cause security issues such
1292
+ * as XSS.
1293
+ */
1294
+ allowNonHttpProtocols?: boolean;
1295
+ }
1296
+
1297
+ /**
1298
+ * A custom link provider.
1299
+ */
1300
+ interface ILinkProvider {
1301
+ /**
1302
+ * Provides a link a buffer position
1303
+ * @param bufferLineNumber The y position of the buffer to check for links
1304
+ * within.
1305
+ * @param callback The callback to be fired when ready with the resulting
1306
+ * link(s) for the line or `undefined`.
1307
+ */
1308
+ provideLinks(bufferLineNumber: number, callback: (links: ILink[] | undefined) => void): void;
1309
+ }
1310
+
1311
+ /**
1312
+ * A link within the terminal.
1313
+ */
1314
+ interface ILink {
1315
+ /**
1316
+ * The buffer range of the link.
1317
+ */
1318
+ range: IBufferRange;
1319
+
1320
+ /**
1321
+ * The text of the link.
1322
+ */
1323
+ text: string;
1324
+
1325
+ /**
1326
+ * What link decorations to show when hovering the link, this property is
1327
+ * tracked and changes made after the link is provided will trigger changes.
1328
+ * If not set, all decroations will be enabled.
1329
+ */
1330
+ decorations?: ILinkDecorations;
1331
+
1332
+ /**
1333
+ * Calls when the link is activated.
1334
+ * @param event The mouse event triggering the callback.
1335
+ * @param text The text of the link.
1336
+ */
1337
+ activate(event: MouseEvent, text: string): void;
1338
+
1339
+ /**
1340
+ * Called when the mouse hovers the link. To use this to create a DOM-based
1341
+ * hover tooltip, create the hover element within `Terminal.element` and add
1342
+ * the `xterm-hover` class to it, that will cause mouse events to not fall
1343
+ * through and activate other links.
1344
+ * @param event The mouse event triggering the callback.
1345
+ * @param text The text of the link.
1346
+ */
1347
+ hover?(event: MouseEvent, text: string): void;
1348
+
1349
+ /**
1350
+ * Called when the mouse leaves the link.
1351
+ * @param event The mouse event triggering the callback.
1352
+ * @param text The text of the link.
1353
+ */
1354
+ leave?(event: MouseEvent, text: string): void;
1355
+
1356
+ /**
1357
+ * Called when the link is released and no longer used by xterm.js.
1358
+ */
1359
+ dispose?(): void;
1360
+ }
1361
+
1362
+ /**
1363
+ * A set of decorations that can be applied to links.
1364
+ */
1365
+ interface ILinkDecorations {
1366
+ /**
1367
+ * Whether the cursor is set to pointer.
1368
+ */
1369
+ pointerCursor: boolean;
1370
+
1371
+ /**
1372
+ * Whether the underline is visible
1373
+ */
1374
+ underline: boolean;
1375
+ }
1376
+
1377
+ /**
1378
+ * A range within a buffer.
1379
+ */
1380
+ interface IBufferRange {
1381
+ /**
1382
+ * The start position of the range.
1383
+ */
1384
+ start: IBufferCellPosition;
1385
+
1386
+ /**
1387
+ * The end position of the range.
1388
+ */
1389
+ end: IBufferCellPosition;
1390
+ }
1391
+
1392
+ /**
1393
+ * A position within a buffer.
1394
+ */
1395
+ interface IBufferCellPosition {
1396
+ /**
1397
+ * The x position within the buffer (1-based).
1398
+ */
1399
+ x: number;
1400
+
1401
+ /**
1402
+ * The y position within the buffer (1-based).
1403
+ */
1404
+ y: number;
1405
+ }
1406
+
1407
+ /**
1408
+ * Represents a terminal buffer.
1409
+ */
1410
+ interface IBuffer {
1411
+ /**
1412
+ * The type of the buffer.
1413
+ */
1414
+ readonly type: 'normal' | 'alternate';
1415
+
1416
+ /**
1417
+ * The y position of the cursor. This ranges between `0` (when the
1418
+ * cursor is at baseY) and `Terminal.rows - 1` (when the cursor is on the
1419
+ * last row).
1420
+ */
1421
+ readonly cursorY: number;
1422
+
1423
+ /**
1424
+ * The x position of the cursor. This ranges between `0` (left side) and
1425
+ * `Terminal.cols` (after last cell of the row).
1426
+ */
1427
+ readonly cursorX: number;
1428
+
1429
+ /**
1430
+ * The line within the buffer where the top of the viewport is.
1431
+ */
1432
+ readonly viewportY: number;
1433
+
1434
+ /**
1435
+ * The line within the buffer where the top of the bottom page is (when
1436
+ * fully scrolled down).
1437
+ */
1438
+ readonly baseY: number;
1439
+
1440
+ /**
1441
+ * The amount of lines in the buffer.
1442
+ */
1443
+ readonly length: number;
1444
+
1445
+ /**
1446
+ * Gets a line from the buffer, or undefined if the line index does not
1447
+ * exist.
1448
+ *
1449
+ * Note that the result of this function should be used immediately after
1450
+ * calling as when the terminal updates it could lead to unexpected
1451
+ * behavior.
1452
+ *
1453
+ * @param y The line index to get.
1454
+ */
1455
+ getLine(y: number): IBufferLine | undefined;
1456
+
1457
+ /**
1458
+ * Creates an empty cell object suitable as a cell reference in
1459
+ * `line.getCell(x, cell)`. Use this to avoid costly recreation of
1460
+ * cell objects when dealing with tons of cells.
1461
+ */
1462
+ getNullCell(): IBufferCell;
1463
+ }
1464
+
1465
+ export interface IBufferElementProvider {
1466
+ /**
1467
+ * Provides a document fragment or HTMLElement containing the buffer
1468
+ * elements.
1469
+ */
1470
+ provideBufferElements(): DocumentFragment | HTMLElement;
1471
+ }
1472
+
1473
+ /**
1474
+ * Represents the terminal's set of buffers.
1475
+ */
1476
+ interface IBufferNamespace {
1477
+ /**
1478
+ * The active buffer, this will either be the normal or alternate buffers.
1479
+ */
1480
+ readonly active: IBuffer;
1481
+
1482
+ /**
1483
+ * The normal buffer.
1484
+ */
1485
+ readonly normal: IBuffer;
1486
+
1487
+ /**
1488
+ * The alternate buffer, this becomes the active buffer when an application
1489
+ * enters this mode via DECSET (`CSI ? 4 7 h`)
1490
+ */
1491
+ readonly alternate: IBuffer;
1492
+
1493
+ /**
1494
+ * Adds an event listener for when the active buffer changes.
1495
+ * @returns an `IDisposable` to stop listening.
1496
+ */
1497
+ onBufferChange: IEvent<IBuffer>;
1498
+ }
1499
+
1500
+ /**
1501
+ * Represents a line in the terminal's buffer.
1502
+ */
1503
+ interface IBufferLine {
1504
+ /**
1505
+ * Whether the line is wrapped from the previous line.
1506
+ */
1507
+ readonly isWrapped: boolean;
1508
+
1509
+ /**
1510
+ * The length of the line, all call to getCell beyond the length will result
1511
+ * in `undefined`. Note that this may exceed columns as the line array may
1512
+ * not be trimmed after a resize, compare against {@link Terminal.cols} to
1513
+ * get the actual maximum length of a line.
1514
+ */
1515
+ readonly length: number;
1516
+
1517
+ /**
1518
+ * Gets a cell from the line, or undefined if the line index does not exist.
1519
+ *
1520
+ * Note that the result of this function should be used immediately after
1521
+ * calling as when the terminal updates it could lead to unexpected
1522
+ * behavior.
1523
+ *
1524
+ * @param x The character index to get.
1525
+ * @param cell Optional cell object to load data into for performance
1526
+ * reasons. This is mainly useful when every cell in the buffer is being
1527
+ * looped over to avoid creating new objects for every cell.
1528
+ */
1529
+ getCell(x: number, cell?: IBufferCell): IBufferCell | undefined;
1530
+
1531
+ /**
1532
+ * Gets the line as a string. Note that this is gets only the string for the
1533
+ * line, not taking isWrapped into account.
1534
+ *
1535
+ * @param trimRight Whether to trim any whitespace at the right of the line.
1536
+ * @param startColumn The column to start from (inclusive).
1537
+ * @param endColumn The column to end at (exclusive).
1538
+ */
1539
+ translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string;
1540
+ }
1541
+
1542
+ /**
1543
+ * Represents a single cell in the terminal's buffer.
1544
+ */
1545
+ interface IBufferCell {
1546
+ /**
1547
+ * The width of the character. Some examples:
1548
+ *
1549
+ * - `1` for most cells.
1550
+ * - `2` for wide character like CJK glyphs.
1551
+ * - `0` for cells immediately following cells with a width of `2`.
1552
+ */
1553
+ getWidth(): number;
1554
+
1555
+ /**
1556
+ * The character(s) within the cell. Examples of what this can contain:
1557
+ *
1558
+ * - A normal width character
1559
+ * - A wide character (eg. CJK)
1560
+ * - An emoji
1561
+ */
1562
+ getChars(): string;
1563
+
1564
+ /**
1565
+ * Gets the UTF32 codepoint of single characters, if content is a combined
1566
+ * string it returns the codepoint of the last character in the string.
1567
+ */
1568
+ getCode(): number;
1569
+
1570
+ /**
1571
+ * Gets the number representation of the foreground color mode, this can be
1572
+ * used to perform quick comparisons of 2 cells to see if they're the same.
1573
+ * Use `isFgRGB`, `isFgPalette` and `isFgDefault` to check what color mode
1574
+ * a cell is.
1575
+ */
1576
+ getFgColorMode(): number;
1577
+
1578
+ /**
1579
+ * Gets the number representation of the background color mode, this can be
1580
+ * used to perform quick comparisons of 2 cells to see if they're the same.
1581
+ * Use `isBgRGB`, `isBgPalette` and `isBgDefault` to check what color mode
1582
+ * a cell is.
1583
+ */
1584
+ getBgColorMode(): number;
1585
+
1586
+ /**
1587
+ * Gets a cell's foreground color number, this differs depending on what the
1588
+ * color mode of the cell is:
1589
+ *
1590
+ * - Default: This should be 0, representing the default foreground color
1591
+ * (CSI 39 m).
1592
+ * - Palette: This is a number from 0 to 255 of ANSI colors (CSI 3(0-7) m,
1593
+ * CSI 9(0-7) m, CSI 38 ; 5 ; 0-255 m).
1594
+ * - RGB: A hex value representing a 'true color': 0xRRGGBB.
1595
+ * (CSI 3 8 ; 2 ; Pi ; Pr ; Pg ; Pb)
1596
+ */
1597
+ getFgColor(): number;
1598
+
1599
+ /**
1600
+ * Gets a cell's background color number, this differs depending on what the
1601
+ * color mode of the cell is:
1602
+ *
1603
+ * - Default: This should be 0, representing the default background color
1604
+ * (CSI 49 m).
1605
+ * - Palette: This is a number from 0 to 255 of ANSI colors
1606
+ * (CSI 4(0-7) m, CSI 10(0-7) m, CSI 48 ; 5 ; 0-255 m).
1607
+ * - RGB: A hex value representing a 'true color': 0xRRGGBB
1608
+ * (CSI 4 8 ; 2 ; Pi ; Pr ; Pg ; Pb)
1609
+ */
1610
+ getBgColor(): number;
1611
+
1612
+ /** Whether the cell has the bold attribute (CSI 1 m). */
1613
+ isBold(): number;
1614
+ /** Whether the cell has the italic attribute (CSI 3 m). */
1615
+ isItalic(): number;
1616
+ /** Whether the cell has the dim attribute (CSI 2 m). */
1617
+ isDim(): number;
1618
+ /** Whether the cell has the underline attribute (CSI 4 m). */
1619
+ isUnderline(): number;
1620
+ /** Whether the cell has the blink attribute (CSI 5 m). */
1621
+ isBlink(): number;
1622
+ /** Whether the cell has the inverse attribute (CSI 7 m). */
1623
+ isInverse(): number;
1624
+ /** Whether the cell has the invisible attribute (CSI 8 m). */
1625
+ isInvisible(): number;
1626
+ /** Whether the cell has the strikethrough attribute (CSI 9 m). */
1627
+ isStrikethrough(): number;
1628
+ /** Whether the cell has the overline attribute (CSI 53 m). */
1629
+ isOverline(): number;
1630
+
1631
+ /** Whether the cell is using the RGB foreground color mode. */
1632
+ isFgRGB(): boolean;
1633
+ /** Whether the cell is using the RGB background color mode. */
1634
+ isBgRGB(): boolean;
1635
+ /** Whether the cell is using the palette foreground color mode. */
1636
+ isFgPalette(): boolean;
1637
+ /** Whether the cell is using the palette background color mode. */
1638
+ isBgPalette(): boolean;
1639
+ /** Whether the cell is using the default foreground color mode. */
1640
+ isFgDefault(): boolean;
1641
+ /** Whether the cell is using the default background color mode. */
1642
+ isBgDefault(): boolean;
1643
+
1644
+ /** Whether the cell has the default attribute (no color or style). */
1645
+ isAttributeDefault(): boolean;
1646
+ }
1647
+
1648
+ /**
1649
+ * Data type to register a CSI, DCS or ESC callback in the parser
1650
+ * in the form:
1651
+ * ESC I..I F
1652
+ * CSI Prefix P..P I..I F
1653
+ * DCS Prefix P..P I..I F data_bytes ST
1654
+ *
1655
+ * with these rules/restrictions:
1656
+ * - prefix can only be used with CSI and DCS
1657
+ * - only one leading prefix byte is recognized by the parser
1658
+ * before any other parameter bytes (P..P)
1659
+ * - intermediate bytes are recognized up to 2
1660
+ *
1661
+ * For custom sequences make sure to read ECMA-48 and the resources at
1662
+ * vt100.net to not clash with existing sequences or reserved address space.
1663
+ * General recommendations:
1664
+ * - use private address space (see ECMA-48)
1665
+ * - use max one intermediate byte (technically not limited by the spec,
1666
+ * in practice there are no sequences with more than one intermediate byte,
1667
+ * thus parsers might get confused with more intermediates)
1668
+ * - test against other common emulators to check whether they escape/ignore
1669
+ * the sequence correctly
1670
+ *
1671
+ * Notes: OSC command registration is handled differently (see addOscHandler)
1672
+ * APC, PM or SOS is currently not supported.
1673
+ */
1674
+ export interface IFunctionIdentifier {
1675
+ /**
1676
+ * Optional prefix byte, must be in range \x3c .. \x3f.
1677
+ * Usable in CSI and DCS.
1678
+ */
1679
+ prefix?: string;
1680
+ /**
1681
+ * Optional intermediate bytes, must be in range \x20 .. \x2f.
1682
+ * Usable in CSI, DCS and ESC.
1683
+ */
1684
+ intermediates?: string;
1685
+ /**
1686
+ * Final byte, must be in range \x40 .. \x7e for CSI and DCS,
1687
+ * \x30 .. \x7e for ESC.
1688
+ */
1689
+ final: string;
1690
+ }
1691
+
1692
+ /**
1693
+ * Allows hooking into the parser for custom handling of escape sequences.
1694
+ *
1695
+ * Note on sync vs. async handlers:
1696
+ * xterm.js implements all parser actions with synchronous handlers.
1697
+ * In general custom handlers should also operate in sync mode wherever
1698
+ * possible to keep the parser fast.
1699
+ * Still the exposed interfaces allow to register async handlers by returning
1700
+ * a `Promise<boolean>`. Here the parser will pause input processing until
1701
+ * the promise got resolved or rejected (in-band blocking). This "full stop"
1702
+ * on the input chain allows to implement backpressure from a certain async
1703
+ * action while the terminal state will not progress any further from input.
1704
+ * It does not mean that the terminal state will not change at all in between,
1705
+ * as user actions like resize or reset are still processed immediately.
1706
+ * It is an error to assume a stable terminal state while giving back control
1707
+ * in between, e.g. by multiple chained `then` calls.
1708
+ * Downside of an async handler is a rather bad throughput performance,
1709
+ * thus use async handlers only as a last resort or for actions that have
1710
+ * to rely on async interfaces itself.
1711
+ */
1712
+ export interface IParser {
1713
+ /**
1714
+ * Adds a handler for CSI escape sequences.
1715
+ * @param id Specifies the function identifier under which the callback gets
1716
+ * registered, e.g. {final: 'm'} for SGR.
1717
+ * @param callback The function to handle the sequence. The callback is
1718
+ * called with the numerical params. If the sequence has subparams the array
1719
+ * will contain subarrays with their numercial values. Return `true` if the
1720
+ * sequence was handled, `false` if the parser should try a previous
1721
+ * handler. The most recently added handler is tried first.
1722
+ * @returns An IDisposable you can call to remove this handler.
1723
+ */
1724
+ registerCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean | Promise<boolean>): IDisposable;
1725
+
1726
+ /**
1727
+ * Adds a handler for DCS escape sequences.
1728
+ * @param id Specifies the function identifier under which the callback gets
1729
+ * registered, e.g. {intermediates: '$' final: 'q'} for DECRQSS.
1730
+ * @param callback The function to handle the sequence. Note that the
1731
+ * function will only be called once if the sequence finished sucessfully.
1732
+ * There is currently no way to intercept smaller data chunks, data chunks
1733
+ * will be stored up until the sequence is finished. Since DCS sequences are
1734
+ * not limited by the amount of data this might impose a problem for big
1735
+ * payloads. Currently xterm.js limits DCS payload to 10 MB which should
1736
+ * give enough room for most use cases. The function gets the payload and
1737
+ * numerical parameters as arguments. Return `true` if the sequence was
1738
+ * handled, `false` if the parser should try a previous handler. The most
1739
+ * recently added handler is tried first.
1740
+ * @returns An IDisposable you can call to remove this handler.
1741
+ */
1742
+ registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean | Promise<boolean>): IDisposable;
1743
+
1744
+ /**
1745
+ * Adds a handler for ESC escape sequences.
1746
+ * @param id Specifies the function identifier under which the callback gets
1747
+ * registered, e.g. {intermediates: '%' final: 'G'} for default charset
1748
+ * selection.
1749
+ * @param callback The function to handle the sequence.
1750
+ * Return `true` if the sequence was handled, `false` if the parser should
1751
+ * try a previous handler. The most recently added handler is tried first.
1752
+ * @returns An IDisposable you can call to remove this handler.
1753
+ */
1754
+ registerEscHandler(id: IFunctionIdentifier, handler: () => boolean | Promise<boolean>): IDisposable;
1755
+
1756
+ /**
1757
+ * Adds a handler for OSC escape sequences.
1758
+ * @param ident The number (first parameter) of the sequence.
1759
+ * @param callback The function to handle the sequence. Note that the
1760
+ * function will only be called once if the sequence finished sucessfully.
1761
+ * There is currently no way to intercept smaller data chunks, data chunks
1762
+ * will be stored up until the sequence is finished. Since OSC sequences are
1763
+ * not limited by the amount of data this might impose a problem for big
1764
+ * payloads. Currently xterm.js limits OSC payload to 10 MB which should
1765
+ * give enough room for most use cases. The callback is called with OSC data
1766
+ * string. Return `true` if the sequence was handled, `false` if the parser
1767
+ * should try a previous handler. The most recently added handler is tried
1768
+ * first.
1769
+ * @returns An IDisposable you can call to remove this handler.
1770
+ */
1771
+ registerOscHandler(ident: number, callback: (data: string) => boolean | Promise<boolean>): IDisposable;
1772
+ }
1773
+
1774
+ /**
1775
+ * (EXPERIMENTAL) Unicode version provider.
1776
+ * Used to register custom Unicode versions with `Terminal.unicode.register`.
1777
+ */
1778
+ export interface IUnicodeVersionProvider {
1779
+ /**
1780
+ * String indicating the Unicode version provided.
1781
+ */
1782
+ readonly version: string;
1783
+
1784
+ /**
1785
+ * Unicode version dependent wcwidth implementation.
1786
+ */
1787
+ wcwidth(codepoint: number): 0 | 1 | 2;
1788
+ charProperties(codepoint: number, preceding: number): number;
1789
+ }
1790
+
1791
+ /**
1792
+ * (EXPERIMENTAL) Unicode handling interface.
1793
+ */
1794
+ export interface IUnicodeHandling {
1795
+ /**
1796
+ * Register a custom Unicode version provider.
1797
+ */
1798
+ register(provider: IUnicodeVersionProvider): void;
1799
+
1800
+ /**
1801
+ * Registered Unicode versions.
1802
+ */
1803
+ readonly versions: ReadonlyArray<string>;
1804
+
1805
+ /**
1806
+ * Getter/setter for active Unicode version.
1807
+ */
1808
+ activeVersion: string;
1809
+ }
1810
+
1811
+ /**
1812
+ * Terminal modes as set by SM/DECSET.
1813
+ */
1814
+ export interface IModes {
1815
+ /**
1816
+ * Application Cursor Keys (DECCKM): `CSI ? 1 h`
1817
+ */
1818
+ readonly applicationCursorKeysMode: boolean;
1819
+ /**
1820
+ * Application Keypad Mode (DECNKM): `CSI ? 6 6 h`
1821
+ */
1822
+ readonly applicationKeypadMode: boolean;
1823
+ /**
1824
+ * Bracketed Paste Mode: `CSI ? 2 0 0 4 h`
1825
+ */
1826
+ readonly bracketedPasteMode: boolean;
1827
+ /**
1828
+ * Insert Mode (IRM): `CSI 4 h`
1829
+ */
1830
+ readonly insertMode: boolean;
1831
+ /**
1832
+ * Mouse Tracking, this can be one of the following:
1833
+ * - none: This is the default value and can be reset with DECRST
1834
+ * - x10: Send Mouse X & Y on button press `CSI ? 9 h`
1835
+ * - vt200: Send Mouse X & Y on button press and release `CSI ? 1 0 0 0 h`
1836
+ * - drag: Use Cell Motion Mouse Tracking `CSI ? 1 0 0 2 h`
1837
+ * - any: Use All Motion Mouse Tracking `CSI ? 1 0 0 3 h`
1838
+ */
1839
+ readonly mouseTrackingMode: 'none' | 'x10' | 'vt200' | 'drag' | 'any';
1840
+ /**
1841
+ * Origin Mode (DECOM): `CSI ? 6 h`
1842
+ */
1843
+ readonly originMode: boolean;
1844
+ /**
1845
+ * Reverse-wraparound Mode: `CSI ? 4 5 h`
1846
+ */
1847
+ readonly reverseWraparoundMode: boolean;
1848
+ /**
1849
+ * Send FocusIn/FocusOut events: `CSI ? 1 0 0 4 h`
1850
+ */
1851
+ readonly sendFocusMode: boolean;
1852
+ /**
1853
+ * Auto-Wrap Mode (DECAWM): `CSI ? 7 h`
1854
+ */
1855
+ readonly wraparoundMode: boolean;
1856
+ }
1857
+ }