1. Removed logic to blend selection with background with 0.3 opacity from ColorManager to a function in color namespace.
2. Changed the DomRenderer and CanvasRenderer where the function defined in color namespace is called.
This commit is contained in:
+12
-1
@@ -3,7 +3,7 @@
|
|||||||
* @license MIT
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { IColor } from 'browser/Types';
|
import { IColor, IColorSet } from 'browser/Types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper functions where the source type is "channels" (individual color channels as numbers).
|
* Helper functions where the source type is "channels" (individual color channels as numbers).
|
||||||
@@ -47,6 +47,17 @@ export namespace color {
|
|||||||
const rgba = channels.toRgba(r, g, b);
|
const rgba = channels.toRgba(r, g, b);
|
||||||
return { css, rgba };
|
return { css, rgba };
|
||||||
}
|
}
|
||||||
|
export function blendSelectionWithBgWithOpacity(colors: IColorSet, opacity: number=0.3): void {
|
||||||
|
const [selectionR, selectionG, selectionB, selectionA] = rgba.toChannels(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 newAlpha: number = Math.round(opacity*255);
|
||||||
|
colors.selection = {
|
||||||
|
css: channels.toCss(selectionR, selectionG, selectionB, newAlpha),
|
||||||
|
rgba: channels.toRgba(selectionR, selectionG, selectionB, newAlpha)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function ensureContrastRatio(bg: IColor, fg: IColor, ratio: number): IColor | undefined {
|
export function ensureContrastRatio(bg: IColor, fg: IColor, ratio: number): IColor | undefined {
|
||||||
const result = rgba.ensureContrastRatio(bg.rgba, fg.rgba, ratio);
|
const result = rgba.ensureContrastRatio(bg.rgba, fg.rgba, ratio);
|
||||||
|
|||||||
@@ -116,16 +116,6 @@ export class ColorManager implements IColorManager {
|
|||||||
this.colors.cursor = this._parseColor(theme.cursor, DEFAULT_CURSOR, true);
|
this.colors.cursor = this._parseColor(theme.cursor, DEFAULT_CURSOR, true);
|
||||||
this.colors.cursorAccent = this._parseColor(theme.cursorAccent, DEFAULT_CURSOR_ACCENT, true);
|
this.colors.cursorAccent = this._parseColor(theme.cursorAccent, DEFAULT_CURSOR_ACCENT, true);
|
||||||
this.colors.selection = this._parseColor(theme.selection, DEFAULT_SELECTION, 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.selectionOpaque = color.blend(this.colors.background, this.colors.selection);
|
||||||
this.colors.ansi[0] = this._parseColor(theme.black, DEFAULT_ANSI_COLORS[0]);
|
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[1] = this._parseColor(theme.red, DEFAULT_ANSI_COLORS[1]);
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { ICharSizeService, ICoreBrowserService } from 'browser/services/Services
|
|||||||
import { IBufferService, IOptionsService, ICoreService } from 'common/services/Services';
|
import { IBufferService, IOptionsService, ICoreService } from 'common/services/Services';
|
||||||
import { removeTerminalFromCache } from 'browser/renderer/atlas/CharAtlasCache';
|
import { removeTerminalFromCache } from 'browser/renderer/atlas/CharAtlasCache';
|
||||||
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
||||||
|
import { color } from 'browser/Color';
|
||||||
|
|
||||||
let nextRendererId = 1;
|
let nextRendererId = 1;
|
||||||
|
|
||||||
@@ -44,7 +45,7 @@ export class Renderer extends Disposable implements IRenderer {
|
|||||||
super();
|
super();
|
||||||
const allowTransparency = this._optionsService.options.allowTransparency;
|
const allowTransparency = this._optionsService.options.allowTransparency;
|
||||||
this._characterJoinerRegistry = new CharacterJoinerRegistry(this._bufferService);
|
this._characterJoinerRegistry = new CharacterJoinerRegistry(this._bufferService);
|
||||||
|
color.blendSelectionWithBgWithOpacity(this._colors);
|
||||||
this._renderLayers = [
|
this._renderLayers = [
|
||||||
new TextRenderLayer(this._screenElement, 0, this._colors, this._characterJoinerRegistry, allowTransparency, this._id, this._bufferService, _optionsService),
|
new TextRenderLayer(this._screenElement, 0, this._colors, this._characterJoinerRegistry, allowTransparency, this._id, this._bufferService, _optionsService),
|
||||||
new SelectionRenderLayer(this._screenElement, 1, this._colors, this._id, this._bufferService, _optionsService),
|
new SelectionRenderLayer(this._screenElement, 1, this._colors, this._id, this._bufferService, _optionsService),
|
||||||
@@ -87,7 +88,6 @@ export class Renderer extends Disposable implements IRenderer {
|
|||||||
|
|
||||||
public setColors(colors: IColorSet): void {
|
public setColors(colors: IColorSet): void {
|
||||||
this._colors = colors;
|
this._colors = colors;
|
||||||
|
|
||||||
// Clear layers and force a full render
|
// Clear layers and force a full render
|
||||||
this._renderLayers.forEach(l => {
|
this._renderLayers.forEach(l => {
|
||||||
l.setColors(this._colors);
|
l.setColors(this._colors);
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export class DomRenderer extends Disposable implements IRenderer {
|
|||||||
@IBufferService private readonly _bufferService: IBufferService
|
@IBufferService private readonly _bufferService: IBufferService
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
color.blendSelectionWithBgWithOpacity(this._colors);
|
||||||
this._rowContainer = document.createElement('div');
|
this._rowContainer = document.createElement('div');
|
||||||
this._rowContainer.classList.add(ROW_CONTAINER_CLASS);
|
this._rowContainer.classList.add(ROW_CONTAINER_CLASS);
|
||||||
this._rowContainer.style.lineHeight = 'normal';
|
this._rowContainer.style.lineHeight = 'normal';
|
||||||
|
|||||||
Reference in New Issue
Block a user