From 493e8ad758ecb1f119a8bef3a5f8ad64c6273f1b Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sun, 19 May 2019 18:06:25 -0700 Subject: [PATCH] Remove webgl dependence on DEFAULT_ANSI_COLORS --- src/renderer/webgl/atlas/CharAtlasUtils.ts | 2 +- src/renderer/webgl/atlas/WebglCharAtlas.ts | 7 +++---- src/ui/ColorManager.ts | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/renderer/webgl/atlas/CharAtlasUtils.ts b/src/renderer/webgl/atlas/CharAtlasUtils.ts index 2bda420f..9bbd614a 100644 --- a/src/renderer/webgl/atlas/CharAtlasUtils.ts +++ b/src/renderer/webgl/atlas/CharAtlasUtils.ts @@ -17,7 +17,7 @@ export function generateConfig(scaledCharWidth: number, scaledCharHeight: number selection: null, // For the static char atlas, we only use the first 16 colors, but we need all 256 for the // dynamic character atlas. - ansi: colors.ansi.slice(0, 16) + ansi: colors.ansi.slice() }; return { devicePixelRatio: window.devicePixelRatio, diff --git a/src/renderer/webgl/atlas/WebglCharAtlas.ts b/src/renderer/webgl/atlas/WebglCharAtlas.ts index a9cd8e7d..85496aa1 100644 --- a/src/renderer/webgl/atlas/WebglCharAtlas.ts +++ b/src/renderer/webgl/atlas/WebglCharAtlas.ts @@ -11,7 +11,6 @@ import { is256Color } from './CharAtlasUtils'; import { clearColor } from './CharAtlasGenerator'; import { DEFAULT_ATTR } from '../../../core/buffer/BufferLine'; import { DEFAULT_COLOR } from '../../../common/Types'; -import { DEFAULT_ANSI_COLORS } from '../../../ui/ColorManager'; import { IColor } from 'xterm'; // In practice we're probably never going to exhaust a texture this large. For debugging purposes, @@ -158,10 +157,10 @@ export default class WebglCharAtlas extends BaseCharAtlas { } private _getColorFromAnsiIndex(idx: number): IColor { - if (idx < this._config.colors.ansi.length) { - return this._config.colors.ansi[idx]; + if (idx >= this._config.colors.ansi.length) { + throw new Error('No color found for idx ' + idx); } - return DEFAULT_ANSI_COLORS[idx]; + return this._config.colors.ansi[idx]; } private _getBackgroundColor(bg: number): IColor { diff --git a/src/ui/ColorManager.ts b/src/ui/ColorManager.ts index 923b2823..276b6e14 100644 --- a/src/ui/ColorManager.ts +++ b/src/ui/ColorManager.ts @@ -16,7 +16,7 @@ const DEFAULT_SELECTION = { // An IIFE to generate DEFAULT_ANSI_COLORS. Do not mutate DEFAULT_ANSI_COLORS, instead make a copy // and mutate that. -export const DEFAULT_ANSI_COLORS = (() => { +export const DEFAULT_ANSI_COLORS: IColor[] = (() => { const colors = [ // dark: fromHex('#2e3436'),