Merge branch 'master' into configure-cursor-bar-width

This commit is contained in:
Nick Pezza
2019-12-07 15:54:35 -05:00
committed by GitHub
7 changed files with 23 additions and 11 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "xterm-addon-attach", "name": "xterm-addon-attach",
"version": "0.3.0", "version": "0.4.0",
"author": { "author": {
"name": "The xterm.js authors", "name": "The xterm.js authors",
"url": "https://xtermjs.org/" "url": "https://xtermjs.org/"
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "xterm-addon-search", "name": "xterm-addon-search",
"version": "0.3.0", "version": "0.4.0",
"author": { "author": {
"name": "The xterm.js authors", "name": "The xterm.js authors",
"url": "https://xtermjs.org/" "url": "https://xtermjs.org/"
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "xterm-addon-webgl", "name": "xterm-addon-webgl",
"version": "0.3.0", "version": "0.4.0",
"author": { "author": {
"name": "The xterm.js authors", "name": "The xterm.js authors",
"url": "https://xtermjs.org/" "url": "https://xtermjs.org/"
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "xterm", "name": "xterm",
"description": "Full xterm terminal, in your browser", "description": "Full xterm terminal, in your browser",
"version": "4.2.0", "version": "4.3.0",
"main": "lib/xterm.js", "main": "lib/xterm.js",
"style": "css/xterm.css", "style": "css/xterm.css",
"types": "typings/xterm.d.ts", "types": "typings/xterm.d.ts",
+1 -1
View File
@@ -108,7 +108,7 @@ export function contrastRatio(l1: number, l2: number): number {
return (l1 + 0.05) / (l2 + 0.05); return (l1 + 0.05) / (l2 + 0.05);
} }
function rgbaToColor(r: number, g: number, b: number): IColor { export function rgbaToColor(r: number, g: number, b: number): IColor {
return { return {
css: toCss(r, g, b), css: toCss(r, g, b),
rgba: toRgba(r, g, b) rgba: toRgba(r, g, b)
+3 -2
View File
@@ -17,12 +17,13 @@ export function addDisposableDomListener(
useCapture?: boolean useCapture?: boolean
): IDisposable { ): IDisposable {
node.addEventListener(type, handler, useCapture); node.addEventListener(type, handler, useCapture);
let disposed = false;
return { return {
dispose: () => { dispose: () => {
if (!handler) { if (!disposed) {
// Already disposed
return; return;
} }
disposed = true;
node.removeEventListener(type, handler, useCapture); node.removeEventListener(type, handler, useCapture);
} }
}; };
@@ -8,7 +8,7 @@ import { INVERTED_DEFAULT_COLOR } from 'browser/renderer/atlas/Constants';
import { NULL_CELL_CODE, WHITESPACE_CELL_CHAR, Attributes } from 'common/buffer/Constants'; import { NULL_CELL_CODE, WHITESPACE_CELL_CHAR, Attributes } from 'common/buffer/Constants';
import { CellData } from 'common/buffer/CellData'; import { CellData } from 'common/buffer/CellData';
import { IOptionsService } from 'common/services/Services'; import { IOptionsService } from 'common/services/Services';
import { ensureContrastRatio } from 'browser/Color'; import { ensureContrastRatio, rgbaToColor } from 'browser/Color';
import { IColorSet, IColor } from 'browser/Types'; import { IColorSet, IColor } from 'browser/Types';
export const BOLD_CLASS = 'xterm-bold'; export const BOLD_CLASS = 'xterm-bold';
@@ -129,7 +129,14 @@ export class DomRendererRowFactory {
} }
break; break;
case Attributes.CM_RGB: case Attributes.CM_RGB:
charElement.setAttribute('style', `${charElement.getAttribute('style') || ''}color:#${padStart(fg.toString(16), '0', 6)};`); const color = rgbaToColor(
(fg >> 16) & 0xFF,
(fg >> 8) & 0xFF,
(fg ) & 0xFF
);
if (!this._applyMinimumContrast(charElement, this._colors.background, color)) {
this._addStyle(charElement, `color:#${padStart(fg.toString(16), '0', 6)}`);
}
break; break;
case Attributes.CM_DEFAULT: case Attributes.CM_DEFAULT:
default: default:
@@ -147,7 +154,7 @@ export class DomRendererRowFactory {
charElement.classList.add(`xterm-bg-${bg}`); charElement.classList.add(`xterm-bg-${bg}`);
break; break;
case Attributes.CM_RGB: case Attributes.CM_RGB:
charElement.setAttribute('style', `${charElement.getAttribute('style') || ''}background-color:#${padStart(bg.toString(16), '0', 6)};`); this._addStyle(charElement, `background-color:#${padStart(bg.toString(16), '0', 6)}`);
break; break;
case Attributes.CM_DEFAULT: case Attributes.CM_DEFAULT:
default: default:
@@ -176,12 +183,16 @@ export class DomRendererRowFactory {
} }
if (adjustedColor) { if (adjustedColor) {
element.setAttribute('style', `${element.getAttribute('style') || ''}color:${adjustedColor.css}`); this._addStyle(element, `color:${adjustedColor.css}`);
return true; return true;
} }
return false; return false;
} }
private _addStyle(element: HTMLElement, style: string): void {
element.setAttribute('style', `${element.getAttribute('style') || ''}${style};`);
}
} }
function padStart(text: string, padChar: string, length: number): string { function padStart(text: string, padChar: string, length: number): string {