@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,90 @@
1
+ {
2
+ "name": "xterm",
3
+ "description": "Full xterm terminal, in your browser",
4
+ "version": "4.19.0",
5
+ "main": "lib/xterm.js",
6
+ "style": "css/xterm.css",
7
+ "types": "typings/xterm.d.ts",
8
+ "repository": "https://github.com/xtermjs/xterm.js",
9
+ "license": "MIT",
10
+ "keywords": [
11
+ "cli",
12
+ "command-line",
13
+ "console",
14
+ "pty",
15
+ "shell",
16
+ "ssh",
17
+ "styles",
18
+ "terminal-emulator",
19
+ "terminal",
20
+ "tty",
21
+ "vt100",
22
+ "webgl",
23
+ "xterm"
24
+ ],
25
+ "scripts": {
26
+ "prepackage": "npm run build",
27
+ "package": "webpack",
28
+ "package-headless": "webpack --config ./webpack.config.headless.js",
29
+ "postpackage-headless": "node ./bin/package_headless.js",
30
+ "start": "node demo/start",
31
+ "start-debug": "node --inspect-brk demo/start",
32
+ "lint": "eslint -c .eslintrc.json --max-warnings 0 --ext .ts src/ addons/",
33
+ "test": "npm run test-unit",
34
+ "posttest": "npm run lint",
35
+ "test-api": "npm run test-api-chromium",
36
+ "test-api-chromium": "node ./bin/test_api.js --browser=chromium --timeout=20000",
37
+ "test-api-firefox": "node ./bin/test_api.js --browser=firefox --timeout=20000",
38
+ "test-api-webkit": "node ./bin/test_api.js --browser=webkit --timeout=20000",
39
+ "test-unit": "node ./bin/test.js",
40
+ "test-unit-coverage": "node ./bin/test.js --coverage",
41
+ "test-unit-dev": "cross-env NODE_PATH='./out' mocha",
42
+ "build": "tsc -b ./tsconfig.all.json",
43
+ "prepare": "npm run setup",
44
+ "setup": "npm run build",
45
+ "presetup": "node ./bin/install-addons.js",
46
+ "prepublishOnly": "npm run package",
47
+ "watch": "tsc -b -w ./tsconfig.all.json --preserveWatchOutput",
48
+ "benchmark": "NODE_PATH=./out xterm-benchmark -r 5 -c test/benchmark/benchmark.json",
49
+ "benchmark-baseline": "NODE_PATH=./out xterm-benchmark -r 5 -c test/benchmark/benchmark.json --baseline out-test/benchmark/test/benchmark/*benchmark.js",
50
+ "benchmark-eval": "NODE_PATH=./out xterm-benchmark -r 5 -c test/benchmark/benchmark.json --eval out-test/benchmark/test/benchmark/*benchmark.js",
51
+ "clean": "rm -rf lib out addons/*/lib addons/*/out",
52
+ "vtfeatures": "node bin/extract_vtfeatures.js src/**/*.ts src/*.ts"
53
+ },
54
+ "devDependencies": {
55
+ "@types/chai": "^4.2.22",
56
+ "@types/debug": "^4.1.7",
57
+ "@types/deep-equal": "^1.0.1",
58
+ "@types/glob": "^7.2.0",
59
+ "@types/jsdom": "^16.2.13",
60
+ "@types/mocha": "^9.0.0",
61
+ "@types/node": "^14.14.44",
62
+ "@types/utf8": "^3.0.0",
63
+ "@types/webpack": "^5.28.0",
64
+ "@types/ws": "^8.2.0",
65
+ "@typescript-eslint/eslint-plugin": "^5.3.0",
66
+ "@typescript-eslint/parser": "^5.3.0",
67
+ "chai": "^4.3.4",
68
+ "cross-env": "^7.0.3",
69
+ "deep-equal": "^2.0.5",
70
+ "eslint": "^8.1.0",
71
+ "express": "^4.17.1",
72
+ "express-ws": "^5.0.2",
73
+ "glob": "^7.2.0",
74
+ "jsdom": "^18.0.1",
75
+ "mocha": "^9.2.0",
76
+ "mustache": "^4.2.0",
77
+ "node-pty": "^0.10.1",
78
+ "nyc": "^15.1.0",
79
+ "playwright": "^1.22.1",
80
+ "source-map-loader": "^3.0.0",
81
+ "source-map-support": "^0.5.20",
82
+ "ts-loader": "^9.1.2",
83
+ "typescript": "^4.4.4",
84
+ "utf8": "^3.0.0",
85
+ "webpack": "^5.61.0",
86
+ "webpack-cli": "^4.9.1",
87
+ "ws": "^8.2.3",
88
+ "xterm-benchmark": "^0.3.1"
89
+ }
90
+ }
@@ -0,0 +1,301 @@
1
+ /**
2
+ * Copyright (c) 2017 The xterm.js authors. All rights reserved.
3
+ * @license MIT
4
+ */
5
+
6
+ import * as Strings from 'browser/LocalizableStrings';
7
+ import { ITerminal, IRenderDebouncer } from 'browser/Types';
8
+ import { IBuffer } from 'common/buffer/Types';
9
+ import { isMac } from 'common/Platform';
10
+ import { TimeBasedDebouncer } from 'browser/TimeBasedDebouncer';
11
+ import { addDisposableDomListener } from 'browser/Lifecycle';
12
+ import { Disposable } from 'common/Lifecycle';
13
+ import { ScreenDprMonitor } from 'browser/ScreenDprMonitor';
14
+ import { IRenderService } from 'browser/services/Services';
15
+ import { removeElementFromParent } from 'browser/Dom';
16
+
17
+ const MAX_ROWS_TO_READ = 20;
18
+
19
+ const enum BoundaryPosition {
20
+ TOP,
21
+ BOTTOM
22
+ }
23
+
24
+ export class AccessibilityManager extends Disposable {
25
+ private _accessibilityTreeRoot: HTMLElement;
26
+ private _rowContainer: HTMLElement;
27
+ private _rowElements: HTMLElement[];
28
+ private _liveRegion: HTMLElement;
29
+ private _liveRegionLineCount: number = 0;
30
+
31
+ private _renderRowsDebouncer: IRenderDebouncer;
32
+ private _screenDprMonitor: ScreenDprMonitor;
33
+
34
+ private _topBoundaryFocusListener: (e: FocusEvent) => void;
35
+ private _bottomBoundaryFocusListener: (e: FocusEvent) => void;
36
+
37
+ /**
38
+ * This queue has a character pushed to it for keys that are pressed, if the
39
+ * next character added to the terminal is equal to the key char then it is
40
+ * not announced (added to live region) because it has already been announced
41
+ * by the textarea event (which cannot be canceled). There are some race
42
+ * condition cases if there is typing while data is streaming, but this covers
43
+ * the main case of typing into the prompt and inputting the answer to a
44
+ * question (Y/N, etc.).
45
+ */
46
+ private _charsToConsume: string[] = [];
47
+
48
+ private _charsToAnnounce: string = '';
49
+
50
+ constructor(
51
+ private readonly _terminal: ITerminal,
52
+ private readonly _renderService: IRenderService
53
+ ) {
54
+ super();
55
+ this._accessibilityTreeRoot = document.createElement('div');
56
+ this._accessibilityTreeRoot.classList.add('xterm-accessibility');
57
+ this._accessibilityTreeRoot.tabIndex = 0;
58
+
59
+ this._rowContainer = document.createElement('div');
60
+ this._rowContainer.setAttribute('role', 'list');
61
+ this._rowContainer.classList.add('xterm-accessibility-tree');
62
+ this._rowElements = [];
63
+ for (let i = 0; i < this._terminal.rows; i++) {
64
+ this._rowElements[i] = this._createAccessibilityTreeNode();
65
+ this._rowContainer.appendChild(this._rowElements[i]);
66
+ }
67
+
68
+ this._topBoundaryFocusListener = e => this._onBoundaryFocus(e, BoundaryPosition.TOP);
69
+ this._bottomBoundaryFocusListener = e => this._onBoundaryFocus(e, BoundaryPosition.BOTTOM);
70
+ this._rowElements[0].addEventListener('focus', this._topBoundaryFocusListener);
71
+ this._rowElements[this._rowElements.length - 1].addEventListener('focus', this._bottomBoundaryFocusListener);
72
+
73
+ this._refreshRowsDimensions();
74
+ this._accessibilityTreeRoot.appendChild(this._rowContainer);
75
+
76
+ this._renderRowsDebouncer = new TimeBasedDebouncer(this._renderRows.bind(this));
77
+ this._refreshRows();
78
+
79
+ this._liveRegion = document.createElement('div');
80
+ this._liveRegion.classList.add('live-region');
81
+ this._liveRegion.setAttribute('aria-live', 'assertive');
82
+ this._accessibilityTreeRoot.appendChild(this._liveRegion);
83
+
84
+ if (!this._terminal.element) {
85
+ throw new Error('Cannot enable accessibility before Terminal.open');
86
+ }
87
+ this._terminal.element.insertAdjacentElement('afterbegin', this._accessibilityTreeRoot);
88
+
89
+ this.register(this._renderRowsDebouncer);
90
+ this.register(this._terminal.onResize(e => this._onResize(e.rows)));
91
+ this.register(this._terminal.onRender(e => this._refreshRows(e.start, e.end)));
92
+ this.register(this._terminal.onScroll(() => this._refreshRows()));
93
+ // Line feed is an issue as the prompt won't be read out after a command is run
94
+ this.register(this._terminal.onA11yChar(char => this._onChar(char)));
95
+ this.register(this._terminal.onLineFeed(() => this._onChar('\n')));
96
+ this.register(this._terminal.onA11yTab(spaceCount => this._onTab(spaceCount)));
97
+ this.register(this._terminal.onKey(e => this._onKey(e.key)));
98
+ this.register(this._terminal.onBlur(() => this._clearLiveRegion()));
99
+ this.register(this._renderService.onDimensionsChange(() => this._refreshRowsDimensions()));
100
+
101
+ this._screenDprMonitor = new ScreenDprMonitor();
102
+ this.register(this._screenDprMonitor);
103
+ this._screenDprMonitor.setListener(() => this._refreshRowsDimensions());
104
+ // This shouldn't be needed on modern browsers but is present in case the
105
+ // media query that drives the ScreenDprMonitor isn't supported
106
+ this.register(addDisposableDomListener(window, 'resize', () => this._refreshRowsDimensions()));
107
+ }
108
+
109
+ public dispose(): void {
110
+ super.dispose();
111
+ removeElementFromParent(this._accessibilityTreeRoot);
112
+ this._rowElements.length = 0;
113
+ }
114
+
115
+ private _onBoundaryFocus(e: FocusEvent, position: BoundaryPosition): void {
116
+ const boundaryElement = e.target as HTMLElement;
117
+ const beforeBoundaryElement = this._rowElements[position === BoundaryPosition.TOP ? 1 : this._rowElements.length - 2];
118
+
119
+ // Don't scroll if the buffer top has reached the end in that direction
120
+ const posInSet = boundaryElement.getAttribute('aria-posinset');
121
+ const lastRowPos = position === BoundaryPosition.TOP ? '1' : `${this._terminal.buffer.lines.length}`;
122
+ if (posInSet === lastRowPos) {
123
+ return;
124
+ }
125
+
126
+ // Don't scroll when the last focused item was not the second row (focus is going the other
127
+ // direction)
128
+ if (e.relatedTarget !== beforeBoundaryElement) {
129
+ return;
130
+ }
131
+
132
+ // Remove old boundary element from array
133
+ let topBoundaryElement: HTMLElement;
134
+ let bottomBoundaryElement: HTMLElement;
135
+ if (position === BoundaryPosition.TOP) {
136
+ topBoundaryElement = boundaryElement;
137
+ bottomBoundaryElement = this._rowElements.pop()!;
138
+ this._rowContainer.removeChild(bottomBoundaryElement);
139
+ } else {
140
+ topBoundaryElement = this._rowElements.shift()!;
141
+ bottomBoundaryElement = boundaryElement;
142
+ this._rowContainer.removeChild(topBoundaryElement);
143
+ }
144
+
145
+ // Remove listeners from old boundary elements
146
+ topBoundaryElement.removeEventListener('focus', this._topBoundaryFocusListener);
147
+ bottomBoundaryElement.removeEventListener('focus', this._bottomBoundaryFocusListener);
148
+
149
+ // Add new element to array/DOM
150
+ if (position === BoundaryPosition.TOP) {
151
+ const newElement = this._createAccessibilityTreeNode();
152
+ this._rowElements.unshift(newElement);
153
+ this._rowContainer.insertAdjacentElement('afterbegin', newElement);
154
+ } else {
155
+ const newElement = this._createAccessibilityTreeNode();
156
+ this._rowElements.push(newElement);
157
+ this._rowContainer.appendChild(newElement);
158
+ }
159
+
160
+ // Add listeners to new boundary elements
161
+ this._rowElements[0].addEventListener('focus', this._topBoundaryFocusListener);
162
+ this._rowElements[this._rowElements.length - 1].addEventListener('focus', this._bottomBoundaryFocusListener);
163
+
164
+ // Scroll up
165
+ this._terminal.scrollLines(position === BoundaryPosition.TOP ? -1 : 1);
166
+
167
+ // Focus new boundary before element
168
+ this._rowElements[position === BoundaryPosition.TOP ? 1 : this._rowElements.length - 2].focus();
169
+
170
+ // Prevent the standard behavior
171
+ e.preventDefault();
172
+ e.stopImmediatePropagation();
173
+ }
174
+
175
+ private _onResize(rows: number): void {
176
+ // Remove bottom boundary listener
177
+ this._rowElements[this._rowElements.length - 1].removeEventListener('focus', this._bottomBoundaryFocusListener);
178
+
179
+ // Grow rows as required
180
+ for (let i = this._rowContainer.children.length; i < this._terminal.rows; i++) {
181
+ this._rowElements[i] = this._createAccessibilityTreeNode();
182
+ this._rowContainer.appendChild(this._rowElements[i]);
183
+ }
184
+ // Shrink rows as required
185
+ while (this._rowElements.length > rows) {
186
+ this._rowContainer.removeChild(this._rowElements.pop()!);
187
+ }
188
+
189
+ // Add bottom boundary listener
190
+ this._rowElements[this._rowElements.length - 1].addEventListener('focus', this._bottomBoundaryFocusListener);
191
+
192
+ this._refreshRowsDimensions();
193
+ }
194
+
195
+ private _createAccessibilityTreeNode(): HTMLElement {
196
+ const element = document.createElement('div');
197
+ element.setAttribute('role', 'listitem');
198
+ element.tabIndex = -1;
199
+ this._refreshRowDimensions(element);
200
+ return element;
201
+ }
202
+
203
+ private _onTab(spaceCount: number): void {
204
+ for (let i = 0; i < spaceCount; i++) {
205
+ this._onChar(' ');
206
+ }
207
+ }
208
+
209
+ private _onChar(char: string): void {
210
+ if (this._liveRegionLineCount < MAX_ROWS_TO_READ + 1) {
211
+ if (this._charsToConsume.length > 0) {
212
+ // Have the screen reader ignore the char if it was just input
213
+ const shiftedChar = this._charsToConsume.shift();
214
+ if (shiftedChar !== char) {
215
+ this._charsToAnnounce += char;
216
+ }
217
+ } else {
218
+ this._charsToAnnounce += char;
219
+ }
220
+
221
+ if (char === '\n') {
222
+ this._liveRegionLineCount++;
223
+ if (this._liveRegionLineCount === MAX_ROWS_TO_READ + 1) {
224
+ this._liveRegion.textContent += Strings.tooMuchOutput;
225
+ }
226
+ }
227
+
228
+ // Only detach/attach on mac as otherwise messages can go unaccounced
229
+ if (isMac) {
230
+ if (this._liveRegion.textContent && this._liveRegion.textContent.length > 0 && !this._liveRegion.parentNode) {
231
+ setTimeout(() => {
232
+ this._accessibilityTreeRoot.appendChild(this._liveRegion);
233
+ }, 0);
234
+ }
235
+ }
236
+ }
237
+ }
238
+
239
+ private _clearLiveRegion(): void {
240
+ this._liveRegion.textContent = '';
241
+ this._liveRegionLineCount = 0;
242
+
243
+ // Only detach/attach on mac as otherwise messages can go unaccounced
244
+ if (isMac) {
245
+ removeElementFromParent(this._liveRegion);
246
+ }
247
+ }
248
+
249
+ private _onKey(keyChar: string): void {
250
+ this._clearLiveRegion();
251
+ this._charsToConsume.push(keyChar);
252
+ }
253
+
254
+ private _refreshRows(start?: number, end?: number): void {
255
+ this._renderRowsDebouncer.refresh(start, end, this._terminal.rows);
256
+ }
257
+
258
+ private _renderRows(start: number, end: number): void {
259
+ const buffer: IBuffer = this._terminal.buffer;
260
+ const setSize = buffer.lines.length.toString();
261
+ for (let i = start; i <= end; i++) {
262
+ const lineData = buffer.translateBufferLineToString(buffer.ydisp + i, true);
263
+ const posInSet = (buffer.ydisp + i + 1).toString();
264
+ const element = this._rowElements[i];
265
+ if (element) {
266
+ if (lineData.length === 0) {
267
+ element.innerText = '\u00a0';
268
+ } else {
269
+ element.textContent = lineData;
270
+ }
271
+ element.setAttribute('aria-posinset', posInSet);
272
+ element.setAttribute('aria-setsize', setSize);
273
+ }
274
+ }
275
+ this._announceCharacters();
276
+ }
277
+
278
+ private _refreshRowsDimensions(): void {
279
+ if (!this._renderService.dimensions.actualCellHeight) {
280
+ return;
281
+ }
282
+ if (this._rowElements.length !== this._terminal.rows) {
283
+ this._onResize(this._terminal.rows);
284
+ }
285
+ for (let i = 0; i < this._terminal.rows; i++) {
286
+ this._refreshRowDimensions(this._rowElements[i]);
287
+ }
288
+ }
289
+
290
+ private _refreshRowDimensions(element: HTMLElement): void {
291
+ element.style.height = `${this._renderService.dimensions.actualCellHeight}px`;
292
+ }
293
+
294
+ private _announceCharacters(): void {
295
+ if (this._charsToAnnounce.length === 0) {
296
+ return;
297
+ }
298
+ this._liveRegion.textContent += this._charsToAnnounce;
299
+ this._charsToAnnounce = '';
300
+ }
301
+ }
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Copyright (c) 2016 The xterm.js authors. All rights reserved.
3
+ * @license MIT
4
+ */
5
+
6
+ import { ISelectionService } from 'browser/services/Services';
7
+ import { ICoreService } from 'common/services/Services';
8
+
9
+ /**
10
+ * Prepares text to be pasted into the terminal by normalizing the line endings
11
+ * @param text The pasted text that needs processing before inserting into the terminal
12
+ */
13
+ export function prepareTextForTerminal(text: string): string {
14
+ return text.replace(/\r?\n/g, '\r');
15
+ }
16
+
17
+ /**
18
+ * Bracket text for paste, if necessary, as per https://cirw.in/blog/bracketed-paste
19
+ * @param text The pasted text to bracket
20
+ */
21
+ export function bracketTextForPaste(text: string, bracketedPasteMode: boolean): string {
22
+ if (bracketedPasteMode) {
23
+ return '\x1b[200~' + text + '\x1b[201~';
24
+ }
25
+ return text;
26
+ }
27
+
28
+ /**
29
+ * Binds copy functionality to the given terminal.
30
+ * @param ev The original copy event to be handled
31
+ */
32
+ export function copyHandler(ev: ClipboardEvent, selectionService: ISelectionService): void {
33
+ if (ev.clipboardData) {
34
+ ev.clipboardData.setData('text/plain', selectionService.selectionText);
35
+ }
36
+ // Prevent or the original text will be copied.
37
+ ev.preventDefault();
38
+ }
39
+
40
+ /**
41
+ * Redirect the clipboard's data to the terminal's input handler.
42
+ * @param ev The original paste event to be handled
43
+ * @param term The terminal on which to apply the handled paste event
44
+ */
45
+ export function handlePasteEvent(ev: ClipboardEvent, textarea: HTMLTextAreaElement, coreService: ICoreService): void {
46
+ ev.stopPropagation();
47
+ if (ev.clipboardData) {
48
+ const text = ev.clipboardData.getData('text/plain');
49
+ paste(text, textarea, coreService);
50
+ }
51
+ }
52
+
53
+ export function paste(text: string, textarea: HTMLTextAreaElement, coreService: ICoreService): void {
54
+ text = prepareTextForTerminal(text);
55
+ text = bracketTextForPaste(text, coreService.decPrivateModes.bracketedPasteMode);
56
+ coreService.triggerDataEvent(text, true);
57
+ textarea.value = '';
58
+ }
59
+
60
+ /**
61
+ * Moves the textarea under the mouse cursor and focuses it.
62
+ * @param ev The original right click event to be handled.
63
+ * @param textarea The terminal's textarea.
64
+ */
65
+ export function moveTextAreaUnderMouseCursor(ev: MouseEvent, textarea: HTMLTextAreaElement, screenElement: HTMLElement): void {
66
+
67
+ // Calculate textarea position relative to the screen element
68
+ const pos = screenElement.getBoundingClientRect();
69
+ const left = ev.clientX - pos.left - 10;
70
+ const top = ev.clientY - pos.top - 10;
71
+
72
+ // Bring textarea at the cursor position
73
+ textarea.style.width = '20px';
74
+ textarea.style.height = '20px';
75
+ textarea.style.left = `${left}px`;
76
+ textarea.style.top = `${top}px`;
77
+ textarea.style.zIndex = '1000';
78
+
79
+ textarea.focus();
80
+ }
81
+
82
+ /**
83
+ * Bind to right-click event and allow right-click copy and paste.
84
+ * @param ev The original right click event to be handled.
85
+ * @param textarea The terminal's textarea.
86
+ * @param selectionService The terminal's selection manager.
87
+ * @param shouldSelectWord If true and there is no selection the current word will be selected
88
+ */
89
+ export function rightClickHandler(ev: MouseEvent, textarea: HTMLTextAreaElement, screenElement: HTMLElement, selectionService: ISelectionService, shouldSelectWord: boolean): void {
90
+ moveTextAreaUnderMouseCursor(ev, textarea, screenElement);
91
+
92
+ if (shouldSelectWord) {
93
+ selectionService.rightClickSelect(ev);
94
+ }
95
+
96
+ // Get textarea ready to copy from the context menu
97
+ textarea.value = selectionService.selectionText;
98
+ textarea.select();
99
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Copyright (c) 2017 The xterm.js authors. All rights reserved.
3
+ * @license MIT
4
+ */
5
+
6
+ import { IColorContrastCache } from 'browser/Types';
7
+ import { IColor } from 'common/Types';
8
+
9
+ export class ColorContrastCache implements IColorContrastCache {
10
+ private _color: { [bg: number]: { [fg: number]: IColor | null | undefined } | undefined } = {};
11
+ private _rgba: { [bg: number]: { [fg: number]: string | null | undefined } | undefined } = {};
12
+
13
+ public clear(): void {
14
+ this._color = {};
15
+ this._rgba = {};
16
+ }
17
+
18
+ public setCss(bg: number, fg: number, value: string | null): void {
19
+ if (!this._rgba[bg]) {
20
+ this._rgba[bg] = {};
21
+ }
22
+ this._rgba[bg]![fg] = value;
23
+ }
24
+
25
+ public getCss(bg: number, fg: number): string | null | undefined {
26
+ return this._rgba[bg] ? this._rgba[bg]![fg] : undefined;
27
+ }
28
+
29
+ public setColor(bg: number, fg: number, value: IColor | null): void {
30
+ if (!this._color[bg]) {
31
+ this._color[bg] = {};
32
+ }
33
+ this._color[bg]![fg] = value;
34
+ }
35
+
36
+ public getColor(bg: number, fg: number): IColor | null | undefined {
37
+ return this._color[bg] ? this._color[bg]![fg] : undefined;
38
+ }
39
+ }