Skip to content

Commit

Permalink
Polish
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyriar committed May 4, 2018
1 parent 09624c1 commit 5b5eb48
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
4 changes: 4 additions & 0 deletions src/renderer/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export const enum FLAGS {
ITALIC = 64
}

/**
* Note that IRenderer implementations should emit the refresh event after
* rendering rows to the screen.
*/
export interface IRenderer extends IEventEmitter {
dimensions: IRenderDimensions;
colorManager: IColorManager;
Expand Down
11 changes: 2 additions & 9 deletions src/renderer/dom/DomRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ export class DomRenderer extends EventEmitter implements IRenderer {
element.style.height = `${this._terminal.charMeasure.height}px`;
});


if (!this._dimensionsStyleElement) {
this._dimensionsStyleElement = document.createElement('style');
this._terminal.screenElement.appendChild(this._dimensionsStyleElement);
Expand Down Expand Up @@ -130,7 +129,7 @@ export class DomRenderer extends EventEmitter implements IRenderer {
`.xterm .${ROW_CONTAINER_CLASS} {` +
` color: ${this.colorManager.colors.foreground.css};` +
` background-color: ${this.colorManager.colors.background.css};` +
`}`;;
`}`;
// Text styles
styles +=
`.xterm span:not(.${BOLD_CLASS}) {` +
Expand Down Expand Up @@ -296,13 +295,11 @@ export class DomRenderer extends EventEmitter implements IRenderer {
const line = terminal.buffer.lines.get(row);
for (let x = 0; x < terminal.cols; x++) {
const charData = line[x];
// const code: number = <number>charData[CHAR_DATA_CODE_INDEX];
const char: string = charData[CHAR_DATA_CHAR_INDEX];
const attr: number = charData[CHAR_DATA_ATTR_INDEX];
let width: number = charData[CHAR_DATA_WIDTH_INDEX];

// The character to the left is a wide character, drawing is owned by
// the char at x-1
// The character to the left is a wide character, drawing is owned by the char at x-1
if (width === 0) {
continue;
}
Expand Down Expand Up @@ -335,7 +332,6 @@ export class DomRenderer extends EventEmitter implements IRenderer {
}

if (flags & FLAGS.BOLD) {
// TODO: Support option that turns bold->bright off
// Convert the FG color to the bold variant
if (fg < 8) {
fg += 8;
Expand All @@ -348,19 +344,16 @@ export class DomRenderer extends EventEmitter implements IRenderer {
}

charElement.textContent = char;
// TODO: Make 257 a constant
if (fg !== 257) {
charElement.classList.add(`xterm-fg-${fg}`);
}
// TODO: Make 256 a constant
if (bg !== 256) {
charElement.classList.add(`xterm-bg-${bg}`);
}
rowElement.appendChild(charElement);
}
}

// TODO: Document that IRenderer needs to emit this?
this._terminal.emit('refresh', {start, end});
}
}

0 comments on commit 5b5eb48

Please sign in to comment.