@xterm/xterm 5.4.0-beta.1
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/LICENSE +21 -0
- package/README.md +235 -0
- package/css/xterm.css +209 -0
- package/lib/xterm.js +2 -0
- package/lib/xterm.js.map +1 -0
- package/package.json +101 -0
- package/src/browser/AccessibilityManager.ts +278 -0
- package/src/browser/Clipboard.ts +93 -0
- package/src/browser/ColorContrastCache.ts +34 -0
- package/src/browser/Lifecycle.ts +33 -0
- package/src/browser/Linkifier2.ts +416 -0
- package/src/browser/LocalizableStrings.ts +12 -0
- package/src/browser/OscLinkProvider.ts +128 -0
- package/src/browser/RenderDebouncer.ts +83 -0
- package/src/browser/Terminal.ts +1317 -0
- package/src/browser/TimeBasedDebouncer.ts +86 -0
- package/src/browser/Types.d.ts +181 -0
- package/src/browser/Viewport.ts +401 -0
- package/src/browser/decorations/BufferDecorationRenderer.ts +134 -0
- package/src/browser/decorations/ColorZoneStore.ts +117 -0
- package/src/browser/decorations/OverviewRulerRenderer.ts +218 -0
- package/src/browser/input/CompositionHelper.ts +246 -0
- package/src/browser/input/Mouse.ts +54 -0
- package/src/browser/input/MoveToCell.ts +249 -0
- package/src/browser/public/Terminal.ts +260 -0
- package/src/browser/renderer/dom/DomRenderer.ts +509 -0
- package/src/browser/renderer/dom/DomRendererRowFactory.ts +526 -0
- package/src/browser/renderer/dom/WidthCache.ts +160 -0
- package/src/browser/renderer/shared/CellColorResolver.ts +137 -0
- package/src/browser/renderer/shared/CharAtlasCache.ts +96 -0
- package/src/browser/renderer/shared/CharAtlasUtils.ts +75 -0
- package/src/browser/renderer/shared/Constants.ts +14 -0
- package/src/browser/renderer/shared/CursorBlinkStateManager.ts +146 -0
- package/src/browser/renderer/shared/CustomGlyphs.ts +687 -0
- package/src/browser/renderer/shared/DevicePixelObserver.ts +41 -0
- package/src/browser/renderer/shared/README.md +1 -0
- package/src/browser/renderer/shared/RendererUtils.ts +58 -0
- package/src/browser/renderer/shared/SelectionRenderModel.ts +91 -0
- package/src/browser/renderer/shared/TextureAtlas.ts +1082 -0
- package/src/browser/renderer/shared/Types.d.ts +173 -0
- package/src/browser/selection/SelectionModel.ts +144 -0
- package/src/browser/selection/Types.d.ts +15 -0
- package/src/browser/services/CharSizeService.ts +102 -0
- package/src/browser/services/CharacterJoinerService.ts +339 -0
- package/src/browser/services/CoreBrowserService.ts +137 -0
- package/src/browser/services/MouseService.ts +46 -0
- package/src/browser/services/RenderService.ts +279 -0
- package/src/browser/services/SelectionService.ts +1031 -0
- package/src/browser/services/Services.ts +147 -0
- package/src/browser/services/ThemeService.ts +237 -0
- package/src/common/CircularList.ts +241 -0
- package/src/common/Clone.ts +23 -0
- package/src/common/Color.ts +357 -0
- package/src/common/CoreTerminal.ts +284 -0
- package/src/common/EventEmitter.ts +78 -0
- package/src/common/InputHandler.ts +3461 -0
- package/src/common/Lifecycle.ts +108 -0
- package/src/common/MultiKeyMap.ts +42 -0
- package/src/common/Platform.ts +44 -0
- package/src/common/SortedList.ts +118 -0
- package/src/common/TaskQueue.ts +166 -0
- package/src/common/TypedArrayUtils.ts +17 -0
- package/src/common/Types.d.ts +553 -0
- package/src/common/WindowsMode.ts +27 -0
- package/src/common/buffer/AttributeData.ts +196 -0
- package/src/common/buffer/Buffer.ts +654 -0
- package/src/common/buffer/BufferLine.ts +524 -0
- package/src/common/buffer/BufferRange.ts +13 -0
- package/src/common/buffer/BufferReflow.ts +223 -0
- package/src/common/buffer/BufferSet.ts +134 -0
- package/src/common/buffer/CellData.ts +94 -0
- package/src/common/buffer/Constants.ts +149 -0
- package/src/common/buffer/Marker.ts +43 -0
- package/src/common/buffer/Types.d.ts +52 -0
- package/src/common/data/Charsets.ts +256 -0
- package/src/common/data/EscapeSequences.ts +153 -0
- package/src/common/input/Keyboard.ts +398 -0
- package/src/common/input/TextDecoder.ts +346 -0
- package/src/common/input/UnicodeV6.ts +145 -0
- package/src/common/input/WriteBuffer.ts +246 -0
- package/src/common/input/XParseColor.ts +80 -0
- package/src/common/parser/Constants.ts +58 -0
- package/src/common/parser/DcsParser.ts +192 -0
- package/src/common/parser/EscapeSequenceParser.ts +792 -0
- package/src/common/parser/OscParser.ts +238 -0
- package/src/common/parser/Params.ts +229 -0
- package/src/common/parser/Types.d.ts +275 -0
- package/src/common/public/AddonManager.ts +53 -0
- package/src/common/public/BufferApiView.ts +35 -0
- package/src/common/public/BufferLineApiView.ts +29 -0
- package/src/common/public/BufferNamespaceApi.ts +36 -0
- package/src/common/public/ParserApi.ts +37 -0
- package/src/common/public/UnicodeApi.ts +27 -0
- package/src/common/services/BufferService.ts +151 -0
- package/src/common/services/CharsetService.ts +34 -0
- package/src/common/services/CoreMouseService.ts +318 -0
- package/src/common/services/CoreService.ts +87 -0
- package/src/common/services/DecorationService.ts +140 -0
- package/src/common/services/InstantiationService.ts +85 -0
- package/src/common/services/LogService.ts +124 -0
- package/src/common/services/OptionsService.ts +202 -0
- package/src/common/services/OscLinkService.ts +115 -0
- package/src/common/services/ServiceRegistry.ts +49 -0
- package/src/common/services/Services.ts +373 -0
- package/src/common/services/UnicodeService.ts +111 -0
- package/src/headless/Terminal.ts +136 -0
- package/src/headless/public/Terminal.ts +195 -0
- package/typings/xterm.d.ts +1857 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
|
|
3
|
+
* @license MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { IAttributeData, IColorRGB, IExtendedAttrs } from 'common/Types';
|
|
7
|
+
import { Attributes, FgFlags, BgFlags, UnderlineStyle, ExtFlags } from 'common/buffer/Constants';
|
|
8
|
+
|
|
9
|
+
export class AttributeData implements IAttributeData {
|
|
10
|
+
public static toColorRGB(value: number): IColorRGB {
|
|
11
|
+
return [
|
|
12
|
+
value >>> Attributes.RED_SHIFT & 255,
|
|
13
|
+
value >>> Attributes.GREEN_SHIFT & 255,
|
|
14
|
+
value & 255
|
|
15
|
+
];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public static fromColorRGB(value: IColorRGB): number {
|
|
19
|
+
return (value[0] & 255) << Attributes.RED_SHIFT | (value[1] & 255) << Attributes.GREEN_SHIFT | value[2] & 255;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public clone(): IAttributeData {
|
|
23
|
+
const newObj = new AttributeData();
|
|
24
|
+
newObj.fg = this.fg;
|
|
25
|
+
newObj.bg = this.bg;
|
|
26
|
+
newObj.extended = this.extended.clone();
|
|
27
|
+
return newObj;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// data
|
|
31
|
+
public fg = 0;
|
|
32
|
+
public bg = 0;
|
|
33
|
+
public extended: IExtendedAttrs = new ExtendedAttrs();
|
|
34
|
+
|
|
35
|
+
// flags
|
|
36
|
+
public isInverse(): number { return this.fg & FgFlags.INVERSE; }
|
|
37
|
+
public isBold(): number { return this.fg & FgFlags.BOLD; }
|
|
38
|
+
public isUnderline(): number {
|
|
39
|
+
if (this.hasExtendedAttrs() && this.extended.underlineStyle !== UnderlineStyle.NONE) {
|
|
40
|
+
return 1;
|
|
41
|
+
}
|
|
42
|
+
return this.fg & FgFlags.UNDERLINE;
|
|
43
|
+
}
|
|
44
|
+
public isBlink(): number { return this.fg & FgFlags.BLINK; }
|
|
45
|
+
public isInvisible(): number { return this.fg & FgFlags.INVISIBLE; }
|
|
46
|
+
public isItalic(): number { return this.bg & BgFlags.ITALIC; }
|
|
47
|
+
public isDim(): number { return this.bg & BgFlags.DIM; }
|
|
48
|
+
public isStrikethrough(): number { return this.fg & FgFlags.STRIKETHROUGH; }
|
|
49
|
+
public isProtected(): number { return this.bg & BgFlags.PROTECTED; }
|
|
50
|
+
public isOverline(): number { return this.bg & BgFlags.OVERLINE; }
|
|
51
|
+
|
|
52
|
+
// color modes
|
|
53
|
+
public getFgColorMode(): number { return this.fg & Attributes.CM_MASK; }
|
|
54
|
+
public getBgColorMode(): number { return this.bg & Attributes.CM_MASK; }
|
|
55
|
+
public isFgRGB(): boolean { return (this.fg & Attributes.CM_MASK) === Attributes.CM_RGB; }
|
|
56
|
+
public isBgRGB(): boolean { return (this.bg & Attributes.CM_MASK) === Attributes.CM_RGB; }
|
|
57
|
+
public isFgPalette(): boolean { return (this.fg & Attributes.CM_MASK) === Attributes.CM_P16 || (this.fg & Attributes.CM_MASK) === Attributes.CM_P256; }
|
|
58
|
+
public isBgPalette(): boolean { return (this.bg & Attributes.CM_MASK) === Attributes.CM_P16 || (this.bg & Attributes.CM_MASK) === Attributes.CM_P256; }
|
|
59
|
+
public isFgDefault(): boolean { return (this.fg & Attributes.CM_MASK) === 0; }
|
|
60
|
+
public isBgDefault(): boolean { return (this.bg & Attributes.CM_MASK) === 0; }
|
|
61
|
+
public isAttributeDefault(): boolean { return this.fg === 0 && this.bg === 0; }
|
|
62
|
+
|
|
63
|
+
// colors
|
|
64
|
+
public getFgColor(): number {
|
|
65
|
+
switch (this.fg & Attributes.CM_MASK) {
|
|
66
|
+
case Attributes.CM_P16:
|
|
67
|
+
case Attributes.CM_P256: return this.fg & Attributes.PCOLOR_MASK;
|
|
68
|
+
case Attributes.CM_RGB: return this.fg & Attributes.RGB_MASK;
|
|
69
|
+
default: return -1; // CM_DEFAULT defaults to -1
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
public getBgColor(): number {
|
|
73
|
+
switch (this.bg & Attributes.CM_MASK) {
|
|
74
|
+
case Attributes.CM_P16:
|
|
75
|
+
case Attributes.CM_P256: return this.bg & Attributes.PCOLOR_MASK;
|
|
76
|
+
case Attributes.CM_RGB: return this.bg & Attributes.RGB_MASK;
|
|
77
|
+
default: return -1; // CM_DEFAULT defaults to -1
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// extended attrs
|
|
82
|
+
public hasExtendedAttrs(): number {
|
|
83
|
+
return this.bg & BgFlags.HAS_EXTENDED;
|
|
84
|
+
}
|
|
85
|
+
public updateExtended(): void {
|
|
86
|
+
if (this.extended.isEmpty()) {
|
|
87
|
+
this.bg &= ~BgFlags.HAS_EXTENDED;
|
|
88
|
+
} else {
|
|
89
|
+
this.bg |= BgFlags.HAS_EXTENDED;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
public getUnderlineColor(): number {
|
|
93
|
+
if ((this.bg & BgFlags.HAS_EXTENDED) && ~this.extended.underlineColor) {
|
|
94
|
+
switch (this.extended.underlineColor & Attributes.CM_MASK) {
|
|
95
|
+
case Attributes.CM_P16:
|
|
96
|
+
case Attributes.CM_P256: return this.extended.underlineColor & Attributes.PCOLOR_MASK;
|
|
97
|
+
case Attributes.CM_RGB: return this.extended.underlineColor & Attributes.RGB_MASK;
|
|
98
|
+
default: return this.getFgColor();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return this.getFgColor();
|
|
102
|
+
}
|
|
103
|
+
public getUnderlineColorMode(): number {
|
|
104
|
+
return (this.bg & BgFlags.HAS_EXTENDED) && ~this.extended.underlineColor
|
|
105
|
+
? this.extended.underlineColor & Attributes.CM_MASK
|
|
106
|
+
: this.getFgColorMode();
|
|
107
|
+
}
|
|
108
|
+
public isUnderlineColorRGB(): boolean {
|
|
109
|
+
return (this.bg & BgFlags.HAS_EXTENDED) && ~this.extended.underlineColor
|
|
110
|
+
? (this.extended.underlineColor & Attributes.CM_MASK) === Attributes.CM_RGB
|
|
111
|
+
: this.isFgRGB();
|
|
112
|
+
}
|
|
113
|
+
public isUnderlineColorPalette(): boolean {
|
|
114
|
+
return (this.bg & BgFlags.HAS_EXTENDED) && ~this.extended.underlineColor
|
|
115
|
+
? (this.extended.underlineColor & Attributes.CM_MASK) === Attributes.CM_P16
|
|
116
|
+
|| (this.extended.underlineColor & Attributes.CM_MASK) === Attributes.CM_P256
|
|
117
|
+
: this.isFgPalette();
|
|
118
|
+
}
|
|
119
|
+
public isUnderlineColorDefault(): boolean {
|
|
120
|
+
return (this.bg & BgFlags.HAS_EXTENDED) && ~this.extended.underlineColor
|
|
121
|
+
? (this.extended.underlineColor & Attributes.CM_MASK) === 0
|
|
122
|
+
: this.isFgDefault();
|
|
123
|
+
}
|
|
124
|
+
public getUnderlineStyle(): UnderlineStyle {
|
|
125
|
+
return this.fg & FgFlags.UNDERLINE
|
|
126
|
+
? (this.bg & BgFlags.HAS_EXTENDED ? this.extended.underlineStyle : UnderlineStyle.SINGLE)
|
|
127
|
+
: UnderlineStyle.NONE;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Extended attributes for a cell.
|
|
134
|
+
* Holds information about different underline styles and color.
|
|
135
|
+
*/
|
|
136
|
+
export class ExtendedAttrs implements IExtendedAttrs {
|
|
137
|
+
private _ext: number = 0;
|
|
138
|
+
public get ext(): number {
|
|
139
|
+
if (this._urlId) {
|
|
140
|
+
return (
|
|
141
|
+
(this._ext & ~ExtFlags.UNDERLINE_STYLE) |
|
|
142
|
+
(this.underlineStyle << 26)
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
return this._ext;
|
|
146
|
+
}
|
|
147
|
+
public set ext(value: number) { this._ext = value; }
|
|
148
|
+
|
|
149
|
+
public get underlineStyle(): UnderlineStyle {
|
|
150
|
+
// Always return the URL style if it has one
|
|
151
|
+
if (this._urlId) {
|
|
152
|
+
return UnderlineStyle.DASHED;
|
|
153
|
+
}
|
|
154
|
+
return (this._ext & ExtFlags.UNDERLINE_STYLE) >> 26;
|
|
155
|
+
}
|
|
156
|
+
public set underlineStyle(value: UnderlineStyle) {
|
|
157
|
+
this._ext &= ~ExtFlags.UNDERLINE_STYLE;
|
|
158
|
+
this._ext |= (value << 26) & ExtFlags.UNDERLINE_STYLE;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
public get underlineColor(): number {
|
|
162
|
+
return this._ext & (Attributes.CM_MASK | Attributes.RGB_MASK);
|
|
163
|
+
}
|
|
164
|
+
public set underlineColor(value: number) {
|
|
165
|
+
this._ext &= ~(Attributes.CM_MASK | Attributes.RGB_MASK);
|
|
166
|
+
this._ext |= value & (Attributes.CM_MASK | Attributes.RGB_MASK);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
private _urlId: number = 0;
|
|
170
|
+
public get urlId(): number {
|
|
171
|
+
return this._urlId;
|
|
172
|
+
}
|
|
173
|
+
public set urlId(value: number) {
|
|
174
|
+
this._urlId = value;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
constructor(
|
|
178
|
+
ext: number = 0,
|
|
179
|
+
urlId: number = 0
|
|
180
|
+
) {
|
|
181
|
+
this._ext = ext;
|
|
182
|
+
this._urlId = urlId;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
public clone(): IExtendedAttrs {
|
|
186
|
+
return new ExtendedAttrs(this._ext, this._urlId);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Convenient method to indicate whether the object holds no additional information,
|
|
191
|
+
* that needs to be persistant in the buffer.
|
|
192
|
+
*/
|
|
193
|
+
public isEmpty(): boolean {
|
|
194
|
+
return this.underlineStyle === UnderlineStyle.NONE && this._urlId === 0;
|
|
195
|
+
}
|
|
196
|
+
}
|