Move char drawing to base and use in cursor layer

This commit is contained in:
Daniel Imms
2017-08-31 17:29:58 -07:00
parent fe7b424ab8
commit 1998675dc0
3 changed files with 40 additions and 37 deletions
+4 -4
View File
@@ -1,6 +1,6 @@
import { IDataRenderLayer } from './Interfaces';
import { IBuffer, ICharMeasure, ITerminal } from '../Interfaces';
import { CHAR_DATA_ATTR_INDEX } from '../Buffer';
import { CHAR_DATA_CODE_INDEX, CHAR_DATA_CHAR_INDEX } from '../Buffer';
import { COLORS } from './Color';
import { GridCache } from './GridCache';
import { FLAGS } from './Types';
@@ -43,14 +43,14 @@ export class CursorRenderLayer extends BaseRenderLayer implements IDataRenderLay
this._clearCursor(scaledCharWidth, scaledCharHeight);
}
// TODO: Draw text in COLORS[0], using the char atlas if possible
// const charData = terminal.buffer.lines.get(viewportRelativeCursorY)[terminal.buffer.x];
this._ctx.save();
this._ctx.fillStyle = COLORS[7];
this._ctx.fillRect(terminal.buffer.x * scaledCharWidth, viewportRelativeCursorY * scaledCharHeight, scaledCharWidth, scaledCharHeight);
this._ctx.restore();
const charData = terminal.buffer.lines.get(viewportRelativeCursorY)[terminal.buffer.x];
this.drawChar(charData[CHAR_DATA_CHAR_INDEX], <number>charData[CHAR_DATA_CODE_INDEX], 0, terminal.buffer.x, viewportRelativeCursorY, scaledCharWidth, scaledCharHeight);
this._state = [terminal.buffer.x, viewportRelativeCursorY];
}