Initial prototype

This commit is contained in:
Daniel Imms
2017-08-30 14:50:16 -07:00
parent 575c10114b
commit c6d4c73c8a
3 changed files with 90 additions and 1 deletions
+13
View File
@@ -175,6 +175,8 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
private body: HTMLBodyElement;
private viewportScrollArea: HTMLElement;
private viewportElement: HTMLElement;
public canvasElement: HTMLCanvasElement;
public canvasContext: CanvasRenderingContext2D;
public selectionContainer: HTMLElement;
private helperContainer: HTMLElement;
private compositionView: HTMLElement;
@@ -703,6 +705,12 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
this.selectionContainer.classList.add('xterm-selection');
this.element.appendChild(this.selectionContainer);
this.canvasElement = document.createElement('canvas');
this.canvasContext = this.canvasElement.getContext('2d');
this.element.appendChild(this.canvasElement);
// Create the container that will hold the lines of the terminal and then
// produce the lines the lines.
this.rowContainer = document.createElement('div');
@@ -746,6 +754,11 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
});
this.charMeasure.measure();
this.charMeasure.on('charsizechanged', () => {
this.canvasElement.setAttribute('width', `${Math.ceil(this.charMeasure.width) * this.cols}px`);
this.canvasElement.setAttribute('height', `${Math.ceil(this.charMeasure.height) * this.rows}px`);
});
this.viewport = new Viewport(this, this.viewportElement, this.viewportScrollArea, this.charMeasure);
this.renderer = new Renderer(this);
this.selectionManager = new SelectionManager(this, this.buffer, this.rowContainer, this.charMeasure);