Move DomRenderer to browser, fix strict errors

This commit is contained in:
Daniel Imms
2019-11-07 17:41:29 -08:00
parent 7c39217392
commit 82e18d7aaa
2 changed files with 22 additions and 22 deletions
+2 -2
View File
@@ -38,7 +38,7 @@ import { SoundService } from 'browser/services/SoundService';
import { MouseZoneManager } from 'browser/MouseZoneManager'; import { MouseZoneManager } from 'browser/MouseZoneManager';
import { AccessibilityManager } from './AccessibilityManager'; import { AccessibilityManager } from './AccessibilityManager';
import { ITheme, IMarker, IDisposable, ISelectionPosition } from 'xterm'; import { ITheme, IMarker, IDisposable, ISelectionPosition } from 'xterm';
import { DomRenderer } from './renderer/dom/DomRenderer'; import { DomRenderer } from 'browser/renderer/dom/DomRenderer';
import { IKeyboardEvent, KeyboardResultType, ICharset, IBufferLine, IAttributeData, CoreMouseEventType, CoreMouseButton, CoreMouseAction } from 'common/Types'; import { IKeyboardEvent, KeyboardResultType, ICharset, IBufferLine, IAttributeData, CoreMouseEventType, CoreMouseButton, CoreMouseAction } from 'common/Types';
import { evaluateKeyboardEvent } from 'common/input/Keyboard'; import { evaluateKeyboardEvent } from 'common/input/Keyboard';
import { EventEmitter, IEvent } from 'common/EventEmitter'; import { EventEmitter, IEvent } from 'common/EventEmitter';
@@ -638,7 +638,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._colorManager.colors, this, this._bufferService, this._charSizeService, this.optionsService); case 'canvas': return new Renderer(this._colorManager.colors, this, this._bufferService, this._charSizeService, this.optionsService);
case 'dom': return new DomRenderer(this._colorManager.colors, this.element, this.screenElement, this._viewportElement, this.linkifier, this._charSizeService, this.optionsService, this._bufferService, this._renderService); case 'dom': return this._instantiationService.createInstance(DomRenderer, this._colorManager.colors, this.element, this.screenElement, this._viewportElement, this.linkifier);
default: throw new Error(`Unrecognized rendererType "${this.options.rendererType}"`); default: throw new Error(`Unrecognized rendererType "${this.options.rendererType}"`);
} }
} }
@@ -29,8 +29,8 @@ export class DomRenderer extends Disposable implements IRenderer {
private _rowFactory: DomRendererRowFactory; private _rowFactory: DomRendererRowFactory;
private _terminalClass: number = nextTerminalId++; private _terminalClass: number = nextTerminalId++;
private _themeStyleElement: HTMLStyleElement; private _themeStyleElement!: HTMLStyleElement;
private _dimensionsStyleElement: HTMLStyleElement; private _dimensionsStyleElement!: HTMLStyleElement;
private _rowContainer: HTMLElement; private _rowContainer: HTMLElement;
private _rowElements: HTMLElement[] = []; private _rowElements: HTMLElement[] = [];
private _selectionContainer: HTMLElement; private _selectionContainer: HTMLElement;
@@ -43,10 +43,10 @@ export class DomRenderer extends Disposable implements IRenderer {
private readonly _screenElement: HTMLElement, private readonly _screenElement: HTMLElement,
private readonly _viewportElement: HTMLElement, private readonly _viewportElement: HTMLElement,
private readonly _linkifier: ILinkifier, private readonly _linkifier: ILinkifier,
private readonly _charSizeService: ICharSizeService, @ICharSizeService private readonly _charSizeService: ICharSizeService,
private readonly _optionsService: IOptionsService, @IOptionsService private readonly _optionsService: IOptionsService,
private readonly _bufferService: IBufferService, @IBufferService private readonly _bufferService: IBufferService,
private readonly _renderService: IRenderService @IRenderService private readonly _renderService: IRenderService
) { ) {
super(); super();
@@ -60,18 +60,18 @@ export class DomRenderer extends Disposable implements IRenderer {
this._selectionContainer.setAttribute('aria-hidden', 'true'); this._selectionContainer.setAttribute('aria-hidden', 'true');
this.dimensions = { this.dimensions = {
scaledCharWidth: null, scaledCharWidth: 0,
scaledCharHeight: null, scaledCharHeight: 0,
scaledCellWidth: null, scaledCellWidth: 0,
scaledCellHeight: null, scaledCellHeight: 0,
scaledCharLeft: null, scaledCharLeft: 0,
scaledCharTop: null, scaledCharTop: 0,
scaledCanvasWidth: null, scaledCanvasWidth: 0,
scaledCanvasHeight: null, scaledCanvasHeight: 0,
canvasWidth: null, canvasWidth: 0,
canvasHeight: null, canvasHeight: 0,
actualCellWidth: null, actualCellWidth: 0,
actualCellHeight: null actualCellHeight: 0
}; };
this._updateDimensions(); this._updateDimensions();
this._injectCss(); this._injectCss();
@@ -246,7 +246,7 @@ export class DomRenderer extends Disposable implements IRenderer {
} }
// Remove excess elements // Remove excess elements
while (this._rowElements.length > rows) { while (this._rowElements.length > rows) {
this._rowContainer.removeChild(this._rowElements.pop()); this._rowContainer.removeChild(this._rowElements.pop()!);
} }
} }
@@ -356,7 +356,7 @@ export class DomRenderer extends Disposable implements IRenderer {
const row = y + this._bufferService.buffer.ydisp; const row = y + this._bufferService.buffer.ydisp;
const lineData = this._bufferService.buffer.lines.get(row); const lineData = this._bufferService.buffer.lines.get(row);
const cursorStyle = this._optionsService.options.cursorStyle; const cursorStyle = this._optionsService.options.cursorStyle;
rowElement.appendChild(this._rowFactory.createRow(lineData, row === cursorAbsoluteY, cursorStyle, cursorX, cursorBlink, this.dimensions.actualCellWidth, this._bufferService.cols)); rowElement.appendChild(this._rowFactory.createRow(lineData!, row === cursorAbsoluteY, cursorStyle, cursorX, cursorBlink, this.dimensions.actualCellWidth, this._bufferService.cols));
} }
} }