Improve type safety in webgl
This commit is contained in:
@@ -33,7 +33,6 @@ export class Terminal implements ITerminalApi {
|
|||||||
public get onResize(): IEvent<{ cols: number, rows: number }> { return this._core.onResize; }
|
public get onResize(): IEvent<{ cols: number, rows: number }> { return this._core.onResize; }
|
||||||
|
|
||||||
public get element(): HTMLElement { return this._core.element; }
|
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 textarea(): HTMLTextAreaElement { return this._core.textarea; }
|
||||||
public get rows(): number { return this._core.rows; }
|
public get rows(): number { return this._core.rows; }
|
||||||
public get cols(): number { return this._core.cols; }
|
public get cols(): number { return this._core.cols; }
|
||||||
|
|||||||
@@ -47,13 +47,13 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this._core = (this._terminal as any)._core;
|
this._core = (<any>this._terminal)._core;
|
||||||
|
|
||||||
this._applyBgLuminanceBasedSelection();
|
this._applyBgLuminanceBasedSelection();
|
||||||
|
|
||||||
this._renderLayers = [
|
this._renderLayers = [
|
||||||
new LinkRenderLayer((<any>this._terminal).screenElement, 2, this._colors, this._core),
|
new LinkRenderLayer(this._core.screenElement, 2, this._colors, this._core),
|
||||||
new CursorRenderLayer((<any>this._terminal).screenElement, 3, this._colors)
|
new CursorRenderLayer(this._core.screenElement, 3, this._colors)
|
||||||
];
|
];
|
||||||
this.dimensions = {
|
this.dimensions = {
|
||||||
scaledCharWidth: null,
|
scaledCharWidth: null,
|
||||||
@@ -83,7 +83,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|||||||
if (!this._gl) {
|
if (!this._gl) {
|
||||||
throw new Error('WebGL2 not supported');
|
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._rectangleRenderer = new RectangleRenderer(this._terminal, this._colors, this._gl, this.dimensions);
|
||||||
this._glyphRenderer = new GlyphRenderer(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 {
|
public dispose(): void {
|
||||||
this._renderLayers.forEach(l => l.dispose());
|
this._renderLayers.forEach(l => l.dispose());
|
||||||
(<any>this._terminal).screenElement.removeChild(this._canvas);
|
this._core.screenElement.removeChild(this._canvas);
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,8 +153,8 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|||||||
this._canvas.style.height = `${this.dimensions.canvasHeight}px`;
|
this._canvas.style.height = `${this.dimensions.canvasHeight}px`;
|
||||||
|
|
||||||
// Resize the screen
|
// Resize the screen
|
||||||
(<any>this._terminal).screenElement.style.width = `${this.dimensions.canvasWidth}px`;
|
this._core.screenElement.style.width = `${this.dimensions.canvasWidth}px`;
|
||||||
(<any>this._terminal).screenElement.style.height = `${this.dimensions.canvasHeight}px`;
|
this._core.screenElement.style.height = `${this.dimensions.canvasHeight}px`;
|
||||||
this._glyphRenderer.setDimensions(this.dimensions);
|
this._glyphRenderer.setDimensions(this.dimensions);
|
||||||
this._glyphRenderer.onResize();
|
this._glyphRenderer.onResize();
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,10 @@
|
|||||||
|
|
||||||
import { Terminal, ITerminalAddon } from 'xterm';
|
import { Terminal, ITerminalAddon } from 'xterm';
|
||||||
import { WebglRenderer } from './WebglRenderer';
|
import { WebglRenderer } from './WebglRenderer';
|
||||||
|
import { IRenderService } from 'browser/services/Services';
|
||||||
|
import { IColorSet } from 'browser/Types';
|
||||||
|
|
||||||
export class WebglRendererAddon implements ITerminalAddon {
|
export class WebglRendererAddon implements ITerminalAddon {
|
||||||
private _terminal: Terminal | undefined;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _preserveDrawingBuffer?: boolean
|
private _preserveDrawingBuffer?: boolean
|
||||||
) {}
|
) {}
|
||||||
@@ -17,8 +17,9 @@ export class WebglRendererAddon implements ITerminalAddon {
|
|||||||
if (!terminal.element) {
|
if (!terminal.element) {
|
||||||
throw new Error('Cannot activate WebglRendererAddon before Terminal.open');
|
throw new Error('Cannot activate WebglRendererAddon before Terminal.open');
|
||||||
}
|
}
|
||||||
this._terminal = terminal;
|
const renderService: IRenderService = (<any>terminal)._core._renderService;
|
||||||
(<any>this._terminal)._core._renderService.setRenderer(new WebglRenderer(terminal, (terminal as any)._core._colorManager.colors, this._preserveDrawingBuffer));
|
const colors: IColorSet = (<any>terminal)._core._colorManager.colors;
|
||||||
|
renderService.setRenderer(new WebglRenderer(terminal, colors, this._preserveDrawingBuffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public dispose(): void {
|
public dispose(): void {
|
||||||
|
|||||||
Reference in New Issue
Block a user