groove-dev 0.16.1 → 0.16.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/node_modules/@groove-dev/daemon/src/index.js +25 -7
  2. package/node_modules/@groove-dev/daemon/src/terminal-pty.js +141 -0
  3. package/node_modules/@groove-dev/gui/dist/assets/{index-Gfb8Zxy9.css → index-BhjOFLBc.css} +32 -1
  4. package/node_modules/@groove-dev/gui/dist/assets/index-CFeltwTB.js +153 -0
  5. package/node_modules/@groove-dev/gui/dist/index.html +2 -2
  6. package/node_modules/@groove-dev/gui/package.json +3 -0
  7. package/node_modules/@groove-dev/gui/src/components/EditorTabs.jsx +3 -3
  8. package/node_modules/@groove-dev/gui/src/components/FileTree.jsx +18 -22
  9. package/node_modules/@groove-dev/gui/src/components/Terminal.jsx +154 -0
  10. package/node_modules/@groove-dev/gui/src/views/FileEditor.jsx +100 -39
  11. package/node_modules/@xterm/addon-fit/LICENSE +19 -0
  12. package/node_modules/@xterm/addon-fit/README.md +24 -0
  13. package/node_modules/@xterm/addon-fit/lib/addon-fit.js +2 -0
  14. package/node_modules/@xterm/addon-fit/lib/addon-fit.js.map +1 -0
  15. package/node_modules/@xterm/addon-fit/lib/addon-fit.mjs +18 -0
  16. package/node_modules/@xterm/addon-fit/lib/addon-fit.mjs.map +7 -0
  17. package/node_modules/@xterm/addon-fit/package.json +26 -0
  18. package/node_modules/@xterm/addon-fit/src/FitAddon.ts +92 -0
  19. package/node_modules/@xterm/addon-fit/typings/addon-fit.d.ts +55 -0
  20. package/node_modules/@xterm/addon-web-links/LICENSE +19 -0
  21. package/node_modules/@xterm/addon-web-links/README.md +21 -0
  22. package/node_modules/@xterm/addon-web-links/lib/addon-web-links.js +2 -0
  23. package/node_modules/@xterm/addon-web-links/lib/addon-web-links.js.map +1 -0
  24. package/node_modules/@xterm/addon-web-links/lib/addon-web-links.mjs +18 -0
  25. package/node_modules/@xterm/addon-web-links/lib/addon-web-links.mjs.map +7 -0
  26. package/node_modules/@xterm/addon-web-links/package.json +26 -0
  27. package/node_modules/@xterm/addon-web-links/src/WebLinkProvider.ts +199 -0
  28. package/node_modules/@xterm/addon-web-links/src/WebLinksAddon.ts +58 -0
  29. package/node_modules/@xterm/addon-web-links/typings/addon-web-links.d.ts +57 -0
  30. package/node_modules/@xterm/xterm/LICENSE +21 -0
  31. package/node_modules/@xterm/xterm/README.md +243 -0
  32. package/node_modules/@xterm/xterm/css/xterm.css +285 -0
  33. package/node_modules/@xterm/xterm/lib/xterm.js +2 -0
  34. package/node_modules/@xterm/xterm/lib/xterm.js.map +1 -0
  35. package/node_modules/@xterm/xterm/lib/xterm.mjs +53 -0
  36. package/node_modules/@xterm/xterm/lib/xterm.mjs.map +7 -0
  37. package/node_modules/@xterm/xterm/package.json +111 -0
  38. package/node_modules/@xterm/xterm/src/browser/AccessibilityManager.ts +435 -0
  39. package/node_modules/@xterm/xterm/src/browser/Clipboard.ts +93 -0
  40. package/node_modules/@xterm/xterm/src/browser/ColorContrastCache.ts +34 -0
  41. package/node_modules/@xterm/xterm/src/browser/CoreBrowserTerminal.ts +1339 -0
  42. package/node_modules/@xterm/xterm/src/browser/Linkifier.ts +403 -0
  43. package/node_modules/@xterm/xterm/src/browser/LocalizableStrings.ts +23 -0
  44. package/node_modules/@xterm/xterm/src/browser/OscLinkProvider.ts +129 -0
  45. package/node_modules/@xterm/xterm/src/browser/RenderDebouncer.ts +84 -0
  46. package/node_modules/@xterm/xterm/src/browser/TimeBasedDebouncer.ts +86 -0
  47. package/node_modules/@xterm/xterm/src/browser/Types.ts +226 -0
  48. package/node_modules/@xterm/xterm/src/browser/Viewport.ts +192 -0
  49. package/node_modules/@xterm/xterm/src/browser/decorations/BufferDecorationRenderer.ts +139 -0
  50. package/node_modules/@xterm/xterm/src/browser/decorations/ColorZoneStore.ts +117 -0
  51. package/node_modules/@xterm/xterm/src/browser/decorations/OverviewRulerRenderer.ts +214 -0
  52. package/node_modules/@xterm/xterm/src/browser/input/CompositionHelper.ts +248 -0
  53. package/node_modules/@xterm/xterm/src/browser/input/Mouse.ts +54 -0
  54. package/node_modules/@xterm/xterm/src/browser/input/MoveToCell.ts +251 -0
  55. package/node_modules/@xterm/xterm/src/browser/public/Terminal.ts +275 -0
  56. package/node_modules/@xterm/xterm/src/browser/renderer/dom/DomRenderer.ts +542 -0
  57. package/node_modules/@xterm/xterm/src/browser/renderer/dom/DomRendererRowFactory.ts +546 -0
  58. package/node_modules/@xterm/xterm/src/browser/renderer/dom/WidthCache.ts +167 -0
  59. package/node_modules/@xterm/xterm/src/browser/renderer/shared/Constants.ts +6 -0
  60. package/node_modules/@xterm/xterm/src/browser/renderer/shared/RendererUtils.ts +95 -0
  61. package/node_modules/@xterm/xterm/src/browser/renderer/shared/SelectionRenderModel.ts +93 -0
  62. package/node_modules/@xterm/xterm/src/browser/renderer/shared/Types.ts +84 -0
  63. package/node_modules/@xterm/xterm/src/browser/selection/SelectionModel.ts +144 -0
  64. package/node_modules/@xterm/xterm/src/browser/selection/Types.ts +15 -0
  65. package/node_modules/@xterm/xterm/src/browser/services/CharSizeService.ts +127 -0
  66. package/node_modules/@xterm/xterm/src/browser/services/CharacterJoinerService.ts +339 -0
  67. package/node_modules/@xterm/xterm/src/browser/services/CoreBrowserService.ts +137 -0
  68. package/node_modules/@xterm/xterm/src/browser/services/LinkProviderService.ts +28 -0
  69. package/node_modules/@xterm/xterm/src/browser/services/MouseService.ts +46 -0
  70. package/node_modules/@xterm/xterm/src/browser/services/RenderService.ts +376 -0
  71. package/node_modules/@xterm/xterm/src/browser/services/SelectionService.ts +1039 -0
  72. package/node_modules/@xterm/xterm/src/browser/services/Services.ts +158 -0
  73. package/node_modules/@xterm/xterm/src/browser/services/ThemeService.ts +198 -0
  74. package/node_modules/@xterm/xterm/src/browser/shared/Constants.ts +8 -0
  75. package/node_modules/@xterm/xterm/src/common/CircularList.ts +241 -0
  76. package/node_modules/@xterm/xterm/src/common/Clone.ts +23 -0
  77. package/node_modules/@xterm/xterm/src/common/Color.ts +376 -0
  78. package/node_modules/@xterm/xterm/src/common/CoreTerminal.ts +283 -0
  79. package/node_modules/@xterm/xterm/src/common/InputHandler.ts +3495 -0
  80. package/node_modules/@xterm/xterm/src/common/MultiKeyMap.ts +42 -0
  81. package/node_modules/@xterm/xterm/src/common/Platform.ts +44 -0
  82. package/node_modules/@xterm/xterm/src/common/SortedList.ts +194 -0
  83. package/node_modules/@xterm/xterm/src/common/TaskQueue.ts +166 -0
  84. package/node_modules/@xterm/xterm/src/common/TypedArrayUtils.ts +17 -0
  85. package/node_modules/@xterm/xterm/src/common/Types.ts +552 -0
  86. package/node_modules/@xterm/xterm/src/common/WindowsMode.ts +27 -0
  87. package/node_modules/@xterm/xterm/src/common/buffer/AttributeData.ts +211 -0
  88. package/node_modules/@xterm/xterm/src/common/buffer/Buffer.ts +662 -0
  89. package/node_modules/@xterm/xterm/src/common/buffer/BufferLine.ts +551 -0
  90. package/node_modules/@xterm/xterm/src/common/buffer/BufferRange.ts +13 -0
  91. package/node_modules/@xterm/xterm/src/common/buffer/BufferReflow.ts +226 -0
  92. package/node_modules/@xterm/xterm/src/common/buffer/BufferSet.ts +134 -0
  93. package/node_modules/@xterm/xterm/src/common/buffer/CellData.ts +94 -0
  94. package/node_modules/@xterm/xterm/src/common/buffer/Constants.ts +157 -0
  95. package/node_modules/@xterm/xterm/src/common/buffer/Marker.ts +43 -0
  96. package/node_modules/@xterm/xterm/src/common/buffer/Types.ts +52 -0
  97. package/node_modules/@xterm/xterm/src/common/data/Charsets.ts +256 -0
  98. package/node_modules/@xterm/xterm/src/common/data/EscapeSequences.ts +153 -0
  99. package/node_modules/@xterm/xterm/src/common/input/Keyboard.ts +373 -0
  100. package/node_modules/@xterm/xterm/src/common/input/TextDecoder.ts +346 -0
  101. package/node_modules/@xterm/xterm/src/common/input/UnicodeV6.ts +145 -0
  102. package/node_modules/@xterm/xterm/src/common/input/WriteBuffer.ts +247 -0
  103. package/node_modules/@xterm/xterm/src/common/input/XParseColor.ts +80 -0
  104. package/node_modules/@xterm/xterm/src/common/parser/Constants.ts +58 -0
  105. package/node_modules/@xterm/xterm/src/common/parser/DcsParser.ts +192 -0
  106. package/node_modules/@xterm/xterm/src/common/parser/EscapeSequenceParser.ts +792 -0
  107. package/node_modules/@xterm/xterm/src/common/parser/OscParser.ts +238 -0
  108. package/node_modules/@xterm/xterm/src/common/parser/Params.ts +229 -0
  109. package/node_modules/@xterm/xterm/src/common/parser/Types.ts +275 -0
  110. package/node_modules/@xterm/xterm/src/common/public/AddonManager.ts +53 -0
  111. package/node_modules/@xterm/xterm/src/common/public/BufferApiView.ts +35 -0
  112. package/node_modules/@xterm/xterm/src/common/public/BufferLineApiView.ts +29 -0
  113. package/node_modules/@xterm/xterm/src/common/public/BufferNamespaceApi.ts +36 -0
  114. package/node_modules/@xterm/xterm/src/common/public/ParserApi.ts +37 -0
  115. package/node_modules/@xterm/xterm/src/common/public/UnicodeApi.ts +27 -0
  116. package/node_modules/@xterm/xterm/src/common/services/BufferService.ts +154 -0
  117. package/node_modules/@xterm/xterm/src/common/services/CharsetService.ts +34 -0
  118. package/node_modules/@xterm/xterm/src/common/services/CoreMouseService.ts +365 -0
  119. package/node_modules/@xterm/xterm/src/common/services/CoreService.ts +92 -0
  120. package/node_modules/@xterm/xterm/src/common/services/DecorationService.ts +140 -0
  121. package/node_modules/@xterm/xterm/src/common/services/InstantiationService.ts +85 -0
  122. package/node_modules/@xterm/xterm/src/common/services/LogService.ts +124 -0
  123. package/node_modules/@xterm/xterm/src/common/services/OptionsService.ts +212 -0
  124. package/node_modules/@xterm/xterm/src/common/services/OscLinkService.ts +115 -0
  125. package/node_modules/@xterm/xterm/src/common/services/ServiceRegistry.ts +49 -0
  126. package/node_modules/@xterm/xterm/src/common/services/Services.ts +396 -0
  127. package/node_modules/@xterm/xterm/src/common/services/UnicodeService.ts +111 -0
  128. package/node_modules/@xterm/xterm/src/vs/base/browser/browser.ts +141 -0
  129. package/node_modules/@xterm/xterm/src/vs/base/browser/canIUse.ts +49 -0
  130. package/node_modules/@xterm/xterm/src/vs/base/browser/dom.ts +2369 -0
  131. package/node_modules/@xterm/xterm/src/vs/base/browser/fastDomNode.ts +316 -0
  132. package/node_modules/@xterm/xterm/src/vs/base/browser/globalPointerMoveMonitor.ts +112 -0
  133. package/node_modules/@xterm/xterm/src/vs/base/browser/iframe.ts +135 -0
  134. package/node_modules/@xterm/xterm/src/vs/base/browser/keyboardEvent.ts +213 -0
  135. package/node_modules/@xterm/xterm/src/vs/base/browser/mouseEvent.ts +229 -0
  136. package/node_modules/@xterm/xterm/src/vs/base/browser/touch.ts +372 -0
  137. package/node_modules/@xterm/xterm/src/vs/base/browser/ui/scrollbar/abstractScrollbar.ts +303 -0
  138. package/node_modules/@xterm/xterm/src/vs/base/browser/ui/scrollbar/horizontalScrollbar.ts +114 -0
  139. package/node_modules/@xterm/xterm/src/vs/base/browser/ui/scrollbar/scrollableElement.ts +720 -0
  140. package/node_modules/@xterm/xterm/src/vs/base/browser/ui/scrollbar/scrollableElementOptions.ts +165 -0
  141. package/node_modules/@xterm/xterm/src/vs/base/browser/ui/scrollbar/scrollbarArrow.ts +114 -0
  142. package/node_modules/@xterm/xterm/src/vs/base/browser/ui/scrollbar/scrollbarState.ts +243 -0
  143. package/node_modules/@xterm/xterm/src/vs/base/browser/ui/scrollbar/scrollbarVisibilityController.ts +118 -0
  144. package/node_modules/@xterm/xterm/src/vs/base/browser/ui/scrollbar/verticalScrollbar.ts +116 -0
  145. package/node_modules/@xterm/xterm/src/vs/base/browser/ui/widget.ts +57 -0
  146. package/node_modules/@xterm/xterm/src/vs/base/browser/window.ts +14 -0
  147. package/node_modules/@xterm/xterm/src/vs/base/common/arrays.ts +887 -0
  148. package/node_modules/@xterm/xterm/src/vs/base/common/arraysFind.ts +202 -0
  149. package/node_modules/@xterm/xterm/src/vs/base/common/assert.ts +71 -0
  150. package/node_modules/@xterm/xterm/src/vs/base/common/async.ts +1992 -0
  151. package/node_modules/@xterm/xterm/src/vs/base/common/cancellation.ts +148 -0
  152. package/node_modules/@xterm/xterm/src/vs/base/common/charCode.ts +450 -0
  153. package/node_modules/@xterm/xterm/src/vs/base/common/collections.ts +140 -0
  154. package/node_modules/@xterm/xterm/src/vs/base/common/decorators.ts +130 -0
  155. package/node_modules/@xterm/xterm/src/vs/base/common/equals.ts +146 -0
  156. package/node_modules/@xterm/xterm/src/vs/base/common/errors.ts +303 -0
  157. package/node_modules/@xterm/xterm/src/vs/base/common/event.ts +1778 -0
  158. package/node_modules/@xterm/xterm/src/vs/base/common/functional.ts +32 -0
  159. package/node_modules/@xterm/xterm/src/vs/base/common/hash.ts +316 -0
  160. package/node_modules/@xterm/xterm/src/vs/base/common/iterator.ts +159 -0
  161. package/node_modules/@xterm/xterm/src/vs/base/common/keyCodes.ts +526 -0
  162. package/node_modules/@xterm/xterm/src/vs/base/common/keybindings.ts +284 -0
  163. package/node_modules/@xterm/xterm/src/vs/base/common/lazy.ts +47 -0
  164. package/node_modules/@xterm/xterm/src/vs/base/common/lifecycle.ts +801 -0
  165. package/node_modules/@xterm/xterm/src/vs/base/common/linkedList.ts +142 -0
  166. package/node_modules/@xterm/xterm/src/vs/base/common/map.ts +202 -0
  167. package/node_modules/@xterm/xterm/src/vs/base/common/numbers.ts +98 -0
  168. package/node_modules/@xterm/xterm/src/vs/base/common/observable.ts +76 -0
  169. package/node_modules/@xterm/xterm/src/vs/base/common/observableInternal/api.ts +31 -0
  170. package/node_modules/@xterm/xterm/src/vs/base/common/observableInternal/autorun.ts +281 -0
  171. package/node_modules/@xterm/xterm/src/vs/base/common/observableInternal/base.ts +489 -0
  172. package/node_modules/@xterm/xterm/src/vs/base/common/observableInternal/debugName.ts +145 -0
  173. package/node_modules/@xterm/xterm/src/vs/base/common/observableInternal/derived.ts +428 -0
  174. package/node_modules/@xterm/xterm/src/vs/base/common/observableInternal/lazyObservableValue.ts +146 -0
  175. package/node_modules/@xterm/xterm/src/vs/base/common/observableInternal/logging.ts +328 -0
  176. package/node_modules/@xterm/xterm/src/vs/base/common/observableInternal/promise.ts +209 -0
  177. package/node_modules/@xterm/xterm/src/vs/base/common/observableInternal/utils.ts +610 -0
  178. package/node_modules/@xterm/xterm/src/vs/base/common/platform.ts +281 -0
  179. package/node_modules/@xterm/xterm/src/vs/base/common/scrollable.ts +522 -0
  180. package/node_modules/@xterm/xterm/src/vs/base/common/sequence.ts +34 -0
  181. package/node_modules/@xterm/xterm/src/vs/base/common/stopwatch.ts +43 -0
  182. package/node_modules/@xterm/xterm/src/vs/base/common/strings.ts +557 -0
  183. package/node_modules/@xterm/xterm/src/vs/base/common/symbols.ts +9 -0
  184. package/node_modules/@xterm/xterm/src/vs/base/common/uint.ts +59 -0
  185. package/node_modules/@xterm/xterm/src/vs/patches/nls.ts +90 -0
  186. package/node_modules/@xterm/xterm/src/vs/typings/base-common.d.ts +20 -0
  187. package/node_modules/@xterm/xterm/src/vs/typings/require.d.ts +42 -0
  188. package/node_modules/@xterm/xterm/src/vs/typings/vscode-globals-nls.d.ts +36 -0
  189. package/node_modules/@xterm/xterm/src/vs/typings/vscode-globals-product.d.ts +33 -0
  190. package/node_modules/@xterm/xterm/typings/xterm.d.ts +1957 -0
  191. package/package.json +1 -1
  192. package/packages/daemon/src/index.js +25 -7
  193. package/packages/daemon/src/terminal-pty.js +141 -0
  194. package/packages/gui/dist/assets/{index-Gfb8Zxy9.css → index-BhjOFLBc.css} +32 -1
  195. package/packages/gui/dist/assets/index-CFeltwTB.js +153 -0
  196. package/packages/gui/dist/index.html +2 -2
  197. package/packages/gui/package.json +3 -0
  198. package/packages/gui/src/components/EditorTabs.jsx +3 -3
  199. package/packages/gui/src/components/FileTree.jsx +18 -22
  200. package/packages/gui/src/components/Terminal.jsx +154 -0
  201. package/packages/gui/src/views/FileEditor.jsx +100 -39
  202. package/node_modules/@groove-dev/gui/dist/assets/index-BQSznoq0.js +0 -103
  203. package/packages/gui/dist/assets/index-BQSznoq0.js +0 -103
@@ -0,0 +1,376 @@
1
+ /**
2
+ * Copyright (c) 2019 The xterm.js authors. All rights reserved.
3
+ * @license MIT
4
+ */
5
+
6
+ import { IColor, IColorRGB } from 'common/Types';
7
+
8
+ let $r = 0;
9
+ let $g = 0;
10
+ let $b = 0;
11
+ let $a = 0;
12
+
13
+ export const NULL_COLOR: IColor = {
14
+ css: '#00000000',
15
+ rgba: 0
16
+ };
17
+
18
+ /**
19
+ * Helper functions where the source type is "channels" (individual color channels as numbers).
20
+ */
21
+ export namespace channels {
22
+ export function toCss(r: number, g: number, b: number, a?: number): string {
23
+ if (a !== undefined) {
24
+ return `#${toPaddedHex(r)}${toPaddedHex(g)}${toPaddedHex(b)}${toPaddedHex(a)}`;
25
+ }
26
+ return `#${toPaddedHex(r)}${toPaddedHex(g)}${toPaddedHex(b)}`;
27
+ }
28
+
29
+ export function toRgba(r: number, g: number, b: number, a: number = 0xFF): number {
30
+ // Note: The aggregated number is RGBA32 (BE), thus needs to be converted to ABGR32
31
+ // on LE systems, before it can be used for direct 32-bit buffer writes.
32
+ // >>> 0 forces an unsigned int
33
+ return (r << 24 | g << 16 | b << 8 | a) >>> 0;
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
+ }
42
+ }
43
+
44
+ /**
45
+ * Helper functions where the source type is `IColor`.
46
+ */
47
+ export namespace color {
48
+ export function blend(bg: IColor, fg: IColor): IColor {
49
+ $a = (fg.rgba & 0xFF) / 255;
50
+ if ($a === 1) {
51
+ return {
52
+ css: fg.css,
53
+ rgba: fg.rgba
54
+ };
55
+ }
56
+ const fgR = (fg.rgba >> 24) & 0xFF;
57
+ const fgG = (fg.rgba >> 16) & 0xFF;
58
+ const fgB = (fg.rgba >> 8) & 0xFF;
59
+ const bgR = (bg.rgba >> 24) & 0xFF;
60
+ const bgG = (bg.rgba >> 16) & 0xFF;
61
+ const bgB = (bg.rgba >> 8) & 0xFF;
62
+ $r = bgR + Math.round((fgR - bgR) * $a);
63
+ $g = bgG + Math.round((fgG - bgG) * $a);
64
+ $b = bgB + Math.round((fgB - bgB) * $a);
65
+ const css = channels.toCss($r, $g, $b);
66
+ const rgba = channels.toRgba($r, $g, $b);
67
+ return { css, rgba };
68
+ }
69
+
70
+ export function isOpaque(color: IColor): boolean {
71
+ return (color.rgba & 0xFF) === 0xFF;
72
+ }
73
+
74
+ export function ensureContrastRatio(bg: IColor, fg: IColor, ratio: number): IColor | undefined {
75
+ const result = rgba.ensureContrastRatio(bg.rgba, fg.rgba, ratio);
76
+ if (!result) {
77
+ return undefined;
78
+ }
79
+ return channels.toColor(
80
+ (result >> 24 & 0xFF),
81
+ (result >> 16 & 0xFF),
82
+ (result >> 8 & 0xFF)
83
+ );
84
+ }
85
+
86
+ export function opaque(color: IColor): IColor {
87
+ const rgbaColor = (color.rgba | 0xFF) >>> 0;
88
+ [$r, $g, $b] = rgba.toChannels(rgbaColor);
89
+ return {
90
+ css: channels.toCss($r, $g, $b),
91
+ rgba: rgbaColor
92
+ };
93
+ }
94
+
95
+ export function opacity(color: IColor, opacity: number): IColor {
96
+ $a = Math.round(opacity * 0xFF);
97
+ [$r, $g, $b] = rgba.toChannels(color.rgba);
98
+ return {
99
+ css: channels.toCss($r, $g, $b, $a),
100
+ rgba: channels.toRgba($r, $g, $b, $a)
101
+ };
102
+ }
103
+
104
+ export function multiplyOpacity(color: IColor, factor: number): IColor {
105
+ $a = color.rgba & 0xFF;
106
+ return opacity(color, ($a * factor) / 0xFF);
107
+ }
108
+
109
+ export function toColorRGB(color: IColor): IColorRGB {
110
+ return [(color.rgba >> 24) & 0xFF, (color.rgba >> 16) & 0xFF, (color.rgba >> 8) & 0xFF];
111
+ }
112
+ }
113
+
114
+ /**
115
+ * Helper functions where the source type is "css" (string: '#rgb', '#rgba', '#rrggbb',
116
+ * '#rrggbbaa').
117
+ */
118
+ export namespace css {
119
+ // Attempt to set get the shared canvas context
120
+ let $ctx: CanvasRenderingContext2D | undefined;
121
+ let $litmusColor: CanvasGradient | undefined;
122
+ try {
123
+ // This is guaranteed to run in the first window, so document should be correct
124
+ const canvas = document.createElement('canvas');
125
+ canvas.width = 1;
126
+ canvas.height = 1;
127
+ const ctx = canvas.getContext('2d', {
128
+ willReadFrequently: true
129
+ });
130
+ if (ctx) {
131
+ $ctx = ctx;
132
+ $ctx.globalCompositeOperation = 'copy';
133
+ $litmusColor = $ctx.createLinearGradient(0, 0, 1, 1);
134
+ }
135
+ }
136
+ catch {
137
+ // noop
138
+ }
139
+
140
+ /**
141
+ * Converts a css string to an IColor, this should handle all valid CSS color strings and will
142
+ * throw if it's invalid. The ideal format to use is `#rrggbb[aa]` as it's the fastest to parse.
143
+ *
144
+ * Only `#rgb[a]`, `#rrggbb[aa]`, `rgb()` and `rgba()` formats are supported when run in a Node
145
+ * environment.
146
+ */
147
+ export function toColor(css: string): IColor {
148
+ // Formats: #rgb[a] and #rrggbb[aa]
149
+ if (css.match(/#[\da-f]{3,8}/i)) {
150
+ switch (css.length) {
151
+ case 4: { // #rgb
152
+ $r = parseInt(css.slice(1, 2).repeat(2), 16);
153
+ $g = parseInt(css.slice(2, 3).repeat(2), 16);
154
+ $b = parseInt(css.slice(3, 4).repeat(2), 16);
155
+ return channels.toColor($r, $g, $b);
156
+ }
157
+ case 5: { // #rgba
158
+ $r = parseInt(css.slice(1, 2).repeat(2), 16);
159
+ $g = parseInt(css.slice(2, 3).repeat(2), 16);
160
+ $b = parseInt(css.slice(3, 4).repeat(2), 16);
161
+ $a = parseInt(css.slice(4, 5).repeat(2), 16);
162
+ return channels.toColor($r, $g, $b, $a);
163
+ }
164
+ case 7: // #rrggbb
165
+ return {
166
+ css,
167
+ rgba: (parseInt(css.slice(1), 16) << 8 | 0xFF) >>> 0
168
+ };
169
+ case 9: // #rrggbbaa
170
+ return {
171
+ css,
172
+ rgba: parseInt(css.slice(1), 16) >>> 0
173
+ };
174
+ }
175
+ }
176
+
177
+ // Formats: rgb() or rgba()
178
+ const rgbaMatch = css.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);
179
+ if (rgbaMatch) {
180
+ $r = parseInt(rgbaMatch[1]);
181
+ $g = parseInt(rgbaMatch[2]);
182
+ $b = parseInt(rgbaMatch[3]);
183
+ $a = Math.round((rgbaMatch[5] === undefined ? 1 : parseFloat(rgbaMatch[5])) * 0xFF);
184
+ return channels.toColor($r, $g, $b, $a);
185
+ }
186
+
187
+ // Validate the context is available for canvas-based color parsing
188
+ if (!$ctx || !$litmusColor) {
189
+ throw new Error('css.toColor: Unsupported css format');
190
+ }
191
+
192
+ // Validate the color using canvas fillStyle
193
+ // See https://html.spec.whatwg.org/multipage/canvas.html#fill-and-stroke-styles
194
+ $ctx.fillStyle = $litmusColor;
195
+ $ctx.fillStyle = css;
196
+ if (typeof $ctx.fillStyle !== 'string') {
197
+ throw new Error('css.toColor: Unsupported css format');
198
+ }
199
+
200
+ $ctx.fillRect(0, 0, 1, 1);
201
+ [$r, $g, $b, $a] = $ctx.getImageData(0, 0, 1, 1).data;
202
+
203
+ // Validate the color is non-transparent as color hue gets lost when drawn to the canvas
204
+ if ($a !== 0xFF) {
205
+ throw new Error('css.toColor: Unsupported css format');
206
+ }
207
+
208
+ // Extract the color from the canvas' fillStyle property which exposes the color value in rgba()
209
+ // format
210
+ // See https://html.spec.whatwg.org/multipage/canvas.html#serialisation-of-a-color
211
+ return {
212
+ rgba: channels.toRgba($r, $g, $b, $a),
213
+ css
214
+ };
215
+ }
216
+ }
217
+
218
+ /**
219
+ * Helper functions where the source type is "rgb" (number: 0xrrggbb).
220
+ */
221
+ export namespace rgb {
222
+ /**
223
+ * Gets the relative luminance of an RGB color, this is useful in determining the contrast ratio
224
+ * between two colors.
225
+ * @param rgb The color to use.
226
+ * @see https://www.w3.org/TR/WCAG20/#relativeluminancedef
227
+ */
228
+ export function relativeLuminance(rgb: number): number {
229
+ return relativeLuminance2(
230
+ (rgb >> 16) & 0xFF,
231
+ (rgb >> 8 ) & 0xFF,
232
+ (rgb ) & 0xFF);
233
+ }
234
+
235
+ /**
236
+ * Gets the relative luminance of an RGB color, this is useful in determining the contrast ratio
237
+ * between two colors.
238
+ * @param r The red channel (0x00 to 0xFF).
239
+ * @param g The green channel (0x00 to 0xFF).
240
+ * @param b The blue channel (0x00 to 0xFF).
241
+ * @see https://www.w3.org/TR/WCAG20/#relativeluminancedef
242
+ */
243
+ export function relativeLuminance2(r: number, g: number, b: number): number {
244
+ const rs = r / 255;
245
+ const gs = g / 255;
246
+ const bs = b / 255;
247
+ const rr = rs <= 0.03928 ? rs / 12.92 : Math.pow((rs + 0.055) / 1.055, 2.4);
248
+ const rg = gs <= 0.03928 ? gs / 12.92 : Math.pow((gs + 0.055) / 1.055, 2.4);
249
+ const rb = bs <= 0.03928 ? bs / 12.92 : Math.pow((bs + 0.055) / 1.055, 2.4);
250
+ return rr * 0.2126 + rg * 0.7152 + rb * 0.0722;
251
+ }
252
+ }
253
+
254
+ /**
255
+ * Helper functions where the source type is "rgba" (number: 0xrrggbbaa).
256
+ */
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
+
275
+ /**
276
+ * Given a foreground color and a background color, either increase or reduce the luminance of the
277
+ * foreground color until the specified contrast ratio is met. If pure white or black is hit
278
+ * without the contrast ratio being met, go the other direction using the background color as the
279
+ * foreground color and take either the first or second result depending on which has the higher
280
+ * contrast ratio.
281
+ *
282
+ * `undefined` will be returned if the contrast ratio is already met.
283
+ *
284
+ * @param bgRgba The background color in rgba format.
285
+ * @param fgRgba The foreground color in rgba format.
286
+ * @param ratio The contrast ratio to achieve.
287
+ */
288
+ export function ensureContrastRatio(bgRgba: number, fgRgba: number, ratio: number): number | undefined {
289
+ const bgL = rgb.relativeLuminance(bgRgba >> 8);
290
+ const fgL = rgb.relativeLuminance(fgRgba >> 8);
291
+ const cr = contrastRatio(bgL, fgL);
292
+ if (cr < ratio) {
293
+ if (fgL < bgL) {
294
+ const resultA = reduceLuminance(bgRgba, fgRgba, ratio);
295
+ const resultARatio = contrastRatio(bgL, rgb.relativeLuminance(resultA >> 8));
296
+ if (resultARatio < ratio) {
297
+ const resultB = increaseLuminance(bgRgba, fgRgba, ratio);
298
+ const resultBRatio = contrastRatio(bgL, rgb.relativeLuminance(resultB >> 8));
299
+ return resultARatio > resultBRatio ? resultA : resultB;
300
+ }
301
+ return resultA;
302
+ }
303
+ const resultA = increaseLuminance(bgRgba, fgRgba, ratio);
304
+ const resultARatio = contrastRatio(bgL, rgb.relativeLuminance(resultA >> 8));
305
+ if (resultARatio < ratio) {
306
+ const resultB = reduceLuminance(bgRgba, fgRgba, ratio);
307
+ const resultBRatio = contrastRatio(bgL, rgb.relativeLuminance(resultB >> 8));
308
+ return resultARatio > resultBRatio ? resultA : resultB;
309
+ }
310
+ return resultA;
311
+ }
312
+ return undefined;
313
+ }
314
+
315
+ export function reduceLuminance(bgRgba: number, fgRgba: number, ratio: number): number {
316
+ // This is a naive but fast approach to reducing luminance as converting to
317
+ // HSL and back is expensive
318
+ const bgR = (bgRgba >> 24) & 0xFF;
319
+ const bgG = (bgRgba >> 16) & 0xFF;
320
+ const bgB = (bgRgba >> 8) & 0xFF;
321
+ let fgR = (fgRgba >> 24) & 0xFF;
322
+ let fgG = (fgRgba >> 16) & 0xFF;
323
+ let fgB = (fgRgba >> 8) & 0xFF;
324
+ let cr = contrastRatio(rgb.relativeLuminance2(fgR, fgG, fgB), rgb.relativeLuminance2(bgR, bgG, bgB));
325
+ while (cr < ratio && (fgR > 0 || fgG > 0 || fgB > 0)) {
326
+ // Reduce by 10% until the ratio is hit
327
+ fgR -= Math.max(0, Math.ceil(fgR * 0.1));
328
+ fgG -= Math.max(0, Math.ceil(fgG * 0.1));
329
+ fgB -= Math.max(0, Math.ceil(fgB * 0.1));
330
+ cr = contrastRatio(rgb.relativeLuminance2(fgR, fgG, fgB), rgb.relativeLuminance2(bgR, bgG, bgB));
331
+ }
332
+ return (fgR << 24 | fgG << 16 | fgB << 8 | 0xFF) >>> 0;
333
+ }
334
+
335
+ export function increaseLuminance(bgRgba: number, fgRgba: number, ratio: number): number {
336
+ // This is a naive but fast approach to increasing luminance as converting to
337
+ // HSL and back is expensive
338
+ const bgR = (bgRgba >> 24) & 0xFF;
339
+ const bgG = (bgRgba >> 16) & 0xFF;
340
+ const bgB = (bgRgba >> 8) & 0xFF;
341
+ let fgR = (fgRgba >> 24) & 0xFF;
342
+ let fgG = (fgRgba >> 16) & 0xFF;
343
+ let fgB = (fgRgba >> 8) & 0xFF;
344
+ let cr = contrastRatio(rgb.relativeLuminance2(fgR, fgG, fgB), rgb.relativeLuminance2(bgR, bgG, bgB));
345
+ while (cr < ratio && (fgR < 0xFF || fgG < 0xFF || fgB < 0xFF)) {
346
+ // Increase by 10% until the ratio is hit
347
+ fgR = Math.min(0xFF, fgR + Math.ceil((255 - fgR) * 0.1));
348
+ fgG = Math.min(0xFF, fgG + Math.ceil((255 - fgG) * 0.1));
349
+ fgB = Math.min(0xFF, fgB + Math.ceil((255 - fgB) * 0.1));
350
+ cr = contrastRatio(rgb.relativeLuminance2(fgR, fgG, fgB), rgb.relativeLuminance2(bgR, bgG, bgB));
351
+ }
352
+ return (fgR << 24 | fgG << 16 | fgB << 8 | 0xFF) >>> 0;
353
+ }
354
+
355
+ export function toChannels(value: number): [number, number, number, number] {
356
+ return [(value >> 24) & 0xFF, (value >> 16) & 0xFF, (value >> 8) & 0xFF, value & 0xFF];
357
+ }
358
+ }
359
+
360
+ export function toPaddedHex(c: number): string {
361
+ const s = c.toString(16);
362
+ return s.length < 2 ? '0' + s : s;
363
+ }
364
+
365
+ /**
366
+ * Gets the contrast ratio between two relative luminance values.
367
+ * @param l1 The first relative luminance.
368
+ * @param l2 The first relative luminance.
369
+ * @see https://www.w3.org/TR/WCAG20/#contrast-ratiodef
370
+ */
371
+ export function contrastRatio(l1: number, l2: number): number {
372
+ if (l1 < l2) {
373
+ return (l2 + 0.05) / (l1 + 0.05);
374
+ }
375
+ return (l1 + 0.05) / (l2 + 0.05);
376
+ }
@@ -0,0 +1,283 @@
1
+ /**
2
+ * Copyright (c) 2014-2020 The xterm.js authors. All rights reserved.
3
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
4
+ * @license MIT
5
+ *
6
+ * Originally forked from (with the author's permission):
7
+ * Fabrice Bellard's javascript vt100 for jslinux:
8
+ * http://bellard.org/jslinux/
9
+ * Copyright (c) 2011 Fabrice Bellard
10
+ * The original design remains. The terminal itself
11
+ * has been extended to include xterm CSI codes, among
12
+ * other features.
13
+ *
14
+ * Terminal Emulation References:
15
+ * http://vt100.net/
16
+ * http://invisible-island.net/xterm/ctlseqs/ctlseqs.txt
17
+ * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
18
+ * http://invisible-island.net/vttest/
19
+ * http://www.inwap.com/pdp10/ansicode.txt
20
+ * http://linux.die.net/man/4/console_codes
21
+ * http://linux.die.net/man/7/urxvt
22
+ */
23
+
24
+ import { IInstantiationService, IOptionsService, IBufferService, ILogService, ICharsetService, ICoreService, ICoreMouseService, IUnicodeService, LogLevelEnum, ITerminalOptions, IOscLinkService } from 'common/services/Services';
25
+ import { InstantiationService } from 'common/services/InstantiationService';
26
+ import { LogService } from 'common/services/LogService';
27
+ import { BufferService, MINIMUM_COLS, MINIMUM_ROWS } from 'common/services/BufferService';
28
+ import { OptionsService } from 'common/services/OptionsService';
29
+ import { IDisposable, IAttributeData, ICoreTerminal, IScrollEvent } from 'common/Types';
30
+ import { CoreService } from 'common/services/CoreService';
31
+ import { CoreMouseService } from 'common/services/CoreMouseService';
32
+ import { UnicodeService } from 'common/services/UnicodeService';
33
+ import { CharsetService } from 'common/services/CharsetService';
34
+ import { updateWindowsModeWrappedState } from 'common/WindowsMode';
35
+ import { IFunctionIdentifier, IParams } from 'common/parser/Types';
36
+ import { IBufferSet } from 'common/buffer/Types';
37
+ import { InputHandler } from 'common/InputHandler';
38
+ import { WriteBuffer } from 'common/input/WriteBuffer';
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
+
43
+ // Only trigger this warning a single time per session
44
+ let hasWriteSyncWarnHappened = false;
45
+
46
+ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
47
+ protected readonly _instantiationService: IInstantiationService;
48
+ protected readonly _bufferService: IBufferService;
49
+ protected readonly _logService: ILogService;
50
+ protected readonly _charsetService: ICharsetService;
51
+ protected readonly _oscLinkService: IOscLinkService;
52
+
53
+ public readonly coreMouseService: ICoreMouseService;
54
+ public readonly coreService: ICoreService;
55
+ public readonly unicodeService: IUnicodeService;
56
+ public readonly optionsService: IOptionsService;
57
+
58
+ protected _inputHandler: InputHandler;
59
+ private _writeBuffer: WriteBuffer;
60
+ private _windowsWrappingHeuristics = this._register(new MutableDisposable());
61
+
62
+ private readonly _onBinary = this._register(new Emitter<string>());
63
+ public readonly onBinary = this._onBinary.event;
64
+ private readonly _onData = this._register(new Emitter<string>());
65
+ public readonly onData = this._onData.event;
66
+ protected _onLineFeed = this._register(new Emitter<void>());
67
+ public readonly onLineFeed = this._onLineFeed.event;
68
+ private readonly _onResize = this._register(new Emitter<{ cols: number, rows: number }>());
69
+ public readonly onResize = this._onResize.event;
70
+ protected readonly _onWriteParsed = this._register(new Emitter<void>());
71
+ public readonly onWriteParsed = this._onWriteParsed.event;
72
+
73
+ /**
74
+ * Internally we track the source of the scroll but this is meaningless outside the library so
75
+ * it's filtered out.
76
+ */
77
+ protected _onScrollApi?: Emitter<number>;
78
+ protected _onScroll = this._register(new Emitter<IScrollEvent>());
79
+ public get onScroll(): Event<number> {
80
+ if (!this._onScrollApi) {
81
+ this._onScrollApi = this._register(new Emitter<number>());
82
+ this._onScroll.event(ev => {
83
+ this._onScrollApi?.fire(ev.position);
84
+ });
85
+ }
86
+ return this._onScrollApi.event;
87
+ }
88
+
89
+ public get cols(): number { return this._bufferService.cols; }
90
+ public get rows(): number { return this._bufferService.rows; }
91
+ public get buffers(): IBufferSet { return this._bufferService.buffers; }
92
+ public get options(): Required<ITerminalOptions> { return this.optionsService.options; }
93
+ public set options(options: ITerminalOptions) {
94
+ for (const key in options) {
95
+ this.optionsService.options[key] = options[key];
96
+ }
97
+ }
98
+
99
+ constructor(
100
+ options: Partial<ITerminalOptions>
101
+ ) {
102
+ super();
103
+
104
+ // Setup and initialize services
105
+ this._instantiationService = new InstantiationService();
106
+ this.optionsService = this._register(new OptionsService(options));
107
+ this._instantiationService.setService(IOptionsService, this.optionsService);
108
+ this._bufferService = this._register(this._instantiationService.createInstance(BufferService));
109
+ this._instantiationService.setService(IBufferService, this._bufferService);
110
+ this._logService = this._register(this._instantiationService.createInstance(LogService));
111
+ this._instantiationService.setService(ILogService, this._logService);
112
+ this.coreService = this._register(this._instantiationService.createInstance(CoreService));
113
+ this._instantiationService.setService(ICoreService, this.coreService);
114
+ this.coreMouseService = this._register(this._instantiationService.createInstance(CoreMouseService));
115
+ this._instantiationService.setService(ICoreMouseService, this.coreMouseService);
116
+ this.unicodeService = this._register(this._instantiationService.createInstance(UnicodeService));
117
+ this._instantiationService.setService(IUnicodeService, this.unicodeService);
118
+ this._charsetService = this._instantiationService.createInstance(CharsetService);
119
+ this._instantiationService.setService(ICharsetService, this._charsetService);
120
+ this._oscLinkService = this._instantiationService.createInstance(OscLinkService);
121
+ this._instantiationService.setService(IOscLinkService, this._oscLinkService);
122
+
123
+
124
+ // Register input handler and handle/forward events
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);
128
+
129
+ // Setup listeners
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 });
138
+ this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop, this._bufferService.buffer.scrollBottom);
139
+ }));
140
+ // Setup WriteBuffer
141
+ this._writeBuffer = this._register(new WriteBuffer((data, promiseResult) => this._inputHandler.parse(data, promiseResult)));
142
+ this._register(Event.forward(this._writeBuffer.onWriteParsed, this._onWriteParsed));
143
+ }
144
+
145
+ public write(data: string | Uint8Array, callback?: () => void): void {
146
+ this._writeBuffer.write(data, callback);
147
+ }
148
+
149
+ /**
150
+ * Write data to terminal synchonously.
151
+ *
152
+ * This method is unreliable with async parser handlers, thus should not
153
+ * be used anymore. If you need blocking semantics on data input consider
154
+ * `write` with a callback instead.
155
+ *
156
+ * @deprecated Unreliable, will be removed soon.
157
+ */
158
+ public writeSync(data: string | Uint8Array, maxSubsequentCalls?: number): void {
159
+ if (this._logService.logLevel <= LogLevelEnum.WARN && !hasWriteSyncWarnHappened) {
160
+ this._logService.warn('writeSync is unreliable and will be removed soon.');
161
+ hasWriteSyncWarnHappened = true;
162
+ }
163
+ this._writeBuffer.writeSync(data, maxSubsequentCalls);
164
+ }
165
+
166
+ public input(data: string, wasUserInput: boolean = true): void {
167
+ this.coreService.triggerDataEvent(data, wasUserInput);
168
+ }
169
+
170
+ public resize(x: number, y: number): void {
171
+ if (isNaN(x) || isNaN(y)) {
172
+ return;
173
+ }
174
+
175
+ x = Math.max(x, MINIMUM_COLS);
176
+ y = Math.max(y, MINIMUM_ROWS);
177
+
178
+ this._bufferService.resize(x, y);
179
+ }
180
+
181
+ /**
182
+ * Scroll the terminal down 1 row, creating a blank line.
183
+ * @param eraseAttr The attribute data to use the for blank line.
184
+ * @param isWrapped Whether the new line is wrapped from the previous line.
185
+ */
186
+ public scroll(eraseAttr: IAttributeData, isWrapped: boolean = false): void {
187
+ this._bufferService.scroll(eraseAttr, isWrapped);
188
+ }
189
+
190
+ /**
191
+ * Scroll the display of the terminal
192
+ * @param disp The number of lines to scroll down (negative scroll up).
193
+ * @param suppressScrollEvent Don't emit the scroll event as scrollLines. This is used to avoid
194
+ * unwanted events being handled by the viewport when the event was triggered from the viewport
195
+ * originally.
196
+ */
197
+ public scrollLines(disp: number, suppressScrollEvent?: boolean): void {
198
+ this._bufferService.scrollLines(disp, suppressScrollEvent);
199
+ }
200
+
201
+ public scrollPages(pageCount: number): void {
202
+ this.scrollLines(pageCount * (this.rows - 1));
203
+ }
204
+
205
+ public scrollToTop(): void {
206
+ this.scrollLines(-this._bufferService.buffer.ydisp);
207
+ }
208
+
209
+ public scrollToBottom(disableSmoothScroll?: boolean): void {
210
+ this.scrollLines(this._bufferService.buffer.ybase - this._bufferService.buffer.ydisp);
211
+ }
212
+
213
+ public scrollToLine(line: number): void {
214
+ const scrollAmount = line - this._bufferService.buffer.ydisp;
215
+ if (scrollAmount !== 0) {
216
+ this.scrollLines(scrollAmount);
217
+ }
218
+ }
219
+
220
+ /** Add handler for ESC escape sequence. See xterm.d.ts for details. */
221
+ public registerEscHandler(id: IFunctionIdentifier, callback: () => boolean | Promise<boolean>): IDisposable {
222
+ return this._inputHandler.registerEscHandler(id, callback);
223
+ }
224
+
225
+ /** Add handler for DCS escape sequence. See xterm.d.ts for details. */
226
+ public registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean | Promise<boolean>): IDisposable {
227
+ return this._inputHandler.registerDcsHandler(id, callback);
228
+ }
229
+
230
+ /** Add handler for CSI escape sequence. See xterm.d.ts for details. */
231
+ public registerCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean | Promise<boolean>): IDisposable {
232
+ return this._inputHandler.registerCsiHandler(id, callback);
233
+ }
234
+
235
+ /** Add handler for OSC escape sequence. See xterm.d.ts for details. */
236
+ public registerOscHandler(ident: number, callback: (data: string) => boolean | Promise<boolean>): IDisposable {
237
+ return this._inputHandler.registerOscHandler(ident, callback);
238
+ }
239
+
240
+ protected _setup(): void {
241
+ this._handleWindowsPtyOptionChange();
242
+ }
243
+
244
+ public reset(): void {
245
+ this._inputHandler.reset();
246
+ this._bufferService.reset();
247
+ this._charsetService.reset();
248
+ this.coreService.reset();
249
+ this.coreMouseService.reset();
250
+ }
251
+
252
+
253
+ private _handleWindowsPtyOptionChange(): void {
254
+ let value = false;
255
+ const windowsPty = this.optionsService.rawOptions.windowsPty;
256
+ if (windowsPty && windowsPty.buildNumber !== undefined && windowsPty.buildNumber !== undefined) {
257
+ value = !!(windowsPty.backend === 'conpty' && windowsPty.buildNumber < 21376);
258
+ } else if (this.optionsService.rawOptions.windowsMode) {
259
+ value = true;
260
+ }
261
+ if (value) {
262
+ this._enableWindowsWrappingHeuristics();
263
+ } else {
264
+ this._windowsWrappingHeuristics.clear();
265
+ }
266
+ }
267
+
268
+ protected _enableWindowsWrappingHeuristics(): void {
269
+ if (!this._windowsWrappingHeuristics.value) {
270
+ const disposables: IDisposable[] = [];
271
+ disposables.push(this.onLineFeed(updateWindowsModeWrappedState.bind(null, this._bufferService)));
272
+ disposables.push(this.registerCsiHandler({ final: 'H' }, () => {
273
+ updateWindowsModeWrappedState(this._bufferService);
274
+ return false;
275
+ }));
276
+ this._windowsWrappingHeuristics.value = toDisposable(() => {
277
+ for (const d of disposables) {
278
+ d.dispose();
279
+ }
280
+ });
281
+ }
282
+ }
283
+ }