Fix save and restore cursor behavior

This broke in #717.

Fixes #818
This commit is contained in:
Daniel Imms
2017-07-27 16:28:27 -07:00
parent f36bd24e1e
commit 604959a319
3 changed files with 20 additions and 8 deletions
+10 -8
View File
@@ -948,7 +948,8 @@ export class InputHandler implements IInputHandler {
this._terminal.cursorHidden = false;
break;
case 1049: // alt screen buffer cursor
this.saveCursor(params);
// TODO: Not sure if we need to save/restore after switching the buffer
// this.saveCursor(params);
// FALL-THROUGH
case 47: // alt screen buffer
case 1047: // alt screen buffer
@@ -1118,9 +1119,10 @@ export class InputHandler implements IInputHandler {
case 1047: // normal screen buffer - clearing it first
// Ensure the selection manager has the correct buffer
this._terminal.buffers.activateNormalBuffer();
if (params[0] === 1049) {
this.restoreCursor(params);
}
// TODO: Not sure if we need to save/restore after switching the buffer
// if (params[0] === 1049) {
// this.restoreCursor(params);
// }
this._terminal.selectionManager.setBuffer(this._terminal.buffer.lines);
this._terminal.refresh(0, this._terminal.rows - 1);
this._terminal.viewport.syncScrollArea();
@@ -1453,8 +1455,8 @@ export class InputHandler implements IInputHandler {
* Save cursor (ANSI.SYS).
*/
public saveCursor(params: number[]): void {
this._terminal.buffers.active.x = this._terminal.buffer.x;
this._terminal.buffers.active.y = this._terminal.buffer.y;
this._terminal.buffer.savedX = this._terminal.buffer.x;
this._terminal.buffer.savedY = this._terminal.buffer.y;
}
@@ -1463,8 +1465,8 @@ export class InputHandler implements IInputHandler {
* Restore cursor (ANSI.SYS).
*/
public restoreCursor(params: number[]): void {
this._terminal.buffer.x = this._terminal.buffers.active.x || 0;
this._terminal.buffer.y = this._terminal.buffers.active.y || 0;
this._terminal.buffer.x = this._terminal.buffer.savedX || 0;
this._terminal.buffer.y = this._terminal.buffer.savedY || 0;
}
}