Support theming cursor accent color

Fixes #963
This commit is contained in:
Daniel Imms
2017-09-10 08:01:16 -07:00
parent 948eedba89
commit 6c06d83525
6 changed files with 9 additions and 1 deletions
+1
View File
@@ -323,6 +323,7 @@ export interface ITheme {
foreground?: string; foreground?: string;
background?: string; background?: string;
cursor?: string; cursor?: string;
cursorAccent?: string;
selection?: string; selection?: string;
black?: string; black?: string;
red?: string; red?: string;
+1
View File
@@ -77,6 +77,7 @@ function generateConfig(scaledCharWidth: number, scaledCharHeight: number, termi
foreground: colors.foreground, foreground: colors.foreground,
background: null, background: null,
cursor: null, cursor: null,
cursorAccent: null,
selection: null, selection: null,
ansi: colors.ansi.slice(0, 16) ansi: colors.ansi.slice(0, 16)
}; };
+3
View File
@@ -9,6 +9,7 @@ import { ITheme } from '../Interfaces';
const DEFAULT_FOREGROUND = '#ffffff'; const DEFAULT_FOREGROUND = '#ffffff';
const DEFAULT_BACKGROUND = '#000000'; const DEFAULT_BACKGROUND = '#000000';
const DEFAULT_CURSOR = '#ffffff'; const DEFAULT_CURSOR = '#ffffff';
const DEFAULT_CURSOR_ACCENT = '#000000';
const DEFAULT_SELECTION = 'rgba(255, 255, 255, 0.3)'; const DEFAULT_SELECTION = 'rgba(255, 255, 255, 0.3)';
export const DEFAULT_ANSI_COLORS = [ export const DEFAULT_ANSI_COLORS = [
// dark: // dark:
@@ -72,6 +73,7 @@ export class ColorManager {
foreground: DEFAULT_FOREGROUND, foreground: DEFAULT_FOREGROUND,
background: DEFAULT_BACKGROUND, background: DEFAULT_BACKGROUND,
cursor: DEFAULT_CURSOR, cursor: DEFAULT_CURSOR,
cursorAccent: DEFAULT_CURSOR_ACCENT,
selection: DEFAULT_SELECTION, selection: DEFAULT_SELECTION,
ansi: generate256Colors(DEFAULT_ANSI_COLORS) ansi: generate256Colors(DEFAULT_ANSI_COLORS)
}; };
@@ -86,6 +88,7 @@ export class ColorManager {
this.colors.foreground = theme.foreground || DEFAULT_FOREGROUND; this.colors.foreground = theme.foreground || DEFAULT_FOREGROUND;
this.colors.background = theme.background || DEFAULT_BACKGROUND; this.colors.background = theme.background || DEFAULT_BACKGROUND;
this.colors.cursor = theme.cursor || DEFAULT_CURSOR; this.colors.cursor = theme.cursor || DEFAULT_CURSOR;
this.colors.cursorAccent = theme.cursorAccent || DEFAULT_CURSOR_ACCENT;
this.colors.selection = theme.selection || DEFAULT_SELECTION; this.colors.selection = theme.selection || DEFAULT_SELECTION;
this.colors.ansi[0] = theme.black || DEFAULT_ANSI_COLORS[0]; this.colors.ansi[0] = theme.black || DEFAULT_ANSI_COLORS[0];
this.colors.ansi[1] = theme.red || DEFAULT_ANSI_COLORS[1]; this.colors.ansi[1] = theme.red || DEFAULT_ANSI_COLORS[1];
+1 -1
View File
@@ -199,7 +199,7 @@ export class CursorRenderLayer extends BaseRenderLayer {
this._ctx.save(); this._ctx.save();
this._ctx.fillStyle = this.colors.cursor; this._ctx.fillStyle = this.colors.cursor;
this.fillCells(x, y, charData[CHAR_DATA_WIDTH_INDEX], 1); this.fillCells(x, y, charData[CHAR_DATA_WIDTH_INDEX], 1);
this._ctx.fillStyle = this.colors.background; this._ctx.fillStyle = this.colors.cursorAccent;
this.fillCharTrueColor(terminal, charData, x, y); this.fillCharTrueColor(terminal, charData, x, y);
this._ctx.restore(); this._ctx.restore();
} }
+1
View File
@@ -72,6 +72,7 @@ export interface IColorSet {
foreground: string; foreground: string;
background: string; background: string;
cursor: string; cursor: string;
cursorAccent: string;
selection: string; selection: string;
ansi: string[]; ansi: string[];
} }
+2
View File
@@ -88,6 +88,8 @@ interface ITheme {
background?: string, background?: string,
/** The cursor color */ /** The cursor color */
cursor?: string, cursor?: string,
/** The accent color of the cursor (used as the foreground color for a block cursor) */
cursorAccent?: string,
/** The selection color (can be transparent) */ /** The selection color (can be transparent) */
selection?: string, selection?: string,
/** ANSI black (eg. `\x1b[30m`) */ /** ANSI black (eg. `\x1b[30m`) */