Merge pull request #500 from Tyriar/fix_vt_tests

Fix many vt tests
This commit is contained in:
Daniel Imms
2017-01-26 08:55:42 -08:00
committed by GitHub
5 changed files with 51 additions and 13 deletions
+16 -1
View File
@@ -60,7 +60,6 @@ export class InputHandler implements IInputHandler {
this._terminal.scroll();
}
} else {
this._terminal.x = this._terminal.cols - 1;
if (ch_width === 2) // FIXME: check for xterm behavior
return;
}
@@ -124,6 +123,10 @@ export class InputHandler implements IInputHandler {
this._terminal.y--;
this._terminal.scroll();
}
// If the end of the line is hit, prevent this action from wrapping around to the next line.
if (this._terminal.x >= this._terminal.cols) {
this._terminal.x--;
}
}
/**
@@ -218,6 +221,10 @@ export class InputHandler implements IInputHandler {
if (this._terminal.y >= this._terminal.rows) {
this._terminal.y = this._terminal.rows - 1;
}
// If the end of the line is hit, prevent this action from wrapping around to the next line.
if (this._terminal.x >= this._terminal.cols) {
this._terminal.x--;
}
}
/**
@@ -244,6 +251,10 @@ export class InputHandler implements IInputHandler {
if (param < 1) {
param = 1;
}
// If the end of the line is hit, prevent this action from wrapping around to the next line.
if (this._terminal.x >= this._terminal.cols) {
this._terminal.x--;
}
this._terminal.x -= param;
if (this._terminal.x < 0) {
this._terminal.x = 0;
@@ -693,6 +704,10 @@ export class InputHandler implements IInputHandler {
if (this._terminal.y >= this._terminal.rows) {
this._terminal.y = this._terminal.rows - 1;
}
// If the end of the line is hit, prevent this action from wrapping around to the next line.
if (this._terminal.x >= this._terminal.cols) {
this._terminal.x--;
}
}
/**
+5 -2
View File
@@ -74,6 +74,7 @@ escapedStateHandler['%'] = (parser, terminal) => {
parser.setState(ParserState.NORMAL);
parser.skipNextChar();
};
escapedStateHandler[C0.CAN] = (parser) => parser.setState(ParserState.NORMAL);
const csiParamStateHandler: {[key: string]: (parser: Parser) => void} = {};
csiParamStateHandler['?'] = (parser) => parser.setPrefix('?');
@@ -94,8 +95,9 @@ csiParamStateHandler['"'] = (parser) => parser.setPostfix('"');
csiParamStateHandler[' '] = (parser) => parser.setPostfix(' ');
csiParamStateHandler['\''] = (parser) => parser.setPostfix('\'');
csiParamStateHandler[';'] = (parser) => parser.finalizeParam();
csiParamStateHandler[C0.CAN] = (parser) => parser.setState(ParserState.NORMAL);
const csiStateHandler: {[key: string]: (handler: IInputHandler, params: number[], prefix: string, postfix: string) => void} = {};
const csiStateHandler: {[key: string]: (handler: IInputHandler, params: number[], prefix: string, postfix: string, parser: Parser) => void} = {};
csiStateHandler['@'] = (handler, params, prefix) => handler.insertChars(params);
csiStateHandler['A'] = (handler, params, prefix) => handler.cursorUp(params);
csiStateHandler['B'] = (handler, params, prefix) => handler.cursorDown(params);
@@ -144,6 +146,7 @@ csiStateHandler['q'] = (handler, params, prefix, postfix) => {
csiStateHandler['r'] = (handler, params) => handler.setScrollRegion(params);
csiStateHandler['s'] = (handler, params) => handler.saveCursor(params);
csiStateHandler['u'] = (handler, params) => handler.restoreCursor(params);
csiStateHandler[C0.CAN] = (handler, params, prefix, postfix, parser) => parser.setState(ParserState.NORMAL);
enum ParserState {
NORMAL = 0,
@@ -455,7 +458,7 @@ export class Parser {
case ParserState.CSI:
if (ch in csiStateHandler) {
csiStateHandler[ch](this._inputHandler, this._terminal.params, this._terminal.prefix, this._terminal.postfix);
csiStateHandler[ch](this._inputHandler, this._terminal.params, this._terminal.prefix, this._terminal.postfix, this);
} else {
this._terminal.error('Unknown CSI code: %s.', ch);
}
+23 -8
View File
@@ -56,7 +56,7 @@ function formatError(in_, out_, expected) {
function terminalToString(term) {
var result = '';
var line_s = '';
for (var line=0; line<term.rows; ++line) {
for (var line = term.ybase; line < term.ybase + term.rows; line++) {
line_s = '';
for (var cell=0; cell<term.cols; ++cell) {
line_s += term.lines.get(line)[cell][1];
@@ -76,16 +76,26 @@ describe('xterm output comparison', function() {
beforeEach(function () {
xterm = new Terminal(COLS, ROWS);
xterm.refresh = function() {};
xterm.viewport = {
syncScrollArea: function() {}
};
});
// omit stack trace for escape sequence files
Error.stackTraceLimit = 0;
var files = glob.sync('**/escape_sequence_files/*.in');
// only successful tests for now
var successful = [0, 2, 6, 12, 13, 18, 20, 22, 27, 28];
for (var a in successful) {
var i = successful[a];
(function(filename){
var skip = [
10, 16, 17, 19, 32, 33, 34, 35, 36, 39,
40, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, 52, 54, 55, 56, 57, 58, 59, 60, 61,
63, 68
];
for (var i = 0; i < files.length; i++) {
if (skip.indexOf(i) >= 0) {
continue;
}
(function(filename) {
it(filename.split('/').slice(-1)[0], function () {
pty_reset();
var in_file = fs.readFileSync(filename, 'utf8');
@@ -100,10 +110,15 @@ describe('xterm output comparison', function() {
var from_emulator = terminalToString(xterm);
console.log = CONSOLE_LOG;
var expected = fs.readFileSync(filename.split('.')[0] + '.text', 'utf8');
if (from_emulator != expected) {
// Some of the tests have whitespace on the right of lines, we trim all the linex
// from xterm.js so ignore this for now at least.
var expectedRightTrimmed = expected.split('\n').map(function (l) {
return l.replace(/\s+$/, '');
}).join('\n');
if (from_emulator != expectedRightTrimmed) {
// uncomment to get noisy output
//throw new Error(formatError(in_file, from_emulator, expected));
throw new Error('mismatch');
throw new Error(formatError(in_file, from_emulator, expected));
// throw new Error('mismatch');
}
});
})(files[i]);
+3 -2
View File
@@ -595,8 +595,9 @@ describe('xterm.js', function() {
xterm.x = xterm.cols - 1;
xterm.wraparoundMode = false;
xterm.write('a' + high + String.fromCharCode(i));
expect(xterm.lines.get(0)[xterm.cols-1][1]).eql(high + String.fromCharCode(i));
expect(xterm.lines.get(0)[xterm.cols-1][1].length).eql(2);
// auto wraparound mode should cut off the rest of the line
expect(xterm.lines.get(0)[xterm.cols-1][1]).eql('a');
expect(xterm.lines.get(0)[xterm.cols-1][1].length).eql(1);
expect(xterm.lines.get(1)[1][1]).eql(' ');
xterm.reset();
}
+4
View File
@@ -2303,6 +2303,10 @@ Terminal.prototype.index = function() {
this.y--;
this.scroll();
}
// If the end of the line is hit, prevent this action from wrapping around to the next line.
if (this.x >= this.cols) {
this.x--;
}
};