@xterm/xterm 5.6.0-beta.11 → 5.6.0-beta.110

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 (129) hide show
  1. package/README.md +9 -3
  2. package/css/xterm.css +71 -4
  3. package/lib/xterm.js +1 -1
  4. package/lib/xterm.js.map +1 -1
  5. package/lib/xterm.mjs +53 -0
  6. package/lib/xterm.mjs.map +7 -0
  7. package/package.json +43 -33
  8. package/src/browser/AccessibilityManager.ts +54 -26
  9. package/src/browser/{Terminal.ts → CoreBrowserTerminal.ts} +142 -145
  10. package/src/browser/Linkifier.ts +26 -14
  11. package/src/browser/LocalizableStrings.ts +15 -4
  12. package/src/browser/{Types.d.ts → Types.ts} +67 -15
  13. package/src/browser/Viewport.ts +143 -370
  14. package/src/browser/decorations/BufferDecorationRenderer.ts +14 -9
  15. package/src/browser/decorations/OverviewRulerRenderer.ts +40 -44
  16. package/src/browser/input/CompositionHelper.ts +2 -1
  17. package/src/browser/public/Terminal.ts +25 -19
  18. package/src/browser/renderer/dom/DomRenderer.ts +19 -14
  19. package/src/browser/renderer/dom/DomRendererRowFactory.ts +35 -15
  20. package/src/browser/renderer/shared/Constants.ts +0 -8
  21. package/src/browser/renderer/shared/Types.ts +84 -0
  22. package/src/browser/services/CharSizeService.ts +6 -6
  23. package/src/browser/services/CoreBrowserService.ts +15 -15
  24. package/src/browser/services/LinkProviderService.ts +2 -2
  25. package/src/browser/services/RenderService.ts +20 -20
  26. package/src/browser/services/SelectionService.ts +8 -8
  27. package/src/browser/services/Services.ts +13 -13
  28. package/src/browser/services/ThemeService.ts +19 -58
  29. package/src/browser/shared/Constants.ts +8 -0
  30. package/src/common/CircularList.ts +5 -5
  31. package/src/common/CoreTerminal.ts +35 -41
  32. package/src/common/InputHandler.ts +83 -56
  33. package/src/common/{Types.d.ts → Types.ts} +13 -17
  34. package/src/common/buffer/Buffer.ts +89 -8
  35. package/src/common/buffer/BufferReflow.ts +9 -6
  36. package/src/common/buffer/BufferSet.ts +5 -5
  37. package/src/common/buffer/Marker.ts +4 -4
  38. package/src/common/buffer/{Types.d.ts → Types.ts} +2 -2
  39. package/src/common/input/Keyboard.ts +0 -24
  40. package/src/common/input/WriteBuffer.ts +3 -3
  41. package/src/common/parser/EscapeSequenceParser.ts +4 -4
  42. package/src/common/public/BufferNamespaceApi.ts +3 -3
  43. package/src/common/services/BufferService.ts +7 -7
  44. package/src/common/services/CoreMouseService.ts +5 -3
  45. package/src/common/services/CoreService.ts +8 -6
  46. package/src/common/services/DecorationService.ts +8 -9
  47. package/src/common/services/InstantiationService.ts +1 -1
  48. package/src/common/services/LogService.ts +2 -2
  49. package/src/common/services/OptionsService.ts +8 -6
  50. package/src/common/services/ServiceRegistry.ts +1 -1
  51. package/src/common/services/Services.ts +27 -17
  52. package/src/common/services/UnicodeService.ts +2 -2
  53. package/src/vs/base/browser/browser.ts +141 -0
  54. package/src/vs/base/browser/canIUse.ts +49 -0
  55. package/src/vs/base/browser/dom.ts +2369 -0
  56. package/src/vs/base/browser/fastDomNode.ts +316 -0
  57. package/src/vs/base/browser/globalPointerMoveMonitor.ts +112 -0
  58. package/src/vs/base/browser/iframe.ts +135 -0
  59. package/src/vs/base/browser/keyboardEvent.ts +213 -0
  60. package/src/vs/base/browser/mouseEvent.ts +229 -0
  61. package/src/vs/base/browser/touch.ts +372 -0
  62. package/src/vs/base/browser/ui/scrollbar/abstractScrollbar.ts +303 -0
  63. package/src/vs/base/browser/ui/scrollbar/horizontalScrollbar.ts +114 -0
  64. package/src/vs/base/browser/ui/scrollbar/scrollableElement.ts +720 -0
  65. package/src/vs/base/browser/ui/scrollbar/scrollableElementOptions.ts +165 -0
  66. package/src/vs/base/browser/ui/scrollbar/scrollbarArrow.ts +114 -0
  67. package/src/vs/base/browser/ui/scrollbar/scrollbarState.ts +243 -0
  68. package/src/vs/base/browser/ui/scrollbar/scrollbarVisibilityController.ts +118 -0
  69. package/src/vs/base/browser/ui/scrollbar/verticalScrollbar.ts +116 -0
  70. package/src/vs/base/browser/ui/widget.ts +57 -0
  71. package/src/vs/base/browser/window.ts +14 -0
  72. package/src/vs/base/common/arrays.ts +887 -0
  73. package/src/vs/base/common/arraysFind.ts +202 -0
  74. package/src/vs/base/common/assert.ts +71 -0
  75. package/src/vs/base/common/async.ts +1992 -0
  76. package/src/vs/base/common/cancellation.ts +148 -0
  77. package/src/vs/base/common/charCode.ts +450 -0
  78. package/src/vs/base/common/collections.ts +140 -0
  79. package/src/vs/base/common/decorators.ts +130 -0
  80. package/src/vs/base/common/equals.ts +146 -0
  81. package/src/vs/base/common/errors.ts +303 -0
  82. package/src/vs/base/common/event.ts +1778 -0
  83. package/src/vs/base/common/functional.ts +32 -0
  84. package/src/vs/base/common/hash.ts +316 -0
  85. package/src/vs/base/common/iterator.ts +159 -0
  86. package/src/vs/base/common/keyCodes.ts +526 -0
  87. package/src/vs/base/common/keybindings.ts +284 -0
  88. package/src/vs/base/common/lazy.ts +47 -0
  89. package/src/vs/base/common/lifecycle.ts +801 -0
  90. package/src/vs/base/common/linkedList.ts +142 -0
  91. package/src/vs/base/common/map.ts +202 -0
  92. package/src/vs/base/common/numbers.ts +98 -0
  93. package/src/vs/base/common/observable.ts +76 -0
  94. package/src/vs/base/common/observableInternal/api.ts +31 -0
  95. package/src/vs/base/common/observableInternal/autorun.ts +281 -0
  96. package/src/vs/base/common/observableInternal/base.ts +489 -0
  97. package/src/vs/base/common/observableInternal/debugName.ts +145 -0
  98. package/src/vs/base/common/observableInternal/derived.ts +428 -0
  99. package/src/vs/base/common/observableInternal/lazyObservableValue.ts +146 -0
  100. package/src/vs/base/common/observableInternal/logging.ts +328 -0
  101. package/src/vs/base/common/observableInternal/promise.ts +209 -0
  102. package/src/vs/base/common/observableInternal/utils.ts +610 -0
  103. package/src/vs/base/common/platform.ts +281 -0
  104. package/src/vs/base/common/scrollable.ts +522 -0
  105. package/src/vs/base/common/sequence.ts +34 -0
  106. package/src/vs/base/common/stopwatch.ts +43 -0
  107. package/src/vs/base/common/strings.ts +557 -0
  108. package/src/vs/base/common/symbols.ts +9 -0
  109. package/src/vs/base/common/uint.ts +59 -0
  110. package/src/vs/patches/nls.ts +90 -0
  111. package/src/vs/typings/base-common.d.ts +20 -0
  112. package/src/vs/typings/require.d.ts +42 -0
  113. package/src/vs/typings/thenable.d.ts +12 -0
  114. package/src/vs/typings/vscode-globals-nls.d.ts +36 -0
  115. package/src/vs/typings/vscode-globals-product.d.ts +33 -0
  116. package/typings/xterm.d.ts +80 -14
  117. package/src/browser/Lifecycle.ts +0 -33
  118. package/src/browser/renderer/shared/CellColorResolver.ts +0 -236
  119. package/src/browser/renderer/shared/CharAtlasCache.ts +0 -96
  120. package/src/browser/renderer/shared/CharAtlasUtils.ts +0 -75
  121. package/src/browser/renderer/shared/CursorBlinkStateManager.ts +0 -146
  122. package/src/browser/renderer/shared/CustomGlyphs.ts +0 -687
  123. package/src/browser/renderer/shared/DevicePixelObserver.ts +0 -41
  124. package/src/browser/renderer/shared/TextureAtlas.ts +0 -1100
  125. package/src/browser/renderer/shared/Types.d.ts +0 -173
  126. package/src/common/EventEmitter.ts +0 -78
  127. package/src/common/Lifecycle.ts +0 -108
  128. /package/src/browser/selection/{Types.d.ts → Types.ts} +0 -0
  129. /package/src/common/parser/{Types.d.ts → Types.ts} +0 -0
@@ -8,10 +8,9 @@ import { IInputHandler, IAttributeData, IDisposable, IWindowOptions, IColorEvent
8
8
  import { C0, C1 } from 'common/data/EscapeSequences';
9
9
  import { CHARSETS, DEFAULT_CHARSET } from 'common/data/Charsets';
10
10
  import { EscapeSequenceParser } from 'common/parser/EscapeSequenceParser';
11
- import { Disposable } from 'common/Lifecycle';
11
+ import { Disposable } from 'vs/base/common/lifecycle';
12
12
  import { StringToUtf32, stringFromCodePoint, Utf8ToUtf32 } from 'common/input/TextDecoder';
13
13
  import { BufferLine, DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';
14
- import { EventEmitter } from 'common/EventEmitter';
15
14
  import { IParsingState, IEscapeSequenceParser, IParams, IFunctionIdentifier } from 'common/parser/Types';
16
15
  import { NULL_CELL_CODE, NULL_CELL_WIDTH, Attributes, FgFlags, BgFlags, Content, UnderlineStyle } from 'common/buffer/Constants';
17
16
  import { CellData } from 'common/buffer/CellData';
@@ -22,6 +21,7 @@ import { OscHandler } from 'common/parser/OscParser';
22
21
  import { DcsHandler } from 'common/parser/DcsParser';
23
22
  import { IBuffer } from 'common/buffer/Types';
24
23
  import { parseColor } from 'common/input/XParseColor';
24
+ import { Emitter } from 'vs/base/common/event';
25
25
 
26
26
  /**
27
27
  * Map collect to glevel. Used in `selectCharset`.
@@ -119,7 +119,6 @@ export class InputHandler extends Disposable implements IInputHandler {
119
119
  private _parseBuffer: Uint32Array = new Uint32Array(4096);
120
120
  private _stringDecoder: StringToUtf32 = new StringToUtf32();
121
121
  private _utf8Decoder: Utf8ToUtf32 = new Utf8ToUtf32();
122
- private _workCell: CellData = new CellData();
123
122
  private _windowTitle = '';
124
123
  private _iconName = '';
125
124
  private _dirtyRowTracker: IDirtyRowTracker;
@@ -132,32 +131,32 @@ export class InputHandler extends Disposable implements IInputHandler {
132
131
 
133
132
  private _activeBuffer: IBuffer;
134
133
 
135
- private readonly _onRequestBell = this.register(new EventEmitter<void>());
134
+ private readonly _onRequestBell = this._register(new Emitter<void>());
136
135
  public readonly onRequestBell = this._onRequestBell.event;
137
- private readonly _onRequestRefreshRows = this.register(new EventEmitter<number, number>());
136
+ private readonly _onRequestRefreshRows = this._register(new Emitter<{ start: number, end: number } | undefined>());
138
137
  public readonly onRequestRefreshRows = this._onRequestRefreshRows.event;
139
- private readonly _onRequestReset = this.register(new EventEmitter<void>());
138
+ private readonly _onRequestReset = this._register(new Emitter<void>());
140
139
  public readonly onRequestReset = this._onRequestReset.event;
141
- private readonly _onRequestSendFocus = this.register(new EventEmitter<void>());
140
+ private readonly _onRequestSendFocus = this._register(new Emitter<void>());
142
141
  public readonly onRequestSendFocus = this._onRequestSendFocus.event;
143
- private readonly _onRequestSyncScrollBar = this.register(new EventEmitter<void>());
142
+ private readonly _onRequestSyncScrollBar = this._register(new Emitter<void>());
144
143
  public readonly onRequestSyncScrollBar = this._onRequestSyncScrollBar.event;
145
- private readonly _onRequestWindowsOptionsReport = this.register(new EventEmitter<WindowsOptionsReportType>());
144
+ private readonly _onRequestWindowsOptionsReport = this._register(new Emitter<WindowsOptionsReportType>());
146
145
  public readonly onRequestWindowsOptionsReport = this._onRequestWindowsOptionsReport.event;
147
146
 
148
- private readonly _onA11yChar = this.register(new EventEmitter<string>());
147
+ private readonly _onA11yChar = this._register(new Emitter<string>());
149
148
  public readonly onA11yChar = this._onA11yChar.event;
150
- private readonly _onA11yTab = this.register(new EventEmitter<number>());
149
+ private readonly _onA11yTab = this._register(new Emitter<number>());
151
150
  public readonly onA11yTab = this._onA11yTab.event;
152
- private readonly _onCursorMove = this.register(new EventEmitter<void>());
151
+ private readonly _onCursorMove = this._register(new Emitter<void>());
153
152
  public readonly onCursorMove = this._onCursorMove.event;
154
- private readonly _onLineFeed = this.register(new EventEmitter<void>());
153
+ private readonly _onLineFeed = this._register(new Emitter<void>());
155
154
  public readonly onLineFeed = this._onLineFeed.event;
156
- private readonly _onScroll = this.register(new EventEmitter<number>());
155
+ private readonly _onScroll = this._register(new Emitter<number>());
157
156
  public readonly onScroll = this._onScroll.event;
158
- private readonly _onTitleChange = this.register(new EventEmitter<string>());
157
+ private readonly _onTitleChange = this._register(new Emitter<string>());
159
158
  public readonly onTitleChange = this._onTitleChange.event;
160
- private readonly _onColor = this.register(new EventEmitter<IColorEvent>());
159
+ private readonly _onColor = this._register(new Emitter<IColorEvent>());
161
160
  public readonly onColor = this._onColor.event;
162
161
 
163
162
  private _parseStack: IParseStack = {
@@ -180,12 +179,12 @@ export class InputHandler extends Disposable implements IInputHandler {
180
179
  private readonly _parser: IEscapeSequenceParser = new EscapeSequenceParser()
181
180
  ) {
182
181
  super();
183
- this.register(this._parser);
182
+ this._register(this._parser);
184
183
  this._dirtyRowTracker = new DirtyRowTracker(this._bufferService);
185
184
 
186
185
  // Track properties used in performance critical code manually to avoid using slow getters
187
186
  this._activeBuffer = this._bufferService.buffer;
188
- this.register(this._bufferService.buffers.onBufferActivate(e => this._activeBuffer = e.activeBuffer));
187
+ this._register(this._bufferService.buffers.onBufferActivate(e => this._activeBuffer = e.activeBuffer));
189
188
 
190
189
  /**
191
190
  * custom fallback handlers
@@ -500,7 +499,10 @@ export class InputHandler extends Disposable implements IInputHandler {
500
499
  const viewportEnd = this._dirtyRowTracker.end + (this._bufferService.buffer.ybase - this._bufferService.buffer.ydisp);
501
500
  const viewportStart = this._dirtyRowTracker.start + (this._bufferService.buffer.ybase - this._bufferService.buffer.ydisp);
502
501
  if (viewportStart < this._bufferService.rows) {
503
- this._onRequestRefreshRows.fire(Math.min(viewportStart, this._bufferService.rows - 1), Math.min(viewportEnd, this._bufferService.rows - 1));
502
+ this._onRequestRefreshRows.fire({
503
+ start: Math.min(viewportStart, this._bufferService.rows - 1),
504
+ end: Math.min(viewportEnd, this._bufferService.rows - 1)
505
+ });
504
506
  }
505
507
  }
506
508
 
@@ -1218,12 +1220,27 @@ export class InputHandler extends Disposable implements IInputHandler {
1218
1220
  this._dirtyRowTracker.markDirty(0);
1219
1221
  break;
1220
1222
  case 2:
1221
- j = this._bufferService.rows;
1222
- this._dirtyRowTracker.markDirty(j - 1);
1223
- while (j--) {
1224
- this._resetBufferLine(j, respectProtect);
1223
+ if (this._optionsService.rawOptions.scrollOnEraseInDisplay) {
1224
+ j = this._bufferService.rows;
1225
+ this._dirtyRowTracker.markRangeDirty(0, j - 1);
1226
+ while (j--) {
1227
+ const currentLine = this._activeBuffer.lines.get(this._activeBuffer.ybase + j);
1228
+ if (currentLine?.getTrimmedLength()) {
1229
+ break;
1230
+ }
1231
+ }
1232
+ for (; j >= 0; j--) {
1233
+ this._bufferService.scroll(this._eraseAttrData());
1234
+ }
1235
+ }
1236
+ else {
1237
+ j = this._bufferService.rows;
1238
+ this._dirtyRowTracker.markDirty(j - 1);
1239
+ while (j--) {
1240
+ this._resetBufferLine(j, respectProtect);
1241
+ }
1242
+ this._dirtyRowTracker.markDirty(0);
1225
1243
  }
1226
- this._dirtyRowTracker.markDirty(0);
1227
1244
  break;
1228
1245
  case 3:
1229
1246
  // Clear scrollback (everything not in viewport)
@@ -1943,7 +1960,7 @@ export class InputHandler extends Disposable implements IInputHandler {
1943
1960
  case 1047: // alt screen buffer
1944
1961
  this._bufferService.buffers.activateAltBuffer(this._eraseAttrData());
1945
1962
  this._coreService.isCursorInitialized = true;
1946
- this._onRequestRefreshRows.fire(0, this._bufferService.rows - 1);
1963
+ this._onRequestRefreshRows.fire(undefined);
1947
1964
  this._onRequestSyncScrollBar.fire();
1948
1965
  break;
1949
1966
  case 2004: // bracketed paste mode (https://cirw.in/blog/bracketed-paste)
@@ -2171,7 +2188,7 @@ export class InputHandler extends Disposable implements IInputHandler {
2171
2188
  this.restoreCursor();
2172
2189
  }
2173
2190
  this._coreService.isCursorInitialized = true;
2174
- this._onRequestRefreshRows.fire(0, this._bufferService.rows - 1);
2191
+ this._onRequestRefreshRows.fire(undefined);
2175
2192
  this._onRequestSyncScrollBar.fire();
2176
2193
  break;
2177
2194
  case 2004: // bracketed paste mode (https://cirw.in/blog/bracketed-paste)
@@ -2712,7 +2729,7 @@ export class InputHandler extends Disposable implements IInputHandler {
2712
2729
 
2713
2730
  /**
2714
2731
  * CSI Ps SP q Set cursor style (DECSCUSR, VT520).
2715
- * Ps = 0 -> blinking block.
2732
+ * Ps = 0 -> reset to option.
2716
2733
  * Ps = 1 -> blinking block (default).
2717
2734
  * Ps = 2 -> steady block.
2718
2735
  * Ps = 3 -> blinking underline.
@@ -2722,31 +2739,37 @@ export class InputHandler extends Disposable implements IInputHandler {
2722
2739
  *
2723
2740
  * @vt: #Y CSI DECSCUSR "Set Cursor Style" "CSI Ps SP q" "Set cursor style."
2724
2741
  * Supported cursor styles:
2725
- * - empty, 0 or 1: steady block
2726
- * - 2: blink block
2727
- * - 3: steady underline
2728
- * - 4: blink underline
2729
- * - 5: steady bar
2730
- * - 6: blink bar
2742
+ * - 0: reset to option
2743
+ * - empty, 1: blinking block
2744
+ * - 2: steady block
2745
+ * - 3: blinking underline
2746
+ * - 4: steady underline
2747
+ * - 5: blinking bar
2748
+ * - 6: steady bar
2731
2749
  */
2732
2750
  public setCursorStyle(params: IParams): boolean {
2733
- const param = params.params[0] || 1;
2734
- switch (param) {
2735
- case 1:
2736
- case 2:
2737
- this._optionsService.options.cursorStyle = 'block';
2738
- break;
2739
- case 3:
2740
- case 4:
2741
- this._optionsService.options.cursorStyle = 'underline';
2742
- break;
2743
- case 5:
2744
- case 6:
2745
- this._optionsService.options.cursorStyle = 'bar';
2746
- break;
2751
+ const param = params.length === 0 ? 1 : params.params[0];
2752
+ if (param === 0) {
2753
+ this._coreService.decPrivateModes.cursorStyle = undefined;
2754
+ this._coreService.decPrivateModes.cursorBlink = undefined;
2755
+ } else {
2756
+ switch (param) {
2757
+ case 1:
2758
+ case 2:
2759
+ this._coreService.decPrivateModes.cursorStyle = 'block';
2760
+ break;
2761
+ case 3:
2762
+ case 4:
2763
+ this._coreService.decPrivateModes.cursorStyle = 'underline';
2764
+ break;
2765
+ case 5:
2766
+ case 6:
2767
+ this._coreService.decPrivateModes.cursorStyle = 'bar';
2768
+ break;
2769
+ }
2770
+ const isBlinking = param % 2 === 1;
2771
+ this._coreService.decPrivateModes.cursorBlink = isBlinking;
2747
2772
  }
2748
- const isBlinking = param % 2 === 1;
2749
- this._optionsService.options.cursorBlink = isBlinking;
2750
2773
  return true;
2751
2774
  }
2752
2775
 
@@ -2972,14 +2995,18 @@ export class InputHandler extends Disposable implements IInputHandler {
2972
2995
  * feedback. Use `OSC 8 ; ; BEL` to finish the current hyperlink.
2973
2996
  */
2974
2997
  public setHyperlink(data: string): boolean {
2975
- const args = data.split(';');
2976
- if (args.length < 2) {
2977
- return false;
2998
+ // Arg parsing is special cases to support unencoded semi-colons in the URIs (#4944)
2999
+ const idx = data.indexOf(';');
3000
+ if (idx === -1) {
3001
+ // malformed sequence, just return as handled
3002
+ return true;
2978
3003
  }
2979
- if (args[1]) {
2980
- return this._createHyperlink(args[0], args[1]);
3004
+ const id = data.slice(0, idx).trim();
3005
+ const uri = data.slice(idx + 1);
3006
+ if (uri) {
3007
+ return this._createHyperlink(id, uri);
2981
3008
  }
2982
- if (args[0].trim()) {
3009
+ if (id.trim()) {
2983
3010
  return false;
2984
3011
  }
2985
3012
  return this._finishHyperlink();
@@ -3452,6 +3479,6 @@ class DirtyRowTracker implements IDirtyRowTracker {
3452
3479
  }
3453
3480
  }
3454
3481
 
3455
- function isValidColorIndex(value: number): value is ColorIndex {
3482
+ export function isValidColorIndex(value: number): value is ColorIndex {
3456
3483
  return 0 <= value && value < 256;
3457
3484
  }
@@ -4,12 +4,12 @@
4
4
  */
5
5
 
6
6
  import { IDeleteEvent, IInsertEvent } from 'common/CircularList';
7
- import { IEvent, IEventEmitter } from 'common/EventEmitter';
8
7
  import { Attributes, UnderlineStyle } from 'common/buffer/Constants'; // eslint-disable-line no-unused-vars
9
8
  import { IBufferSet } from 'common/buffer/Types';
10
9
  import { IParams } from 'common/parser/Types';
11
10
  import { ICoreMouseService, ICoreService, IOptionsService, IUnicodeService } from 'common/services/Services';
12
11
  import { IFunctionIdentifier, ITerminalOptions as IPublicTerminalOptions } from '@xterm/xterm';
12
+ import type { Emitter, Event } from 'vs/base/common/event';
13
13
 
14
14
  export interface ICoreTerminal {
15
15
  coreMouseService: ICoreMouseService;
@@ -60,12 +60,6 @@ export interface IKeyboardEvent {
60
60
 
61
61
  export interface IScrollEvent {
62
62
  position: number;
63
- source: ScrollSource;
64
- }
65
-
66
- export const enum ScrollSource {
67
- TERMINAL,
68
- VIEWPORT,
69
63
  }
70
64
 
71
65
  export interface ICircularList<T> {
@@ -73,12 +67,12 @@ export interface ICircularList<T> {
73
67
  maxLength: number;
74
68
  isFull: boolean;
75
69
 
76
- onDeleteEmitter: IEventEmitter<IDeleteEvent>;
77
- onDelete: IEvent<IDeleteEvent>;
78
- onInsertEmitter: IEventEmitter<IInsertEvent>;
79
- onInsert: IEvent<IInsertEvent>;
80
- onTrimEmitter: IEventEmitter<number>;
81
- onTrim: IEvent<number>;
70
+ onDeleteEmitter: Emitter<IDeleteEvent>;
71
+ onDelete: Event<IDeleteEvent>;
72
+ onInsertEmitter: Emitter<IInsertEvent>;
73
+ onInsert: Event<IInsertEvent>;
74
+ onTrimEmitter: Emitter<number>;
75
+ onTrim: Event<number>;
82
76
 
83
77
  get(index: number): T | undefined;
84
78
  set(index: number, value: T): void;
@@ -264,7 +258,7 @@ export interface IMarker extends IDisposable {
264
258
  readonly id: number;
265
259
  readonly isDisposed: boolean;
266
260
  readonly line: number;
267
- onDispose: IEvent<void>;
261
+ onDispose: Event<void>;
268
262
  }
269
263
  export interface IModes {
270
264
  insertMode: boolean;
@@ -274,6 +268,8 @@ export interface IDecPrivateModes {
274
268
  applicationCursorKeys: boolean;
275
269
  applicationKeypad: boolean;
276
270
  bracketedPasteMode: boolean;
271
+ cursorBlink: boolean | undefined;
272
+ cursorStyle: CursorStyle | undefined;
277
273
  origin: boolean;
278
274
  reverseWraparound: boolean;
279
275
  sendFocus: boolean;
@@ -425,8 +421,8 @@ type Enumerate<N extends number, Acc extends number[] = []> = Acc['length'] exte
425
421
  : Enumerate<N, [...Acc, Acc['length']]>;
426
422
  type IntRange<F extends number, T extends number> = Exclude<Enumerate<T>, Enumerate<F>>;
427
423
 
428
- type ColorIndex = IntRange<0, 256>; // number from 0 to 255
429
- type AllColorIndex = ColorIndex | SpecialColorIndex;
424
+ export type ColorIndex = IntRange<0, 256>; // number from 0 to 255
425
+ export type AllColorIndex = ColorIndex | SpecialColorIndex;
430
426
  export const enum SpecialColorIndex {
431
427
  FOREGROUND = 256,
432
428
  BACKGROUND = 257,
@@ -452,7 +448,7 @@ export type IColorEvent = (IColorReportRequest | IColorSetRequest | IColorRestor
452
448
  * Calls the parser and handles actions generated by the parser.
453
449
  */
454
450
  export interface IInputHandler {
455
- onTitleChange: IEvent<string>;
451
+ onTitleChange: Event<string>;
456
452
 
457
453
  parse(data: string | Uint8Array, promiseResult?: boolean): void | Promise<boolean>;
458
454
  print(data: Uint32Array, start: number, end: number): void;
@@ -161,6 +161,10 @@ export class Buffer implements IBuffer {
161
161
  this.lines.maxLength = newMaxLength;
162
162
  }
163
163
 
164
+ // if (this._cols > newCols) {
165
+ // console.log('increase!');
166
+ // }
167
+
164
168
  // The following adjustments should only happen if the buffer has been
165
169
  // initialized/filled.
166
170
  if (this.lines.length > 0) {
@@ -311,11 +315,42 @@ export class Buffer implements IBuffer {
311
315
  }
312
316
 
313
317
  private _reflowLarger(newCols: number, newRows: number): void {
314
- const toRemove: number[] = reflowLargerGetLinesToRemove(this.lines, this._cols, newCols, this.ybase + this.y, this.getNullCell(DEFAULT_ATTR_DATA));
318
+ const reflowCursorLine = this._optionsService.rawOptions.reflowCursorLine;
319
+ const toRemove: number[] = reflowLargerGetLinesToRemove(this.lines, this._cols, newCols, this.ybase + this.y, this.getNullCell(DEFAULT_ATTR_DATA), reflowCursorLine);
315
320
  if (toRemove.length > 0) {
316
321
  const newLayoutResult = reflowLargerCreateNewLayout(this.lines, toRemove);
317
322
  reflowLargerApplyNewLayout(this.lines, newLayoutResult.layout);
323
+
324
+ // For conpty, it has its own copy of the buffer _without scrollback_ internally. Its behavior
325
+ // when reflowing larger is to insert empty lines at the bottom of the buffer as when lines
326
+ // unwrap conpty's view cannot pull scrollback down, so it adds empty lines at the end.
327
+ let removedInViewport = 0;
328
+ const isWindowsMode = this._optionsService.rawOptions.windowsMode || this._optionsService.rawOptions.windowsPty.backend !== undefined || this._optionsService.rawOptions.windowsPty.buildNumber !== undefined;
329
+ if (isWindowsMode) {
330
+ for (let i = (toRemove.length / 2) - 1; i >= 0; i--) {
331
+ if (toRemove[i * 2 + 0] > this.ybase + removedInViewport) {
332
+ removedInViewport += toRemove[i * 2 + 1];
333
+ }
334
+ }
335
+ }
336
+
318
337
  this._reflowLargerAdjustViewport(newCols, newRows, newLayoutResult.countRemoved);
338
+
339
+ // Apply empty lines for any removed in viewport for conpty.
340
+ if (isWindowsMode) {
341
+ if (removedInViewport > 0) {
342
+ for (let i = 0; i < removedInViewport; i++) {
343
+ // Just add the new missing rows on Windows as conpty reprints the screen with it's
344
+ // view of the world. Once a line enters scrollback for conpty it remains there
345
+ this.lines.push(new BufferLine(newCols, this.getNullCell(DEFAULT_ATTR_DATA)));
346
+ }
347
+ if (this.ybase === this.ydisp) {
348
+ this.ydisp += removedInViewport;
349
+ }
350
+ this.ybase += removedInViewport;
351
+ this.y -= removedInViewport;
352
+ }
353
+ }
319
354
  }
320
355
  }
321
356
 
@@ -343,10 +378,11 @@ export class Buffer implements IBuffer {
343
378
  }
344
379
 
345
380
  private _reflowSmaller(newCols: number, newRows: number): void {
381
+ const reflowCursorLine = this._optionsService.rawOptions.reflowCursorLine;
346
382
  const nullCell = this.getNullCell(DEFAULT_ATTR_DATA);
347
383
  // Gather all BufferLines that need to be inserted into the Buffer here so that they can be
348
384
  // batched up and only committed once
349
- const toInsert = [];
385
+ const toInsert: { start: number, newLines: IBufferLine[] }[] = [];
350
386
  let countToInsert = 0;
351
387
  // Go backwards as many lines may be trimmed and this will avoid considering them
352
388
  for (let y = this.lines.length - 1; y >= 0; y--) {
@@ -363,11 +399,13 @@ export class Buffer implements IBuffer {
363
399
  wrappedLines.unshift(nextLine);
364
400
  }
365
401
 
366
- // If these lines contain the cursor don't touch them, the program will handle fixing up
367
- // wrapped lines with the cursor
368
- const absoluteY = this.ybase + this.y;
369
- if (absoluteY >= y && absoluteY < y + wrappedLines.length) {
370
- continue;
402
+ if (!reflowCursorLine) {
403
+ // If these lines contain the cursor don't touch them, the program will handle fixing up
404
+ // wrapped lines with the cursor
405
+ const absoluteY = this.ybase + this.y;
406
+ if (absoluteY >= y && absoluteY < y + wrappedLines.length) {
407
+ continue;
408
+ }
371
409
  }
372
410
 
373
411
  const lastLineLength = wrappedLines[wrappedLines.length - 1].getTrimmedLength();
@@ -459,6 +497,20 @@ export class Buffer implements IBuffer {
459
497
  this.savedY = Math.min(this.savedY + linesToAdd, this.ybase + newRows - 1);
460
498
  }
461
499
 
500
+ // For conpty, it has its own copy of the buffer _without scrollback_ internally. Its behavior
501
+ // when reflowing smaller is to reflow all lines inside the viewport, and removing empty or
502
+ // whitespace only lines from the bottom, until non-whitespace is hit in order to prevent
503
+ // content from being pushed into the scrollback.
504
+ let addedInViewport = 0;
505
+ const isWindowsMode = this._optionsService.rawOptions.windowsMode || this._optionsService.rawOptions.windowsPty.backend !== undefined || this._optionsService.rawOptions.windowsPty.buildNumber !== undefined;
506
+ if (isWindowsMode) {
507
+ for (let i = toInsert.length - 1; i >= 0; i--) {
508
+ if (toInsert[i].start > this.ybase + addedInViewport) {
509
+ addedInViewport += toInsert[i].newLines.length;
510
+ }
511
+ }
512
+ }
513
+
462
514
  // Rearrange lines in the buffer if there are any insertions, this is done at the end rather
463
515
  // than earlier so that it's a single O(n) pass through the buffer, instead of O(n^2) from many
464
516
  // costly calls to CircularList.splice.
@@ -512,6 +564,35 @@ export class Buffer implements IBuffer {
512
564
  this.lines.onTrimEmitter.fire(amountToTrim);
513
565
  }
514
566
  }
567
+
568
+ // Apply empty lines to remove calculated earlier for conpty.
569
+ if (isWindowsMode) {
570
+ if (addedInViewport > 0) {
571
+ let emptyLinesAtBottom = 0;
572
+ for (let i = this.lines.length - 1; i >= this.ybase + this.y; i--) {
573
+ const line = this.lines.get(i) as BufferLine;
574
+ if (line.isWrapped || line.getTrimmedLength() > 0) {
575
+ break;
576
+ }
577
+ emptyLinesAtBottom++;
578
+ }
579
+ const emptyLinesToRemove = Math.min(addedInViewport, emptyLinesAtBottom);
580
+ if (emptyLinesToRemove > 0) {
581
+ for (let i = 0; i < emptyLinesToRemove; i++) {
582
+ this.lines.pop();
583
+ }
584
+ if (this.ybase === this.ydisp) {
585
+ this.ydisp -= emptyLinesToRemove;
586
+ }
587
+ this.ybase -= emptyLinesToRemove;
588
+ this.y += emptyLinesToRemove;
589
+ this.lines.onDeleteEmitter.fire({
590
+ index: this.lines.length - emptyLinesToRemove,
591
+ amount: emptyLinesToRemove
592
+ });
593
+ }
594
+ }
595
+ }
515
596
  }
516
597
 
517
598
  /**
@@ -611,8 +692,8 @@ export class Buffer implements IBuffer {
611
692
  this._isClearing = true;
612
693
  for (let i = 0; i < this.markers.length; i++) {
613
694
  this.markers[i].dispose();
614
- this.markers.splice(i--, 1);
615
695
  }
696
+ this.markers.length = 0;
616
697
  this._isClearing = false;
617
698
  }
618
699
 
@@ -20,8 +20,9 @@ export interface INewLayoutResult {
20
20
  * @param newCols The columns after resize.
21
21
  * @param bufferAbsoluteY The absolute y position of the cursor (baseY + cursorY).
22
22
  * @param nullCell The cell data to use when filling in empty cells.
23
+ * @param reflowCursorLine Whether to reflow the line containing the cursor.
23
24
  */
24
- export function reflowLargerGetLinesToRemove(lines: CircularList<IBufferLine>, oldCols: number, newCols: number, bufferAbsoluteY: number, nullCell: ICellData): number[] {
25
+ export function reflowLargerGetLinesToRemove(lines: CircularList<IBufferLine>, oldCols: number, newCols: number, bufferAbsoluteY: number, nullCell: ICellData, reflowCursorLine: boolean): number[] {
25
26
  // Gather all BufferLines that need to be removed from the Buffer here so that they can be
26
27
  // batched up and only committed once
27
28
  const toRemove: number[] = [];
@@ -41,11 +42,13 @@ export function reflowLargerGetLinesToRemove(lines: CircularList<IBufferLine>, o
41
42
  nextLine = lines.get(++i) as BufferLine;
42
43
  }
43
44
 
44
- // If these lines contain the cursor don't touch them, the program will handle fixing up wrapped
45
- // lines with the cursor
46
- if (bufferAbsoluteY >= y && bufferAbsoluteY < i) {
47
- y += wrappedLines.length - 1;
48
- continue;
45
+ if (!reflowCursorLine) {
46
+ // If these lines contain the cursor don't touch them, the program will handle fixing up
47
+ // wrapped lines with the cursor
48
+ if (bufferAbsoluteY >= y && bufferAbsoluteY < i) {
49
+ y += wrappedLines.length - 1;
50
+ continue;
51
+ }
49
52
  }
50
53
 
51
54
  // Copy buffer data to new locations
@@ -3,12 +3,12 @@
3
3
  * @license MIT
4
4
  */
5
5
 
6
- import { EventEmitter } from 'common/EventEmitter';
7
- import { Disposable } from 'common/Lifecycle';
6
+ import { Disposable } from 'vs/base/common/lifecycle';
8
7
  import { IAttributeData } from 'common/Types';
9
8
  import { Buffer } from 'common/buffer/Buffer';
10
9
  import { IBuffer, IBufferSet } from 'common/buffer/Types';
11
10
  import { IBufferService, IOptionsService } from 'common/services/Services';
11
+ import { Emitter } from 'vs/base/common/event';
12
12
 
13
13
  /**
14
14
  * The BufferSet represents the set of two buffers used by xterm terminals (normal and alt) and
@@ -19,7 +19,7 @@ export class BufferSet extends Disposable implements IBufferSet {
19
19
  private _alt!: Buffer;
20
20
  private _activeBuffer!: Buffer;
21
21
 
22
- private readonly _onBufferActivate = this.register(new EventEmitter<{activeBuffer: IBuffer, inactiveBuffer: IBuffer}>());
22
+ private readonly _onBufferActivate = this._register(new Emitter<{ activeBuffer: IBuffer, inactiveBuffer: IBuffer }>());
23
23
  public readonly onBufferActivate = this._onBufferActivate.event;
24
24
 
25
25
  /**
@@ -31,8 +31,8 @@ export class BufferSet extends Disposable implements IBufferSet {
31
31
  ) {
32
32
  super();
33
33
  this.reset();
34
- this.register(this._optionsService.onSpecificOptionChange('scrollback', () => this.resize(this._bufferService.cols, this._bufferService.rows)));
35
- this.register(this._optionsService.onSpecificOptionChange('tabStopWidth', () => this.setupTabStops()));
34
+ this._register(this._optionsService.onSpecificOptionChange('scrollback', () => this.resize(this._bufferService.cols, this._bufferService.rows)));
35
+ this._register(this._optionsService.onSpecificOptionChange('tabStopWidth', () => this.setupTabStops()));
36
36
  }
37
37
 
38
38
  public reset(): void {
@@ -3,9 +3,9 @@
3
3
  * @license MIT
4
4
  */
5
5
 
6
- import { EventEmitter } from 'common/EventEmitter';
7
- import { disposeArray } from 'common/Lifecycle';
8
6
  import { IDisposable, IMarker } from 'common/Types';
7
+ import { Emitter } from 'vs/base/common/event';
8
+ import { dispose } from 'vs/base/common/lifecycle';
9
9
 
10
10
  export class Marker implements IMarker {
11
11
  private static _nextId = 1;
@@ -16,7 +16,7 @@ export class Marker implements IMarker {
16
16
  private readonly _id: number = Marker._nextId++;
17
17
  public get id(): number { return this._id; }
18
18
 
19
- private readonly _onDispose = this.register(new EventEmitter<void>());
19
+ private readonly _onDispose = this.register(new Emitter<void>());
20
20
  public readonly onDispose = this._onDispose.event;
21
21
 
22
22
  constructor(
@@ -32,7 +32,7 @@ export class Marker implements IMarker {
32
32
  this.line = -1;
33
33
  // Emit before super.dispose such that dispose listeners get a change to react
34
34
  this._onDispose.fire();
35
- disposeArray(this._disposables);
35
+ dispose(this._disposables);
36
36
  this._disposables.length = 0;
37
37
  }
38
38
 
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import { IAttributeData, ICircularList, IBufferLine, ICellData, IMarker, ICharset, IDisposable } from 'common/Types';
7
- import { IEvent } from 'common/EventEmitter';
7
+ import type { Event } from 'vs/base/common/event';
8
8
 
9
9
  // BufferIndex denotes a position in the buffer: [rowIndex, colIndex]
10
10
  export type BufferIndex = [number, number];
@@ -42,7 +42,7 @@ export interface IBufferSet extends IDisposable {
42
42
  normal: IBuffer;
43
43
  active: IBuffer;
44
44
 
45
- onBufferActivate: IEvent<{ activeBuffer: IBuffer, inactiveBuffer: IBuffer }>;
45
+ onBufferActivate: Event<{ activeBuffer: IBuffer, inactiveBuffer: IBuffer }>;
46
46
 
47
47
  activateNormalBuffer(): void;
48
48
  activateAltBuffer(fillAttr?: IAttributeData): void;
@@ -117,12 +117,6 @@ export function evaluateKeyboardEvent(
117
117
  }
118
118
  if (modifiers) {
119
119
  result.key = C0.ESC + '[1;' + (modifiers + 1) + 'D';
120
- // HACK: Make Alt + left-arrow behave like Ctrl + left-arrow: move one word backwards
121
- // http://unix.stackexchange.com/a/108106
122
- // macOS uses different escape sequences than linux
123
- if (result.key === C0.ESC + '[1;3D') {
124
- result.key = C0.ESC + (isMac ? 'b' : '[1;5D');
125
- }
126
120
  } else if (applicationCursorMode) {
127
121
  result.key = C0.ESC + 'OD';
128
122
  } else {
@@ -136,12 +130,6 @@ export function evaluateKeyboardEvent(
136
130
  }
137
131
  if (modifiers) {
138
132
  result.key = C0.ESC + '[1;' + (modifiers + 1) + 'C';
139
- // HACK: Make Alt + right-arrow behave like Ctrl + right-arrow: move one word forward
140
- // http://unix.stackexchange.com/a/108106
141
- // macOS uses different escape sequences than linux
142
- if (result.key === C0.ESC + '[1;3C') {
143
- result.key = C0.ESC + (isMac ? 'f' : '[1;5C');
144
- }
145
133
  } else if (applicationCursorMode) {
146
134
  result.key = C0.ESC + 'OC';
147
135
  } else {
@@ -155,12 +143,6 @@ export function evaluateKeyboardEvent(
155
143
  }
156
144
  if (modifiers) {
157
145
  result.key = C0.ESC + '[1;' + (modifiers + 1) + 'A';
158
- // HACK: Make Alt + up-arrow behave like Ctrl + up-arrow
159
- // http://unix.stackexchange.com/a/108106
160
- // macOS uses different escape sequences than linux
161
- if (!isMac && result.key === C0.ESC + '[1;3A') {
162
- result.key = C0.ESC + '[1;5A';
163
- }
164
146
  } else if (applicationCursorMode) {
165
147
  result.key = C0.ESC + 'OA';
166
148
  } else {
@@ -174,12 +156,6 @@ export function evaluateKeyboardEvent(
174
156
  }
175
157
  if (modifiers) {
176
158
  result.key = C0.ESC + '[1;' + (modifiers + 1) + 'B';
177
- // HACK: Make Alt + down-arrow behave like Ctrl + down-arrow
178
- // http://unix.stackexchange.com/a/108106
179
- // macOS uses different escape sequences than linux
180
- if (!isMac && result.key === C0.ESC + '[1;3B') {
181
- result.key = C0.ESC + '[1;5B';
182
- }
183
159
  } else if (applicationCursorMode) {
184
160
  result.key = C0.ESC + 'OB';
185
161
  } else {