@xterm/xterm 5.4.0-beta.21 → 5.4.0-beta.23

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xterm/xterm",
3
3
  "description": "Full xterm terminal, in your browser",
4
- "version": "5.4.0-beta.21",
4
+ "version": "5.4.0-beta.23",
5
5
  "main": "lib/xterm.js",
6
6
  "style": "css/xterm.css",
7
7
  "types": "typings/xterm.d.ts",
@@ -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 { color, rgba } from 'common/Color';
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 channels = color.toColorRGB(acc === 'ansi'
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(channels)}${C1_ESCAPED.ST}`);
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] = rgba.toColor(...req.color));
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] = rgba.toColor(...req.color));
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 { color, rgba } from 'common/Color';
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 = rgba.toColor(bg >> 16, bg >> 8 & 0xFF, bg & 0xFF);
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 = rgba.toColor(
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
- // TODO: This object creation is slow
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 = rgba.toColor(arr[0], arr[1], arr[2]);
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 = rgba.toColor(
408
+ const color = channels.toColor(
410
409
  (result >> 24) & 0xFF,
411
410
  (result >> 16) & 0xFF,
412
411
  (result >> 8) & 0xFF
@@ -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 rgba.toColor(
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 rgba.toColor($r, $g, $b);
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 rgba.toColor($r, $g, $b, $a);
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 rgba.toColor($r, $g, $b, $a);
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 {
@@ -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
 
@@ -1014,7 +1014,7 @@ declare module '@xterm/xterm' {
1014
1014
  * Attaches a custom wheel event handler which is run before keys are
1015
1015
  * processed, giving consumers of xterm.js control over whether to proceed
1016
1016
  * or cancel terminal wheel events.
1017
- * @param customMouseEventHandler The custom WheelEvent handler to attach.
1017
+ * @param customWheelEventHandler The custom WheelEvent handler to attach.
1018
1018
  * This is a function that takes a WheelEvent, allowing consumers to stop
1019
1019
  * propagation and/or prevent the default action. The function returns
1020
1020
  * whether the event should be processed by xterm.js.
@@ -1022,7 +1022,7 @@ declare module '@xterm/xterm' {
1022
1022
  * @example A handler that prevents all wheel events while ctrl is held from
1023
1023
  * being processed.
1024
1024
  * ```ts
1025
- * term.attachCustomKeyEventHandler(ev => {
1025
+ * term.attachCustomWheelEventHandler(ev => {
1026
1026
  * if (ev.ctrlKey) {
1027
1027
  * return false;
1028
1028
  * }