@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.
- package/dist/index.js +1 -1
- package/dist/lib/xterm/LICENSE +21 -0
- package/dist/lib/xterm/README.md +225 -0
- package/dist/lib/xterm/css/xterm.css +190 -0
- package/dist/lib/xterm/lib/xterm.js +2 -0
- package/dist/lib/xterm/lib/xterm.js.map +1 -0
- package/dist/lib/xterm/package.json +90 -0
- package/dist/lib/xterm/src/browser/AccessibilityManager.ts +301 -0
- package/dist/lib/xterm/src/browser/Clipboard.ts +99 -0
- package/dist/lib/xterm/src/browser/ColorContrastCache.ts +39 -0
- package/dist/lib/xterm/src/browser/ColorManager.ts +268 -0
- package/dist/lib/xterm/src/browser/Dom.ts +10 -0
- package/dist/lib/xterm/src/browser/Lifecycle.ts +30 -0
- package/dist/lib/xterm/src/browser/Linkifier.ts +356 -0
- package/dist/lib/xterm/src/browser/Linkifier2.ts +397 -0
- package/dist/lib/xterm/src/browser/LocalizableStrings.ts +10 -0
- package/dist/lib/xterm/src/browser/MouseZoneManager.ts +236 -0
- package/dist/lib/xterm/src/browser/RenderDebouncer.ts +82 -0
- package/dist/lib/xterm/src/browser/ScreenDprMonitor.ts +69 -0
- package/dist/lib/xterm/src/browser/Terminal.ts +1447 -0
- package/dist/lib/xterm/src/browser/TimeBasedDebouncer.ts +86 -0
- package/dist/lib/xterm/src/browser/Types.d.ts +317 -0
- package/dist/lib/xterm/src/browser/Viewport.ts +276 -0
- package/dist/lib/xterm/src/browser/decorations/BufferDecorationRenderer.ts +131 -0
- package/dist/lib/xterm/src/browser/decorations/ColorZoneStore.ts +117 -0
- package/dist/lib/xterm/src/browser/decorations/OverviewRulerRenderer.ts +228 -0
- package/dist/lib/xterm/src/browser/input/CompositionHelper.ts +237 -0
- package/dist/lib/xterm/src/browser/input/Mouse.ts +64 -0
- package/dist/lib/xterm/src/browser/input/MoveToCell.ts +249 -0
- package/dist/lib/xterm/src/browser/public/Terminal.ts +298 -0
- package/dist/lib/xterm/src/browser/renderer/BaseRenderLayer.ts +582 -0
- package/dist/lib/xterm/src/browser/renderer/CursorRenderLayer.ts +378 -0
- package/dist/lib/xterm/src/browser/renderer/CustomGlyphs.ts +632 -0
- package/dist/lib/xterm/src/browser/renderer/GridCache.ts +33 -0
- package/dist/lib/xterm/src/browser/renderer/LinkRenderLayer.ts +84 -0
- package/dist/lib/xterm/src/browser/renderer/Renderer.ts +219 -0
- package/dist/lib/xterm/src/browser/renderer/RendererUtils.ts +26 -0
- package/dist/lib/xterm/src/browser/renderer/SelectionRenderLayer.ts +131 -0
- package/dist/lib/xterm/src/browser/renderer/TextRenderLayer.ts +344 -0
- package/dist/lib/xterm/src/browser/renderer/Types.d.ts +109 -0
- package/dist/lib/xterm/src/browser/renderer/atlas/BaseCharAtlas.ts +58 -0
- package/dist/lib/xterm/src/browser/renderer/atlas/CharAtlasCache.ts +95 -0
- package/dist/lib/xterm/src/browser/renderer/atlas/CharAtlasUtils.ts +54 -0
- package/dist/lib/xterm/src/browser/renderer/atlas/Constants.ts +15 -0
- package/dist/lib/xterm/src/browser/renderer/atlas/DynamicCharAtlas.ts +404 -0
- package/dist/lib/xterm/src/browser/renderer/atlas/LRUMap.ts +136 -0
- package/dist/lib/xterm/src/browser/renderer/atlas/Types.d.ts +29 -0
- package/dist/lib/xterm/src/browser/renderer/dom/DomRenderer.ts +403 -0
- package/dist/lib/xterm/src/browser/renderer/dom/DomRendererRowFactory.ts +344 -0
- package/dist/lib/xterm/src/browser/selection/SelectionModel.ts +144 -0
- package/dist/lib/xterm/src/browser/selection/Types.d.ts +15 -0
- package/dist/lib/xterm/src/browser/services/CharSizeService.ts +87 -0
- package/dist/lib/xterm/src/browser/services/CharacterJoinerService.ts +339 -0
- package/dist/lib/xterm/src/browser/services/CoreBrowserService.ts +20 -0
- package/dist/lib/xterm/src/browser/services/MouseService.ts +36 -0
- package/dist/lib/xterm/src/browser/services/RenderService.ts +237 -0
- package/dist/lib/xterm/src/browser/services/SelectionService.ts +1027 -0
- package/dist/lib/xterm/src/browser/services/Services.ts +123 -0
- package/dist/lib/xterm/src/browser/services/SoundService.ts +63 -0
- package/dist/lib/xterm/src/common/CircularList.ts +239 -0
- package/dist/lib/xterm/src/common/Clone.ts +23 -0
- package/dist/lib/xterm/src/common/Color.ts +285 -0
- package/dist/lib/xterm/src/common/CoreTerminal.ts +300 -0
- package/dist/lib/xterm/src/common/EventEmitter.ts +69 -0
- package/dist/lib/xterm/src/common/InputHandler.ts +3230 -0
- package/dist/lib/xterm/src/common/Lifecycle.ts +68 -0
- package/dist/lib/xterm/src/common/Platform.ts +31 -0
- package/dist/lib/xterm/src/common/SortedList.ts +88 -0
- package/dist/lib/xterm/src/common/TypedArrayUtils.ts +50 -0
- package/dist/lib/xterm/src/common/Types.d.ts +489 -0
- package/dist/lib/xterm/src/common/WindowsMode.ts +27 -0
- package/dist/lib/xterm/src/common/buffer/AttributeData.ts +148 -0
- package/dist/lib/xterm/src/common/buffer/Buffer.ts +711 -0
- package/dist/lib/xterm/src/common/buffer/BufferLine.ts +441 -0
- package/dist/lib/xterm/src/common/buffer/BufferRange.ts +13 -0
- package/dist/lib/xterm/src/common/buffer/BufferReflow.ts +220 -0
- package/dist/lib/xterm/src/common/buffer/BufferSet.ts +131 -0
- package/dist/lib/xterm/src/common/buffer/CellData.ts +94 -0
- package/dist/lib/xterm/src/common/buffer/Constants.ts +139 -0
- package/dist/lib/xterm/src/common/buffer/Marker.ts +37 -0
- package/dist/lib/xterm/src/common/buffer/Types.d.ts +64 -0
- package/dist/lib/xterm/src/common/data/Charsets.ts +256 -0
- package/dist/lib/xterm/src/common/data/EscapeSequences.ts +153 -0
- package/dist/lib/xterm/src/common/input/Keyboard.ts +398 -0
- package/dist/lib/xterm/src/common/input/TextDecoder.ts +346 -0
- package/dist/lib/xterm/src/common/input/UnicodeV6.ts +133 -0
- package/dist/lib/xterm/src/common/input/WriteBuffer.ts +229 -0
- package/dist/lib/xterm/src/common/input/XParseColor.ts +80 -0
- package/dist/lib/xterm/src/common/parser/Constants.ts +58 -0
- package/dist/lib/xterm/src/common/parser/DcsParser.ts +192 -0
- package/dist/lib/xterm/src/common/parser/EscapeSequenceParser.ts +796 -0
- package/dist/lib/xterm/src/common/parser/OscParser.ts +238 -0
- package/dist/lib/xterm/src/common/parser/Params.ts +229 -0
- package/dist/lib/xterm/src/common/parser/Types.d.ts +274 -0
- package/dist/lib/xterm/src/common/public/AddonManager.ts +56 -0
- package/dist/lib/xterm/src/common/public/BufferApiView.ts +35 -0
- package/dist/lib/xterm/src/common/public/BufferLineApiView.ts +29 -0
- package/dist/lib/xterm/src/common/public/BufferNamespaceApi.ts +33 -0
- package/dist/lib/xterm/src/common/public/ParserApi.ts +37 -0
- package/dist/lib/xterm/src/common/public/UnicodeApi.ts +27 -0
- package/dist/lib/xterm/src/common/services/BufferService.ts +185 -0
- package/dist/lib/xterm/src/common/services/CharsetService.ts +34 -0
- package/dist/lib/xterm/src/common/services/CoreMouseService.ts +309 -0
- package/dist/lib/xterm/src/common/services/CoreService.ts +92 -0
- package/dist/lib/xterm/src/common/services/DecorationService.ts +139 -0
- package/dist/lib/xterm/src/common/services/DirtyRowService.ts +53 -0
- package/dist/lib/xterm/src/common/services/InstantiationService.ts +83 -0
- package/dist/lib/xterm/src/common/services/LogService.ts +88 -0
- package/dist/lib/xterm/src/common/services/OptionsService.ts +178 -0
- package/dist/lib/xterm/src/common/services/ServiceRegistry.ts +49 -0
- package/dist/lib/xterm/src/common/services/Services.ts +323 -0
- package/dist/lib/xterm/src/common/services/UnicodeService.ts +82 -0
- package/dist/lib/xterm/src/headless/Terminal.ts +170 -0
- package/dist/lib/xterm/src/headless/Types.d.ts +31 -0
- package/dist/lib/xterm/src/headless/public/Terminal.ts +216 -0
- package/dist/lib/xterm/typings/xterm.d.ts +1872 -0
- package/dist/lib/xterm-fit/LICENSE +19 -0
- package/dist/lib/xterm-fit/README.md +24 -0
- package/dist/lib/xterm-fit/lib/xterm-addon-fit.js +2 -0
- package/dist/lib/xterm-fit/lib/xterm-addon-fit.js.map +1 -0
- package/dist/lib/xterm-fit/out/FitAddon.js +58 -0
- package/dist/lib/xterm-fit/out/FitAddon.js.map +1 -0
- package/dist/lib/xterm-fit/out-test/FitAddon.api.js.map +1 -0
- package/dist/lib/xterm-fit/package.json +21 -0
- package/dist/lib/xterm-fit/src/FitAddon.ts +86 -0
- package/dist/lib/xterm-fit/typings/xterm-addon-fit.d.ts +55 -0
- package/dist/lib/xterm-links/LICENSE +19 -0
- package/dist/lib/xterm-links/README.md +21 -0
- package/dist/lib/xterm-links/lib/xterm-addon-web-links.js +2 -0
- package/dist/lib/xterm-links/lib/xterm-addon-web-links.js.map +1 -0
- package/dist/lib/xterm-links/package.json +26 -0
- package/dist/lib/xterm-links/src/WebLinkProvider.ts +145 -0
- package/dist/lib/xterm-links/src/WebLinksAddon.ts +77 -0
- package/dist/lib/xterm-links/typings/xterm-addon-web-links.d.ts +58 -0
- package/package.json +1 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2017 The xterm.js authors. All rights reserved.
|
|
3
|
+
* @license MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { IRenderDimensions } from 'browser/renderer/Types';
|
|
7
|
+
import { BaseRenderLayer } from './BaseRenderLayer';
|
|
8
|
+
import { INVERTED_DEFAULT_COLOR } from 'browser/renderer/atlas/Constants';
|
|
9
|
+
import { is256Color } from 'browser/renderer/atlas/CharAtlasUtils';
|
|
10
|
+
import { IColorSet, ILinkifierEvent, ILinkifier, ILinkifier2 } from 'browser/Types';
|
|
11
|
+
import { IBufferService, IDecorationService, IOptionsService } from 'common/services/Services';
|
|
12
|
+
|
|
13
|
+
export class LinkRenderLayer extends BaseRenderLayer {
|
|
14
|
+
private _state: ILinkifierEvent | undefined;
|
|
15
|
+
|
|
16
|
+
constructor(
|
|
17
|
+
container: HTMLElement,
|
|
18
|
+
zIndex: number,
|
|
19
|
+
colors: IColorSet,
|
|
20
|
+
rendererId: number,
|
|
21
|
+
linkifier: ILinkifier,
|
|
22
|
+
linkifier2: ILinkifier2,
|
|
23
|
+
@IBufferService bufferService: IBufferService,
|
|
24
|
+
@IOptionsService optionsService: IOptionsService,
|
|
25
|
+
@IDecorationService decorationService: IDecorationService
|
|
26
|
+
) {
|
|
27
|
+
super(container, 'link', zIndex, true, colors, rendererId, bufferService, optionsService, decorationService);
|
|
28
|
+
linkifier.onShowLinkUnderline(e => this._onShowLinkUnderline(e));
|
|
29
|
+
linkifier.onHideLinkUnderline(e => this._onHideLinkUnderline(e));
|
|
30
|
+
|
|
31
|
+
linkifier2.onShowLinkUnderline(e => this._onShowLinkUnderline(e));
|
|
32
|
+
linkifier2.onHideLinkUnderline(e => this._onHideLinkUnderline(e));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public resize(dim: IRenderDimensions): void {
|
|
36
|
+
super.resize(dim);
|
|
37
|
+
// Resizing the canvas discards the contents of the canvas so clear state
|
|
38
|
+
this._state = undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public reset(): void {
|
|
42
|
+
this._clearCurrentLink();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private _clearCurrentLink(): void {
|
|
46
|
+
if (this._state) {
|
|
47
|
+
this._clearCells(this._state.x1, this._state.y1, this._state.cols - this._state.x1, 1);
|
|
48
|
+
const middleRowCount = this._state.y2 - this._state.y1 - 1;
|
|
49
|
+
if (middleRowCount > 0) {
|
|
50
|
+
this._clearCells(0, this._state.y1 + 1, this._state.cols, middleRowCount);
|
|
51
|
+
}
|
|
52
|
+
this._clearCells(0, this._state.y2, this._state.x2, 1);
|
|
53
|
+
this._state = undefined;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private _onShowLinkUnderline(e: ILinkifierEvent): void {
|
|
58
|
+
if (e.fg === INVERTED_DEFAULT_COLOR) {
|
|
59
|
+
this._ctx.fillStyle = this._colors.background.css;
|
|
60
|
+
} else if (e.fg && is256Color(e.fg)) {
|
|
61
|
+
// 256 color support
|
|
62
|
+
this._ctx.fillStyle = this._colors.ansi[e.fg].css;
|
|
63
|
+
} else {
|
|
64
|
+
this._ctx.fillStyle = this._colors.foreground.css;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (e.y1 === e.y2) {
|
|
68
|
+
// Single line link
|
|
69
|
+
this._fillBottomLineAtCells(e.x1, e.y1, e.x2 - e.x1);
|
|
70
|
+
} else {
|
|
71
|
+
// Multi-line link
|
|
72
|
+
this._fillBottomLineAtCells(e.x1, e.y1, e.cols - e.x1);
|
|
73
|
+
for (let y = e.y1 + 1; y < e.y2; y++) {
|
|
74
|
+
this._fillBottomLineAtCells(0, y, e.cols);
|
|
75
|
+
}
|
|
76
|
+
this._fillBottomLineAtCells(0, e.y2, e.x2);
|
|
77
|
+
}
|
|
78
|
+
this._state = e;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
private _onHideLinkUnderline(e: ILinkifierEvent): void {
|
|
82
|
+
this._clearCurrentLink();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2017 The xterm.js authors. All rights reserved.
|
|
3
|
+
* @license MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { TextRenderLayer } from 'browser/renderer/TextRenderLayer';
|
|
7
|
+
import { SelectionRenderLayer } from 'browser/renderer/SelectionRenderLayer';
|
|
8
|
+
import { CursorRenderLayer } from 'browser/renderer/CursorRenderLayer';
|
|
9
|
+
import { IRenderLayer, IRenderer, IRenderDimensions, IRequestRedrawEvent } from 'browser/renderer/Types';
|
|
10
|
+
import { LinkRenderLayer } from 'browser/renderer/LinkRenderLayer';
|
|
11
|
+
import { Disposable } from 'common/Lifecycle';
|
|
12
|
+
import { IColorSet, ILinkifier, ILinkifier2 } from 'browser/Types';
|
|
13
|
+
import { ICharSizeService } from 'browser/services/Services';
|
|
14
|
+
import { IBufferService, IOptionsService, IInstantiationService } from 'common/services/Services';
|
|
15
|
+
import { removeTerminalFromCache } from 'browser/renderer/atlas/CharAtlasCache';
|
|
16
|
+
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
|
17
|
+
|
|
18
|
+
let nextRendererId = 1;
|
|
19
|
+
|
|
20
|
+
export class Renderer extends Disposable implements IRenderer {
|
|
21
|
+
private _id = nextRendererId++;
|
|
22
|
+
|
|
23
|
+
private _renderLayers: IRenderLayer[];
|
|
24
|
+
private _devicePixelRatio: number;
|
|
25
|
+
|
|
26
|
+
public dimensions: IRenderDimensions;
|
|
27
|
+
|
|
28
|
+
private _onRequestRedraw = new EventEmitter<IRequestRedrawEvent>();
|
|
29
|
+
public get onRequestRedraw(): IEvent<IRequestRedrawEvent> { return this._onRequestRedraw.event; }
|
|
30
|
+
|
|
31
|
+
constructor(
|
|
32
|
+
private _colors: IColorSet,
|
|
33
|
+
private readonly _screenElement: HTMLElement,
|
|
34
|
+
linkifier: ILinkifier,
|
|
35
|
+
linkifier2: ILinkifier2,
|
|
36
|
+
@IInstantiationService instantiationService: IInstantiationService,
|
|
37
|
+
@IBufferService private readonly _bufferService: IBufferService,
|
|
38
|
+
@ICharSizeService private readonly _charSizeService: ICharSizeService,
|
|
39
|
+
@IOptionsService private readonly _optionsService: IOptionsService
|
|
40
|
+
) {
|
|
41
|
+
super();
|
|
42
|
+
const allowTransparency = this._optionsService.rawOptions.allowTransparency;
|
|
43
|
+
this._renderLayers = [
|
|
44
|
+
instantiationService.createInstance(TextRenderLayer, this._screenElement, 0, this._colors, allowTransparency, this._id),
|
|
45
|
+
instantiationService.createInstance(SelectionRenderLayer, this._screenElement, 1, this._colors, this._id),
|
|
46
|
+
instantiationService.createInstance(LinkRenderLayer, this._screenElement, 2, this._colors, this._id, linkifier, linkifier2),
|
|
47
|
+
instantiationService.createInstance(CursorRenderLayer, this._screenElement, 3, this._colors, this._id, this._onRequestRedraw)
|
|
48
|
+
];
|
|
49
|
+
this.dimensions = {
|
|
50
|
+
scaledCharWidth: 0,
|
|
51
|
+
scaledCharHeight: 0,
|
|
52
|
+
scaledCellWidth: 0,
|
|
53
|
+
scaledCellHeight: 0,
|
|
54
|
+
scaledCharLeft: 0,
|
|
55
|
+
scaledCharTop: 0,
|
|
56
|
+
scaledCanvasWidth: 0,
|
|
57
|
+
scaledCanvasHeight: 0,
|
|
58
|
+
canvasWidth: 0,
|
|
59
|
+
canvasHeight: 0,
|
|
60
|
+
actualCellWidth: 0,
|
|
61
|
+
actualCellHeight: 0
|
|
62
|
+
};
|
|
63
|
+
this._devicePixelRatio = window.devicePixelRatio;
|
|
64
|
+
this._updateDimensions();
|
|
65
|
+
this.onOptionsChanged();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public dispose(): void {
|
|
69
|
+
for (const l of this._renderLayers) {
|
|
70
|
+
l.dispose();
|
|
71
|
+
}
|
|
72
|
+
super.dispose();
|
|
73
|
+
removeTerminalFromCache(this._id);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public onDevicePixelRatioChange(): void {
|
|
77
|
+
// If the device pixel ratio changed, the char atlas needs to be regenerated
|
|
78
|
+
// and the terminal needs to refreshed
|
|
79
|
+
if (this._devicePixelRatio !== window.devicePixelRatio) {
|
|
80
|
+
this._devicePixelRatio = window.devicePixelRatio;
|
|
81
|
+
this.onResize(this._bufferService.cols, this._bufferService.rows);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public setColors(colors: IColorSet): void {
|
|
86
|
+
this._colors = colors;
|
|
87
|
+
// Clear layers and force a full render
|
|
88
|
+
for (const l of this._renderLayers) {
|
|
89
|
+
l.setColors(this._colors);
|
|
90
|
+
l.reset();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
public onResize(cols: number, rows: number): void {
|
|
95
|
+
// Update character and canvas dimensions
|
|
96
|
+
this._updateDimensions();
|
|
97
|
+
|
|
98
|
+
// Resize all render layers
|
|
99
|
+
for (const l of this._renderLayers) {
|
|
100
|
+
l.resize(this.dimensions);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Resize the screen
|
|
104
|
+
this._screenElement.style.width = `${this.dimensions.canvasWidth}px`;
|
|
105
|
+
this._screenElement.style.height = `${this.dimensions.canvasHeight}px`;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public onCharSizeChanged(): void {
|
|
109
|
+
this.onResize(this._bufferService.cols, this._bufferService.rows);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
public onBlur(): void {
|
|
113
|
+
this._runOperation(l => l.onBlur());
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
public onFocus(): void {
|
|
117
|
+
this._runOperation(l => l.onFocus());
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
public onSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean = false): void {
|
|
121
|
+
this._runOperation(l => l.onSelectionChanged(start, end, columnSelectMode));
|
|
122
|
+
// Selection foreground requires a full re-render
|
|
123
|
+
if (this._colors.selectionForeground) {
|
|
124
|
+
this._onRequestRedraw.fire({ start: 0, end: this._bufferService.rows - 1 });
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
public onCursorMove(): void {
|
|
129
|
+
this._runOperation(l => l.onCursorMove());
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
public onOptionsChanged(): void {
|
|
133
|
+
this._runOperation(l => l.onOptionsChanged());
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
public clear(): void {
|
|
137
|
+
this._runOperation(l => l.reset());
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
private _runOperation(operation: (layer: IRenderLayer) => void): void {
|
|
141
|
+
for (const l of this._renderLayers) {
|
|
142
|
+
operation(l);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Performs the refresh loop callback, calling refresh only if a refresh is
|
|
148
|
+
* necessary before queueing up the next one.
|
|
149
|
+
*/
|
|
150
|
+
public renderRows(start: number, end: number): void {
|
|
151
|
+
for (const l of this._renderLayers) {
|
|
152
|
+
l.onGridChanged(start, end);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
public clearTextureAtlas(): void {
|
|
157
|
+
for (const layer of this._renderLayers) {
|
|
158
|
+
layer.clearTextureAtlas();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Recalculates the character and canvas dimensions.
|
|
164
|
+
*/
|
|
165
|
+
private _updateDimensions(): void {
|
|
166
|
+
if (!this._charSizeService.hasValidSize) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Calculate the scaled character width. Width is floored as it must be
|
|
171
|
+
// drawn to an integer grid in order for the CharAtlas "stamps" to not be
|
|
172
|
+
// blurry. When text is drawn to the grid not using the CharAtlas, it is
|
|
173
|
+
// clipped to ensure there is no overlap with the next cell.
|
|
174
|
+
this.dimensions.scaledCharWidth = Math.floor(this._charSizeService.width * window.devicePixelRatio);
|
|
175
|
+
|
|
176
|
+
// Calculate the scaled character height. Height is ceiled in case
|
|
177
|
+
// devicePixelRatio is a floating point number in order to ensure there is
|
|
178
|
+
// enough space to draw the character to the cell.
|
|
179
|
+
this.dimensions.scaledCharHeight = Math.ceil(this._charSizeService.height * window.devicePixelRatio);
|
|
180
|
+
|
|
181
|
+
// Calculate the scaled cell height, if lineHeight is not 1 then the value
|
|
182
|
+
// will be floored because since lineHeight can never be lower then 1, there
|
|
183
|
+
// is a guarentee that the scaled line height will always be larger than
|
|
184
|
+
// scaled char height.
|
|
185
|
+
this.dimensions.scaledCellHeight = Math.floor(this.dimensions.scaledCharHeight * this._optionsService.rawOptions.lineHeight);
|
|
186
|
+
|
|
187
|
+
// Calculate the y coordinate within a cell that text should draw from in
|
|
188
|
+
// order to draw in the center of a cell.
|
|
189
|
+
this.dimensions.scaledCharTop = this._optionsService.rawOptions.lineHeight === 1 ? 0 : Math.round((this.dimensions.scaledCellHeight - this.dimensions.scaledCharHeight) / 2);
|
|
190
|
+
|
|
191
|
+
// Calculate the scaled cell width, taking the letterSpacing into account.
|
|
192
|
+
this.dimensions.scaledCellWidth = this.dimensions.scaledCharWidth + Math.round(this._optionsService.rawOptions.letterSpacing);
|
|
193
|
+
|
|
194
|
+
// Calculate the x coordinate with a cell that text should draw from in
|
|
195
|
+
// order to draw in the center of a cell.
|
|
196
|
+
this.dimensions.scaledCharLeft = Math.floor(this._optionsService.rawOptions.letterSpacing / 2);
|
|
197
|
+
|
|
198
|
+
// Recalculate the canvas dimensions; scaled* define the actual number of
|
|
199
|
+
// pixel in the canvas
|
|
200
|
+
this.dimensions.scaledCanvasHeight = this._bufferService.rows * this.dimensions.scaledCellHeight;
|
|
201
|
+
this.dimensions.scaledCanvasWidth = this._bufferService.cols * this.dimensions.scaledCellWidth;
|
|
202
|
+
|
|
203
|
+
// The the size of the canvas on the page. It's very important that this
|
|
204
|
+
// rounds to nearest integer and not ceils as browsers often set
|
|
205
|
+
// window.devicePixelRatio as something like 1.100000023841858, when it's
|
|
206
|
+
// actually 1.1. Ceiling causes blurriness as the backing canvas image is 1
|
|
207
|
+
// pixel too large for the canvas element size.
|
|
208
|
+
this.dimensions.canvasHeight = Math.round(this.dimensions.scaledCanvasHeight / window.devicePixelRatio);
|
|
209
|
+
this.dimensions.canvasWidth = Math.round(this.dimensions.scaledCanvasWidth / window.devicePixelRatio);
|
|
210
|
+
|
|
211
|
+
// Get the _actual_ dimensions of an individual cell. This needs to be
|
|
212
|
+
// derived from the canvasWidth/Height calculated above which takes into
|
|
213
|
+
// account window.devicePixelRatio. ICharSizeService.width/height by itself
|
|
214
|
+
// is insufficient when the page is not at 100% zoom level as it's measured
|
|
215
|
+
// in CSS pixels, but the actual char size on the canvas can differ.
|
|
216
|
+
this.dimensions.actualCellHeight = this.dimensions.canvasHeight / this._bufferService.rows;
|
|
217
|
+
this.dimensions.actualCellWidth = this.dimensions.canvasWidth / this._bufferService.cols;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
|
|
3
|
+
* @license MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export function throwIfFalsy<T>(value: T | undefined | null): T {
|
|
7
|
+
if (!value) {
|
|
8
|
+
throw new Error('value must not be falsy');
|
|
9
|
+
}
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function isPowerlineGlyph(codepoint: number): boolean {
|
|
14
|
+
// Only return true for Powerline symbols which require
|
|
15
|
+
// different padding and should be excluded from minimum contrast
|
|
16
|
+
// ratio standards
|
|
17
|
+
return 0xE0A4 <= codepoint && codepoint <= 0xE0D6;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function isBoxOrBlockGlyph(codepoint: number): boolean {
|
|
21
|
+
return (0x2500 <= codepoint && codepoint <= 0x259F);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function excludeFromContrastRatioDemands(codepoint: number): boolean {
|
|
25
|
+
return isPowerlineGlyph(codepoint) || isBoxOrBlockGlyph(codepoint);
|
|
26
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2017 The xterm.js authors. All rights reserved.
|
|
3
|
+
* @license MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { IRenderDimensions } from 'browser/renderer/Types';
|
|
7
|
+
import { BaseRenderLayer } from 'browser/renderer/BaseRenderLayer';
|
|
8
|
+
import { IColorSet } from 'browser/Types';
|
|
9
|
+
import { IBufferService, IDecorationService, IOptionsService } from 'common/services/Services';
|
|
10
|
+
|
|
11
|
+
interface ISelectionState {
|
|
12
|
+
start?: [number, number];
|
|
13
|
+
end?: [number, number];
|
|
14
|
+
columnSelectMode?: boolean;
|
|
15
|
+
ydisp?: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class SelectionRenderLayer extends BaseRenderLayer {
|
|
19
|
+
private _state!: ISelectionState;
|
|
20
|
+
|
|
21
|
+
constructor(
|
|
22
|
+
container: HTMLElement,
|
|
23
|
+
zIndex: number,
|
|
24
|
+
colors: IColorSet,
|
|
25
|
+
rendererId: number,
|
|
26
|
+
@IBufferService bufferService: IBufferService,
|
|
27
|
+
@IOptionsService optionsService: IOptionsService,
|
|
28
|
+
@IDecorationService decorationService: IDecorationService
|
|
29
|
+
) {
|
|
30
|
+
super(container, 'selection', zIndex, true, colors, rendererId, bufferService, optionsService, decorationService);
|
|
31
|
+
this._clearState();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private _clearState(): void {
|
|
35
|
+
this._state = {
|
|
36
|
+
start: undefined,
|
|
37
|
+
end: undefined,
|
|
38
|
+
columnSelectMode: undefined,
|
|
39
|
+
ydisp: undefined
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public resize(dim: IRenderDimensions): void {
|
|
44
|
+
super.resize(dim);
|
|
45
|
+
// Resizing the canvas discards the contents of the canvas so clear state
|
|
46
|
+
this._clearState();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public reset(): void {
|
|
50
|
+
if (this._state.start && this._state.end) {
|
|
51
|
+
this._clearState();
|
|
52
|
+
this._clearAll();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public onSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void {
|
|
57
|
+
super.onSelectionChanged(start, end, columnSelectMode);
|
|
58
|
+
|
|
59
|
+
// Selection has not changed
|
|
60
|
+
if (!this._didStateChange(start, end, columnSelectMode, this._bufferService.buffer.ydisp)) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Remove all selections
|
|
65
|
+
this._clearAll();
|
|
66
|
+
|
|
67
|
+
// Selection does not exist
|
|
68
|
+
if (!start || !end) {
|
|
69
|
+
this._clearState();
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Translate from buffer position to viewport position
|
|
74
|
+
const viewportStartRow = start[1] - this._bufferService.buffer.ydisp;
|
|
75
|
+
const viewportEndRow = end[1] - this._bufferService.buffer.ydisp;
|
|
76
|
+
const viewportCappedStartRow = Math.max(viewportStartRow, 0);
|
|
77
|
+
const viewportCappedEndRow = Math.min(viewportEndRow, this._bufferService.rows - 1);
|
|
78
|
+
|
|
79
|
+
// No need to draw the selection
|
|
80
|
+
if (viewportCappedStartRow >= this._bufferService.rows || viewportCappedEndRow < 0) {
|
|
81
|
+
this._state.ydisp = this._bufferService.buffer.ydisp;
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
this._ctx.fillStyle = this._colors.selectionTransparent.css;
|
|
86
|
+
|
|
87
|
+
if (columnSelectMode) {
|
|
88
|
+
const startCol = start[0];
|
|
89
|
+
const width = end[0] - startCol;
|
|
90
|
+
const height = viewportCappedEndRow - viewportCappedStartRow + 1;
|
|
91
|
+
this._fillCells(startCol, viewportCappedStartRow, width, height);
|
|
92
|
+
} else {
|
|
93
|
+
// Draw first row
|
|
94
|
+
const startCol = viewportStartRow === viewportCappedStartRow ? start[0] : 0;
|
|
95
|
+
const startRowEndCol = viewportCappedStartRow === viewportEndRow ? end[0] : this._bufferService.cols;
|
|
96
|
+
this._fillCells(startCol, viewportCappedStartRow, startRowEndCol - startCol, 1);
|
|
97
|
+
|
|
98
|
+
// Draw middle rows
|
|
99
|
+
const middleRowsCount = Math.max(viewportCappedEndRow - viewportCappedStartRow - 1, 0);
|
|
100
|
+
this._fillCells(0, viewportCappedStartRow + 1, this._bufferService.cols, middleRowsCount);
|
|
101
|
+
|
|
102
|
+
// Draw final row
|
|
103
|
+
if (viewportCappedStartRow !== viewportCappedEndRow) {
|
|
104
|
+
// Only draw viewportEndRow if it's not the same as viewportStartRow
|
|
105
|
+
const endCol = viewportEndRow === viewportCappedEndRow ? end[0] : this._bufferService.cols;
|
|
106
|
+
this._fillCells(0, viewportCappedEndRow, endCol, 1);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Save state for next render
|
|
111
|
+
this._state.start = [start[0], start[1]];
|
|
112
|
+
this._state.end = [end[0], end[1]];
|
|
113
|
+
this._state.columnSelectMode = columnSelectMode;
|
|
114
|
+
this._state.ydisp = this._bufferService.buffer.ydisp;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private _didStateChange(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean, ydisp: number): boolean {
|
|
118
|
+
return !this._areCoordinatesEqual(start, this._state.start) ||
|
|
119
|
+
!this._areCoordinatesEqual(end, this._state.end) ||
|
|
120
|
+
columnSelectMode !== this._state.columnSelectMode ||
|
|
121
|
+
ydisp !== this._state.ydisp;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
private _areCoordinatesEqual(coord1: [number, number] | undefined, coord2: [number, number] | undefined): boolean {
|
|
125
|
+
if (!coord1 || !coord2) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return coord1[0] === coord2[0] && coord1[1] === coord2[1];
|
|
130
|
+
}
|
|
131
|
+
}
|