@xterm/xterm 5.4.0-beta.21 → 5.4.0-beta.22
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/lib/xterm.js +1 -1
- package/lib/xterm.js.map +1 -1
- package/package.json +1 -1
- package/src/browser/Terminal.ts +5 -5
- package/src/browser/renderer/dom/DomRendererRowFactory.ts +3 -3
- package/src/browser/renderer/shared/TextureAtlas.ts +4 -5
- package/src/common/Color.ts +11 -12
- package/src/common/Types.d.ts +2 -2
package/package.json
CHANGED
package/src/browser/Terminal.ts
CHANGED
|
@@ -41,7 +41,7 @@ import { RenderService } from 'browser/services/RenderService';
|
|
|
41
41
|
import { SelectionService } from 'browser/services/SelectionService';
|
|
42
42
|
import { ICharSizeService, ICharacterJoinerService, ICoreBrowserService, ILinkProviderService, IMouseService, IRenderService, ISelectionService, IThemeService } from 'browser/services/Services';
|
|
43
43
|
import { ThemeService } from 'browser/services/ThemeService';
|
|
44
|
-
import {
|
|
44
|
+
import { channels, color } from 'common/Color';
|
|
45
45
|
import { CoreTerminal } from 'common/CoreTerminal';
|
|
46
46
|
import { EventEmitter, IEvent, forwardEvent } from 'common/EventEmitter';
|
|
47
47
|
import { MutableDisposable, toDisposable } from 'common/Lifecycle';
|
|
@@ -211,17 +211,17 @@ export class Terminal extends CoreTerminal implements ITerminal {
|
|
|
211
211
|
}
|
|
212
212
|
switch (req.type) {
|
|
213
213
|
case ColorRequestType.REPORT:
|
|
214
|
-
const
|
|
214
|
+
const colorRgb = color.toColorRGB(acc === 'ansi'
|
|
215
215
|
? this._themeService.colors.ansi[req.index]
|
|
216
216
|
: this._themeService.colors[acc]);
|
|
217
|
-
this.coreService.triggerDataEvent(`${C0.ESC}]${ident};${toRgbString(
|
|
217
|
+
this.coreService.triggerDataEvent(`${C0.ESC}]${ident};${toRgbString(colorRgb)}${C1_ESCAPED.ST}`);
|
|
218
218
|
break;
|
|
219
219
|
case ColorRequestType.SET:
|
|
220
220
|
if (acc === 'ansi') {
|
|
221
|
-
this._themeService.modifyColors(colors => colors.ansi[req.index] =
|
|
221
|
+
this._themeService.modifyColors(colors => colors.ansi[req.index] = channels.toColor(...req.color));
|
|
222
222
|
} else {
|
|
223
223
|
const narrowedAcc = acc;
|
|
224
|
-
this._themeService.modifyColors(colors => colors[narrowedAcc] =
|
|
224
|
+
this._themeService.modifyColors(colors => colors[narrowedAcc] = channels.toColor(...req.color));
|
|
225
225
|
}
|
|
226
226
|
break;
|
|
227
227
|
case ColorRequestType.RESTORE:
|
|
@@ -8,7 +8,7 @@ import { INVERTED_DEFAULT_COLOR } from 'browser/renderer/shared/Constants';
|
|
|
8
8
|
import { WHITESPACE_CELL_CHAR, Attributes } from 'common/buffer/Constants';
|
|
9
9
|
import { CellData } from 'common/buffer/CellData';
|
|
10
10
|
import { ICoreService, IDecorationService, IOptionsService } from 'common/services/Services';
|
|
11
|
-
import {
|
|
11
|
+
import { channels, color } from 'common/Color';
|
|
12
12
|
import { ICharacterJoinerService, ICoreBrowserService, IThemeService } from 'browser/services/Services';
|
|
13
13
|
import { JoinedCellData } from 'browser/services/CharacterJoinerService';
|
|
14
14
|
import { treatGlyphAsBackgroundColor } from 'browser/renderer/shared/RendererUtils';
|
|
@@ -376,7 +376,7 @@ export class DomRendererRowFactory {
|
|
|
376
376
|
classes.push(`xterm-bg-${bg}`);
|
|
377
377
|
break;
|
|
378
378
|
case Attributes.CM_RGB:
|
|
379
|
-
resolvedBg =
|
|
379
|
+
resolvedBg = channels.toColor(bg >> 16, bg >> 8 & 0xFF, bg & 0xFF);
|
|
380
380
|
this._addStyle(charElement, `background-color:#${padStart((bg >>> 0).toString(16), '0', 6)}`);
|
|
381
381
|
break;
|
|
382
382
|
case Attributes.CM_DEFAULT:
|
|
@@ -408,7 +408,7 @@ export class DomRendererRowFactory {
|
|
|
408
408
|
}
|
|
409
409
|
break;
|
|
410
410
|
case Attributes.CM_RGB:
|
|
411
|
-
const color =
|
|
411
|
+
const color = channels.toColor(
|
|
412
412
|
(fg >> 16) & 0xFF,
|
|
413
413
|
(fg >> 8) & 0xFF,
|
|
414
414
|
(fg ) & 0xFF
|
|
@@ -8,7 +8,7 @@ import { DIM_OPACITY, TEXT_BASELINE } from 'browser/renderer/shared/Constants';
|
|
|
8
8
|
import { tryDrawCustomChar } from 'browser/renderer/shared/CustomGlyphs';
|
|
9
9
|
import { computeNextVariantOffset, treatGlyphAsBackgroundColor, isPowerlineGlyph, isRestrictedPowerlineGlyph, throwIfFalsy } from 'browser/renderer/shared/RendererUtils';
|
|
10
10
|
import { IBoundingBox, ICharAtlasConfig, IRasterizedGlyph, ITextureAtlas } from 'browser/renderer/shared/Types';
|
|
11
|
-
import { NULL_COLOR, color, rgba } from 'common/Color';
|
|
11
|
+
import { NULL_COLOR, channels, color, rgba } from 'common/Color';
|
|
12
12
|
import { EventEmitter } from 'common/EventEmitter';
|
|
13
13
|
import { FourKeyMap } from 'common/MultiKeyMap';
|
|
14
14
|
import { IdleTaskQueue } from 'common/TaskQueue';
|
|
@@ -291,8 +291,7 @@ export class TextureAtlas implements ITextureAtlas {
|
|
|
291
291
|
break;
|
|
292
292
|
case Attributes.CM_RGB:
|
|
293
293
|
const arr = AttributeData.toColorRGB(bgColor);
|
|
294
|
-
|
|
295
|
-
result = rgba.toColor(arr[0], arr[1], arr[2]);
|
|
294
|
+
result = channels.toColor(arr[0], arr[1], arr[2]);
|
|
296
295
|
break;
|
|
297
296
|
case Attributes.CM_DEFAULT:
|
|
298
297
|
default:
|
|
@@ -324,7 +323,7 @@ export class TextureAtlas implements ITextureAtlas {
|
|
|
324
323
|
break;
|
|
325
324
|
case Attributes.CM_RGB:
|
|
326
325
|
const arr = AttributeData.toColorRGB(fgColor);
|
|
327
|
-
result =
|
|
326
|
+
result = channels.toColor(arr[0], arr[1], arr[2]);
|
|
328
327
|
break;
|
|
329
328
|
case Attributes.CM_DEFAULT:
|
|
330
329
|
default:
|
|
@@ -406,7 +405,7 @@ export class TextureAtlas implements ITextureAtlas {
|
|
|
406
405
|
return undefined;
|
|
407
406
|
}
|
|
408
407
|
|
|
409
|
-
const color =
|
|
408
|
+
const color = channels.toColor(
|
|
410
409
|
(result >> 24) & 0xFF,
|
|
411
410
|
(result >> 16) & 0xFF,
|
|
412
411
|
(result >> 8) & 0xFF
|
package/src/common/Color.ts
CHANGED
|
@@ -33,6 +33,13 @@ export namespace channels {
|
|
|
33
33
|
// >>> 0 forces an unsigned int
|
|
34
34
|
return (r << 24 | g << 16 | b << 8 | a) >>> 0;
|
|
35
35
|
}
|
|
36
|
+
|
|
37
|
+
export function toColor(r: number, g: number, b: number, a?: number): IColor {
|
|
38
|
+
return {
|
|
39
|
+
css: channels.toCss(r, g, b, a),
|
|
40
|
+
rgba: channels.toRgba(r, g, b, a)
|
|
41
|
+
};
|
|
42
|
+
}
|
|
36
43
|
}
|
|
37
44
|
|
|
38
45
|
/**
|
|
@@ -70,7 +77,7 @@ export namespace color {
|
|
|
70
77
|
if (!result) {
|
|
71
78
|
return undefined;
|
|
72
79
|
}
|
|
73
|
-
return
|
|
80
|
+
return channels.toColor(
|
|
74
81
|
(result >> 24 & 0xFF),
|
|
75
82
|
(result >> 16 & 0xFF),
|
|
76
83
|
(result >> 8 & 0xFF)
|
|
@@ -142,14 +149,14 @@ export namespace css {
|
|
|
142
149
|
$r = parseInt(css.slice(1, 2).repeat(2), 16);
|
|
143
150
|
$g = parseInt(css.slice(2, 3).repeat(2), 16);
|
|
144
151
|
$b = parseInt(css.slice(3, 4).repeat(2), 16);
|
|
145
|
-
return
|
|
152
|
+
return channels.toColor($r, $g, $b);
|
|
146
153
|
}
|
|
147
154
|
case 5: { // #rgba
|
|
148
155
|
$r = parseInt(css.slice(1, 2).repeat(2), 16);
|
|
149
156
|
$g = parseInt(css.slice(2, 3).repeat(2), 16);
|
|
150
157
|
$b = parseInt(css.slice(3, 4).repeat(2), 16);
|
|
151
158
|
$a = parseInt(css.slice(4, 5).repeat(2), 16);
|
|
152
|
-
return
|
|
159
|
+
return channels.toColor($r, $g, $b, $a);
|
|
153
160
|
}
|
|
154
161
|
case 7: // #rrggbb
|
|
155
162
|
return {
|
|
@@ -171,7 +178,7 @@ export namespace css {
|
|
|
171
178
|
$g = parseInt(rgbaMatch[2]);
|
|
172
179
|
$b = parseInt(rgbaMatch[3]);
|
|
173
180
|
$a = Math.round((rgbaMatch[5] === undefined ? 1 : parseFloat(rgbaMatch[5])) * 0xFF);
|
|
174
|
-
return
|
|
181
|
+
return channels.toColor($r, $g, $b, $a);
|
|
175
182
|
}
|
|
176
183
|
|
|
177
184
|
// Validate the context is available for canvas-based color parsing
|
|
@@ -342,17 +349,9 @@ export namespace rgba {
|
|
|
342
349
|
return (fgR << 24 | fgG << 16 | fgB << 8 | 0xFF) >>> 0;
|
|
343
350
|
}
|
|
344
351
|
|
|
345
|
-
// FIXME: Move this to channels NS?
|
|
346
352
|
export function toChannels(value: number): [number, number, number, number] {
|
|
347
353
|
return [(value >> 24) & 0xFF, (value >> 16) & 0xFF, (value >> 8) & 0xFF, value & 0xFF];
|
|
348
354
|
}
|
|
349
|
-
|
|
350
|
-
export function toColor(r: number, g: number, b: number, a?: number): IColor {
|
|
351
|
-
return {
|
|
352
|
-
css: channels.toCss(r, g, b, a),
|
|
353
|
-
rgba: channels.toRgba(r, g, b, a)
|
|
354
|
-
};
|
|
355
|
-
}
|
|
356
355
|
}
|
|
357
356
|
|
|
358
357
|
export function toPaddedHex(c: number): string {
|
package/src/common/Types.d.ts
CHANGED
|
@@ -110,8 +110,8 @@ export interface ICharset {
|
|
|
110
110
|
export type CharData = [number, string, number, number];
|
|
111
111
|
|
|
112
112
|
export interface IColor {
|
|
113
|
-
css: string;
|
|
114
|
-
rgba: number; // 32-bit int with rgba in each byte
|
|
113
|
+
readonly css: string;
|
|
114
|
+
readonly rgba: number; // 32-bit int with rgba in each byte
|
|
115
115
|
}
|
|
116
116
|
export type IColorRGB = [number, number, number];
|
|
117
117
|
|