Update color codes after merging the move to constants

This commit is contained in:
Daniel Imms
2018-11-24 05:52:23 -08:00
parent 186b2be4b9
commit 60e3ddbfd0
4 changed files with 20 additions and 26 deletions
+7 -7
View File
@@ -8,8 +8,9 @@ import { IColorManager, IRenderDimensions } from '../Types';
import { createProgram, expandFloat32Array, PROJECTION_MATRIX } from './WebglUtils';
import { IColor } from '../../shared/Types';
import { IRenderModel, IWebGLVertexArrayObject, IWebGL2RenderingContext, ISelectionRenderModel } from './Types';
import { RENDER_INVERTED_DEFAULT_COLOR } from './RenderModel';
import { fill } from '../../common/TypedArrayUtils';
import { INVERTED_DEFAULT_COLOR, DEFAULT_COLOR } from '../atlas/Types';
import { is256Color } from '../atlas/CharAtlasUtils';
const enum VertexAttribLocations {
POSITION = 0,
@@ -243,16 +244,15 @@ export class RectangleRenderer {
let rectangleCount = 1;
const DEFAULT_BACKGROUND_COLOR = 256;
for (let y = 0; y < terminal.rows; y++) {
let currentStartX = -1;
let currentBg = DEFAULT_BACKGROUND_COLOR;
let currentBg = DEFAULT_COLOR;
for (let x = 0; x < terminal.cols; x++) {
const modelIndex = ((y * terminal.cols) + x) * 4;
const bg = model.cells[modelIndex + 2];
if (bg !== currentBg) {
// A rectangle needs to be drawn if going from non-default to another color
if (currentBg !== DEFAULT_BACKGROUND_COLOR) {
if (currentBg !== DEFAULT_COLOR) {
const offset = rectangleCount++ * INDICES_PER_RECTANGLE;
this._updateRectangle(vertices, offset, currentBg, currentStartX, x, y);
}
@@ -261,7 +261,7 @@ export class RectangleRenderer {
}
}
// Finish rectangle if it's still going
if (currentBg !== DEFAULT_BACKGROUND_COLOR) {
if (currentBg !== DEFAULT_COLOR) {
const offset = rectangleCount++ * INDICES_PER_RECTANGLE;
this._updateRectangle(vertices, offset, currentBg, currentStartX, terminal.cols, y);
}
@@ -271,9 +271,9 @@ export class RectangleRenderer {
private _updateRectangle(vertices: IVertices, offset: number, bg: number, startX: number, endX: number, y: number): void {
let color: IColor | null = null;
if (bg === RENDER_INVERTED_DEFAULT_COLOR) {
if (bg === INVERTED_DEFAULT_COLOR) {
color = this._colorManager.colors.foreground;
} else if (bg < 256) {
} else if (is256Color(bg)) {
color = this._colorManager.colors.ansi[bg];
}
if (vertices.attributes.length < offset + 4) {
-5
View File
@@ -8,11 +8,6 @@ import { fill } from '../../common/TypedArrayUtils';
export const RENDER_MODEL_INDICIES_PER_CELL = 4;
// HACK: Cannot use INVERTED_DEFAULT_COLOR (-1) here because _model.cells is a
// Uint32Array. This should be changed when true color is introduced to whatever
// the mechanism is for the buffer.
export const RENDER_INVERTED_DEFAULT_COLOR = 258;
export const COMBINED_CHAR_BIT_MASK = 0x80000000;
export class RenderModel implements IRenderModel {
+7 -8
View File
@@ -3,7 +3,7 @@
* @license MIT
*/
import { DIM_OPACITY, IGlyphIdentifier } from '../atlas/Types';
import { DIM_OPACITY, IGlyphIdentifier, INVERTED_DEFAULT_COLOR, DEFAULT_COLOR } from '../atlas/Types';
import { ICharAtlasConfig } from '../../shared/atlas/Types';
import { IColor } from '../../shared/Types';
import BaseCharAtlas from '../atlas/BaseCharAtlas';
@@ -12,7 +12,7 @@ import { clearColor } from '../../shared/atlas/CharAtlasGenerator';
import { IRasterizedGlyph, IBoundingBox, IRasterizedGlyphSet } from './Types';
import { DEFAULT_ATTR } from '../../Buffer';
import { FLAGS } from '../Types';
import { RENDER_INVERTED_DEFAULT_COLOR } from './RenderModel';
import { is256Color } from '../atlas/CharAtlasUtils';
// In practice we're probably never going to exhaust a texture this large. For debugging purposes,
// however, it can be useful to set this to a really tiny value, to verify that LRU eviction works.
@@ -97,7 +97,7 @@ export default class WebglCharAtlas extends BaseCharAtlas {
protected _doWarmUp(): void {
// Pre-fill with ASCII 33-126
for (let i = 33; i < 126; i++) {
const rasterizedGlyph = this._drawToCache(i, DEFAULT_ATTR, 256, 257, true);
const rasterizedGlyph = this._drawToCache(i, DEFAULT_ATTR, DEFAULT_COLOR, DEFAULT_COLOR, true);
this._cacheMap[i] = {
[DEFAULT_ATTR]: rasterizedGlyph
};
@@ -175,19 +175,18 @@ export default class WebglCharAtlas extends BaseCharAtlas {
// transparent in the atlas. Otherwise we'd end up drawing the transparent background twice
// around the anti-aliased edges of the glyph, and it would look too dark.
return TRANSPARENT_COLOR;
} else if (bg === RENDER_INVERTED_DEFAULT_COLOR) {
} else if (bg === INVERTED_DEFAULT_COLOR) {
return this._config.colors.foreground;
} else if (bg < 256) {
} else if (is256Color(bg)) {
return this._getColorFromAnsiIndex(bg);
}
return this._config.colors.background;
}
private _getForegroundColor(fg: number): IColor {
if (fg === RENDER_INVERTED_DEFAULT_COLOR) {
if (fg === INVERTED_DEFAULT_COLOR) {
return this._config.colors.background;
} else if (fg < 256) {
// 256 color support
} else if (is256Color(fg)) {
return this._getColorFromAnsiIndex(fg);
}
return this._config.colors.foreground;
+6 -6
View File
@@ -18,8 +18,8 @@ import { ScreenDprMonitor } from '../../ui/ScreenDprMonitor';
import { RectangleRenderer } from './RectangleRenderer';
import { CHAR_DATA_ATTR_INDEX, CHAR_DATA_CODE_INDEX, CHAR_DATA_CHAR_INDEX } from '../../Buffer';
import { IWebGL2RenderingContext } from './Types';
import { INVERTED_DEFAULT_COLOR } from '../atlas/Types';
import { RenderModel, RENDER_INVERTED_DEFAULT_COLOR, COMBINED_CHAR_BIT_MASK } from './RenderModel';
import { INVERTED_DEFAULT_COLOR, DEFAULT_COLOR } from '../atlas/Types';
import { RenderModel, COMBINED_CHAR_BIT_MASK } from './RenderModel';
export const INDICIES_PER_CELL = 4;
@@ -302,11 +302,11 @@ export class WebglRenderer extends EventEmitter implements IRenderer {
const temp = bg;
bg = fg;
fg = temp;
if (fg === 256) {
fg = RENDER_INVERTED_DEFAULT_COLOR;
if (fg === DEFAULT_COLOR) {
fg = INVERTED_DEFAULT_COLOR;
}
if (bg === 257) {
bg = RENDER_INVERTED_DEFAULT_COLOR;
if (bg === DEFAULT_COLOR) {
bg = INVERTED_DEFAULT_COLOR;
}
}
const drawInBrightColor = terminal.options.drawBoldTextInBrightColors && !!(flags & FLAGS.BOLD) && fg < 8 && fg !== INVERTED_DEFAULT_COLOR;