@wendongfly/myhi 1.0.2 → 1.0.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 (135) hide show
  1. package/dist/index.js +1 -1
  2. package/dist/lib/xterm/LICENSE +21 -0
  3. package/dist/lib/xterm/README.md +225 -0
  4. package/dist/lib/xterm/css/xterm.css +190 -0
  5. package/dist/lib/xterm/lib/xterm.js +2 -0
  6. package/dist/lib/xterm/lib/xterm.js.map +1 -0
  7. package/dist/lib/xterm/package.json +90 -0
  8. package/dist/lib/xterm/src/browser/AccessibilityManager.ts +301 -0
  9. package/dist/lib/xterm/src/browser/Clipboard.ts +99 -0
  10. package/dist/lib/xterm/src/browser/ColorContrastCache.ts +39 -0
  11. package/dist/lib/xterm/src/browser/ColorManager.ts +268 -0
  12. package/dist/lib/xterm/src/browser/Dom.ts +10 -0
  13. package/dist/lib/xterm/src/browser/Lifecycle.ts +30 -0
  14. package/dist/lib/xterm/src/browser/Linkifier.ts +356 -0
  15. package/dist/lib/xterm/src/browser/Linkifier2.ts +397 -0
  16. package/dist/lib/xterm/src/browser/LocalizableStrings.ts +10 -0
  17. package/dist/lib/xterm/src/browser/MouseZoneManager.ts +236 -0
  18. package/dist/lib/xterm/src/browser/RenderDebouncer.ts +82 -0
  19. package/dist/lib/xterm/src/browser/ScreenDprMonitor.ts +69 -0
  20. package/dist/lib/xterm/src/browser/Terminal.ts +1447 -0
  21. package/dist/lib/xterm/src/browser/TimeBasedDebouncer.ts +86 -0
  22. package/dist/lib/xterm/src/browser/Types.d.ts +317 -0
  23. package/dist/lib/xterm/src/browser/Viewport.ts +276 -0
  24. package/dist/lib/xterm/src/browser/decorations/BufferDecorationRenderer.ts +131 -0
  25. package/dist/lib/xterm/src/browser/decorations/ColorZoneStore.ts +117 -0
  26. package/dist/lib/xterm/src/browser/decorations/OverviewRulerRenderer.ts +228 -0
  27. package/dist/lib/xterm/src/browser/input/CompositionHelper.ts +237 -0
  28. package/dist/lib/xterm/src/browser/input/Mouse.ts +64 -0
  29. package/dist/lib/xterm/src/browser/input/MoveToCell.ts +249 -0
  30. package/dist/lib/xterm/src/browser/public/Terminal.ts +298 -0
  31. package/dist/lib/xterm/src/browser/renderer/BaseRenderLayer.ts +582 -0
  32. package/dist/lib/xterm/src/browser/renderer/CursorRenderLayer.ts +378 -0
  33. package/dist/lib/xterm/src/browser/renderer/CustomGlyphs.ts +632 -0
  34. package/dist/lib/xterm/src/browser/renderer/GridCache.ts +33 -0
  35. package/dist/lib/xterm/src/browser/renderer/LinkRenderLayer.ts +84 -0
  36. package/dist/lib/xterm/src/browser/renderer/Renderer.ts +219 -0
  37. package/dist/lib/xterm/src/browser/renderer/RendererUtils.ts +26 -0
  38. package/dist/lib/xterm/src/browser/renderer/SelectionRenderLayer.ts +131 -0
  39. package/dist/lib/xterm/src/browser/renderer/TextRenderLayer.ts +344 -0
  40. package/dist/lib/xterm/src/browser/renderer/Types.d.ts +109 -0
  41. package/dist/lib/xterm/src/browser/renderer/atlas/BaseCharAtlas.ts +58 -0
  42. package/dist/lib/xterm/src/browser/renderer/atlas/CharAtlasCache.ts +95 -0
  43. package/dist/lib/xterm/src/browser/renderer/atlas/CharAtlasUtils.ts +54 -0
  44. package/dist/lib/xterm/src/browser/renderer/atlas/Constants.ts +15 -0
  45. package/dist/lib/xterm/src/browser/renderer/atlas/DynamicCharAtlas.ts +404 -0
  46. package/dist/lib/xterm/src/browser/renderer/atlas/LRUMap.ts +136 -0
  47. package/dist/lib/xterm/src/browser/renderer/atlas/Types.d.ts +29 -0
  48. package/dist/lib/xterm/src/browser/renderer/dom/DomRenderer.ts +403 -0
  49. package/dist/lib/xterm/src/browser/renderer/dom/DomRendererRowFactory.ts +344 -0
  50. package/dist/lib/xterm/src/browser/selection/SelectionModel.ts +144 -0
  51. package/dist/lib/xterm/src/browser/selection/Types.d.ts +15 -0
  52. package/dist/lib/xterm/src/browser/services/CharSizeService.ts +87 -0
  53. package/dist/lib/xterm/src/browser/services/CharacterJoinerService.ts +339 -0
  54. package/dist/lib/xterm/src/browser/services/CoreBrowserService.ts +20 -0
  55. package/dist/lib/xterm/src/browser/services/MouseService.ts +36 -0
  56. package/dist/lib/xterm/src/browser/services/RenderService.ts +237 -0
  57. package/dist/lib/xterm/src/browser/services/SelectionService.ts +1027 -0
  58. package/dist/lib/xterm/src/browser/services/Services.ts +123 -0
  59. package/dist/lib/xterm/src/browser/services/SoundService.ts +63 -0
  60. package/dist/lib/xterm/src/common/CircularList.ts +239 -0
  61. package/dist/lib/xterm/src/common/Clone.ts +23 -0
  62. package/dist/lib/xterm/src/common/Color.ts +285 -0
  63. package/dist/lib/xterm/src/common/CoreTerminal.ts +300 -0
  64. package/dist/lib/xterm/src/common/EventEmitter.ts +69 -0
  65. package/dist/lib/xterm/src/common/InputHandler.ts +3230 -0
  66. package/dist/lib/xterm/src/common/Lifecycle.ts +68 -0
  67. package/dist/lib/xterm/src/common/Platform.ts +31 -0
  68. package/dist/lib/xterm/src/common/SortedList.ts +88 -0
  69. package/dist/lib/xterm/src/common/TypedArrayUtils.ts +50 -0
  70. package/dist/lib/xterm/src/common/Types.d.ts +489 -0
  71. package/dist/lib/xterm/src/common/WindowsMode.ts +27 -0
  72. package/dist/lib/xterm/src/common/buffer/AttributeData.ts +148 -0
  73. package/dist/lib/xterm/src/common/buffer/Buffer.ts +711 -0
  74. package/dist/lib/xterm/src/common/buffer/BufferLine.ts +441 -0
  75. package/dist/lib/xterm/src/common/buffer/BufferRange.ts +13 -0
  76. package/dist/lib/xterm/src/common/buffer/BufferReflow.ts +220 -0
  77. package/dist/lib/xterm/src/common/buffer/BufferSet.ts +131 -0
  78. package/dist/lib/xterm/src/common/buffer/CellData.ts +94 -0
  79. package/dist/lib/xterm/src/common/buffer/Constants.ts +139 -0
  80. package/dist/lib/xterm/src/common/buffer/Marker.ts +37 -0
  81. package/dist/lib/xterm/src/common/buffer/Types.d.ts +64 -0
  82. package/dist/lib/xterm/src/common/data/Charsets.ts +256 -0
  83. package/dist/lib/xterm/src/common/data/EscapeSequences.ts +153 -0
  84. package/dist/lib/xterm/src/common/input/Keyboard.ts +398 -0
  85. package/dist/lib/xterm/src/common/input/TextDecoder.ts +346 -0
  86. package/dist/lib/xterm/src/common/input/UnicodeV6.ts +133 -0
  87. package/dist/lib/xterm/src/common/input/WriteBuffer.ts +229 -0
  88. package/dist/lib/xterm/src/common/input/XParseColor.ts +80 -0
  89. package/dist/lib/xterm/src/common/parser/Constants.ts +58 -0
  90. package/dist/lib/xterm/src/common/parser/DcsParser.ts +192 -0
  91. package/dist/lib/xterm/src/common/parser/EscapeSequenceParser.ts +796 -0
  92. package/dist/lib/xterm/src/common/parser/OscParser.ts +238 -0
  93. package/dist/lib/xterm/src/common/parser/Params.ts +229 -0
  94. package/dist/lib/xterm/src/common/parser/Types.d.ts +274 -0
  95. package/dist/lib/xterm/src/common/public/AddonManager.ts +56 -0
  96. package/dist/lib/xterm/src/common/public/BufferApiView.ts +35 -0
  97. package/dist/lib/xterm/src/common/public/BufferLineApiView.ts +29 -0
  98. package/dist/lib/xterm/src/common/public/BufferNamespaceApi.ts +33 -0
  99. package/dist/lib/xterm/src/common/public/ParserApi.ts +37 -0
  100. package/dist/lib/xterm/src/common/public/UnicodeApi.ts +27 -0
  101. package/dist/lib/xterm/src/common/services/BufferService.ts +185 -0
  102. package/dist/lib/xterm/src/common/services/CharsetService.ts +34 -0
  103. package/dist/lib/xterm/src/common/services/CoreMouseService.ts +309 -0
  104. package/dist/lib/xterm/src/common/services/CoreService.ts +92 -0
  105. package/dist/lib/xterm/src/common/services/DecorationService.ts +139 -0
  106. package/dist/lib/xterm/src/common/services/DirtyRowService.ts +53 -0
  107. package/dist/lib/xterm/src/common/services/InstantiationService.ts +83 -0
  108. package/dist/lib/xterm/src/common/services/LogService.ts +88 -0
  109. package/dist/lib/xterm/src/common/services/OptionsService.ts +178 -0
  110. package/dist/lib/xterm/src/common/services/ServiceRegistry.ts +49 -0
  111. package/dist/lib/xterm/src/common/services/Services.ts +323 -0
  112. package/dist/lib/xterm/src/common/services/UnicodeService.ts +82 -0
  113. package/dist/lib/xterm/src/headless/Terminal.ts +170 -0
  114. package/dist/lib/xterm/src/headless/Types.d.ts +31 -0
  115. package/dist/lib/xterm/src/headless/public/Terminal.ts +216 -0
  116. package/dist/lib/xterm/typings/xterm.d.ts +1872 -0
  117. package/dist/lib/xterm-fit/LICENSE +19 -0
  118. package/dist/lib/xterm-fit/README.md +24 -0
  119. package/dist/lib/xterm-fit/lib/xterm-addon-fit.js +2 -0
  120. package/dist/lib/xterm-fit/lib/xterm-addon-fit.js.map +1 -0
  121. package/dist/lib/xterm-fit/out/FitAddon.js +58 -0
  122. package/dist/lib/xterm-fit/out/FitAddon.js.map +1 -0
  123. package/dist/lib/xterm-fit/out-test/FitAddon.api.js.map +1 -0
  124. package/dist/lib/xterm-fit/package.json +21 -0
  125. package/dist/lib/xterm-fit/src/FitAddon.ts +86 -0
  126. package/dist/lib/xterm-fit/typings/xterm-addon-fit.d.ts +55 -0
  127. package/dist/lib/xterm-links/LICENSE +19 -0
  128. package/dist/lib/xterm-links/README.md +21 -0
  129. package/dist/lib/xterm-links/lib/xterm-addon-web-links.js +2 -0
  130. package/dist/lib/xterm-links/lib/xterm-addon-web-links.js.map +1 -0
  131. package/dist/lib/xterm-links/package.json +26 -0
  132. package/dist/lib/xterm-links/src/WebLinkProvider.ts +145 -0
  133. package/dist/lib/xterm-links/src/WebLinksAddon.ts +77 -0
  134. package/dist/lib/xterm-links/typings/xterm-addon-web-links.d.ts +58 -0
  135. package/package.json +1 -1
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Copyright (c) 2019 The xterm.js authors. All rights reserved.
3
+ * @license MIT
4
+ */
5
+
6
+ import { ICharsetService } from 'common/services/Services';
7
+ import { ICharset } from 'common/Types';
8
+
9
+ export class CharsetService implements ICharsetService {
10
+ public serviceBrand: any;
11
+
12
+ public charset: ICharset | undefined;
13
+ public glevel: number = 0;
14
+
15
+ private _charsets: (ICharset | undefined)[] = [];
16
+
17
+ public reset(): void {
18
+ this.charset = undefined;
19
+ this._charsets = [];
20
+ this.glevel = 0;
21
+ }
22
+
23
+ public setgLevel(g: number): void {
24
+ this.glevel = g;
25
+ this.charset = this._charsets[g];
26
+ }
27
+
28
+ public setgCharset(g: number, charset: ICharset | undefined): void {
29
+ this._charsets[g] = charset;
30
+ if (this.glevel === g) {
31
+ this.charset = charset;
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,309 @@
1
+ /**
2
+ * Copyright (c) 2019 The xterm.js authors. All rights reserved.
3
+ * @license MIT
4
+ */
5
+ import { IBufferService, ICoreService, ICoreMouseService } from 'common/services/Services';
6
+ import { EventEmitter, IEvent } from 'common/EventEmitter';
7
+ import { ICoreMouseProtocol, ICoreMouseEvent, CoreMouseEncoding, CoreMouseEventType, CoreMouseButton, CoreMouseAction } from 'common/Types';
8
+
9
+ /**
10
+ * Supported default protocols.
11
+ */
12
+ const DEFAULT_PROTOCOLS: {[key: string]: ICoreMouseProtocol} = {
13
+ /**
14
+ * NONE
15
+ * Events: none
16
+ * Modifiers: none
17
+ */
18
+ NONE: {
19
+ events: CoreMouseEventType.NONE,
20
+ restrict: () => false
21
+ },
22
+ /**
23
+ * X10
24
+ * Events: mousedown
25
+ * Modifiers: none
26
+ */
27
+ X10: {
28
+ events: CoreMouseEventType.DOWN,
29
+ restrict: (e: ICoreMouseEvent) => {
30
+ // no wheel, no move, no up
31
+ if (e.button === CoreMouseButton.WHEEL || e.action !== CoreMouseAction.DOWN) {
32
+ return false;
33
+ }
34
+ // no modifiers
35
+ e.ctrl = false;
36
+ e.alt = false;
37
+ e.shift = false;
38
+ return true;
39
+ }
40
+ },
41
+ /**
42
+ * VT200
43
+ * Events: mousedown / mouseup / wheel
44
+ * Modifiers: all
45
+ */
46
+ VT200: {
47
+ events: CoreMouseEventType.DOWN | CoreMouseEventType.UP | CoreMouseEventType.WHEEL,
48
+ restrict: (e: ICoreMouseEvent) => {
49
+ // no move
50
+ if (e.action === CoreMouseAction.MOVE) {
51
+ return false;
52
+ }
53
+ return true;
54
+ }
55
+ },
56
+ /**
57
+ * DRAG
58
+ * Events: mousedown / mouseup / wheel / mousedrag
59
+ * Modifiers: all
60
+ */
61
+ DRAG: {
62
+ events: CoreMouseEventType.DOWN | CoreMouseEventType.UP | CoreMouseEventType.WHEEL | CoreMouseEventType.DRAG,
63
+ restrict: (e: ICoreMouseEvent) => {
64
+ // no move without button
65
+ if (e.action === CoreMouseAction.MOVE && e.button === CoreMouseButton.NONE) {
66
+ return false;
67
+ }
68
+ return true;
69
+ }
70
+ },
71
+ /**
72
+ * ANY
73
+ * Events: all mouse related events
74
+ * Modifiers: all
75
+ */
76
+ ANY: {
77
+ events:
78
+ CoreMouseEventType.DOWN | CoreMouseEventType.UP | CoreMouseEventType.WHEEL
79
+ | CoreMouseEventType.DRAG | CoreMouseEventType.MOVE,
80
+ restrict: (e: ICoreMouseEvent) => true
81
+ }
82
+ };
83
+
84
+ const enum Modifiers {
85
+ SHIFT = 4,
86
+ ALT = 8,
87
+ CTRL = 16
88
+ }
89
+
90
+ // helper for default encoders to generate the event code.
91
+ function eventCode(e: ICoreMouseEvent, isSGR: boolean): number {
92
+ let code = (e.ctrl ? Modifiers.CTRL : 0) | (e.shift ? Modifiers.SHIFT : 0) | (e.alt ? Modifiers.ALT : 0);
93
+ if (e.button === CoreMouseButton.WHEEL) {
94
+ code |= 64;
95
+ code |= e.action;
96
+ } else {
97
+ code |= e.button & 3;
98
+ if (e.button & 4) {
99
+ code |= 64;
100
+ }
101
+ if (e.button & 8) {
102
+ code |= 128;
103
+ }
104
+ if (e.action === CoreMouseAction.MOVE) {
105
+ code |= CoreMouseAction.MOVE;
106
+ } else if (e.action === CoreMouseAction.UP && !isSGR) {
107
+ // special case - only SGR can report button on release
108
+ // all others have to go with NONE
109
+ code |= CoreMouseButton.NONE;
110
+ }
111
+ }
112
+ return code;
113
+ }
114
+
115
+ const S = String.fromCharCode;
116
+
117
+ /**
118
+ * Supported default encodings.
119
+ */
120
+ const DEFAULT_ENCODINGS: {[key: string]: CoreMouseEncoding} = {
121
+ /**
122
+ * DEFAULT - CSI M Pb Px Py
123
+ * Single byte encoding for coords and event code.
124
+ * Can encode values up to 223 (1-based).
125
+ */
126
+ DEFAULT: (e: ICoreMouseEvent) => {
127
+ const params = [eventCode(e, false) + 32, e.col + 32, e.row + 32];
128
+ // supress mouse report if we exceed addressible range
129
+ // Note this is handled differently by emulators
130
+ // - xterm: sends 0;0 coords instead
131
+ // - vte, konsole: no report
132
+ if (params[0] > 255 || params[1] > 255 || params[2] > 255) {
133
+ return '';
134
+ }
135
+ return `\x1b[M${S(params[0])}${S(params[1])}${S(params[2])}`;
136
+ },
137
+ /**
138
+ * SGR - CSI < Pb ; Px ; Py M|m
139
+ * No encoding limitation.
140
+ * Can report button on release and works with a well formed sequence.
141
+ */
142
+ SGR: (e: ICoreMouseEvent) => {
143
+ const final = (e.action === CoreMouseAction.UP && e.button !== CoreMouseButton.WHEEL) ? 'm' : 'M';
144
+ return `\x1b[<${eventCode(e, true)};${e.col};${e.row}${final}`;
145
+ }
146
+ };
147
+
148
+ /**
149
+ * CoreMouseService
150
+ *
151
+ * Provides mouse tracking reports with different protocols and encodings.
152
+ * - protocols: NONE (default), X10, VT200, DRAG, ANY
153
+ * - encodings: DEFAULT, SGR (UTF8, URXVT removed in #2507)
154
+ *
155
+ * Custom protocols/encodings can be added by `addProtocol` / `addEncoding`.
156
+ * To activate a protocol/encoding, set `activeProtocol` / `activeEncoding`.
157
+ * Switching a protocol will send a notification event `onProtocolChange`
158
+ * with a list of needed events to track.
159
+ *
160
+ * The service handles the mouse tracking state and decides whether to send
161
+ * a tracking report to the backend based on protocol and encoding limitations.
162
+ * To send a mouse event call `triggerMouseEvent`.
163
+ */
164
+ export class CoreMouseService implements ICoreMouseService {
165
+ private _protocols: {[name: string]: ICoreMouseProtocol} = {};
166
+ private _encodings: {[name: string]: CoreMouseEncoding} = {};
167
+ private _activeProtocol: string = '';
168
+ private _activeEncoding: string = '';
169
+ private _onProtocolChange = new EventEmitter<CoreMouseEventType>();
170
+ private _lastEvent: ICoreMouseEvent | null = null;
171
+
172
+ constructor(
173
+ @IBufferService private readonly _bufferService: IBufferService,
174
+ @ICoreService private readonly _coreService: ICoreService
175
+ ) {
176
+ // register default protocols and encodings
177
+ for (const name of Object.keys(DEFAULT_PROTOCOLS)) this.addProtocol(name, DEFAULT_PROTOCOLS[name]);
178
+ for (const name of Object.keys(DEFAULT_ENCODINGS)) this.addEncoding(name, DEFAULT_ENCODINGS[name]);
179
+ // call reset to set defaults
180
+ this.reset();
181
+ }
182
+
183
+ public addProtocol(name: string, protocol: ICoreMouseProtocol): void {
184
+ this._protocols[name] = protocol;
185
+ }
186
+
187
+ public addEncoding(name: string, encoding: CoreMouseEncoding): void {
188
+ this._encodings[name] = encoding;
189
+ }
190
+
191
+ public get activeProtocol(): string {
192
+ return this._activeProtocol;
193
+ }
194
+
195
+ public get areMouseEventsActive(): boolean {
196
+ return this._protocols[this._activeProtocol].events !== 0;
197
+ }
198
+
199
+ public set activeProtocol(name: string) {
200
+ if (!this._protocols[name]) {
201
+ throw new Error(`unknown protocol "${name}"`);
202
+ }
203
+ this._activeProtocol = name;
204
+ this._onProtocolChange.fire(this._protocols[name].events);
205
+ }
206
+
207
+ public get activeEncoding(): string {
208
+ return this._activeEncoding;
209
+ }
210
+
211
+ public set activeEncoding(name: string) {
212
+ if (!this._encodings[name]) {
213
+ throw new Error(`unknown encoding "${name}"`);
214
+ }
215
+ this._activeEncoding = name;
216
+ }
217
+
218
+ public reset(): void {
219
+ this.activeProtocol = 'NONE';
220
+ this.activeEncoding = 'DEFAULT';
221
+ this._lastEvent = null;
222
+ }
223
+
224
+ /**
225
+ * Event to announce changes in mouse tracking.
226
+ */
227
+ public get onProtocolChange(): IEvent<CoreMouseEventType> {
228
+ return this._onProtocolChange.event;
229
+ }
230
+
231
+ /**
232
+ * Triggers a mouse event to be sent.
233
+ *
234
+ * Returns true if the event passed all protocol restrictions and a report
235
+ * was sent, otherwise false. The return value may be used to decide whether
236
+ * the default event action in the bowser component should be omitted.
237
+ *
238
+ * Note: The method will change values of the given event object
239
+ * to fullfill protocol and encoding restrictions.
240
+ */
241
+ public triggerMouseEvent(e: ICoreMouseEvent): boolean {
242
+ // range check for col/row
243
+ if (e.col < 0 || e.col >= this._bufferService.cols
244
+ || e.row < 0 || e.row >= this._bufferService.rows) {
245
+ return false;
246
+ }
247
+
248
+ // filter nonsense combinations of button + action
249
+ if (e.button === CoreMouseButton.WHEEL && e.action === CoreMouseAction.MOVE) {
250
+ return false;
251
+ }
252
+ if (e.button === CoreMouseButton.NONE && e.action !== CoreMouseAction.MOVE) {
253
+ return false;
254
+ }
255
+ if (e.button !== CoreMouseButton.WHEEL && (e.action === CoreMouseAction.LEFT || e.action === CoreMouseAction.RIGHT)) {
256
+ return false;
257
+ }
258
+
259
+ // report 1-based coords
260
+ e.col++;
261
+ e.row++;
262
+
263
+ // debounce move at grid level
264
+ if (e.action === CoreMouseAction.MOVE && this._lastEvent && this._compareEvents(this._lastEvent, e)) {
265
+ return false;
266
+ }
267
+
268
+ // apply protocol restrictions
269
+ if (!this._protocols[this._activeProtocol].restrict(e)) {
270
+ return false;
271
+ }
272
+
273
+ // encode report and send
274
+ const report = this._encodings[this._activeEncoding](e);
275
+ if (report) {
276
+ // always send DEFAULT as binary data
277
+ if (this._activeEncoding === 'DEFAULT') {
278
+ this._coreService.triggerBinaryEvent(report);
279
+ } else {
280
+ this._coreService.triggerDataEvent(report, true);
281
+ }
282
+ }
283
+
284
+ this._lastEvent = e;
285
+
286
+ return true;
287
+ }
288
+
289
+ public explainEvents(events: CoreMouseEventType): {[event: string]: boolean} {
290
+ return {
291
+ down: !!(events & CoreMouseEventType.DOWN),
292
+ up: !!(events & CoreMouseEventType.UP),
293
+ drag: !!(events & CoreMouseEventType.DRAG),
294
+ move: !!(events & CoreMouseEventType.MOVE),
295
+ wheel: !!(events & CoreMouseEventType.WHEEL)
296
+ };
297
+ }
298
+
299
+ private _compareEvents(e1: ICoreMouseEvent, e2: ICoreMouseEvent): boolean {
300
+ if (e1.col !== e2.col) return false;
301
+ if (e1.row !== e2.row) return false;
302
+ if (e1.button !== e2.button) return false;
303
+ if (e1.action !== e2.action) return false;
304
+ if (e1.ctrl !== e2.ctrl) return false;
305
+ if (e1.alt !== e2.alt) return false;
306
+ if (e1.shift !== e2.shift) return false;
307
+ return true;
308
+ }
309
+ }
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Copyright (c) 2019 The xterm.js authors. All rights reserved.
3
+ * @license MIT
4
+ */
5
+
6
+ import { ICoreService, ILogService, IOptionsService, IBufferService } from 'common/services/Services';
7
+ import { EventEmitter, IEvent } from 'common/EventEmitter';
8
+ import { IDecPrivateModes, IModes } from 'common/Types';
9
+ import { clone } from 'common/Clone';
10
+ import { Disposable } from 'common/Lifecycle';
11
+
12
+ const DEFAULT_MODES: IModes = Object.freeze({
13
+ insertMode: false
14
+ });
15
+
16
+ const DEFAULT_DEC_PRIVATE_MODES: IDecPrivateModes = Object.freeze({
17
+ applicationCursorKeys: false,
18
+ applicationKeypad: false,
19
+ bracketedPasteMode: false,
20
+ origin: false,
21
+ reverseWraparound: false,
22
+ sendFocus: false,
23
+ wraparound: true // defaults: xterm - true, vt100 - false
24
+ });
25
+
26
+ export class CoreService extends Disposable implements ICoreService {
27
+ public serviceBrand: any;
28
+
29
+ public isCursorInitialized: boolean = false;
30
+ public isCursorHidden: boolean = false;
31
+ public modes: IModes;
32
+ public decPrivateModes: IDecPrivateModes;
33
+
34
+ // Circular dependency, this must be unset or memory will leak after Terminal.dispose
35
+ private _scrollToBottom: (() => void) | undefined;
36
+
37
+ private _onData = this.register(new EventEmitter<string>());
38
+ public get onData(): IEvent<string> { return this._onData.event; }
39
+ private _onUserInput = this.register(new EventEmitter<void>());
40
+ public get onUserInput(): IEvent<void> { return this._onUserInput.event; }
41
+ private _onBinary = this.register(new EventEmitter<string>());
42
+ public get onBinary(): IEvent<string> { return this._onBinary.event; }
43
+
44
+ constructor(
45
+ // TODO: Move this into a service
46
+ scrollToBottom: () => void,
47
+ @IBufferService private readonly _bufferService: IBufferService,
48
+ @ILogService private readonly _logService: ILogService,
49
+ @IOptionsService private readonly _optionsService: IOptionsService
50
+ ) {
51
+ super();
52
+ this._scrollToBottom = scrollToBottom;
53
+ this.register({ dispose: () => this._scrollToBottom = undefined });
54
+ this.modes = clone(DEFAULT_MODES);
55
+ this.decPrivateModes = clone(DEFAULT_DEC_PRIVATE_MODES);
56
+ }
57
+
58
+ public reset(): void {
59
+ this.modes = clone(DEFAULT_MODES);
60
+ this.decPrivateModes = clone(DEFAULT_DEC_PRIVATE_MODES);
61
+ }
62
+
63
+ public triggerDataEvent(data: string, wasUserInput: boolean = false): void {
64
+ // Prevents all events to pty process if stdin is disabled
65
+ if (this._optionsService.rawOptions.disableStdin) {
66
+ return;
67
+ }
68
+
69
+ // Input is being sent to the terminal, the terminal should focus the prompt.
70
+ const buffer = this._bufferService.buffer;
71
+ if (buffer.ybase !== buffer.ydisp) {
72
+ this._scrollToBottom!();
73
+ }
74
+
75
+ // Fire onUserInput so listeners can react as well (eg. clear selection)
76
+ if (wasUserInput) {
77
+ this._onUserInput.fire();
78
+ }
79
+
80
+ // Fire onData API
81
+ this._logService.debug(`sending data "${data}"`, () => data.split('').map(e => e.charCodeAt(0)));
82
+ this._onData.fire(data);
83
+ }
84
+
85
+ public triggerBinaryEvent(data: string): void {
86
+ if (this._optionsService.rawOptions.disableStdin) {
87
+ return;
88
+ }
89
+ this._logService.debug(`sending binary "${data}"`, () => data.split('').map(e => e.charCodeAt(0)));
90
+ this._onBinary.fire(data);
91
+ }
92
+ }
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Copyright (c) 2022 The xterm.js authors. All rights reserved.
3
+ * @license MIT
4
+ */
5
+
6
+ import { css } from 'common/Color';
7
+ import { EventEmitter } from 'common/EventEmitter';
8
+ import { Disposable } from 'common/Lifecycle';
9
+ import { IDecorationService, IInternalDecoration } from 'common/services/Services';
10
+ import { SortedList } from 'common/SortedList';
11
+ import { IColor } from 'common/Types';
12
+ import { IDecorationOptions, IDecoration, IMarker, IEvent } from 'xterm';
13
+
14
+ export class DecorationService extends Disposable implements IDecorationService {
15
+ public serviceBrand: any;
16
+
17
+ /**
18
+ * A list of all decorations, sorted by the marker's line value. This relies on the fact that
19
+ * while marker line values do change, they should all change by the same amount so this should
20
+ * never become out of order.
21
+ */
22
+ private readonly _decorations: SortedList<IInternalDecoration> = new SortedList(e => e.marker.line);
23
+
24
+ private _onDecorationRegistered = this.register(new EventEmitter<IInternalDecoration>());
25
+ public get onDecorationRegistered(): IEvent<IInternalDecoration> { return this._onDecorationRegistered.event; }
26
+ private _onDecorationRemoved = this.register(new EventEmitter<IInternalDecoration>());
27
+ public get onDecorationRemoved(): IEvent<IInternalDecoration> { return this._onDecorationRemoved.event; }
28
+
29
+ public get decorations(): IterableIterator<IInternalDecoration> { return this._decorations.values(); }
30
+
31
+ constructor() {
32
+ super();
33
+ }
34
+
35
+ public registerDecoration(options: IDecorationOptions): IDecoration | undefined {
36
+ if (options.marker.isDisposed) {
37
+ return undefined;
38
+ }
39
+ const decoration = new Decoration(options);
40
+ if (decoration) {
41
+ const markerDispose = decoration.marker.onDispose(() => decoration.dispose());
42
+ decoration.onDispose(() => {
43
+ if (decoration) {
44
+ if (this._decorations.delete(decoration)) {
45
+ this._onDecorationRemoved.fire(decoration);
46
+ }
47
+ markerDispose.dispose();
48
+ }
49
+ });
50
+ this._decorations.insert(decoration);
51
+ this._onDecorationRegistered.fire(decoration);
52
+ }
53
+ return decoration;
54
+ }
55
+
56
+ public reset(): void {
57
+ for (const d of this._decorations.values()) {
58
+ d.dispose();
59
+ }
60
+ this._decorations.clear();
61
+ }
62
+
63
+ public *getDecorationsAtLine(line: number): IterableIterator<IInternalDecoration> {
64
+ return this._decorations.getKeyIterator(line);
65
+ }
66
+
67
+ public *getDecorationsAtCell(x: number, line: number, layer?: 'bottom' | 'top'): IterableIterator<IInternalDecoration> {
68
+ let xmin = 0;
69
+ let xmax = 0;
70
+ for (const d of this._decorations.getKeyIterator(line)) {
71
+ xmin = d.options.x ?? 0;
72
+ xmax = xmin + (d.options.width ?? 1);
73
+ if (x >= xmin && x < xmax && (!layer || (d.options.layer ?? 'bottom') === layer)) {
74
+ yield d;
75
+ }
76
+ }
77
+ }
78
+
79
+ public dispose(): void {
80
+ for (const d of this._decorations.values()) {
81
+ this._onDecorationRemoved.fire(d);
82
+ }
83
+ this.reset();
84
+ }
85
+ }
86
+
87
+ class Decoration extends Disposable implements IInternalDecoration {
88
+ public readonly marker: IMarker;
89
+ public element: HTMLElement | undefined;
90
+ public isDisposed: boolean = false;
91
+
92
+ public readonly onRenderEmitter = this.register(new EventEmitter<HTMLElement>());
93
+ public readonly onRender = this.onRenderEmitter.event;
94
+ private _onDispose = this.register(new EventEmitter<void>());
95
+ public readonly onDispose = this._onDispose.event;
96
+
97
+ private _cachedBg: IColor | undefined | null = null;
98
+ public get backgroundColorRGB(): IColor | undefined {
99
+ if (this._cachedBg === null) {
100
+ if (this.options.backgroundColor) {
101
+ this._cachedBg = css.toColor(this.options.backgroundColor);
102
+ } else {
103
+ this._cachedBg = undefined;
104
+ }
105
+ }
106
+ return this._cachedBg;
107
+ }
108
+
109
+ private _cachedFg: IColor | undefined | null = null;
110
+ public get foregroundColorRGB(): IColor | undefined {
111
+ if (this._cachedFg === null) {
112
+ if (this.options.foregroundColor) {
113
+ this._cachedFg = css.toColor(this.options.foregroundColor);
114
+ } else {
115
+ this._cachedFg = undefined;
116
+ }
117
+ }
118
+ return this._cachedFg;
119
+ }
120
+
121
+ constructor(
122
+ public readonly options: IDecorationOptions
123
+ ) {
124
+ super();
125
+ this.marker = options.marker;
126
+ if (this.options.overviewRulerOptions && !this.options.overviewRulerOptions.position) {
127
+ this.options.overviewRulerOptions.position = 'full';
128
+ }
129
+ }
130
+
131
+ public override dispose(): void {
132
+ if (this._isDisposed) {
133
+ return;
134
+ }
135
+ this._isDisposed = true;
136
+ this._onDispose.fire();
137
+ super.dispose();
138
+ }
139
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Copyright (c) 2019 The xterm.js authors. All rights reserved.
3
+ * @license MIT
4
+ */
5
+
6
+ import { IBufferService, IDirtyRowService } from 'common/services/Services';
7
+
8
+ export class DirtyRowService implements IDirtyRowService {
9
+ public serviceBrand: any;
10
+
11
+ private _start!: number;
12
+ private _end!: number;
13
+
14
+ public get start(): number { return this._start; }
15
+ public get end(): number { return this._end; }
16
+
17
+ constructor(
18
+ @IBufferService private readonly _bufferService: IBufferService
19
+ ) {
20
+ this.clearRange();
21
+ }
22
+
23
+ public clearRange(): void {
24
+ this._start = this._bufferService.buffer.y;
25
+ this._end = this._bufferService.buffer.y;
26
+ }
27
+
28
+ public markDirty(y: number): void {
29
+ if (y < this._start) {
30
+ this._start = y;
31
+ } else if (y > this._end) {
32
+ this._end = y;
33
+ }
34
+ }
35
+
36
+ public markRangeDirty(y1: number, y2: number): void {
37
+ if (y1 > y2) {
38
+ const temp = y1;
39
+ y1 = y2;
40
+ y2 = temp;
41
+ }
42
+ if (y1 < this._start) {
43
+ this._start = y1;
44
+ }
45
+ if (y2 > this._end) {
46
+ this._end = y2;
47
+ }
48
+ }
49
+
50
+ public markAllDirty(): void {
51
+ this.markRangeDirty(0, this._bufferService.rows - 1);
52
+ }
53
+ }