From 6daa3f449925661f8985e42f9a78bd37c9a973e5 Mon Sep 17 00:00:00 2001 From: Puneethnaik Date: Sun, 31 May 2020 12:42:14 +0530 Subject: [PATCH] ColorManager.ts : modified the setTheme function to add opacity of 0.3 to the selection color if selection color provided is opaque. --- src/browser/ColorManager.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/browser/ColorManager.ts b/src/browser/ColorManager.ts index 6ca4fd96e..057797e96 100644 --- a/src/browser/ColorManager.ts +++ b/src/browser/ColorManager.ts @@ -5,7 +5,7 @@ import { IColorManager, IColor, IColorSet, IColorContrastCache } from 'browser/Types'; import { ITheme } from 'common/services/Services'; -import { channels, color, css } from 'browser/Color'; +import { channels, color, css, rgba } from 'browser/Color'; import { ColorContrastCache } from 'browser/ColorContrastCache'; const DEFAULT_FOREGROUND = css.toColor('#ffffff'); @@ -116,6 +116,16 @@ export class ColorManager implements IColorManager { this.colors.cursor = this._parseColor(theme.cursor, DEFAULT_CURSOR, true); this.colors.cursorAccent = this._parseColor(theme.cursorAccent, DEFAULT_CURSOR_ACCENT, true); this.colors.selection = this._parseColor(theme.selection, DEFAULT_SELECTION, true); + const [selectionR, selectionG, selectionB, selectionA] = rgba.toChannels(this.colors.selection.rgba); + // The selection color is opaque. It needs to be blended with background color at 0.3 opacity Issue #2737 + if (selectionA === 0xFF) { + const opacity = 0.3; + const newAlpha = Math.round(opacity*255); + this.colors.selection = { + css: channels.toCss(selectionR, selectionG, selectionB, newAlpha), + rgba: channels.toRgba(selectionR, selectionG, selectionB, newAlpha) + }; + } this.colors.selectionOpaque = color.blend(this.colors.background, this.colors.selection); this.colors.ansi[0] = this._parseColor(theme.black, DEFAULT_ANSI_COLORS[0]); this.colors.ansi[1] = this._parseColor(theme.red, DEFAULT_ANSI_COLORS[1]);