Merge pull request #6 from juancampa/selection-simple-2

Only apply the selection hack for the WebGL renderer
This commit is contained in:
Daniel Imms
2019-03-08 12:18:45 -08:00
committed by GitHub
2 changed files with 12 additions and 9 deletions
+1 -9
View File
@@ -121,15 +121,7 @@ export class ColorManager implements IColorManager {
this.colors.background = this._parseColor(theme.background, DEFAULT_BACKGROUND);
this.colors.cursor = this._parseColor(theme.cursor, DEFAULT_CURSOR, true);
this.colors.cursorAccent = this._parseColor(theme.cursorAccent, DEFAULT_CURSOR_ACCENT, true);
// HACK: while webgl renderer adds support for selection colors
// this.colors.selection = this._parseColor(theme.selection, DEFAULT_SELECTION, true);
if (this.getLuminance(this.colors.background) > 0.5) {
this.colors.selection = this._parseColor('#000', DEFAULT_SELECTION, true);
} else {
this.colors.selection = this._parseColor('#fff', DEFAULT_SELECTION, true);
}
this.colors.selection = this._parseColor(theme.selection, DEFAULT_SELECTION, true);
this.colors.ansi[0] = this._parseColor(theme.black, DEFAULT_ANSI_COLORS[0]);
this.colors.ansi[1] = this._parseColor(theme.red, DEFAULT_ANSI_COLORS[1]);
this.colors.ansi[2] = this._parseColor(theme.green, DEFAULT_ANSI_COLORS[2]);
+11
View File
@@ -52,6 +52,7 @@ export class WebglRenderer extends EventEmitter implements IRenderer {
this.colorManager = new ColorManager(document, allowTransparency);
if (theme) {
this.colorManager.setTheme(theme);
this._applyBgLuminanceBasedSelection();
}
this._renderLayers = [
@@ -107,6 +108,15 @@ export class WebglRenderer extends EventEmitter implements IRenderer {
super.dispose();
}
private _applyBgLuminanceBasedSelection(): void {
// HACK: This is needed until webgl renderer adds support for selection colors
if (this.colorManager.getLuminance(this.colorManager.colors.background) > 0.5) {
this.colorManager.colors.selection = { css: '#000', rgba: 255 };
} else {
this.colorManager.colors.selection = { css: '#fff', rgba: 4294967295 };
}
}
public onIntersectionChange(entry: IntersectionObserverEntry): void {
this._isPaused = entry.intersectionRatio === 0;
if (!this._isPaused && this._needsFullRefresh) {
@@ -127,6 +137,7 @@ export class WebglRenderer extends EventEmitter implements IRenderer {
public setTheme(theme: ITheme | undefined): IColorSet {
if (theme) {
this.colorManager.setTheme(theme);
this._applyBgLuminanceBasedSelection();
}
// Clear layers and force a full render