@xterm/xterm 6.1.0-beta.25 → 6.1.0-beta.250

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 (163) hide show
  1. package/README.md +62 -38
  2. package/css/xterm.css +29 -22
  3. package/lib/xterm.js +1 -1
  4. package/lib/xterm.js.map +1 -1
  5. package/lib/xterm.mjs +8 -34
  6. package/lib/xterm.mjs.map +4 -4
  7. package/package.json +25 -22
  8. package/src/browser/AccessibilityManager.ts +11 -6
  9. package/src/browser/Clipboard.ts +6 -3
  10. package/src/browser/CoreBrowserTerminal.ts +149 -319
  11. package/src/browser/Dom.ts +178 -0
  12. package/src/browser/Linkifier.ts +11 -11
  13. package/src/browser/OscLinkProvider.ts +82 -14
  14. package/src/browser/RenderDebouncer.ts +2 -2
  15. package/src/browser/TimeBasedDebouncer.ts +2 -2
  16. package/src/browser/Types.ts +12 -11
  17. package/src/browser/Viewport.ts +55 -20
  18. package/src/browser/decorations/BufferDecorationRenderer.ts +1 -1
  19. package/src/browser/decorations/OverviewRulerRenderer.ts +33 -17
  20. package/src/browser/input/CompositionHelper.ts +44 -8
  21. package/src/browser/public/Terminal.ts +25 -28
  22. package/src/browser/renderer/dom/DomRenderer.ts +242 -76
  23. package/src/browser/renderer/dom/DomRendererRowFactory.ts +19 -13
  24. package/src/browser/renderer/dom/WidthCache.ts +54 -52
  25. package/src/browser/renderer/shared/Constants.ts +7 -0
  26. package/src/browser/renderer/shared/TextBlinkStateManager.ts +97 -0
  27. package/src/browser/renderer/shared/Types.ts +8 -2
  28. package/src/browser/scrollable/abstractScrollbar.ts +300 -0
  29. package/src/browser/scrollable/fastDomNode.ts +126 -0
  30. package/src/browser/scrollable/globalPointerMoveMonitor.ts +90 -0
  31. package/src/browser/scrollable/horizontalScrollbar.ts +85 -0
  32. package/src/browser/scrollable/mouseEvent.ts +292 -0
  33. package/src/browser/scrollable/scrollable.ts +486 -0
  34. package/src/browser/scrollable/scrollableElement.ts +581 -0
  35. package/src/browser/scrollable/scrollableElementOptions.ts +161 -0
  36. package/src/browser/scrollable/scrollbarArrow.ts +110 -0
  37. package/src/browser/scrollable/scrollbarState.ts +246 -0
  38. package/src/browser/scrollable/scrollbarVisibilityController.ts +113 -0
  39. package/src/browser/scrollable/touch.ts +485 -0
  40. package/src/browser/scrollable/verticalScrollbar.ts +143 -0
  41. package/src/browser/scrollable/widget.ts +23 -0
  42. package/src/browser/services/CharSizeService.ts +2 -2
  43. package/src/browser/services/CoreBrowserService.ts +7 -5
  44. package/src/browser/services/KeyboardService.ts +67 -0
  45. package/src/browser/services/LinkProviderService.ts +1 -1
  46. package/src/browser/services/MouseCoordsService.ts +47 -0
  47. package/src/browser/services/MouseService.ts +518 -25
  48. package/src/browser/services/RenderService.ts +28 -16
  49. package/src/browser/services/SelectionService.ts +45 -39
  50. package/src/browser/services/Services.ts +40 -17
  51. package/src/browser/services/ThemeService.ts +2 -2
  52. package/src/common/Async.ts +141 -0
  53. package/src/common/CircularList.ts +2 -2
  54. package/src/common/Color.ts +8 -0
  55. package/src/common/CoreTerminal.ts +32 -22
  56. package/src/common/Event.ts +118 -0
  57. package/src/common/InputHandler.ts +286 -87
  58. package/src/common/Lifecycle.ts +113 -0
  59. package/src/common/Platform.ts +13 -3
  60. package/src/common/SortedList.ts +7 -3
  61. package/src/common/StringBuilder.ts +67 -0
  62. package/src/common/TaskQueue.ts +14 -5
  63. package/src/common/Types.ts +51 -31
  64. package/src/common/Version.ts +9 -0
  65. package/src/common/buffer/Buffer.ts +34 -19
  66. package/src/common/buffer/BufferLine.ts +140 -68
  67. package/src/common/buffer/BufferLineStringCache.ts +69 -0
  68. package/src/common/buffer/BufferReflow.ts +4 -1
  69. package/src/common/buffer/BufferSet.ts +11 -6
  70. package/src/common/buffer/CellData.ts +57 -0
  71. package/src/common/buffer/Marker.ts +2 -2
  72. package/src/common/buffer/Types.ts +6 -2
  73. package/src/common/data/EscapeSequences.ts +71 -70
  74. package/src/common/input/Keyboard.ts +14 -7
  75. package/src/common/input/KittyKeyboard.ts +526 -0
  76. package/src/common/input/Win32InputMode.ts +297 -0
  77. package/src/common/input/WriteBuffer.ts +107 -38
  78. package/src/common/input/XParseColor.ts +2 -2
  79. package/src/common/parser/ApcParser.ts +196 -0
  80. package/src/common/parser/Constants.ts +14 -4
  81. package/src/common/parser/DcsParser.ts +11 -12
  82. package/src/common/parser/EscapeSequenceParser.ts +205 -63
  83. package/src/common/parser/OscParser.ts +11 -12
  84. package/src/common/parser/Params.ts +27 -8
  85. package/src/common/parser/Types.ts +36 -2
  86. package/src/common/public/BufferLineApiView.ts +2 -2
  87. package/src/common/public/BufferNamespaceApi.ts +3 -3
  88. package/src/common/public/ParserApi.ts +3 -0
  89. package/src/common/services/BufferService.ts +14 -9
  90. package/src/common/services/CharsetService.ts +4 -0
  91. package/src/common/services/CoreService.ts +22 -9
  92. package/src/common/services/DecorationService.ts +255 -8
  93. package/src/common/services/LogService.ts +1 -31
  94. package/src/common/services/{CoreMouseService.ts → MouseStateService.ts} +21 -132
  95. package/src/common/services/OptionsService.ts +13 -4
  96. package/src/common/services/ServiceRegistry.ts +9 -7
  97. package/src/common/services/Services.ts +49 -40
  98. package/src/common/services/UnicodeService.ts +1 -1
  99. package/typings/xterm.d.ts +318 -34
  100. package/src/common/Clone.ts +0 -23
  101. package/src/common/TypedArrayUtils.ts +0 -17
  102. package/src/vs/base/browser/browser.ts +0 -141
  103. package/src/vs/base/browser/canIUse.ts +0 -49
  104. package/src/vs/base/browser/dom.ts +0 -2369
  105. package/src/vs/base/browser/fastDomNode.ts +0 -316
  106. package/src/vs/base/browser/globalPointerMoveMonitor.ts +0 -112
  107. package/src/vs/base/browser/iframe.ts +0 -135
  108. package/src/vs/base/browser/keyboardEvent.ts +0 -213
  109. package/src/vs/base/browser/mouseEvent.ts +0 -229
  110. package/src/vs/base/browser/touch.ts +0 -372
  111. package/src/vs/base/browser/ui/scrollbar/abstractScrollbar.ts +0 -303
  112. package/src/vs/base/browser/ui/scrollbar/horizontalScrollbar.ts +0 -114
  113. package/src/vs/base/browser/ui/scrollbar/scrollableElement.ts +0 -720
  114. package/src/vs/base/browser/ui/scrollbar/scrollableElementOptions.ts +0 -165
  115. package/src/vs/base/browser/ui/scrollbar/scrollbarArrow.ts +0 -114
  116. package/src/vs/base/browser/ui/scrollbar/scrollbarState.ts +0 -243
  117. package/src/vs/base/browser/ui/scrollbar/scrollbarVisibilityController.ts +0 -118
  118. package/src/vs/base/browser/ui/scrollbar/verticalScrollbar.ts +0 -116
  119. package/src/vs/base/browser/ui/widget.ts +0 -57
  120. package/src/vs/base/browser/window.ts +0 -14
  121. package/src/vs/base/common/arrays.ts +0 -887
  122. package/src/vs/base/common/arraysFind.ts +0 -202
  123. package/src/vs/base/common/assert.ts +0 -71
  124. package/src/vs/base/common/async.ts +0 -1992
  125. package/src/vs/base/common/cancellation.ts +0 -148
  126. package/src/vs/base/common/charCode.ts +0 -450
  127. package/src/vs/base/common/collections.ts +0 -140
  128. package/src/vs/base/common/decorators.ts +0 -130
  129. package/src/vs/base/common/equals.ts +0 -146
  130. package/src/vs/base/common/errors.ts +0 -303
  131. package/src/vs/base/common/event.ts +0 -1778
  132. package/src/vs/base/common/functional.ts +0 -32
  133. package/src/vs/base/common/hash.ts +0 -316
  134. package/src/vs/base/common/iterator.ts +0 -159
  135. package/src/vs/base/common/keyCodes.ts +0 -526
  136. package/src/vs/base/common/keybindings.ts +0 -284
  137. package/src/vs/base/common/lazy.ts +0 -47
  138. package/src/vs/base/common/lifecycle.ts +0 -801
  139. package/src/vs/base/common/linkedList.ts +0 -142
  140. package/src/vs/base/common/map.ts +0 -202
  141. package/src/vs/base/common/numbers.ts +0 -98
  142. package/src/vs/base/common/observable.ts +0 -76
  143. package/src/vs/base/common/observableInternal/api.ts +0 -31
  144. package/src/vs/base/common/observableInternal/autorun.ts +0 -281
  145. package/src/vs/base/common/observableInternal/base.ts +0 -489
  146. package/src/vs/base/common/observableInternal/debugName.ts +0 -145
  147. package/src/vs/base/common/observableInternal/derived.ts +0 -428
  148. package/src/vs/base/common/observableInternal/lazyObservableValue.ts +0 -146
  149. package/src/vs/base/common/observableInternal/logging.ts +0 -328
  150. package/src/vs/base/common/observableInternal/promise.ts +0 -209
  151. package/src/vs/base/common/observableInternal/utils.ts +0 -610
  152. package/src/vs/base/common/platform.ts +0 -281
  153. package/src/vs/base/common/scrollable.ts +0 -522
  154. package/src/vs/base/common/sequence.ts +0 -34
  155. package/src/vs/base/common/stopwatch.ts +0 -43
  156. package/src/vs/base/common/strings.ts +0 -557
  157. package/src/vs/base/common/symbols.ts +0 -9
  158. package/src/vs/base/common/uint.ts +0 -59
  159. package/src/vs/patches/nls.ts +0 -90
  160. package/src/vs/typings/base-common.d.ts +0 -20
  161. package/src/vs/typings/require.d.ts +0 -42
  162. package/src/vs/typings/vscode-globals-nls.d.ts +0 -36
  163. package/src/vs/typings/vscode-globals-product.d.ts +0 -33
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Copyright (c) 2026 The xterm.js authors. All rights reserved.
3
+ * @license MIT
4
+ */
5
+
6
+ import type { IBufferLineStringCache, IBufferLineStringCacheEntry } from 'common/buffer/BufferLine';
7
+ import { disposableTimeout } from 'common/Async';
8
+ import { Disposable, MutableDisposable, toDisposable, type IDisposable } from 'common/Lifecycle';
9
+
10
+ const enum Constants {
11
+ CACHE_TTL_MS = 15000
12
+ }
13
+
14
+ export class BufferLineStringCache extends Disposable implements IBufferLineStringCache {
15
+ public generation: number = 0;
16
+ public readonly entries: Set<IBufferLineStringCacheEntry> = new Set();
17
+ private readonly _clearTimeout = this._register(new MutableDisposable<IDisposable>());
18
+ private _lastAccessTimestamp: number = 0;
19
+
20
+ constructor() {
21
+ super();
22
+ this._register(toDisposable(() => this.entries.clear()));
23
+ }
24
+
25
+ public touch(): void {
26
+ this._scheduleClear();
27
+ }
28
+
29
+ public allocateEntry(): IBufferLineStringCacheEntry {
30
+ const entry: IBufferLineStringCacheEntry = {
31
+ value: undefined,
32
+ isTrimmed: false,
33
+ generation: this.generation
34
+ };
35
+ this.entries.add(entry);
36
+ this._scheduleClear();
37
+ return entry;
38
+ }
39
+
40
+ public clear(): void {
41
+ this._clearTimeout.clear();
42
+ this._lastAccessTimestamp = 0;
43
+ this.generation++;
44
+ for (const entry of this.entries) {
45
+ entry.value = undefined;
46
+ entry.isTrimmed = false;
47
+ }
48
+ this.entries.clear();
49
+ }
50
+
51
+ private _scheduleClear(): void {
52
+ this._lastAccessTimestamp = Date.now();
53
+ if (this._clearTimeout.value) {
54
+ return;
55
+ }
56
+ this._scheduleClearTimeout(Constants.CACHE_TTL_MS);
57
+ }
58
+
59
+ private _scheduleClearTimeout(timeoutMs: number): void {
60
+ this._clearTimeout.value = disposableTimeout(() => {
61
+ const elapsed = Date.now() - this._lastAccessTimestamp;
62
+ if (elapsed >= Constants.CACHE_TTL_MS) {
63
+ this.clear();
64
+ return;
65
+ }
66
+ this._scheduleClearTimeout(Constants.CACHE_TTL_MS - elapsed);
67
+ }, timeoutMs);
68
+ }
69
+ }
@@ -178,7 +178,10 @@ export function reflowLargerApplyNewLayout(lines: CircularList<IBufferLine>, new
178
178
  */
179
179
  export function reflowSmallerGetNewLineLengths(wrappedLines: BufferLine[], oldCols: number, newCols: number): number[] {
180
180
  const newLineLengths: number[] = [];
181
- const cellsNeeded = wrappedLines.map((l, i) => getWrappedLineTrimmedLength(wrappedLines, i, oldCols)).reduce((p, c) => p + c);
181
+ let cellsNeeded = 0;
182
+ for (let i = 0; i < wrappedLines.length; i++) {
183
+ cellsNeeded += getWrappedLineTrimmedLength(wrappedLines, i, oldCols);
184
+ }
182
185
 
183
186
  // Use srcCol and srcLine to find the new wrapping point, use that to get the cellsAvailable and
184
187
  // linesNeeded
@@ -3,12 +3,12 @@
3
3
  * @license MIT
4
4
  */
5
5
 
6
- import { Disposable } from 'vs/base/common/lifecycle';
6
+ import { Disposable, MutableDisposable } from 'common/Lifecycle';
7
7
  import { IAttributeData } from 'common/Types';
8
8
  import { Buffer } from 'common/buffer/Buffer';
9
9
  import { IBuffer, IBufferSet } from 'common/buffer/Types';
10
- import { IBufferService, IOptionsService } from 'common/services/Services';
11
- import { Emitter } from 'vs/base/common/event';
10
+ import { IBufferService, ILogService, IOptionsService } from 'common/services/Services';
11
+ import { Emitter } from 'common/Event';
12
12
 
13
13
  /**
14
14
  * The BufferSet represents the set of two buffers used by xterm terminals (normal and alt) and
@@ -18,6 +18,8 @@ export class BufferSet extends Disposable implements IBufferSet {
18
18
  private _normal!: Buffer;
19
19
  private _alt!: Buffer;
20
20
  private _activeBuffer!: Buffer;
21
+ private readonly _normalBuffer = this._register(new MutableDisposable<Buffer>());
22
+ private readonly _altBuffer = this._register(new MutableDisposable<Buffer>());
21
23
 
22
24
  private readonly _onBufferActivate = this._register(new Emitter<{ activeBuffer: IBuffer, inactiveBuffer: IBuffer }>());
23
25
  public readonly onBufferActivate = this._onBufferActivate.event;
@@ -27,7 +29,8 @@ export class BufferSet extends Disposable implements IBufferSet {
27
29
  */
28
30
  constructor(
29
31
  private readonly _optionsService: IOptionsService,
30
- private readonly _bufferService: IBufferService
32
+ private readonly _bufferService: IBufferService,
33
+ private readonly _logService: ILogService
31
34
  ) {
32
35
  super();
33
36
  this.reset();
@@ -36,12 +39,14 @@ export class BufferSet extends Disposable implements IBufferSet {
36
39
  }
37
40
 
38
41
  public reset(): void {
39
- this._normal = new Buffer(true, this._optionsService, this._bufferService);
42
+ this._normal = new Buffer(true, this._optionsService, this._bufferService, this._logService);
43
+ this._normalBuffer.value = this._normal;
40
44
  this._normal.fillViewportRows();
41
45
 
42
46
  // The alt buffer should never have scrollback.
43
47
  // See http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-The-Alternate-Screen-Buffer
44
- this._alt = new Buffer(false, this._optionsService, this._bufferService);
48
+ this._alt = new Buffer(false, this._optionsService, this._bufferService, this._logService);
49
+ this._altBuffer.value = this._alt;
45
50
  this._activeBuffer = this._normal;
46
51
  this._onBufferActivate.fire({
47
52
  activeBuffer: this._normal,
@@ -7,6 +7,7 @@ import { CharData, ICellData, IExtendedAttrs } from 'common/Types';
7
7
  import { stringFromCodePoint } from 'common/input/TextDecoder';
8
8
  import { CHAR_DATA_CHAR_INDEX, CHAR_DATA_WIDTH_INDEX, CHAR_DATA_ATTR_INDEX, Content } from 'common/buffer/Constants';
9
9
  import { AttributeData, ExtendedAttrs } from 'common/buffer/AttributeData';
10
+ import type { IBufferCell as IBufferCellApi } from '@xterm/xterm';
10
11
 
11
12
  /**
12
13
  * CellData - represents a single Cell in the terminal buffer.
@@ -91,4 +92,60 @@ export class CellData extends AttributeData implements ICellData {
91
92
  public getAsCharData(): CharData {
92
93
  return [this.fg, this.getChars(), this.getWidth(), this.getCode()];
93
94
  }
95
+
96
+ public attributesEquals(other: IBufferCellApi): boolean {
97
+ if (this.getFgColorMode() !== other.getFgColorMode() || this.getFgColor() !== other.getFgColor()) {
98
+ return false;
99
+ }
100
+ if (this.getBgColorMode() !== other.getBgColorMode() || this.getBgColor() !== other.getBgColor()) {
101
+ return false;
102
+ }
103
+ if (this.isInverse() !== other.isInverse()) {
104
+ return false;
105
+ }
106
+ if (this.isBold() !== other.isBold()) {
107
+ return false;
108
+ }
109
+ if (this.isUnderline() !== other.isUnderline()) {
110
+ return false;
111
+ }
112
+ if (this.isUnderline()) {
113
+ if (this.getUnderlineStyle() !== other.getUnderlineStyle()) {
114
+ return false;
115
+ }
116
+ const thisDefault = this.isUnderlineColorDefault();
117
+ const otherDefault = other.isUnderlineColorDefault();
118
+ if (!(thisDefault && otherDefault)) {
119
+ if (thisDefault !== otherDefault) {
120
+ return false;
121
+ }
122
+ if (this.getUnderlineColor() !== other.getUnderlineColor()) {
123
+ return false;
124
+ }
125
+ if (this.getUnderlineColorMode() !== other.getUnderlineColorMode()) {
126
+ return false;
127
+ }
128
+ }
129
+ }
130
+ if (this.isOverline() !== other.isOverline()) {
131
+ return false;
132
+ }
133
+ if (this.isBlink() !== other.isBlink()) {
134
+ return false;
135
+ }
136
+ if (this.isInvisible() !== other.isInvisible()) {
137
+ return false;
138
+ }
139
+ if (this.isItalic() !== other.isItalic()) {
140
+ return false;
141
+ }
142
+ if (this.isDim() !== other.isDim()) {
143
+ return false;
144
+ }
145
+ if (this.isStrikethrough() !== other.isStrikethrough()) {
146
+ return false;
147
+ }
148
+ return true;
149
+ }
150
+
94
151
  }
@@ -4,8 +4,8 @@
4
4
  */
5
5
 
6
6
  import { IDisposable, IMarker } from 'common/Types';
7
- import { Emitter } from 'vs/base/common/event';
8
- import { dispose } from 'vs/base/common/lifecycle';
7
+ import { Emitter } from 'common/Event';
8
+ import { dispose } from 'common/Lifecycle';
9
9
 
10
10
  export class Marker implements IMarker {
11
11
  private static _nextId = 1;
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import { IAttributeData, ICircularList, IBufferLine, ICellData, IMarker, ICharset, IDisposable } from 'common/Types';
7
- import type { Event } from 'vs/base/common/event';
7
+ import type { IEvent } from 'common/Event';
8
8
 
9
9
  // BufferIndex denotes a position in the buffer: [rowIndex, colIndex]
10
10
  export type BufferIndex = [number, number];
@@ -22,6 +22,10 @@ export interface IBuffer {
22
22
  savedY: number;
23
23
  savedX: number;
24
24
  savedCharset: ICharset | undefined;
25
+ savedCharsets: (ICharset | undefined)[];
26
+ savedGlevel: number;
27
+ savedOriginMode: boolean;
28
+ savedWraparoundMode: boolean;
25
29
  savedCurAttrData: IAttributeData;
26
30
  isCursorInViewport: boolean;
27
31
  markers: IMarker[];
@@ -42,7 +46,7 @@ export interface IBufferSet extends IDisposable {
42
46
  normal: IBuffer;
43
47
  active: IBuffer;
44
48
 
45
- onBufferActivate: Event<{ activeBuffer: IBuffer, inactiveBuffer: IBuffer }>;
49
+ onBufferActivate: IEvent<{ activeBuffer: IBuffer, inactiveBuffer: IBuffer }>;
46
50
 
47
51
  activateNormalBuffer(): void;
48
52
  activateAltBuffer(fillAttr?: IAttributeData): void;
@@ -7,147 +7,148 @@
7
7
  * C0 control codes
8
8
  * See = https://en.wikipedia.org/wiki/C0_and_C1_control_codes
9
9
  */
10
- export namespace C0 {
10
+ export const enum C0 {
11
11
  /** Null (Caret = ^@, C = \0) */
12
- export const NUL = '\x00';
12
+ NUL = '\x00',
13
13
  /** Start of Heading (Caret = ^A) */
14
- export const SOH = '\x01';
14
+ SOH = '\x01',
15
15
  /** Start of Text (Caret = ^B) */
16
- export const STX = '\x02';
16
+ STX = '\x02',
17
17
  /** End of Text (Caret = ^C) */
18
- export const ETX = '\x03';
18
+ ETX = '\x03',
19
19
  /** End of Transmission (Caret = ^D) */
20
- export const EOT = '\x04';
20
+ EOT = '\x04',
21
21
  /** Enquiry (Caret = ^E) */
22
- export const ENQ = '\x05';
22
+ ENQ = '\x05',
23
23
  /** Acknowledge (Caret = ^F) */
24
- export const ACK = '\x06';
24
+ ACK = '\x06',
25
25
  /** Bell (Caret = ^G, C = \a) */
26
- export const BEL = '\x07';
26
+ BEL = '\x07',
27
27
  /** Backspace (Caret = ^H, C = \b) */
28
- export const BS = '\x08';
28
+ BS = '\x08',
29
29
  /** Character Tabulation, Horizontal Tabulation (Caret = ^I, C = \t) */
30
- export const HT = '\x09';
30
+ HT = '\x09',
31
31
  /** Line Feed (Caret = ^J, C = \n) */
32
- export const LF = '\x0a';
32
+ LF = '\x0a',
33
33
  /** Line Tabulation, Vertical Tabulation (Caret = ^K, C = \v) */
34
- export const VT = '\x0b';
34
+ VT = '\x0b',
35
35
  /** Form Feed (Caret = ^L, C = \f) */
36
- export const FF = '\x0c';
36
+ FF = '\x0c',
37
37
  /** Carriage Return (Caret = ^M, C = \r) */
38
- export const CR = '\x0d';
38
+ CR = '\x0d',
39
39
  /** Shift Out (Caret = ^N) */
40
- export const SO = '\x0e';
40
+ SO = '\x0e',
41
41
  /** Shift In (Caret = ^O) */
42
- export const SI = '\x0f';
42
+ SI = '\x0f',
43
43
  /** Data Link Escape (Caret = ^P) */
44
- export const DLE = '\x10';
44
+ DLE = '\x10',
45
45
  /** Device Control One (XON) (Caret = ^Q) */
46
- export const DC1 = '\x11';
46
+ DC1 = '\x11',
47
47
  /** Device Control Two (Caret = ^R) */
48
- export const DC2 = '\x12';
48
+ DC2 = '\x12',
49
49
  /** Device Control Three (XOFF) (Caret = ^S) */
50
- export const DC3 = '\x13';
50
+ DC3 = '\x13',
51
51
  /** Device Control Four (Caret = ^T) */
52
- export const DC4 = '\x14';
52
+ DC4 = '\x14',
53
53
  /** Negative Acknowledge (Caret = ^U) */
54
- export const NAK = '\x15';
54
+ NAK = '\x15',
55
55
  /** Synchronous Idle (Caret = ^V) */
56
- export const SYN = '\x16';
56
+ SYN = '\x16',
57
57
  /** End of Transmission Block (Caret = ^W) */
58
- export const ETB = '\x17';
58
+ ETB = '\x17',
59
59
  /** Cancel (Caret = ^X) */
60
- export const CAN = '\x18';
60
+ CAN = '\x18',
61
61
  /** End of Medium (Caret = ^Y) */
62
- export const EM = '\x19';
62
+ EM = '\x19',
63
63
  /** Substitute (Caret = ^Z) */
64
- export const SUB = '\x1a';
64
+ SUB = '\x1a',
65
65
  /** Escape (Caret = ^[, C = \e) */
66
- export const ESC = '\x1b';
66
+ ESC = '\x1b',
67
67
  /** File Separator (Caret = ^\) */
68
- export const FS = '\x1c';
68
+ FS = '\x1c',
69
69
  /** Group Separator (Caret = ^]) */
70
- export const GS = '\x1d';
70
+ GS = '\x1d',
71
71
  /** Record Separator (Caret = ^^) */
72
- export const RS = '\x1e';
72
+ RS = '\x1e',
73
73
  /** Unit Separator (Caret = ^_) */
74
- export const US = '\x1f';
74
+ US = '\x1f',
75
75
  /** Space */
76
- export const SP = '\x20';
76
+ SP = '\x20',
77
77
  /** Delete (Caret = ^?) */
78
- export const DEL = '\x7f';
78
+ DEL = '\x7f'
79
79
  }
80
80
 
81
81
  /**
82
82
  * C1 control codes
83
83
  * See = https://en.wikipedia.org/wiki/C0_and_C1_control_codes
84
84
  */
85
- export namespace C1 {
85
+ export const enum C1 {
86
86
  /** padding character */
87
- export const PAD = '\x80';
87
+ PAD = '\x80',
88
88
  /** High Octet Preset */
89
- export const HOP = '\x81';
89
+ HOP = '\x81',
90
90
  /** Break Permitted Here */
91
- export const BPH = '\x82';
91
+ BPH = '\x82',
92
92
  /** No Break Here */
93
- export const NBH = '\x83';
93
+ NBH = '\x83',
94
94
  /** Index */
95
- export const IND = '\x84';
95
+ IND = '\x84',
96
96
  /** Next Line */
97
- export const NEL = '\x85';
97
+ NEL = '\x85',
98
98
  /** Start of Selected Area */
99
- export const SSA = '\x86';
99
+ SSA = '\x86',
100
100
  /** End of Selected Area */
101
- export const ESA = '\x87';
101
+ ESA = '\x87',
102
102
  /** Horizontal Tabulation Set */
103
- export const HTS = '\x88';
103
+ HTS = '\x88',
104
104
  /** Horizontal Tabulation With Justification */
105
- export const HTJ = '\x89';
105
+ HTJ = '\x89',
106
106
  /** Vertical Tabulation Set */
107
- export const VTS = '\x8a';
107
+ VTS = '\x8a',
108
108
  /** Partial Line Down */
109
- export const PLD = '\x8b';
109
+ PLD = '\x8b',
110
110
  /** Partial Line Up */
111
- export const PLU = '\x8c';
111
+ PLU = '\x8c',
112
112
  /** Reverse Index */
113
- export const RI = '\x8d';
113
+ RI = '\x8d',
114
114
  /** Single-Shift 2 */
115
- export const SS2 = '\x8e';
115
+ SS2 = '\x8e',
116
116
  /** Single-Shift 3 */
117
- export const SS3 = '\x8f';
117
+ SS3 = '\x8f',
118
118
  /** Device Control String */
119
- export const DCS = '\x90';
119
+ DCS = '\x90',
120
120
  /** Private Use 1 */
121
- export const PU1 = '\x91';
121
+ PU1 = '\x91',
122
122
  /** Private Use 2 */
123
- export const PU2 = '\x92';
123
+ PU2 = '\x92',
124
124
  /** Set Transmit State */
125
- export const STS = '\x93';
125
+ STS = '\x93',
126
126
  /** Destructive backspace, intended to eliminate ambiguity about meaning of BS. */
127
- export const CCH = '\x94';
127
+ CCH = '\x94',
128
128
  /** Message Waiting */
129
- export const MW = '\x95';
129
+ MW = '\x95',
130
130
  /** Start of Protected Area */
131
- export const SPA = '\x96';
131
+ SPA = '\x96',
132
132
  /** End of Protected Area */
133
- export const EPA = '\x97';
133
+ EPA = '\x97',
134
134
  /** Start of String */
135
- export const SOS = '\x98';
135
+ SOS = '\x98',
136
136
  /** Single Graphic Character Introducer */
137
- export const SGCI = '\x99';
137
+ SGCI = '\x99',
138
138
  /** Single Character Introducer */
139
- export const SCI = '\x9a';
139
+ SCI = '\x9a',
140
140
  /** Control Sequence Introducer */
141
- export const CSI = '\x9b';
141
+ CSI = '\x9b',
142
142
  /** String Terminator */
143
- export const ST = '\x9c';
143
+ ST = '\x9c',
144
144
  /** Operating System Command */
145
- export const OSC = '\x9d';
145
+ OSC = '\x9d',
146
146
  /** Privacy Message */
147
- export const PM = '\x9e';
147
+ PM = '\x9e',
148
148
  /** Application Program Command */
149
- export const APC = '\x9f';
149
+ APC = '\x9f'
150
150
  }
151
- export namespace C1_ESCAPED {
152
- export const ST = `${C0.ESC}\\`;
151
+
152
+ export const enum C1ESCAPED {
153
+ ST = '\x1b\\'
153
154
  }
@@ -99,7 +99,13 @@ export function evaluateKeyboardEvent(
99
99
  break;
100
100
  case 13:
101
101
  // return/enter
102
- result.key = ev.altKey ? C0.ESC + C0.CR : C0.CR;
102
+ if (ev.key === 'c' && ev.ctrlKey) {
103
+ // HACK: Safari on iPad, iOS, AppleVisionPro sends key 13 when typing ctrl-c on hardware
104
+ // keyboard
105
+ result.key = C0.ETX;
106
+ } else {
107
+ result.key = ev.altKey ? C0.ESC + C0.CR : C0.CR;
108
+ }
103
109
  result.cancel = true;
104
110
  break;
105
111
  case 27:
@@ -315,6 +321,8 @@ export function evaluateKeyboardEvent(
315
321
  result.key = String.fromCharCode(ev.keyCode - 51 + 27);
316
322
  } else if (ev.keyCode === 56) {
317
323
  result.key = C0.DEL;
324
+ } else if (ev.key === '/') {
325
+ result.key = C0.US; // https://github.com/xtermjs/xterm.js/issues/5457
318
326
  } else if (ev.keyCode === 219) {
319
327
  result.key = C0.ESC;
320
328
  } else if (ev.keyCode === 220) {
@@ -358,12 +366,11 @@ export function evaluateKeyboardEvent(
358
366
  // Include only keys that that result in a _single_ character; don't include num lock,
359
367
  // volume up, etc.
360
368
  result.key = ev.key;
361
- } else if (ev.key && ev.ctrlKey) {
362
- if (ev.key === '_') { // ^_
363
- result.key = C0.US;
364
- }
365
- if (ev.key === '@') { // ^ + shift + 2 = ^ + @
366
- result.key = C0.NUL;
369
+ } else if (ev.key && ev.ctrlKey && ev.shiftKey) {
370
+ switch (ev.code) {
371
+ case 'Minus': result.key = C0.US; break; // ^_ (Ctrl+Shift+-_
372
+ case 'Digit2': result.key = C0.NUL; break; // ^@ (Ctrl+Shift+2)
373
+ case 'Digit6': result.key = C0.RS; break; // ^^ (Ctrl+Shift+6)
367
374
  }
368
375
  }
369
376
  break;