Improve type safety in webgl

This commit is contained in:
Daniel Imms
2019-06-14 22:25:43 -07:00
parent 3a7aa77950
commit ddb9fbd1d6
3 changed files with 12 additions and 12 deletions
-1
View File
@@ -33,7 +33,6 @@ export class Terminal implements ITerminalApi {
public get onResize(): IEvent<{ cols: number, rows: number }> { return this._core.onResize; }
public get element(): HTMLElement { return this._core.element; }
public get screenElement(): HTMLElement { return this._core.screenElement; }
public get textarea(): HTMLTextAreaElement { return this._core.textarea; }
public get rows(): number { return this._core.rows; }
public get cols(): number { return this._core.cols; }
+7 -7
View File
@@ -47,13 +47,13 @@ export class WebglRenderer extends Disposable implements IRenderer {
) {
super();
this._core = (this._terminal as any)._core;
this._core = (<any>this._terminal)._core;
this._applyBgLuminanceBasedSelection();
this._renderLayers = [
new LinkRenderLayer((<any>this._terminal).screenElement, 2, this._colors, this._core),
new CursorRenderLayer((<any>this._terminal).screenElement, 3, this._colors)
new LinkRenderLayer(this._core.screenElement, 2, this._colors, this._core),
new CursorRenderLayer(this._core.screenElement, 3, this._colors)
];
this.dimensions = {
scaledCharWidth: null,
@@ -83,7 +83,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
if (!this._gl) {
throw new Error('WebGL2 not supported');
}
(<any>this._terminal).screenElement.appendChild(this._canvas);
this._core.screenElement.appendChild(this._canvas);
this._rectangleRenderer = new RectangleRenderer(this._terminal, this._colors, this._gl, this.dimensions);
this._glyphRenderer = new GlyphRenderer(this._terminal, this._colors, this._gl, this.dimensions);
@@ -94,7 +94,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
public dispose(): void {
this._renderLayers.forEach(l => l.dispose());
(<any>this._terminal).screenElement.removeChild(this._canvas);
this._core.screenElement.removeChild(this._canvas);
super.dispose();
}
@@ -153,8 +153,8 @@ export class WebglRenderer extends Disposable implements IRenderer {
this._canvas.style.height = `${this.dimensions.canvasHeight}px`;
// Resize the screen
(<any>this._terminal).screenElement.style.width = `${this.dimensions.canvasWidth}px`;
(<any>this._terminal).screenElement.style.height = `${this.dimensions.canvasHeight}px`;
this._core.screenElement.style.width = `${this.dimensions.canvasWidth}px`;
this._core.screenElement.style.height = `${this.dimensions.canvasHeight}px`;
this._glyphRenderer.setDimensions(this.dimensions);
this._glyphRenderer.onResize();
+5 -4
View File
@@ -5,10 +5,10 @@
import { Terminal, ITerminalAddon } from 'xterm';
import { WebglRenderer } from './WebglRenderer';
import { IRenderService } from 'browser/services/Services';
import { IColorSet } from 'browser/Types';
export class WebglRendererAddon implements ITerminalAddon {
private _terminal: Terminal | undefined;
constructor(
private _preserveDrawingBuffer?: boolean
) {}
@@ -17,8 +17,9 @@ export class WebglRendererAddon implements ITerminalAddon {
if (!terminal.element) {
throw new Error('Cannot activate WebglRendererAddon before Terminal.open');
}
this._terminal = terminal;
(<any>this._terminal)._core._renderService.setRenderer(new WebglRenderer(terminal, (terminal as any)._core._colorManager.colors, this._preserveDrawingBuffer));
const renderService: IRenderService = (<any>terminal)._core._renderService;
const colors: IColorSet = (<any>terminal)._core._colorManager.colors;
renderService.setRenderer(new WebglRenderer(terminal, colors, this._preserveDrawingBuffer));
}
public dispose(): void {