@wendongfly/myhi 1.0.2 → 1.0.3

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