@wendongfly/zihi 1.1.0 → 1.1.2

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 (157) hide show
  1. package/dist/index.js +1 -1
  2. package/dist/lib/xterm/README.md +27 -14
  3. package/dist/lib/xterm/css/xterm.css +81 -5
  4. package/dist/lib/xterm/lib/xterm.js +1 -1
  5. package/dist/lib/xterm/lib/xterm.js.map +1 -1
  6. package/dist/lib/xterm/lib/xterm.mjs +53 -0
  7. package/dist/lib/xterm/lib/xterm.mjs.map +7 -0
  8. package/dist/lib/xterm/package.json +49 -38
  9. package/dist/lib/xterm/src/browser/AccessibilityManager.ts +185 -50
  10. package/dist/lib/xterm/src/browser/CoreBrowserTerminal.ts +1339 -0
  11. package/dist/lib/xterm/src/browser/Linkifier.ts +403 -0
  12. package/dist/lib/xterm/src/browser/LocalizableStrings.ts +15 -4
  13. package/dist/lib/xterm/src/browser/OscLinkProvider.ts +2 -1
  14. package/dist/lib/xterm/src/browser/RenderDebouncer.ts +6 -5
  15. package/dist/lib/xterm/src/browser/TimeBasedDebouncer.ts +2 -2
  16. package/dist/lib/xterm/src/browser/Types.ts +226 -0
  17. package/dist/lib/xterm/src/browser/Viewport.ts +148 -357
  18. package/dist/lib/xterm/src/browser/decorations/BufferDecorationRenderer.ts +17 -12
  19. package/dist/lib/xterm/src/browser/decorations/OverviewRulerRenderer.ts +47 -52
  20. package/dist/lib/xterm/src/browser/input/CompositionHelper.ts +5 -3
  21. package/dist/lib/xterm/src/browser/input/MoveToCell.ts +3 -1
  22. package/dist/lib/xterm/src/browser/public/Terminal.ts +39 -24
  23. package/dist/lib/xterm/src/browser/renderer/dom/DomRenderer.ts +76 -40
  24. package/dist/lib/xterm/src/browser/renderer/dom/DomRendererRowFactory.ts +47 -23
  25. package/dist/lib/xterm/src/browser/renderer/dom/WidthCache.ts +19 -9
  26. package/dist/lib/xterm/src/browser/renderer/shared/Constants.ts +0 -8
  27. package/dist/lib/xterm/src/browser/renderer/shared/RendererUtils.ts +38 -1
  28. package/dist/lib/xterm/src/browser/renderer/shared/SelectionRenderModel.ts +6 -4
  29. package/dist/lib/xterm/src/browser/renderer/shared/Types.ts +84 -0
  30. package/dist/lib/xterm/src/browser/selection/Types.ts +15 -0
  31. package/dist/lib/xterm/src/browser/services/CharSizeService.ts +57 -32
  32. package/dist/lib/xterm/src/browser/services/CoreBrowserService.ts +108 -4
  33. package/dist/lib/xterm/src/browser/services/LinkProviderService.ts +28 -0
  34. package/dist/lib/xterm/src/browser/services/RenderService.ts +132 -40
  35. package/dist/lib/xterm/src/browser/services/SelectionService.ts +19 -9
  36. package/dist/lib/xterm/src/browser/services/Services.ts +36 -16
  37. package/dist/lib/xterm/src/browser/services/ThemeService.ts +19 -58
  38. package/dist/lib/xterm/src/browser/shared/Constants.ts +8 -0
  39. package/dist/lib/xterm/src/common/CircularList.ts +5 -5
  40. package/dist/lib/xterm/src/common/Color.ts +34 -14
  41. package/dist/lib/xterm/src/common/CoreTerminal.ts +40 -41
  42. package/dist/lib/xterm/src/common/InputHandler.ts +177 -125
  43. package/dist/lib/xterm/src/common/Platform.ts +2 -1
  44. package/dist/lib/xterm/src/common/SortedList.ts +86 -10
  45. package/dist/lib/xterm/src/common/TaskQueue.ts +7 -7
  46. package/dist/lib/xterm/src/common/Types.ts +552 -0
  47. package/dist/lib/xterm/src/common/buffer/AttributeData.ts +15 -0
  48. package/dist/lib/xterm/src/common/buffer/Buffer.ts +15 -7
  49. package/dist/lib/xterm/src/common/buffer/BufferLine.ts +53 -22
  50. package/dist/lib/xterm/src/common/buffer/BufferRange.ts +1 -1
  51. package/dist/lib/xterm/src/common/buffer/BufferReflow.ts +9 -6
  52. package/dist/lib/xterm/src/common/buffer/BufferSet.ts +5 -5
  53. package/dist/lib/xterm/src/common/buffer/Constants.ts +10 -2
  54. package/dist/lib/xterm/src/common/buffer/Marker.ts +4 -4
  55. package/dist/lib/xterm/src/common/buffer/Types.ts +52 -0
  56. package/dist/lib/xterm/src/common/input/Keyboard.ts +2 -27
  57. package/dist/lib/xterm/src/common/input/UnicodeV6.ts +18 -5
  58. package/dist/lib/xterm/src/common/input/WriteBuffer.ts +9 -8
  59. package/dist/lib/xterm/src/common/parser/EscapeSequenceParser.ts +13 -13
  60. package/dist/lib/xterm/src/common/parser/Types.ts +275 -0
  61. package/dist/lib/xterm/src/common/public/AddonManager.ts +1 -1
  62. package/dist/lib/xterm/src/common/public/BufferApiView.ts +1 -1
  63. package/dist/lib/xterm/src/common/public/BufferLineApiView.ts +1 -1
  64. package/dist/lib/xterm/src/common/public/BufferNamespaceApi.ts +4 -4
  65. package/dist/lib/xterm/src/common/public/ParserApi.ts +1 -1
  66. package/dist/lib/xterm/src/common/public/UnicodeApi.ts +1 -1
  67. package/dist/lib/xterm/src/common/services/BufferService.ts +14 -11
  68. package/dist/lib/xterm/src/common/services/CoreMouseService.ts +53 -6
  69. package/dist/lib/xterm/src/common/services/CoreService.ts +13 -8
  70. package/dist/lib/xterm/src/common/services/DecorationService.ts +11 -11
  71. package/dist/lib/xterm/src/common/services/InstantiationService.ts +1 -1
  72. package/dist/lib/xterm/src/common/services/LogService.ts +2 -2
  73. package/dist/lib/xterm/src/common/services/OptionsService.ts +16 -5
  74. package/dist/lib/xterm/src/common/services/ServiceRegistry.ts +1 -1
  75. package/dist/lib/xterm/src/common/services/Services.ts +73 -19
  76. package/dist/lib/xterm/src/common/services/UnicodeService.ts +30 -5
  77. package/dist/lib/xterm/src/vs/base/browser/browser.ts +141 -0
  78. package/dist/lib/xterm/src/vs/base/browser/canIUse.ts +49 -0
  79. package/dist/lib/xterm/src/vs/base/browser/dom.ts +2369 -0
  80. package/dist/lib/xterm/src/vs/base/browser/fastDomNode.ts +316 -0
  81. package/dist/lib/xterm/src/vs/base/browser/globalPointerMoveMonitor.ts +112 -0
  82. package/dist/lib/xterm/src/vs/base/browser/iframe.ts +135 -0
  83. package/dist/lib/xterm/src/vs/base/browser/keyboardEvent.ts +213 -0
  84. package/dist/lib/xterm/src/vs/base/browser/mouseEvent.ts +229 -0
  85. package/dist/lib/xterm/src/vs/base/browser/touch.ts +372 -0
  86. package/dist/lib/xterm/src/vs/base/browser/ui/scrollbar/abstractScrollbar.ts +303 -0
  87. package/dist/lib/xterm/src/vs/base/browser/ui/scrollbar/horizontalScrollbar.ts +114 -0
  88. package/dist/lib/xterm/src/vs/base/browser/ui/scrollbar/scrollableElement.ts +720 -0
  89. package/dist/lib/xterm/src/vs/base/browser/ui/scrollbar/scrollableElementOptions.ts +165 -0
  90. package/dist/lib/xterm/src/vs/base/browser/ui/scrollbar/scrollbarArrow.ts +114 -0
  91. package/dist/lib/xterm/src/vs/base/browser/ui/scrollbar/scrollbarState.ts +243 -0
  92. package/dist/lib/xterm/src/vs/base/browser/ui/scrollbar/scrollbarVisibilityController.ts +118 -0
  93. package/dist/lib/xterm/src/vs/base/browser/ui/scrollbar/verticalScrollbar.ts +116 -0
  94. package/dist/lib/xterm/src/vs/base/browser/ui/widget.ts +57 -0
  95. package/dist/lib/xterm/src/vs/base/browser/window.ts +14 -0
  96. package/dist/lib/xterm/src/vs/base/common/arrays.ts +887 -0
  97. package/dist/lib/xterm/src/vs/base/common/arraysFind.ts +202 -0
  98. package/dist/lib/xterm/src/vs/base/common/assert.ts +71 -0
  99. package/dist/lib/xterm/src/vs/base/common/async.ts +1992 -0
  100. package/dist/lib/xterm/src/vs/base/common/cancellation.ts +148 -0
  101. package/dist/lib/xterm/src/vs/base/common/charCode.ts +450 -0
  102. package/dist/lib/xterm/src/vs/base/common/collections.ts +140 -0
  103. package/dist/lib/xterm/src/vs/base/common/decorators.ts +130 -0
  104. package/dist/lib/xterm/src/vs/base/common/equals.ts +146 -0
  105. package/dist/lib/xterm/src/vs/base/common/errors.ts +303 -0
  106. package/dist/lib/xterm/src/vs/base/common/event.ts +1778 -0
  107. package/dist/lib/xterm/src/vs/base/common/functional.ts +32 -0
  108. package/dist/lib/xterm/src/vs/base/common/hash.ts +316 -0
  109. package/dist/lib/xterm/src/vs/base/common/iterator.ts +159 -0
  110. package/dist/lib/xterm/src/vs/base/common/keyCodes.ts +526 -0
  111. package/dist/lib/xterm/src/vs/base/common/keybindings.ts +284 -0
  112. package/dist/lib/xterm/src/vs/base/common/lazy.ts +47 -0
  113. package/dist/lib/xterm/src/vs/base/common/lifecycle.ts +801 -0
  114. package/dist/lib/xterm/src/vs/base/common/linkedList.ts +142 -0
  115. package/dist/lib/xterm/src/vs/base/common/map.ts +202 -0
  116. package/dist/lib/xterm/src/vs/base/common/numbers.ts +98 -0
  117. package/dist/lib/xterm/src/vs/base/common/observable.ts +76 -0
  118. package/dist/lib/xterm/src/vs/base/common/observableInternal/api.ts +31 -0
  119. package/dist/lib/xterm/src/vs/base/common/observableInternal/autorun.ts +281 -0
  120. package/dist/lib/xterm/src/vs/base/common/observableInternal/base.ts +489 -0
  121. package/dist/lib/xterm/src/vs/base/common/observableInternal/debugName.ts +145 -0
  122. package/dist/lib/xterm/src/vs/base/common/observableInternal/derived.ts +428 -0
  123. package/dist/lib/xterm/src/vs/base/common/observableInternal/lazyObservableValue.ts +146 -0
  124. package/dist/lib/xterm/src/vs/base/common/observableInternal/logging.ts +328 -0
  125. package/dist/lib/xterm/src/vs/base/common/observableInternal/promise.ts +209 -0
  126. package/dist/lib/xterm/src/vs/base/common/observableInternal/utils.ts +610 -0
  127. package/dist/lib/xterm/src/vs/base/common/platform.ts +281 -0
  128. package/dist/lib/xterm/src/vs/base/common/scrollable.ts +522 -0
  129. package/dist/lib/xterm/src/vs/base/common/sequence.ts +34 -0
  130. package/dist/lib/xterm/src/vs/base/common/stopwatch.ts +43 -0
  131. package/dist/lib/xterm/src/vs/base/common/strings.ts +557 -0
  132. package/dist/lib/xterm/src/vs/base/common/symbols.ts +9 -0
  133. package/dist/lib/xterm/src/vs/base/common/uint.ts +59 -0
  134. package/dist/lib/xterm/src/vs/patches/nls.ts +90 -0
  135. package/dist/lib/xterm/src/vs/typings/base-common.d.ts +20 -0
  136. package/dist/lib/xterm/src/vs/typings/require.d.ts +42 -0
  137. package/dist/lib/xterm/src/vs/typings/vscode-globals-nls.d.ts +36 -0
  138. package/dist/lib/xterm/src/vs/typings/vscode-globals-product.d.ts +33 -0
  139. package/dist/lib/xterm/typings/xterm.d.ts +156 -43
  140. package/dist/lib/xterm-fit/README.md +5 -5
  141. package/dist/lib/xterm-fit/lib/addon-fit.js +2 -0
  142. package/dist/lib/xterm-fit/lib/addon-fit.js.map +1 -0
  143. package/dist/lib/xterm-fit/lib/addon-fit.mjs +18 -0
  144. package/dist/lib/xterm-fit/lib/addon-fit.mjs.map +7 -0
  145. package/dist/lib/xterm-fit/package.json +9 -9
  146. package/dist/lib/xterm-fit/src/FitAddon.ts +7 -4
  147. package/dist/lib/xterm-fit/typings/addon-fit.d.ts +55 -0
  148. package/dist/lib/xterm-links/README.md +5 -5
  149. package/dist/lib/xterm-links/lib/addon-web-links.js +2 -0
  150. package/dist/lib/xterm-links/lib/addon-web-links.js.map +1 -0
  151. package/dist/lib/xterm-links/lib/addon-web-links.mjs +18 -0
  152. package/dist/lib/xterm-links/lib/addon-web-links.mjs.map +7 -0
  153. package/dist/lib/xterm-links/package.json +9 -9
  154. package/dist/lib/xterm-links/src/WebLinkProvider.ts +16 -15
  155. package/dist/lib/xterm-links/src/WebLinksAddon.ts +4 -3
  156. package/dist/lib/xterm-links/typings/addon-web-links.d.ts +57 -0
  157. package/package.json +5 -6
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import { CharData, IAttributeData, IBufferLine, ICellData, IExtendedAttrs } from 'common/Types';
7
- import { AttributeData, ExtendedAttrs } from 'common/buffer/AttributeData';
7
+ import { AttributeData } from 'common/buffer/AttributeData';
8
8
  import { CellData } from 'common/buffer/CellData';
9
9
  import { Attributes, BgFlags, CHAR_DATA_ATTR_INDEX, CHAR_DATA_CHAR_INDEX, CHAR_DATA_WIDTH_INDEX, Content, NULL_CELL_CHAR, NULL_CELL_CODE, NULL_CELL_WIDTH, WHITESPACE_CELL_CHAR } from 'common/buffer/Constants';
10
10
  import { stringFromCodePoint } from 'common/input/TextDecoder';
@@ -212,13 +212,13 @@ export class BufferLine implements IBufferLine {
212
212
  * Since the input handler see the incoming chars as UTF32 codepoints,
213
213
  * it gets an optimized access method.
214
214
  */
215
- public setCellFromCodePoint(index: number, codePoint: number, width: number, fg: number, bg: number, eAttrs: IExtendedAttrs): void {
216
- if (bg & BgFlags.HAS_EXTENDED) {
217
- this._extendedAttrs[index] = eAttrs;
215
+ public setCellFromCodepoint(index: number, codePoint: number, width: number, attrs: IAttributeData): void {
216
+ if (attrs.bg & BgFlags.HAS_EXTENDED) {
217
+ this._extendedAttrs[index] = attrs.extended;
218
218
  }
219
219
  this._data[index * CELL_SIZE + Cell.CONTENT] = codePoint | (width << Content.WIDTH_SHIFT);
220
- this._data[index * CELL_SIZE + Cell.FG] = fg;
221
- this._data[index * CELL_SIZE + Cell.BG] = bg;
220
+ this._data[index * CELL_SIZE + Cell.FG] = attrs.fg;
221
+ this._data[index * CELL_SIZE + Cell.BG] = attrs.bg;
222
222
  }
223
223
 
224
224
  /**
@@ -227,7 +227,7 @@ export class BufferLine implements IBufferLine {
227
227
  * onto a leading char. Since we already set the attrs
228
228
  * by the previous `setDataFromCodePoint` call, we can omit it here.
229
229
  */
230
- public addCodepointToCell(index: number, codePoint: number): void {
230
+ public addCodepointToCell(index: number, codePoint: number, width: number): void {
231
231
  let content = this._data[index * CELL_SIZE + Cell.CONTENT];
232
232
  if (content & Content.IS_COMBINED_MASK) {
233
233
  // we already have a combined string, simply add
@@ -245,16 +245,20 @@ export class BufferLine implements IBufferLine {
245
245
  // simply set the data in the cell buffer with a width of 1
246
246
  content = codePoint | (1 << Content.WIDTH_SHIFT);
247
247
  }
248
- this._data[index * CELL_SIZE + Cell.CONTENT] = content;
249
248
  }
249
+ if (width) {
250
+ content &= ~Content.WIDTH_MASK;
251
+ content |= width << Content.WIDTH_SHIFT;
252
+ }
253
+ this._data[index * CELL_SIZE + Cell.CONTENT] = content;
250
254
  }
251
255
 
252
- public insertCells(pos: number, n: number, fillCellData: ICellData, eraseAttr?: IAttributeData): void {
256
+ public insertCells(pos: number, n: number, fillCellData: ICellData): void {
253
257
  pos %= this.length;
254
258
 
255
259
  // handle fullwidth at pos: reset cell one to the left if pos is second cell of a wide char
256
260
  if (pos && this.getWidth(pos - 1) === 2) {
257
- this.setCellFromCodePoint(pos - 1, 0, 1, eraseAttr?.fg || 0, eraseAttr?.bg || 0, eraseAttr?.extended || new ExtendedAttrs());
261
+ this.setCellFromCodepoint(pos - 1, 0, 1, fillCellData);
258
262
  }
259
263
 
260
264
  if (n < this.length - pos) {
@@ -273,11 +277,11 @@ export class BufferLine implements IBufferLine {
273
277
 
274
278
  // handle fullwidth at line end: reset last cell if it is first cell of a wide char
275
279
  if (this.getWidth(this.length - 1) === 2) {
276
- this.setCellFromCodePoint(this.length - 1, 0, 1, eraseAttr?.fg || 0, eraseAttr?.bg || 0, eraseAttr?.extended || new ExtendedAttrs());
280
+ this.setCellFromCodepoint(this.length - 1, 0, 1, fillCellData);
277
281
  }
278
282
  }
279
283
 
280
- public deleteCells(pos: number, n: number, fillCellData: ICellData, eraseAttr?: IAttributeData): void {
284
+ public deleteCells(pos: number, n: number, fillCellData: ICellData): void {
281
285
  pos %= this.length;
282
286
  if (n < this.length - pos) {
283
287
  const cell = new CellData();
@@ -297,21 +301,21 @@ export class BufferLine implements IBufferLine {
297
301
  // - reset pos-1 if wide char
298
302
  // - reset pos if width==0 (previous second cell of a wide char)
299
303
  if (pos && this.getWidth(pos - 1) === 2) {
300
- this.setCellFromCodePoint(pos - 1, 0, 1, eraseAttr?.fg || 0, eraseAttr?.bg || 0, eraseAttr?.extended || new ExtendedAttrs());
304
+ this.setCellFromCodepoint(pos - 1, 0, 1, fillCellData);
301
305
  }
302
306
  if (this.getWidth(pos) === 0 && !this.hasContent(pos)) {
303
- this.setCellFromCodePoint(pos, 0, 1, eraseAttr?.fg || 0, eraseAttr?.bg || 0, eraseAttr?.extended || new ExtendedAttrs());
307
+ this.setCellFromCodepoint(pos, 0, 1, fillCellData);
304
308
  }
305
309
  }
306
310
 
307
- public replaceCells(start: number, end: number, fillCellData: ICellData, eraseAttr?: IAttributeData, respectProtect: boolean = false): void {
311
+ public replaceCells(start: number, end: number, fillCellData: ICellData, respectProtect: boolean = false): void {
308
312
  // full branching on respectProtect==true, hopefully getting fast JIT for standard case
309
313
  if (respectProtect) {
310
314
  if (start && this.getWidth(start - 1) === 2 && !this.isProtected(start - 1)) {
311
- this.setCellFromCodePoint(start - 1, 0, 1, eraseAttr?.fg || 0, eraseAttr?.bg || 0, eraseAttr?.extended || new ExtendedAttrs());
315
+ this.setCellFromCodepoint(start - 1, 0, 1, fillCellData);
312
316
  }
313
317
  if (end < this.length && this.getWidth(end - 1) === 2 && !this.isProtected(end)) {
314
- this.setCellFromCodePoint(end, 0, 1, eraseAttr?.fg || 0, eraseAttr?.bg || 0, eraseAttr?.extended || new ExtendedAttrs());
318
+ this.setCellFromCodepoint(end, 0, 1, fillCellData);
315
319
  }
316
320
  while (start < end && start < this.length) {
317
321
  if (!this.isProtected(start)) {
@@ -324,11 +328,11 @@ export class BufferLine implements IBufferLine {
324
328
 
325
329
  // handle fullwidth at start: reset cell one to the left if start is second cell of a wide char
326
330
  if (start && this.getWidth(start - 1) === 2) {
327
- this.setCellFromCodePoint(start - 1, 0, 1, eraseAttr?.fg || 0, eraseAttr?.bg || 0, eraseAttr?.extended || new ExtendedAttrs());
331
+ this.setCellFromCodepoint(start - 1, 0, 1, fillCellData);
328
332
  }
329
333
  // handle fullwidth at last cell + 1: reset to empty cell if it is second part of a wide char
330
334
  if (end < this.length && this.getWidth(end - 1) === 2) {
331
- this.setCellFromCodePoint(end, 0, 1, eraseAttr?.fg || 0, eraseAttr?.bg || 0, eraseAttr?.extended || new ExtendedAttrs());
335
+ this.setCellFromCodepoint(end, 0, 1, fillCellData);
332
336
  }
333
337
 
334
338
  while (start < end && start < this.length) {
@@ -504,16 +508,43 @@ export class BufferLine implements IBufferLine {
504
508
  }
505
509
  }
506
510
 
507
- public translateToString(trimRight: boolean = false, startCol: number = 0, endCol: number = this.length): string {
511
+ /**
512
+ * Translates the buffer line to a string.
513
+ *
514
+ * @param trimRight Whether to trim any empty cells on the right.
515
+ * @param startCol The column to start the string (0-based inclusive).
516
+ * @param endCol The column to end the string (0-based exclusive).
517
+ * @param outColumns if specified, this array will be filled with column numbers such that
518
+ * `returnedString[i]` is displayed at `outColumns[i]` column. `outColumns[returnedString.length]`
519
+ * is where the character following `returnedString` will be displayed.
520
+ *
521
+ * When a single cell is translated to multiple UTF-16 code units (e.g. surrogate pair) in the
522
+ * returned string, the corresponding entries in `outColumns` will have the same column number.
523
+ */
524
+ public translateToString(trimRight?: boolean, startCol?: number, endCol?: number, outColumns?: number[]): string {
525
+ startCol = startCol ?? 0;
526
+ endCol = endCol ?? this.length;
508
527
  if (trimRight) {
509
528
  endCol = Math.min(endCol, this.getTrimmedLength());
510
529
  }
530
+ if (outColumns) {
531
+ outColumns.length = 0;
532
+ }
511
533
  let result = '';
512
534
  while (startCol < endCol) {
513
535
  const content = this._data[startCol * CELL_SIZE + Cell.CONTENT];
514
536
  const cp = content & Content.CODEPOINT_MASK;
515
- result += (content & Content.IS_COMBINED_MASK) ? this._combined[startCol] : (cp) ? stringFromCodePoint(cp) : WHITESPACE_CELL_CHAR;
516
- startCol += (content >> Content.WIDTH_SHIFT) || 1; // always advance by 1
537
+ const chars = (content & Content.IS_COMBINED_MASK) ? this._combined[startCol] : (cp) ? stringFromCodePoint(cp) : WHITESPACE_CELL_CHAR;
538
+ result += chars;
539
+ if (outColumns) {
540
+ for (let i = 0; i < chars.length; ++i) {
541
+ outColumns.push(startCol);
542
+ }
543
+ }
544
+ startCol += (content >> Content.WIDTH_SHIFT) || 1; // always advance by at least 1
545
+ }
546
+ if (outColumns) {
547
+ outColumns.push(startCol);
517
548
  }
518
549
  return result;
519
550
  }
@@ -3,7 +3,7 @@
3
3
  * @license MIT
4
4
  */
5
5
 
6
- import { IBufferRange } from 'xterm';
6
+ import { IBufferRange } from '@xterm/xterm';
7
7
 
8
8
  export function getRangeLength(range: IBufferRange, bufferCols: number): number {
9
9
  if (range.start.y > range.end.y) {
@@ -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 {
@@ -134,9 +134,17 @@ export const enum BgFlags {
134
134
 
135
135
  export const enum ExtFlags {
136
136
  /**
137
- * bit 27..32 (upper 3 unused)
137
+ * bit 27..29
138
138
  */
139
- UNDERLINE_STYLE = 0x1C000000
139
+ UNDERLINE_STYLE = 0x1C000000,
140
+
141
+ /**
142
+ * bit 30..32
143
+ *
144
+ * An optional variant for the glyph, this can be used for example to offset underlines by a
145
+ * number of pixels to create a perfect pattern.
146
+ */
147
+ VARIANT_OFFSET = 0xE0000000
140
148
  }
141
149
 
142
150
  export const enum UnderlineStyle {
@@ -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
 
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Copyright (c) 2019 The xterm.js authors. All rights reserved.
3
+ * @license MIT
4
+ */
5
+
6
+ import { IAttributeData, ICircularList, IBufferLine, ICellData, IMarker, ICharset, IDisposable } from 'common/Types';
7
+ import type { Event } from 'vs/base/common/event';
8
+
9
+ // BufferIndex denotes a position in the buffer: [rowIndex, colIndex]
10
+ export type BufferIndex = [number, number];
11
+
12
+ export interface IBuffer {
13
+ readonly lines: ICircularList<IBufferLine>;
14
+ ydisp: number;
15
+ ybase: number;
16
+ y: number;
17
+ x: number;
18
+ tabs: any;
19
+ scrollBottom: number;
20
+ scrollTop: number;
21
+ hasScrollback: boolean;
22
+ savedY: number;
23
+ savedX: number;
24
+ savedCharset: ICharset | undefined;
25
+ savedCurAttrData: IAttributeData;
26
+ isCursorInViewport: boolean;
27
+ markers: IMarker[];
28
+ translateBufferLineToString(lineIndex: number, trimRight: boolean, startCol?: number, endCol?: number): string;
29
+ getWrappedRangeForLine(y: number): { first: number, last: number };
30
+ nextStop(x?: number): number;
31
+ prevStop(x?: number): number;
32
+ getBlankLine(attr: IAttributeData, isWrapped?: boolean): IBufferLine;
33
+ getNullCell(attr?: IAttributeData): ICellData;
34
+ getWhitespaceCell(attr?: IAttributeData): ICellData;
35
+ addMarker(y: number): IMarker;
36
+ clearMarkers(y: number): void;
37
+ clearAllMarkers(): void;
38
+ }
39
+
40
+ export interface IBufferSet extends IDisposable {
41
+ alt: IBuffer;
42
+ normal: IBuffer;
43
+ active: IBuffer;
44
+
45
+ onBufferActivate: Event<{ activeBuffer: IBuffer, inactiveBuffer: IBuffer }>;
46
+
47
+ activateNormalBuffer(): void;
48
+ activateAltBuffer(fillAttr?: IAttributeData): void;
49
+ reset(): void;
50
+ resize(newCols: number, newRows: number): void;
51
+ setupTabStops(i?: number): void;
52
+ }
@@ -83,11 +83,10 @@ export function evaluateKeyboardEvent(
83
83
  break;
84
84
  case 8:
85
85
  // backspace
86
+ result.key = ev.ctrlKey ? '\b' : C0.DEL; // ^H or ^?
86
87
  if (ev.altKey) {
87
- result.key = C0.ESC + C0.DEL; // \e ^?
88
- break;
88
+ result.key = C0.ESC + result.key;
89
89
  }
90
- result.key = C0.DEL; // ^?
91
90
  break;
92
91
  case 9:
93
92
  // tab
@@ -118,12 +117,6 @@ export function evaluateKeyboardEvent(
118
117
  }
119
118
  if (modifiers) {
120
119
  result.key = C0.ESC + '[1;' + (modifiers + 1) + 'D';
121
- // HACK: Make Alt + left-arrow behave like Ctrl + left-arrow: move one word backwards
122
- // http://unix.stackexchange.com/a/108106
123
- // macOS uses different escape sequences than linux
124
- if (result.key === C0.ESC + '[1;3D') {
125
- result.key = C0.ESC + (isMac ? 'b' : '[1;5D');
126
- }
127
120
  } else if (applicationCursorMode) {
128
121
  result.key = C0.ESC + 'OD';
129
122
  } else {
@@ -137,12 +130,6 @@ export function evaluateKeyboardEvent(
137
130
  }
138
131
  if (modifiers) {
139
132
  result.key = C0.ESC + '[1;' + (modifiers + 1) + 'C';
140
- // HACK: Make Alt + right-arrow behave like Ctrl + right-arrow: move one word forward
141
- // http://unix.stackexchange.com/a/108106
142
- // macOS uses different escape sequences than linux
143
- if (result.key === C0.ESC + '[1;3C') {
144
- result.key = C0.ESC + (isMac ? 'f' : '[1;5C');
145
- }
146
133
  } else if (applicationCursorMode) {
147
134
  result.key = C0.ESC + 'OC';
148
135
  } else {
@@ -156,12 +143,6 @@ export function evaluateKeyboardEvent(
156
143
  }
157
144
  if (modifiers) {
158
145
  result.key = C0.ESC + '[1;' + (modifiers + 1) + 'A';
159
- // HACK: Make Alt + up-arrow behave like Ctrl + up-arrow
160
- // http://unix.stackexchange.com/a/108106
161
- // macOS uses different escape sequences than linux
162
- if (!isMac && result.key === C0.ESC + '[1;3A') {
163
- result.key = C0.ESC + '[1;5A';
164
- }
165
146
  } else if (applicationCursorMode) {
166
147
  result.key = C0.ESC + 'OA';
167
148
  } else {
@@ -175,12 +156,6 @@ export function evaluateKeyboardEvent(
175
156
  }
176
157
  if (modifiers) {
177
158
  result.key = C0.ESC + '[1;' + (modifiers + 1) + 'B';
178
- // HACK: Make Alt + down-arrow behave like Ctrl + down-arrow
179
- // http://unix.stackexchange.com/a/108106
180
- // macOS uses different escape sequences than linux
181
- if (!isMac && result.key === C0.ESC + '[1;3B') {
182
- result.key = C0.ESC + '[1;5B';
183
- }
184
159
  } else if (applicationCursorMode) {
185
160
  result.key = C0.ESC + 'OB';
186
161
  } else {
@@ -2,9 +2,8 @@
2
2
  * Copyright (c) 2019 The xterm.js authors. All rights reserved.
3
3
  * @license MIT
4
4
  */
5
- import { IUnicodeVersionProvider } from 'common/services/Services';
6
-
7
- type CharWidth = 0 | 1 | 2;
5
+ import { IUnicodeVersionProvider, UnicodeCharProperties, UnicodeCharWidth } from 'common/services/Services';
6
+ import { UnicodeService } from 'common/services/UnicodeService';
8
7
 
9
8
  const BMP_COMBINING = [
10
9
  [0x0300, 0x036F], [0x0483, 0x0486], [0x0488, 0x0489],
@@ -121,12 +120,26 @@ export class UnicodeV6 implements IUnicodeVersionProvider {
121
120
  }
122
121
  }
123
122
 
124
- public wcwidth(num: number): CharWidth {
123
+ public wcwidth(num: number): UnicodeCharWidth {
125
124
  if (num < 32) return 0;
126
125
  if (num < 127) return 1;
127
- if (num < 65536) return table[num] as CharWidth;
126
+ if (num < 65536) return table[num] as UnicodeCharWidth;
128
127
  if (bisearch(num, HIGH_COMBINING)) return 0;
129
128
  if ((num >= 0x20000 && num <= 0x2fffd) || (num >= 0x30000 && num <= 0x3fffd)) return 2;
130
129
  return 1;
131
130
  }
131
+
132
+ public charProperties(codepoint: number, preceding: UnicodeCharProperties): UnicodeCharProperties {
133
+ let width = this.wcwidth(codepoint);
134
+ let shouldJoin = width === 0 && preceding !== 0;
135
+ if (shouldJoin) {
136
+ const oldWidth = UnicodeService.extractWidth(preceding);
137
+ if (oldWidth === 0) {
138
+ shouldJoin = false;
139
+ } else if (oldWidth > width) {
140
+ width = oldWidth;
141
+ }
142
+ }
143
+ return UnicodeService.createPropertyValue(0, width, shouldJoin);
144
+ }
132
145
  }
@@ -4,8 +4,8 @@
4
4
  * @license MIT
5
5
  */
6
6
 
7
- import { EventEmitter } from 'common/EventEmitter';
8
- import { Disposable } from 'common/Lifecycle';
7
+ import { Disposable } from 'vs/base/common/lifecycle';
8
+ import { Emitter } from 'vs/base/common/event';
9
9
 
10
10
  declare const setTimeout: (handler: () => void, timeout?: number) => void;
11
11
 
@@ -43,7 +43,7 @@ export class WriteBuffer extends Disposable {
43
43
  private _syncCalls = 0;
44
44
  private _didUserInput = false;
45
45
 
46
- private readonly _onWriteParsed = this.register(new EventEmitter<void>());
46
+ private readonly _onWriteParsed = this._register(new Emitter<void>());
47
47
  public readonly onWriteParsed = this._onWriteParsed.event;
48
48
 
49
49
  constructor(private _action: (data: string | Uint8Array, promiseResult?: boolean) => void | Promise<boolean>) {
@@ -137,7 +137,7 @@ export class WriteBuffer extends Disposable {
137
137
  * effectively lowering the redrawing needs, schematically:
138
138
  *
139
139
  * macroTask _innerWrite:
140
- * if (Date.now() - (lastTime | 0) < WRITE_TIMEOUT_MS):
140
+ * if (performance.now() - (lastTime | 0) < WRITE_TIMEOUT_MS):
141
141
  * schedule microTask _innerWrite(lastTime)
142
142
  * else:
143
143
  * schedule macroTask _innerWrite(0)
@@ -158,7 +158,7 @@ export class WriteBuffer extends Disposable {
158
158
  * Note, for pure sync code `lastTime` and `promiseResult` have no meaning.
159
159
  */
160
160
  protected _innerWrite(lastTime: number = 0, promiseResult: boolean = true): void {
161
- const startTime = lastTime || Date.now();
161
+ const startTime = lastTime || performance.now();
162
162
  while (this._writeBuffer.length > this._bufferOffset) {
163
163
  const data = this._writeBuffer[this._bufferOffset];
164
164
  const result = this._action(data, promiseResult);
@@ -186,7 +186,7 @@ export class WriteBuffer extends Disposable {
186
186
  * responsibility to slice hard work), but we can at least schedule a screen update as we
187
187
  * gain control.
188
188
  */
189
- const continuation: (r: boolean) => void = (r: boolean) => Date.now() - startTime >= WRITE_TIMEOUT_MS
189
+ const continuation: (r: boolean) => void = (r: boolean) => performance.now() - startTime >= WRITE_TIMEOUT_MS
190
190
  ? setTimeout(() => this._innerWrite(0, r))
191
191
  : this._innerWrite(startTime, r);
192
192
 
@@ -202,7 +202,8 @@ export class WriteBuffer extends Disposable {
202
202
  * throughput by eval'ing `startTime` upfront pulling at least one more chunk into the
203
203
  * current microtask queue (executed before setTimeout).
204
204
  */
205
- // const continuation: (r: boolean) => void = Date.now() - startTime >= WRITE_TIMEOUT_MS
205
+ // const continuation: (r: boolean) => void = performance.now() - startTime >=
206
+ // WRITE_TIMEOUT_MS
206
207
  // ? r => setTimeout(() => this._innerWrite(0, r))
207
208
  // : r => this._innerWrite(startTime, r);
208
209
 
@@ -222,7 +223,7 @@ export class WriteBuffer extends Disposable {
222
223
  this._bufferOffset++;
223
224
  this._pendingData -= data.length;
224
225
 
225
- if (Date.now() - startTime >= WRITE_TIMEOUT_MS) {
226
+ if (performance.now() - startTime >= WRITE_TIMEOUT_MS) {
226
227
  break;
227
228
  }
228
229
  }
@@ -5,7 +5,7 @@
5
5
 
6
6
  import { IParsingState, IDcsHandler, IEscapeSequenceParser, IParams, IOscHandler, IHandlerCollection, CsiHandlerType, OscFallbackHandlerType, IOscParser, EscHandlerType, IDcsParser, DcsFallbackHandlerType, IFunctionIdentifier, ExecuteFallbackHandlerType, CsiFallbackHandlerType, EscFallbackHandlerType, PrintHandlerType, PrintFallbackHandlerType, ExecuteHandlerType, IParserStackState, ParserStackType, ResumableHandlersType } from 'common/parser/Types';
7
7
  import { ParserState, ParserAction } from 'common/parser/Constants';
8
- import { Disposable, toDisposable } from 'common/Lifecycle';
8
+ import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
9
9
  import { IDisposable } from 'common/Types';
10
10
  import { Params } from 'common/parser/Params';
11
11
  import { OscParser } from 'common/parser/OscParser';
@@ -230,7 +230,7 @@ export const VT500_TRANSITION_TABLE = (function (): TransitionTable {
230
230
  export class EscapeSequenceParser extends Disposable implements IEscapeSequenceParser {
231
231
  public initialState: number;
232
232
  public currentState: number;
233
- public precedingCodepoint: number;
233
+ public precedingJoinState: number; // UnicodeJoinProperties
234
234
 
235
235
  // buffers over several parse calls
236
236
  protected _params: Params;
@@ -271,7 +271,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
271
271
  this._params = new Params(); // defaults to 32 storable params/subparams
272
272
  this._params.addParam(0); // ZDM
273
273
  this._collect = 0;
274
- this.precedingCodepoint = 0;
274
+ this.precedingJoinState = 0;
275
275
 
276
276
  // set default fallback handlers and handler lookup containers
277
277
  this._printHandlerFb = (data, start, end): void => { };
@@ -283,13 +283,13 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
283
283
  this._executeHandlers = Object.create(null);
284
284
  this._csiHandlers = Object.create(null);
285
285
  this._escHandlers = Object.create(null);
286
- this.register(toDisposable(() => {
286
+ this._register(toDisposable(() => {
287
287
  this._csiHandlers = Object.create(null);
288
288
  this._executeHandlers = Object.create(null);
289
289
  this._escHandlers = Object.create(null);
290
290
  }));
291
- this._oscParser = this.register(new OscParser());
292
- this._dcsParser = this.register(new DcsParser());
291
+ this._oscParser = this._register(new OscParser());
292
+ this._dcsParser = this._register(new DcsParser());
293
293
  this._errorHandler = this._errorHandlerFb;
294
294
 
295
295
  // swallow 7bit ST (ESC+\)
@@ -448,7 +448,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
448
448
  this._params.reset();
449
449
  this._params.addParam(0); // ZDM
450
450
  this._collect = 0;
451
- this.precedingCodepoint = 0;
451
+ this.precedingJoinState = 0;
452
452
  // abort pending continuation from async handler
453
453
  // Here the RESET type indicates, that the next parse call will
454
454
  // ignore any saved stack, instead continues sync with next codepoint from GROUND
@@ -610,7 +610,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
610
610
  // cleanup before continuing with the main sync loop
611
611
  this._parseStack.state = ParserStackType.NONE;
612
612
  start = this._parseStack.chunkPos + 1;
613
- this.precedingCodepoint = 0;
613
+ this.precedingJoinState = 0;
614
614
  this.currentState = this._parseStack.transition & TableAccess.TRANSITION_STATE_MASK;
615
615
  }
616
616
  }
@@ -653,7 +653,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
653
653
  case ParserAction.EXECUTE:
654
654
  if (this._executeHandlers[code]) this._executeHandlers[code]();
655
655
  else this._executeHandlerFb(code);
656
- this.precedingCodepoint = 0;
656
+ this.precedingJoinState = 0;
657
657
  break;
658
658
  case ParserAction.IGNORE:
659
659
  break;
@@ -688,7 +688,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
688
688
  if (j < 0) {
689
689
  this._csiHandlerFb(this._collect << 8 | code, this._params);
690
690
  }
691
- this.precedingCodepoint = 0;
691
+ this.precedingJoinState = 0;
692
692
  break;
693
693
  case ParserAction.PARAM:
694
694
  // inner loop: digits (0x30 - 0x39) and ; (0x3b) and : (0x3a)
@@ -727,7 +727,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
727
727
  if (jj < 0) {
728
728
  this._escHandlerFb(this._collect << 8 | code);
729
729
  }
730
- this.precedingCodepoint = 0;
730
+ this.precedingJoinState = 0;
731
731
  break;
732
732
  case ParserAction.CLEAR:
733
733
  this._params.reset();
@@ -758,7 +758,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
758
758
  this._params.reset();
759
759
  this._params.addParam(0); // ZDM
760
760
  this._collect = 0;
761
- this.precedingCodepoint = 0;
761
+ this.precedingJoinState = 0;
762
762
  break;
763
763
  case ParserAction.OSC_START:
764
764
  this._oscParser.start();
@@ -783,7 +783,7 @@ export class EscapeSequenceParser extends Disposable implements IEscapeSequenceP
783
783
  this._params.reset();
784
784
  this._params.addParam(0); // ZDM
785
785
  this._collect = 0;
786
- this.precedingCodepoint = 0;
786
+ this.precedingJoinState = 0;
787
787
  break;
788
788
  }
789
789
  this.currentState = transition & TableAccess.TRANSITION_STATE_MASK;