Tell renderer to draw selection

This commit is contained in:
Daniel Imms
2017-05-19 20:06:05 -07:00
parent 207c4cf961
commit b594407cd5
3 changed files with 11 additions and 1 deletions
+4
View File
@@ -318,6 +318,10 @@ export class Renderer {
this._terminal.emit('refresh', {element: this._terminal.element, start: start, end: end});
};
public refreshSelection(start: [number, number], end: [number, number]) {
console.log('renderer, refresh:', start, end);
}
}
+6 -1
View File
@@ -4,9 +4,11 @@
import { CharMeasure } from './utils/CharMeasure';
import { CircularList } from './utils/CircularList';
import { EventEmitter } from './EventEmitter';
import * as Mouse from './utils/Mouse';
export class SelectionManager {
export class SelectionManager extends EventEmitter {
// TODO: Create a SelectionModel
private _selectionStart: [number, number];
private _selectionEnd: [number, number];
@@ -18,6 +20,7 @@ export class SelectionManager {
private _mouseMoveListener: EventListener;
constructor(buffer: CircularList<any>, rowContainer: HTMLElement, selectionContainer: HTMLElement, charMeasure: CharMeasure) {
super();
this._rowContainer = rowContainer;
this._selectionContainer = selectionContainer;
this._buffer = buffer;
@@ -44,6 +47,8 @@ export class SelectionManager {
* Redraws the selection.
*/
public refresh(): void {
// TODO: Figure out when to refresh the selection vs when to refresh the viewport
this.emit('refresh', { start: this._selectionStart, end: this._selectionEnd });
console.log(`Selection: Start: (${this._selectionStart[0]}, ${this._selectionStart[1]}), End: (${this._selectionEnd[0]}, ${this._selectionEnd[1]})`);
this._selectionContainer.innerHTML = `<div><br><br></div>`;
}
+1
View File
@@ -698,6 +698,7 @@ Terminal.prototype.open = function(parent, focus) {
this.viewport = new Viewport(this, this.viewportElement, this.viewportScrollArea, this.charMeasure);
this.renderer = new Renderer(this);
this.selectionManager = new SelectionManager(this.lines, this.rowContainer, this.selectionContainer, this.charMeasure);
this.selectionManager.on('refresh', data => this.renderer.refreshSelection(data.start, data.end));
// Setup loop that draws to screen
this.refresh(0, this.rows - 1);