@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
@@ -5,12 +5,12 @@
5
5
 
6
6
  import { ColorContrastCache } from 'browser/ColorContrastCache';
7
7
  import { IThemeService } from 'browser/services/Services';
8
- import { IColorContrastCache, IColorSet, ReadonlyColorSet } from 'browser/Types';
9
- import { channels, color, css, NULL_COLOR } from 'common/Color';
10
- import { EventEmitter } from 'common/EventEmitter';
11
- import { Disposable } from 'common/Lifecycle';
8
+ import { DEFAULT_ANSI_COLORS, IColorContrastCache, IColorSet, ReadonlyColorSet } from 'browser/Types';
9
+ import { color, css, NULL_COLOR } from 'common/Color';
10
+ import { Disposable } from 'vs/base/common/lifecycle';
12
11
  import { IOptionsService, ITheme } from 'common/services/Services';
13
12
  import { AllColorIndex, IColor, SpecialColorIndex } from 'common/Types';
13
+ import { Emitter } from 'vs/base/common/event';
14
14
 
15
15
  interface IRestoreColorSet {
16
16
  foreground: IColor;
@@ -23,59 +23,12 @@ interface IRestoreColorSet {
23
23
  const DEFAULT_FOREGROUND = css.toColor('#ffffff');
24
24
  const DEFAULT_BACKGROUND = css.toColor('#000000');
25
25
  const DEFAULT_CURSOR = css.toColor('#ffffff');
26
- const DEFAULT_CURSOR_ACCENT = css.toColor('#000000');
26
+ const DEFAULT_CURSOR_ACCENT = DEFAULT_BACKGROUND;
27
27
  const DEFAULT_SELECTION = {
28
28
  css: 'rgba(255, 255, 255, 0.3)',
29
29
  rgba: 0xFFFFFF4D
30
30
  };
31
-
32
- // An IIFE to generate DEFAULT_ANSI_COLORS.
33
- export const DEFAULT_ANSI_COLORS = Object.freeze((() => {
34
- const colors = [
35
- // dark:
36
- css.toColor('#2e3436'),
37
- css.toColor('#cc0000'),
38
- css.toColor('#4e9a06'),
39
- css.toColor('#c4a000'),
40
- css.toColor('#3465a4'),
41
- css.toColor('#75507b'),
42
- css.toColor('#06989a'),
43
- css.toColor('#d3d7cf'),
44
- // bright:
45
- css.toColor('#555753'),
46
- css.toColor('#ef2929'),
47
- css.toColor('#8ae234'),
48
- css.toColor('#fce94f'),
49
- css.toColor('#729fcf'),
50
- css.toColor('#ad7fa8'),
51
- css.toColor('#34e2e2'),
52
- css.toColor('#eeeeec')
53
- ];
54
-
55
- // Fill in the remaining 240 ANSI colors.
56
- // Generate colors (16-231)
57
- const v = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff];
58
- for (let i = 0; i < 216; i++) {
59
- const r = v[(i / 36) % 6 | 0];
60
- const g = v[(i / 6) % 6 | 0];
61
- const b = v[i % 6];
62
- colors.push({
63
- css: channels.toCss(r, g, b),
64
- rgba: channels.toRgba(r, g, b)
65
- });
66
- }
67
-
68
- // Generate greys (232-255)
69
- for (let i = 0; i < 24; i++) {
70
- const c = 8 + i * 10;
71
- colors.push({
72
- css: channels.toCss(c, c, c),
73
- rgba: channels.toRgba(c, c, c)
74
- });
75
- }
76
-
77
- return colors;
78
- })());
31
+ const DEFAULT_OVERVIEW_RULER_BORDER = DEFAULT_FOREGROUND;
79
32
 
80
33
  export class ThemeService extends Disposable implements IThemeService {
81
34
  public serviceBrand: undefined;
@@ -87,7 +40,7 @@ export class ThemeService extends Disposable implements IThemeService {
87
40
 
88
41
  public get colors(): ReadonlyColorSet { return this._colors; }
89
42
 
90
- private readonly _onChangeColors = this.register(new EventEmitter<ReadonlyColorSet>());
43
+ private readonly _onChangeColors = this._register(new Emitter<ReadonlyColorSet>());
91
44
  public readonly onChangeColors = this._onChangeColors.event;
92
45
 
93
46
  constructor(
@@ -105,6 +58,10 @@ export class ThemeService extends Disposable implements IThemeService {
105
58
  selectionBackgroundOpaque: color.blend(DEFAULT_BACKGROUND, DEFAULT_SELECTION),
106
59
  selectionInactiveBackgroundTransparent: DEFAULT_SELECTION,
107
60
  selectionInactiveBackgroundOpaque: color.blend(DEFAULT_BACKGROUND, DEFAULT_SELECTION),
61
+ scrollbarSliderBackground: color.opacity(DEFAULT_FOREGROUND, 0.2),
62
+ scrollbarSliderHoverBackground: color.opacity(DEFAULT_FOREGROUND, 0.4),
63
+ scrollbarSliderActiveBackground: color.opacity(DEFAULT_FOREGROUND, 0.5),
64
+ overviewRulerBorder: DEFAULT_FOREGROUND,
108
65
  ansi: DEFAULT_ANSI_COLORS.slice(),
109
66
  contrastCache: this._contrastCache,
110
67
  halfContrastCache: this._halfContrastCache
@@ -112,8 +69,8 @@ export class ThemeService extends Disposable implements IThemeService {
112
69
  this._updateRestoreColors();
113
70
  this._setTheme(this._optionsService.rawOptions.theme);
114
71
 
115
- this.register(this._optionsService.onSpecificOptionChange('minimumContrastRatio', () => this._contrastCache.clear()));
116
- this.register(this._optionsService.onSpecificOptionChange('theme', () => this._setTheme(this._optionsService.rawOptions.theme)));
72
+ this._register(this._optionsService.onSpecificOptionChange('minimumContrastRatio', () => this._contrastCache.clear()));
73
+ this._register(this._optionsService.onSpecificOptionChange('theme', () => this._setTheme(this._optionsService.rawOptions.theme)));
117
74
  }
118
75
 
119
76
  /**
@@ -125,8 +82,8 @@ export class ThemeService extends Disposable implements IThemeService {
125
82
  const colors = this._colors;
126
83
  colors.foreground = parseColor(theme.foreground, DEFAULT_FOREGROUND);
127
84
  colors.background = parseColor(theme.background, DEFAULT_BACKGROUND);
128
- colors.cursor = parseColor(theme.cursor, DEFAULT_CURSOR);
129
- colors.cursorAccent = parseColor(theme.cursorAccent, DEFAULT_CURSOR_ACCENT);
85
+ colors.cursor = color.blend(colors.background, parseColor(theme.cursor, DEFAULT_CURSOR));
86
+ colors.cursorAccent = color.blend(colors.background, parseColor(theme.cursorAccent, DEFAULT_CURSOR_ACCENT));
130
87
  colors.selectionBackgroundTransparent = parseColor(theme.selectionBackground, DEFAULT_SELECTION);
131
88
  colors.selectionBackgroundOpaque = color.blend(colors.background, colors.selectionBackgroundTransparent);
132
89
  colors.selectionInactiveBackgroundTransparent = parseColor(theme.selectionInactiveBackground, colors.selectionBackgroundTransparent);
@@ -148,6 +105,10 @@ export class ThemeService extends Disposable implements IThemeService {
148
105
  const opacity = 0.3;
149
106
  colors.selectionInactiveBackgroundTransparent = color.opacity(colors.selectionInactiveBackgroundTransparent, opacity);
150
107
  }
108
+ colors.scrollbarSliderBackground = parseColor(theme.scrollbarSliderBackground, color.opacity(colors.foreground, 0.2));
109
+ colors.scrollbarSliderHoverBackground = parseColor(theme.scrollbarSliderHoverBackground, color.opacity(colors.foreground, 0.4));
110
+ colors.scrollbarSliderActiveBackground = parseColor(theme.scrollbarSliderActiveBackground, color.opacity(colors.foreground, 0.5));
111
+ colors.overviewRulerBorder = parseColor(theme.overviewRulerBorder, DEFAULT_OVERVIEW_RULER_BORDER);
151
112
  colors.ansi = DEFAULT_ANSI_COLORS.slice();
152
113
  colors.ansi[0] = parseColor(theme.black, DEFAULT_ANSI_COLORS[0]);
153
114
  colors.ansi[1] = parseColor(theme.red, DEFAULT_ANSI_COLORS[1]);
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2024 The xterm.js authors. All rights reserved.
3
+ * @license MIT
4
+ */
5
+
6
+ export const enum ViewportConstants {
7
+ DEFAULT_SCROLL_BAR_WIDTH = 14
8
+ }
@@ -4,8 +4,8 @@
4
4
  */
5
5
 
6
6
  import { ICircularList } from 'common/Types';
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
  export interface IInsertEvent {
11
11
  index: number;
@@ -26,11 +26,11 @@ export class CircularList<T> extends Disposable implements ICircularList<T> {
26
26
  private _startIndex: number;
27
27
  private _length: number;
28
28
 
29
- public readonly onDeleteEmitter = this.register(new EventEmitter<IDeleteEvent>());
29
+ public readonly onDeleteEmitter = this._register(new Emitter<IDeleteEvent>());
30
30
  public readonly onDelete = this.onDeleteEmitter.event;
31
- public readonly onInsertEmitter = this.register(new EventEmitter<IInsertEvent>());
31
+ public readonly onInsertEmitter = this._register(new Emitter<IInsertEvent>());
32
32
  public readonly onInsert = this.onInsertEmitter.event;
33
- public readonly onTrimEmitter = this.register(new EventEmitter<number>());
33
+ public readonly onTrimEmitter = this._register(new Emitter<number>());
34
34
  public readonly onTrim = this.onTrimEmitter.event;
35
35
 
36
36
  constructor(
@@ -3,7 +3,6 @@
3
3
  * @license MIT
4
4
  */
5
5
 
6
- import { isNode } from 'common/Platform';
7
6
  import { IColor, IColorRGB } from 'common/Types';
8
7
 
9
8
  let $r = 0;
@@ -33,6 +32,13 @@ export namespace channels {
33
32
  // >>> 0 forces an unsigned int
34
33
  return (r << 24 | g << 16 | b << 8 | a) >>> 0;
35
34
  }
35
+
36
+ export function toColor(r: number, g: number, b: number, a?: number): IColor {
37
+ return {
38
+ css: channels.toCss(r, g, b, a),
39
+ rgba: channels.toRgba(r, g, b, a)
40
+ };
41
+ }
36
42
  }
37
43
 
38
44
  /**
@@ -70,7 +76,7 @@ export namespace color {
70
76
  if (!result) {
71
77
  return undefined;
72
78
  }
73
- return rgba.toColor(
79
+ return channels.toColor(
74
80
  (result >> 24 & 0xFF),
75
81
  (result >> 16 & 0xFF),
76
82
  (result >> 8 & 0xFF)
@@ -110,9 +116,11 @@ export namespace color {
110
116
  * '#rrggbbaa').
111
117
  */
112
118
  export namespace css {
119
+ // Attempt to set get the shared canvas context
113
120
  let $ctx: CanvasRenderingContext2D | undefined;
114
121
  let $litmusColor: CanvasGradient | undefined;
115
- if (!isNode) {
122
+ try {
123
+ // This is guaranteed to run in the first window, so document should be correct
116
124
  const canvas = document.createElement('canvas');
117
125
  canvas.width = 1;
118
126
  canvas.height = 1;
@@ -125,6 +133,9 @@ export namespace css {
125
133
  $litmusColor = $ctx.createLinearGradient(0, 0, 1, 1);
126
134
  }
127
135
  }
136
+ catch {
137
+ // noop
138
+ }
128
139
 
129
140
  /**
130
141
  * Converts a css string to an IColor, this should handle all valid CSS color strings and will
@@ -141,14 +152,14 @@ export namespace css {
141
152
  $r = parseInt(css.slice(1, 2).repeat(2), 16);
142
153
  $g = parseInt(css.slice(2, 3).repeat(2), 16);
143
154
  $b = parseInt(css.slice(3, 4).repeat(2), 16);
144
- return rgba.toColor($r, $g, $b);
155
+ return channels.toColor($r, $g, $b);
145
156
  }
146
157
  case 5: { // #rgba
147
158
  $r = parseInt(css.slice(1, 2).repeat(2), 16);
148
159
  $g = parseInt(css.slice(2, 3).repeat(2), 16);
149
160
  $b = parseInt(css.slice(3, 4).repeat(2), 16);
150
161
  $a = parseInt(css.slice(4, 5).repeat(2), 16);
151
- return rgba.toColor($r, $g, $b, $a);
162
+ return channels.toColor($r, $g, $b, $a);
152
163
  }
153
164
  case 7: // #rrggbb
154
165
  return {
@@ -170,7 +181,7 @@ export namespace css {
170
181
  $g = parseInt(rgbaMatch[2]);
171
182
  $b = parseInt(rgbaMatch[3]);
172
183
  $a = Math.round((rgbaMatch[5] === undefined ? 1 : parseFloat(rgbaMatch[5])) * 0xFF);
173
- return rgba.toColor($r, $g, $b, $a);
184
+ return channels.toColor($r, $g, $b, $a);
174
185
  }
175
186
 
176
187
  // Validate the context is available for canvas-based color parsing
@@ -244,6 +255,23 @@ export namespace rgb {
244
255
  * Helper functions where the source type is "rgba" (number: 0xrrggbbaa).
245
256
  */
246
257
  export namespace rgba {
258
+ export function blend(bg: number, fg: number): number {
259
+ $a = (fg & 0xFF) / 0xFF;
260
+ if ($a === 1) {
261
+ return fg;
262
+ }
263
+ const fgR = (fg >> 24) & 0xFF;
264
+ const fgG = (fg >> 16) & 0xFF;
265
+ const fgB = (fg >> 8) & 0xFF;
266
+ const bgR = (bg >> 24) & 0xFF;
267
+ const bgG = (bg >> 16) & 0xFF;
268
+ const bgB = (bg >> 8) & 0xFF;
269
+ $r = bgR + Math.round((fgR - bgR) * $a);
270
+ $g = bgG + Math.round((fgG - bgG) * $a);
271
+ $b = bgB + Math.round((fgB - bgB) * $a);
272
+ return channels.toRgba($r, $g, $b);
273
+ }
274
+
247
275
  /**
248
276
  * Given a foreground color and a background color, either increase or reduce the luminance of the
249
277
  * foreground color until the specified contrast ratio is met. If pure white or black is hit
@@ -324,17 +352,9 @@ export namespace rgba {
324
352
  return (fgR << 24 | fgG << 16 | fgB << 8 | 0xFF) >>> 0;
325
353
  }
326
354
 
327
- // FIXME: Move this to channels NS?
328
355
  export function toChannels(value: number): [number, number, number, number] {
329
356
  return [(value >> 24) & 0xFF, (value >> 16) & 0xFF, (value >> 8) & 0xFF, value & 0xFF];
330
357
  }
331
-
332
- export function toColor(r: number, g: number, b: number, a?: number): IColor {
333
- return {
334
- css: channels.toCss(r, g, b, a),
335
- rgba: channels.toRgba(r, g, b, a)
336
- };
337
- }
338
358
  }
339
359
 
340
360
  export function toPaddedHex(c: number): string {
@@ -21,15 +21,13 @@
21
21
  * http://linux.die.net/man/7/urxvt
22
22
  */
23
23
 
24
- import { Disposable, MutableDisposable, toDisposable } from 'common/Lifecycle';
25
24
  import { IInstantiationService, IOptionsService, IBufferService, ILogService, ICharsetService, ICoreService, ICoreMouseService, IUnicodeService, LogLevelEnum, ITerminalOptions, IOscLinkService } from 'common/services/Services';
26
25
  import { InstantiationService } from 'common/services/InstantiationService';
27
26
  import { LogService } from 'common/services/LogService';
28
27
  import { BufferService, MINIMUM_COLS, MINIMUM_ROWS } from 'common/services/BufferService';
29
28
  import { OptionsService } from 'common/services/OptionsService';
30
- import { IDisposable, IAttributeData, ICoreTerminal, IScrollEvent, ScrollSource } from 'common/Types';
29
+ import { IDisposable, IAttributeData, ICoreTerminal, IScrollEvent } from 'common/Types';
31
30
  import { CoreService } from 'common/services/CoreService';
32
- import { EventEmitter, IEvent, forwardEvent } from 'common/EventEmitter';
33
31
  import { CoreMouseService } from 'common/services/CoreMouseService';
34
32
  import { UnicodeService } from 'common/services/UnicodeService';
35
33
  import { CharsetService } from 'common/services/CharsetService';
@@ -39,6 +37,8 @@ import { IBufferSet } from 'common/buffer/Types';
39
37
  import { InputHandler } from 'common/InputHandler';
40
38
  import { WriteBuffer } from 'common/input/WriteBuffer';
41
39
  import { OscLinkService } from 'common/services/OscLinkService';
40
+ import { Emitter, Event } from 'vs/base/common/event';
41
+ import { Disposable, MutableDisposable, toDisposable } from 'vs/base/common/lifecycle';
42
42
 
43
43
  // Only trigger this warning a single time per session
44
44
  let hasWriteSyncWarnHappened = false;
@@ -57,28 +57,28 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
57
57
 
58
58
  protected _inputHandler: InputHandler;
59
59
  private _writeBuffer: WriteBuffer;
60
- private _windowsWrappingHeuristics = this.register(new MutableDisposable());
60
+ private _windowsWrappingHeuristics = this._register(new MutableDisposable());
61
61
 
62
- private readonly _onBinary = this.register(new EventEmitter<string>());
62
+ private readonly _onBinary = this._register(new Emitter<string>());
63
63
  public readonly onBinary = this._onBinary.event;
64
- private readonly _onData = this.register(new EventEmitter<string>());
64
+ private readonly _onData = this._register(new Emitter<string>());
65
65
  public readonly onData = this._onData.event;
66
- protected _onLineFeed = this.register(new EventEmitter<void>());
66
+ protected _onLineFeed = this._register(new Emitter<void>());
67
67
  public readonly onLineFeed = this._onLineFeed.event;
68
- private readonly _onResize = this.register(new EventEmitter<{ cols: number, rows: number }>());
68
+ private readonly _onResize = this._register(new Emitter<{ cols: number, rows: number }>());
69
69
  public readonly onResize = this._onResize.event;
70
- protected readonly _onWriteParsed = this.register(new EventEmitter<void>());
70
+ protected readonly _onWriteParsed = this._register(new Emitter<void>());
71
71
  public readonly onWriteParsed = this._onWriteParsed.event;
72
72
 
73
73
  /**
74
74
  * Internally we track the source of the scroll but this is meaningless outside the library so
75
75
  * it's filtered out.
76
76
  */
77
- protected _onScrollApi?: EventEmitter<number, void>;
78
- protected _onScroll = this.register(new EventEmitter<IScrollEvent, void>());
79
- public get onScroll(): IEvent<number, void> {
77
+ protected _onScrollApi?: Emitter<number>;
78
+ protected _onScroll = this._register(new Emitter<IScrollEvent>());
79
+ public get onScroll(): Event<number> {
80
80
  if (!this._onScrollApi) {
81
- this._onScrollApi = this.register(new EventEmitter<number, void>());
81
+ this._onScrollApi = this._register(new Emitter<number>());
82
82
  this._onScroll.event(ev => {
83
83
  this._onScrollApi?.fire(ev.position);
84
84
  });
@@ -103,47 +103,43 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
103
103
 
104
104
  // Setup and initialize services
105
105
  this._instantiationService = new InstantiationService();
106
- this.optionsService = this.register(new OptionsService(options));
106
+ this.optionsService = this._register(new OptionsService(options));
107
107
  this._instantiationService.setService(IOptionsService, this.optionsService);
108
- this._bufferService = this.register(this._instantiationService.createInstance(BufferService));
108
+ this._bufferService = this._register(this._instantiationService.createInstance(BufferService));
109
109
  this._instantiationService.setService(IBufferService, this._bufferService);
110
- this._logService = this.register(this._instantiationService.createInstance(LogService));
110
+ this._logService = this._register(this._instantiationService.createInstance(LogService));
111
111
  this._instantiationService.setService(ILogService, this._logService);
112
- this.coreService = this.register(this._instantiationService.createInstance(CoreService));
112
+ this.coreService = this._register(this._instantiationService.createInstance(CoreService));
113
113
  this._instantiationService.setService(ICoreService, this.coreService);
114
- this.coreMouseService = this.register(this._instantiationService.createInstance(CoreMouseService));
114
+ this.coreMouseService = this._register(this._instantiationService.createInstance(CoreMouseService));
115
115
  this._instantiationService.setService(ICoreMouseService, this.coreMouseService);
116
- this.unicodeService = this.register(this._instantiationService.createInstance(UnicodeService));
116
+ this.unicodeService = this._register(this._instantiationService.createInstance(UnicodeService));
117
117
  this._instantiationService.setService(IUnicodeService, this.unicodeService);
118
118
  this._charsetService = this._instantiationService.createInstance(CharsetService);
119
119
  this._instantiationService.setService(ICharsetService, this._charsetService);
120
120
  this._oscLinkService = this._instantiationService.createInstance(OscLinkService);
121
121
  this._instantiationService.setService(IOscLinkService, this._oscLinkService);
122
122
 
123
+
123
124
  // Register input handler and handle/forward events
124
- this._inputHandler = this.register(new InputHandler(this._bufferService, this._charsetService, this.coreService, this._logService, this.optionsService, this._oscLinkService, this.coreMouseService, this.unicodeService));
125
- this.register(forwardEvent(this._inputHandler.onLineFeed, this._onLineFeed));
126
- this.register(this._inputHandler);
125
+ this._inputHandler = this._register(new InputHandler(this._bufferService, this._charsetService, this.coreService, this._logService, this.optionsService, this._oscLinkService, this.coreMouseService, this.unicodeService));
126
+ this._register(Event.forward(this._inputHandler.onLineFeed, this._onLineFeed));
127
+ this._register(this._inputHandler);
127
128
 
128
129
  // Setup listeners
129
- this.register(forwardEvent(this._bufferService.onResize, this._onResize));
130
- this.register(forwardEvent(this.coreService.onData, this._onData));
131
- this.register(forwardEvent(this.coreService.onBinary, this._onBinary));
132
- this.register(this.coreService.onRequestScrollToBottom(() => this.scrollToBottom()));
133
- this.register(this.coreService.onUserInput(() => this._writeBuffer.handleUserInput()));
134
- this.register(this.optionsService.onMultipleOptionChange(['windowsMode', 'windowsPty'], () => this._handleWindowsPtyOptionChange()));
135
- this.register(this._bufferService.onScroll(event => {
136
- this._onScroll.fire({ position: this._bufferService.buffer.ydisp, source: ScrollSource.TERMINAL });
137
- this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop, this._bufferService.buffer.scrollBottom);
138
- }));
139
- this.register(this._inputHandler.onScroll(event => {
140
- this._onScroll.fire({ position: this._bufferService.buffer.ydisp, source: ScrollSource.TERMINAL });
130
+ this._register(Event.forward(this._bufferService.onResize, this._onResize));
131
+ this._register(Event.forward(this.coreService.onData, this._onData));
132
+ this._register(Event.forward(this.coreService.onBinary, this._onBinary));
133
+ this._register(this.coreService.onRequestScrollToBottom(() => this.scrollToBottom(true)));
134
+ this._register(this.coreService.onUserInput(() => this._writeBuffer.handleUserInput()));
135
+ this._register(this.optionsService.onMultipleOptionChange(['windowsMode', 'windowsPty'], () => this._handleWindowsPtyOptionChange()));
136
+ this._register(this._bufferService.onScroll(() => {
137
+ this._onScroll.fire({ position: this._bufferService.buffer.ydisp });
141
138
  this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop, this._bufferService.buffer.scrollBottom);
142
139
  }));
143
-
144
140
  // Setup WriteBuffer
145
- this._writeBuffer = this.register(new WriteBuffer((data, promiseResult) => this._inputHandler.parse(data, promiseResult)));
146
- this.register(forwardEvent(this._writeBuffer.onWriteParsed, this._onWriteParsed));
141
+ this._writeBuffer = this._register(new WriteBuffer((data, promiseResult) => this._inputHandler.parse(data, promiseResult)));
142
+ this._register(Event.forward(this._writeBuffer.onWriteParsed, this._onWriteParsed));
147
143
  }
148
144
 
149
145
  public write(data: string | Uint8Array, callback?: () => void): void {
@@ -167,6 +163,10 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
167
163
  this._writeBuffer.writeSync(data, maxSubsequentCalls);
168
164
  }
169
165
 
166
+ public input(data: string, wasUserInput: boolean = true): void {
167
+ this.coreService.triggerDataEvent(data, wasUserInput);
168
+ }
169
+
170
170
  public resize(x: number, y: number): void {
171
171
  if (isNaN(x) || isNaN(y)) {
172
172
  return;
@@ -193,10 +193,9 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
193
193
  * @param suppressScrollEvent Don't emit the scroll event as scrollLines. This is used to avoid
194
194
  * unwanted events being handled by the viewport when the event was triggered from the viewport
195
195
  * originally.
196
- * @param source Which component the event came from.
197
196
  */
198
- public scrollLines(disp: number, suppressScrollEvent?: boolean, source?: ScrollSource): void {
199
- this._bufferService.scrollLines(disp, suppressScrollEvent, source);
197
+ public scrollLines(disp: number, suppressScrollEvent?: boolean): void {
198
+ this._bufferService.scrollLines(disp, suppressScrollEvent);
200
199
  }
201
200
 
202
201
  public scrollPages(pageCount: number): void {
@@ -207,7 +206,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
207
206
  this.scrollLines(-this._bufferService.buffer.ydisp);
208
207
  }
209
208
 
210
- public scrollToBottom(): void {
209
+ public scrollToBottom(disableSmoothScroll?: boolean): void {
211
210
  this.scrollLines(this._bufferService.buffer.ybase - this._bufferService.buffer.ydisp);
212
211
  }
213
212