Fix turning from alt screen to normal screen and vice versa. Fix https://github.com/sourcelair/xterm.js/issues/229 .
This commit is contained in:
committed by
Paris Kasidiaris
parent
4626e19b75
commit
6810de85e1
+2
-10
@@ -30,21 +30,13 @@ export class BufferSet extends EventEmitter {
|
||||
return this._normal;
|
||||
}
|
||||
|
||||
private resetTerminal() {
|
||||
this._terminal.reset();
|
||||
this._terminal.viewport.syncScrollArea();
|
||||
this._terminal.showCursor();
|
||||
}
|
||||
|
||||
public activateNormalBuffer(): void {
|
||||
this._activeBuffer = this._normal;
|
||||
this.resetTerminal();
|
||||
this.emit('activate', this._normal);
|
||||
this.emit('activate', this._normal); // todo maybe simpler this._terminal.buffer = this._terminal.buffers.normal than using EventEmitter?
|
||||
}
|
||||
|
||||
public activateAltBuffer(): void {
|
||||
this._activeBuffer = this._alt;
|
||||
this.resetTerminal();
|
||||
this.emit('activate', this._alt);
|
||||
this.emit('activate', this._alt); // todo maybe simpler this._terminal.buffer = this._terminal.buffers.alt than using EventEmitter?
|
||||
}
|
||||
}
|
||||
|
||||
+13
-12
@@ -942,16 +942,14 @@ export class InputHandler implements IInputHandler {
|
||||
this._terminal.cursorHidden = false;
|
||||
break;
|
||||
case 1049: // alt screen buffer cursor
|
||||
// this._terminal.saveCursor();
|
||||
; // FALL-THROUGH
|
||||
this.saveCursor(params);
|
||||
// FALL-THROUGH
|
||||
case 47: // alt screen buffer
|
||||
case 1047: // alt screen buffer
|
||||
if (!this._terminal.normal) {
|
||||
let normal = {
|
||||
scrollBottom: this._terminal.buffer.scrollBottom,
|
||||
};
|
||||
this._terminal.buffers.activateAltBuffer();
|
||||
}
|
||||
this._terminal.buffers.activateAltBuffer();
|
||||
this._terminal.reset();
|
||||
this._terminal.viewport.syncScrollArea();
|
||||
this._terminal.showCursor();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1114,6 +1112,9 @@ 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);
|
||||
}
|
||||
this._terminal.selectionManager.setBuffer(this._terminal.buffer.lines);
|
||||
this._terminal.refresh(0, this._terminal.rows - 1);
|
||||
this._terminal.viewport.syncScrollArea();
|
||||
@@ -1446,8 +1447,8 @@ export class InputHandler implements IInputHandler {
|
||||
* Save cursor (ANSI.SYS).
|
||||
*/
|
||||
public saveCursor(params: number[]): void {
|
||||
this._terminal.savedX = this._terminal.buffer.x;
|
||||
this._terminal.savedY = this._terminal.buffer.y;
|
||||
this._terminal.buffers.active.x = this._terminal.buffer.x;
|
||||
this._terminal.buffers.active.y = this._terminal.buffer.y;
|
||||
}
|
||||
|
||||
|
||||
@@ -1456,8 +1457,8 @@ export class InputHandler implements IInputHandler {
|
||||
* Restore cursor (ANSI.SYS).
|
||||
*/
|
||||
public restoreCursor(params: number[]): void {
|
||||
this._terminal.buffer.x = this._terminal.savedX || 0;
|
||||
this._terminal.buffer.y = this._terminal.savedY || 0;
|
||||
this._terminal.buffer.x = this._terminal.buffers.active.x || 0;
|
||||
this._terminal.buffer.y = this._terminal.buffers.active.y || 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-6
@@ -161,7 +161,6 @@ function Terminal(options) {
|
||||
this.originMode = false;
|
||||
this.insertMode = false;
|
||||
this.wraparoundMode = true; // defaults: xterm - true, vt100 - false
|
||||
this.normal = null;
|
||||
|
||||
// charset
|
||||
this.charset = null;
|
||||
@@ -228,10 +227,12 @@ function Terminal(options) {
|
||||
this.surrogate_high = '';
|
||||
|
||||
// Create the terminal's buffers and set the current buffer
|
||||
this.buffers = new BufferSet(this);
|
||||
this.buffer = this.buffers.active; // Convenience shortcut;
|
||||
if (!this.buffers) {
|
||||
this.buffers = new BufferSet(this);
|
||||
this.buffer = this.buffers.active; // Convenience shortcut;
|
||||
}
|
||||
this.buffers.on('activate', function (buffer) {
|
||||
this.buffer = buffer;
|
||||
this._terminal.buffer = buffer;
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -2026,8 +2027,6 @@ Terminal.prototype.resize = function(x, y) {
|
||||
|
||||
this.refresh(0, this.rows - 1);
|
||||
|
||||
this.normal = null;
|
||||
|
||||
this.geometry = [this.cols, this.rows];
|
||||
this.emit('resize', {terminal: this, cols: x, rows: y});
|
||||
};
|
||||
@@ -2305,9 +2304,13 @@ Terminal.prototype.reset = function() {
|
||||
this.options.cols = this.cols;
|
||||
var customKeyEventHandler = this.customKeyEventHandler;
|
||||
var cursorBlinkInterval = this.cursorBlinkInterval;
|
||||
var inputHandler = this.inputHandler;
|
||||
var buf = this.buffers;
|
||||
Terminal.call(this, this.options);
|
||||
this.customKeyEventHandler = customKeyEventHandler;
|
||||
this.cursorBlinkInterval = cursorBlinkInterval;
|
||||
this.inputHandler = inputHandler;
|
||||
this.buffers = buf;
|
||||
this.refresh(0, this.rows - 1);
|
||||
this.viewport.syncScrollArea();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user