This commit is contained in:
Daniel Imms
2017-05-20 15:21:12 -07:00
parent 597c6939c8
commit e63fdf580b
2 changed files with 19 additions and 8 deletions
+3
View File
@@ -355,6 +355,9 @@ export class Renderer {
// TODO: Only redraw selections when necessary // TODO: Only redraw selections when necessary
// TODO: Fix selection on the first row going out the left of the terminal
// TODO: Fix selection on the last row not going to the last column
// Create the selections // Create the selections
const documentFragment = document.createDocumentFragment(); const documentFragment = document.createDocumentFragment();
// Draw first row // Draw first row
+16 -8
View File
@@ -64,8 +64,9 @@ export class SelectionManager extends EventEmitter {
result += line[i][1]; result += line[i][1];
} }
// TODO: Trim line here instead of in handlers/Clipboard? // TODO: Trim line here instead of in handlers/Clipboard?
return result; // TODO: Only trim off the whitespace at the end of a line
// TODO: Handle the double-width character case // TODO: Handle the double-width character case
return result;
} }
/** /**
@@ -81,10 +82,6 @@ export class SelectionManager extends EventEmitter {
* @param amount The amount the buffer is being trimmed. * @param amount The amount the buffer is being trimmed.
*/ */
private _onTrim(amount: number) { private _onTrim(amount: number) {
// TODO: Somehow map the selection coordinates with the list that is constantly being trimmed
// Maybe we need an ID in the CircularList that starts from 0 for the first entry and increments
// console.log('trimmed: ' + amount);
// Adjust the selection position based on the trimmed amount. // Adjust the selection position based on the trimmed amount.
this._selectionStart[0] -= amount; this._selectionStart[0] -= amount;
this._selectionEnd[0] -= amount; this._selectionEnd[0] -= amount;
@@ -115,6 +112,10 @@ export class SelectionManager extends EventEmitter {
return coords; return coords;
} }
/**
* Handles te mousedown event, setting up for a new selection.
* @param event The mousedown event.
*/
private _onMouseDown(event: MouseEvent) { private _onMouseDown(event: MouseEvent) {
this._selectionStart = this._getMouseBufferCoords(event); this._selectionStart = this._getMouseBufferCoords(event);
if (this._selectionStart) { if (this._selectionStart) {
@@ -124,16 +125,23 @@ export class SelectionManager extends EventEmitter {
} }
} }
/**
* Handles the mousemove event when the mouse button is down, recording the
* end of the selection and refreshing the selection.
* @param event The mousemove event.
*/
private _onMouseMove(event: MouseEvent) { private _onMouseMove(event: MouseEvent) {
this._selectionEnd = this._getMouseBufferCoords(event); this._selectionEnd = this._getMouseBufferCoords(event);
// TODO: Only draw here if the selection changes // TODO: Only draw here if the selection changes
this.refresh(); this.refresh();
} }
/**
* Handles the mouseup event, removing the mousemove listener when
* appropriate.
* @param event The mouseup event.
*/
private _onMouseUp(event: MouseEvent) { private _onMouseUp(event: MouseEvent) {
// console.log('mouseup');
// console.log('start', this._selectionStart);
// console.log('end', this._selectionEnd);
if (!this._selectionStart) { if (!this._selectionStart) {
return; return;
} }