mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Merge branch 'master' into alt-selection
This commit is contained in:
@@ -13,6 +13,7 @@ npm-debug.log
|
||||
.env
|
||||
build/
|
||||
.vscode/
|
||||
.DS_Store
|
||||
|
||||
# Directories needed for code coverage
|
||||
/coverage/
|
||||
|
||||
Generated
+1144
-954
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -39,7 +39,7 @@
|
||||
"@types/jsdom": "^11.0.1",
|
||||
"@types/mocha": "^2.2.33",
|
||||
"@types/node": "^6.0.41",
|
||||
"browserify": "^13.1.0",
|
||||
"browserify": "^13.3.0",
|
||||
"chai": "3.5.0",
|
||||
"docdash": "0.4.0",
|
||||
"express": "4.13.4",
|
||||
|
||||
@@ -15,6 +15,9 @@ import { CircularList } from './utils/CircularList';
|
||||
export class Buffer {
|
||||
public lines: CircularList<[number, string, number][]>;
|
||||
|
||||
public savedY: number;
|
||||
public savedX: number;
|
||||
|
||||
/**
|
||||
* Create a new Buffer.
|
||||
* @param {Terminal} terminal - The terminal the Buffer will belong to
|
||||
|
||||
@@ -3,6 +3,21 @@ import { InputHandler } from './InputHandler';
|
||||
import { wcwidth } from './InputHandler';
|
||||
|
||||
describe('InputHandler', () => {
|
||||
describe('save and restore cursor', () => {
|
||||
let terminal = { buffer: { x: 1, y: 2 } };
|
||||
let inputHandler = new InputHandler(terminal);
|
||||
// Save cursor position
|
||||
inputHandler.saveCursor([]);
|
||||
assert.equal(terminal.buffer.x, 1);
|
||||
assert.equal(terminal.buffer.y, 2);
|
||||
// Change cursor position
|
||||
terminal.buffer.x = 10;
|
||||
terminal.buffer.y = 20;
|
||||
// Restore cursor position
|
||||
inputHandler.restoreCursor([]);
|
||||
assert.equal(terminal.buffer.x, 1);
|
||||
assert.equal(terminal.buffer.y, 2);
|
||||
});
|
||||
describe('setCursorStyle', () => {
|
||||
it('should call Terminal.setOption with correct params', () => {
|
||||
let options = {};
|
||||
|
||||
+19
-11
@@ -132,6 +132,12 @@ export class InputHandler implements IInputHandler {
|
||||
if (this._terminal.buffer.x >= this._terminal.cols) {
|
||||
this._terminal.buffer.x--;
|
||||
}
|
||||
/**
|
||||
* This event is emitted whenever the terminal outputs a LF or NL.
|
||||
*
|
||||
* @event lineFeed
|
||||
*/
|
||||
this._terminal.emit('lineFeed');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -281,7 +287,7 @@ export class InputHandler implements IInputHandler {
|
||||
this._terminal.buffer.y = this._terminal.rows - 1;
|
||||
}
|
||||
this._terminal.buffer.x = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -299,7 +305,7 @@ export class InputHandler implements IInputHandler {
|
||||
this._terminal.buffer.y = 0;
|
||||
}
|
||||
this._terminal.buffer.x = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -942,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
|
||||
@@ -1107,14 +1114,15 @@ export class InputHandler implements IInputHandler {
|
||||
this._terminal.cursorHidden = true;
|
||||
break;
|
||||
case 1049: // alt screen buffer cursor
|
||||
; // FALL-THROUGH
|
||||
// FALL-THROUGH
|
||||
case 47: // normal screen buffer
|
||||
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();
|
||||
@@ -1447,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1457,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -184,6 +184,10 @@ export class Parser {
|
||||
public parse(data: string): ParserState {
|
||||
let l = data.length, j, cs, ch, code, low;
|
||||
|
||||
if (this._terminal.debug) {
|
||||
this._terminal.log('data: ' + data);
|
||||
}
|
||||
|
||||
this._position = 0;
|
||||
// apply leftover surrogate high from last write
|
||||
if (this._terminal.surrogate_high) {
|
||||
@@ -458,6 +462,9 @@ export class Parser {
|
||||
|
||||
case ParserState.CSI:
|
||||
if (ch in csiStateHandler) {
|
||||
if (this._terminal.debug) {
|
||||
this._terminal.log(`CSI ${this._terminal.prefix ? this._terminal.prefix : ''} ${this._terminal.params ? this._terminal.params.join(';') : ''} ${this._terminal.postfix ? this._terminal.postfix : ''} ${ch}`);
|
||||
}
|
||||
csiStateHandler[ch](this._inputHandler, this._terminal.params, this._terminal.prefix, this._terminal.postfix, this);
|
||||
} else {
|
||||
this._terminal.error('Unknown CSI code: %s.', ch);
|
||||
|
||||
@@ -1941,6 +1941,9 @@ Terminal.prototype.resize = function(x, y) {
|
||||
ch = [this.defAttr, ' ', 1]; // does xterm use the default attr?
|
||||
i = this.buffer.lines.length;
|
||||
while (i--) {
|
||||
if (this.buffer.lines.get(i) === undefined) {
|
||||
this.buffer.lines.set(i, this.blankLine());
|
||||
}
|
||||
while (this.buffer.lines.get(i).length < x) {
|
||||
this.buffer.lines.get(i).push(ch);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user