Move DomRendererRowFactory to browser
This commit is contained in:
+1
-1
@@ -691,7 +691,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
|
|||||||
private _createRenderer(): IRenderer {
|
private _createRenderer(): IRenderer {
|
||||||
switch (this.options.rendererType) {
|
switch (this.options.rendererType) {
|
||||||
case 'canvas': return new Renderer(this, this._colorManager.colors, this._charSizeService); break;
|
case 'canvas': return new Renderer(this, this._colorManager.colors, this._charSizeService); break;
|
||||||
case 'dom': return new DomRenderer(this, this._colorManager.colors, this._charSizeService); break;
|
case 'dom': return new DomRenderer(this, this._colorManager.colors, this._charSizeService, this.optionsService); break;
|
||||||
default: throw new Error(`Unrecognized rendererType "${this.options.rendererType}"`);
|
default: throw new Error(`Unrecognized rendererType "${this.options.rendererType}"`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-8
@@ -5,25 +5,21 @@
|
|||||||
|
|
||||||
import jsdom = require('jsdom');
|
import jsdom = require('jsdom');
|
||||||
import { assert } from 'chai';
|
import { assert } from 'chai';
|
||||||
import { DomRendererRowFactory } from './DomRendererRowFactory';
|
import { DomRendererRowFactory } from 'browser/renderer/dom/DomRendererRowFactory';
|
||||||
import { NULL_CELL_CODE, NULL_CELL_WIDTH, NULL_CELL_CHAR, DEFAULT_ATTR, FgFlags, BgFlags, Attributes } from 'common/buffer/Constants';
|
import { NULL_CELL_CODE, NULL_CELL_WIDTH, NULL_CELL_CHAR, DEFAULT_ATTR, FgFlags, BgFlags, Attributes } from 'common/buffer/Constants';
|
||||||
import { BufferLine, DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';
|
import { BufferLine, DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';
|
||||||
import { ITerminalOptions } from '../../Types';
|
|
||||||
import { IBufferLine } from 'common/Types';
|
import { IBufferLine } from 'common/Types';
|
||||||
import { CellData } from 'common/buffer/CellData';
|
import { CellData } from 'common/buffer/CellData';
|
||||||
|
import { MockOptionsService } from 'common/TestUtils.test';
|
||||||
|
|
||||||
describe('DomRendererRowFactory', () => {
|
describe('DomRendererRowFactory', () => {
|
||||||
let dom: jsdom.JSDOM;
|
let dom: jsdom.JSDOM;
|
||||||
const options: ITerminalOptions = {};
|
|
||||||
let rowFactory: DomRendererRowFactory;
|
let rowFactory: DomRendererRowFactory;
|
||||||
let lineData: IBufferLine;
|
let lineData: IBufferLine;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
dom = new jsdom.JSDOM('');
|
dom = new jsdom.JSDOM('');
|
||||||
|
rowFactory = new DomRendererRowFactory(dom.window.document, new MockOptionsService({ drawBoldTextInBrightColors: true }));
|
||||||
options.drawBoldTextInBrightColors = true;
|
|
||||||
|
|
||||||
rowFactory = new DomRendererRowFactory(options, dom.window.document);
|
|
||||||
lineData = createEmptyLineData(2);
|
lineData = createEmptyLineData(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -38,7 +34,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
it('should set correct attributes for double width characters', () => {
|
it('should set correct attributes for double width characters', () => {
|
||||||
lineData.setCell(0, CellData.fromCharData([DEFAULT_ATTR, '語', 2, '語'.charCodeAt(0)]));
|
lineData.setCell(0, CellData.fromCharData([DEFAULT_ATTR, '語', 2, '語'.charCodeAt(0)]));
|
||||||
// There should be no element for the following "empty" cell
|
// There should be no element for the following "empty" cell
|
||||||
lineData.setCell(1, CellData.fromCharData([DEFAULT_ATTR, '', 0, undefined]));
|
lineData.setCell(1, CellData.fromCharData([DEFAULT_ATTR, '', 0, 0]));
|
||||||
const fragment = rowFactory.createRow(lineData, false, undefined, 0, false, 5, 20);
|
const fragment = rowFactory.createRow(lineData, false, undefined, 0, false, 5, 20);
|
||||||
assert.equal(getFragmentHtml(fragment),
|
assert.equal(getFragmentHtml(fragment),
|
||||||
'<span style="width: 10px;">語</span>'
|
'<span style="width: 10px;">語</span>'
|
||||||
+4
-4
@@ -3,12 +3,12 @@
|
|||||||
* @license MIT
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ITerminalOptions } from '../../Types';
|
|
||||||
import { IBufferLine } from 'common/Types';
|
import { IBufferLine } from 'common/Types';
|
||||||
import { INVERTED_DEFAULT_COLOR } from 'browser/renderer/atlas/Constants';
|
import { INVERTED_DEFAULT_COLOR } from 'browser/renderer/atlas/Constants';
|
||||||
import { AttributeData } from 'common/buffer/AttributeData';
|
import { AttributeData } from 'common/buffer/AttributeData';
|
||||||
import { NULL_CELL_CODE, WHITESPACE_CELL_CHAR } from 'common/buffer/Constants';
|
import { NULL_CELL_CODE, WHITESPACE_CELL_CHAR } from 'common/buffer/Constants';
|
||||||
import { CellData } from 'common/buffer/CellData';
|
import { CellData } from 'common/buffer/CellData';
|
||||||
|
import { ITerminalOptions, IOptionsService } from 'common/services/Services';
|
||||||
|
|
||||||
export const BOLD_CLASS = 'xterm-bold';
|
export const BOLD_CLASS = 'xterm-bold';
|
||||||
export const DIM_CLASS = 'xterm-dim';
|
export const DIM_CLASS = 'xterm-dim';
|
||||||
@@ -24,8 +24,8 @@ export class DomRendererRowFactory {
|
|||||||
private _workCell: CellData = new CellData();
|
private _workCell: CellData = new CellData();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _terminalOptions: ITerminalOptions,
|
private _document: Document,
|
||||||
private _document: Document
|
private _optionsService: IOptionsService
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ export class DomRendererRowFactory {
|
|||||||
charElement.setAttribute('style', style);
|
charElement.setAttribute('style', style);
|
||||||
} else if (this._workCell.isFgPalette()) {
|
} else if (this._workCell.isFgPalette()) {
|
||||||
let fg = this._workCell.getFgColor();
|
let fg = this._workCell.getFgColor();
|
||||||
if (this._workCell.isBold() && fg < 8 && !swapColor && this._terminalOptions.drawBoldTextInBrightColors) {
|
if (this._workCell.isBold() && fg < 8 && !swapColor && this._optionsService.options.drawBoldTextInBrightColors) {
|
||||||
fg += 8;
|
fg += 8;
|
||||||
}
|
}
|
||||||
charElement.classList.add(`xterm-${swapColor ? 'b' : 'f'}g-${fg}`);
|
charElement.classList.add(`xterm-${swapColor ? 'b' : 'f'}g-${fg}`);
|
||||||
@@ -5,11 +5,12 @@
|
|||||||
|
|
||||||
import { IRenderer, IRenderDimensions, CharacterJoinerHandler } from 'browser/renderer/Types';
|
import { IRenderer, IRenderDimensions, CharacterJoinerHandler } from 'browser/renderer/Types';
|
||||||
import { ILinkifierEvent, ITerminal } from '../../Types';
|
import { ILinkifierEvent, ITerminal } from '../../Types';
|
||||||
import { BOLD_CLASS, ITALIC_CLASS, CURSOR_CLASS, CURSOR_STYLE_BLOCK_CLASS, CURSOR_BLINK_CLASS, CURSOR_STYLE_BAR_CLASS, CURSOR_STYLE_UNDERLINE_CLASS, DomRendererRowFactory } from './DomRendererRowFactory';
|
import { BOLD_CLASS, ITALIC_CLASS, CURSOR_CLASS, CURSOR_STYLE_BLOCK_CLASS, CURSOR_BLINK_CLASS, CURSOR_STYLE_BAR_CLASS, CURSOR_STYLE_UNDERLINE_CLASS, DomRendererRowFactory } from 'browser/renderer/dom/DomRendererRowFactory';
|
||||||
import { INVERTED_DEFAULT_COLOR } from 'browser/renderer/atlas/Constants';
|
import { INVERTED_DEFAULT_COLOR } from 'browser/renderer/atlas/Constants';
|
||||||
import { Disposable } from 'common/Lifecycle';
|
import { Disposable } from 'common/Lifecycle';
|
||||||
import { IColorSet } from 'browser/Types';
|
import { IColorSet } from 'browser/Types';
|
||||||
import { ICharSizeService } from 'browser/services/Services';
|
import { ICharSizeService } from 'browser/services/Services';
|
||||||
|
import { IOptionsService } from 'common/services/Services';
|
||||||
|
|
||||||
const TERMINAL_CLASS_PREFIX = 'xterm-dom-renderer-owner-';
|
const TERMINAL_CLASS_PREFIX = 'xterm-dom-renderer-owner-';
|
||||||
const ROW_CONTAINER_CLASS = 'xterm-rows';
|
const ROW_CONTAINER_CLASS = 'xterm-rows';
|
||||||
@@ -43,7 +44,8 @@ export class DomRenderer extends Disposable implements IRenderer {
|
|||||||
constructor(
|
constructor(
|
||||||
private _terminal: ITerminal,
|
private _terminal: ITerminal,
|
||||||
private _colors: IColorSet,
|
private _colors: IColorSet,
|
||||||
private _charSizeService: ICharSizeService
|
private _charSizeService: ICharSizeService,
|
||||||
|
private _optionsService: IOptionsService
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
@@ -73,7 +75,7 @@ export class DomRenderer extends Disposable implements IRenderer {
|
|||||||
this._updateDimensions();
|
this._updateDimensions();
|
||||||
this._injectCss();
|
this._injectCss();
|
||||||
|
|
||||||
this._rowFactory = new DomRendererRowFactory(_terminal.options, document);
|
this._rowFactory = new DomRendererRowFactory(document, this._optionsService);
|
||||||
|
|
||||||
this._terminal.element.classList.add(TERMINAL_CLASS_PREFIX + this._terminalClass);
|
this._terminal.element.classList.add(TERMINAL_CLASS_PREFIX + this._terminalClass);
|
||||||
this._terminal.screenElement.appendChild(this._rowContainer);
|
this._terminal.screenElement.appendChild(this._rowContainer);
|
||||||
|
|||||||
Reference in New Issue
Block a user