+16
-1
@@ -60,7 +60,6 @@ export class InputHandler implements IInputHandler {
|
|||||||
this._terminal.scroll();
|
this._terminal.scroll();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this._terminal.x = this._terminal.cols - 1;
|
|
||||||
if (ch_width === 2) // FIXME: check for xterm behavior
|
if (ch_width === 2) // FIXME: check for xterm behavior
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -124,6 +123,10 @@ export class InputHandler implements IInputHandler {
|
|||||||
this._terminal.y--;
|
this._terminal.y--;
|
||||||
this._terminal.scroll();
|
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) {
|
if (this._terminal.y >= this._terminal.rows) {
|
||||||
this._terminal.y = this._terminal.rows - 1;
|
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) {
|
if (param < 1) {
|
||||||
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;
|
this._terminal.x -= param;
|
||||||
if (this._terminal.x < 0) {
|
if (this._terminal.x < 0) {
|
||||||
this._terminal.x = 0;
|
this._terminal.x = 0;
|
||||||
@@ -693,6 +704,10 @@ export class InputHandler implements IInputHandler {
|
|||||||
if (this._terminal.y >= this._terminal.rows) {
|
if (this._terminal.y >= this._terminal.rows) {
|
||||||
this._terminal.y = this._terminal.rows - 1;
|
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
@@ -74,6 +74,7 @@ escapedStateHandler['%'] = (parser, terminal) => {
|
|||||||
parser.setState(ParserState.NORMAL);
|
parser.setState(ParserState.NORMAL);
|
||||||
parser.skipNextChar();
|
parser.skipNextChar();
|
||||||
};
|
};
|
||||||
|
escapedStateHandler[C0.CAN] = (parser) => parser.setState(ParserState.NORMAL);
|
||||||
|
|
||||||
const csiParamStateHandler: {[key: string]: (parser: Parser) => void} = {};
|
const csiParamStateHandler: {[key: string]: (parser: Parser) => void} = {};
|
||||||
csiParamStateHandler['?'] = (parser) => parser.setPrefix('?');
|
csiParamStateHandler['?'] = (parser) => parser.setPrefix('?');
|
||||||
@@ -94,8 +95,9 @@ csiParamStateHandler['"'] = (parser) => parser.setPostfix('"');
|
|||||||
csiParamStateHandler[' '] = (parser) => parser.setPostfix(' ');
|
csiParamStateHandler[' '] = (parser) => parser.setPostfix(' ');
|
||||||
csiParamStateHandler['\''] = (parser) => parser.setPostfix('\'');
|
csiParamStateHandler['\''] = (parser) => parser.setPostfix('\'');
|
||||||
csiParamStateHandler[';'] = (parser) => parser.finalizeParam();
|
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['@'] = (handler, params, prefix) => handler.insertChars(params);
|
||||||
csiStateHandler['A'] = (handler, params, prefix) => handler.cursorUp(params);
|
csiStateHandler['A'] = (handler, params, prefix) => handler.cursorUp(params);
|
||||||
csiStateHandler['B'] = (handler, params, prefix) => handler.cursorDown(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['r'] = (handler, params) => handler.setScrollRegion(params);
|
||||||
csiStateHandler['s'] = (handler, params) => handler.saveCursor(params);
|
csiStateHandler['s'] = (handler, params) => handler.saveCursor(params);
|
||||||
csiStateHandler['u'] = (handler, params) => handler.restoreCursor(params);
|
csiStateHandler['u'] = (handler, params) => handler.restoreCursor(params);
|
||||||
|
csiStateHandler[C0.CAN] = (handler, params, prefix, postfix, parser) => parser.setState(ParserState.NORMAL);
|
||||||
|
|
||||||
enum ParserState {
|
enum ParserState {
|
||||||
NORMAL = 0,
|
NORMAL = 0,
|
||||||
@@ -455,7 +458,7 @@ export class Parser {
|
|||||||
|
|
||||||
case ParserState.CSI:
|
case ParserState.CSI:
|
||||||
if (ch in csiStateHandler) {
|
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 {
|
} else {
|
||||||
this._terminal.error('Unknown CSI code: %s.', ch);
|
this._terminal.error('Unknown CSI code: %s.', ch);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ function formatError(in_, out_, expected) {
|
|||||||
function terminalToString(term) {
|
function terminalToString(term) {
|
||||||
var result = '';
|
var result = '';
|
||||||
var line_s = '';
|
var line_s = '';
|
||||||
for (var line=0; line<term.rows; ++line) {
|
for (var line = term.ybase; line < term.ybase + term.rows; line++) {
|
||||||
line_s = '';
|
line_s = '';
|
||||||
for (var cell=0; cell<term.cols; ++cell) {
|
for (var cell=0; cell<term.cols; ++cell) {
|
||||||
line_s += term.lines.get(line)[cell][1];
|
line_s += term.lines.get(line)[cell][1];
|
||||||
@@ -76,16 +76,26 @@ describe('xterm output comparison', function() {
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
xterm = new Terminal(COLS, ROWS);
|
xterm = new Terminal(COLS, ROWS);
|
||||||
xterm.refresh = function() {};
|
xterm.refresh = function() {};
|
||||||
|
xterm.viewport = {
|
||||||
|
syncScrollArea: function() {}
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
// omit stack trace for escape sequence files
|
// omit stack trace for escape sequence files
|
||||||
Error.stackTraceLimit = 0;
|
Error.stackTraceLimit = 0;
|
||||||
var files = glob.sync('**/escape_sequence_files/*.in');
|
var files = glob.sync('**/escape_sequence_files/*.in');
|
||||||
// only successful tests for now
|
// only successful tests for now
|
||||||
var successful = [0, 2, 6, 12, 13, 18, 20, 22, 27, 28];
|
var skip = [
|
||||||
for (var a in successful) {
|
10, 16, 17, 19, 32, 33, 34, 35, 36, 39,
|
||||||
var i = successful[a];
|
40, 42, 43, 44, 45, 46, 47, 48, 49, 50,
|
||||||
(function(filename){
|
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 () {
|
it(filename.split('/').slice(-1)[0], function () {
|
||||||
pty_reset();
|
pty_reset();
|
||||||
var in_file = fs.readFileSync(filename, 'utf8');
|
var in_file = fs.readFileSync(filename, 'utf8');
|
||||||
@@ -100,10 +110,15 @@ describe('xterm output comparison', function() {
|
|||||||
var from_emulator = terminalToString(xterm);
|
var from_emulator = terminalToString(xterm);
|
||||||
console.log = CONSOLE_LOG;
|
console.log = CONSOLE_LOG;
|
||||||
var expected = fs.readFileSync(filename.split('.')[0] + '.text', 'utf8');
|
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
|
// uncomment to get noisy output
|
||||||
//throw new Error(formatError(in_file, from_emulator, expected));
|
throw new Error(formatError(in_file, from_emulator, expected));
|
||||||
throw new Error('mismatch');
|
// throw new Error('mismatch');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})(files[i]);
|
})(files[i]);
|
||||||
|
|||||||
+3
-2
@@ -595,8 +595,9 @@ describe('xterm.js', function() {
|
|||||||
xterm.x = xterm.cols - 1;
|
xterm.x = xterm.cols - 1;
|
||||||
xterm.wraparoundMode = false;
|
xterm.wraparoundMode = false;
|
||||||
xterm.write('a' + high + String.fromCharCode(i));
|
xterm.write('a' + high + String.fromCharCode(i));
|
||||||
expect(xterm.lines.get(0)[xterm.cols-1][1]).eql(high + String.fromCharCode(i));
|
// auto wraparound mode should cut off the rest of the line
|
||||||
expect(xterm.lines.get(0)[xterm.cols-1][1].length).eql(2);
|
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(' ');
|
expect(xterm.lines.get(1)[1][1]).eql(' ');
|
||||||
xterm.reset();
|
xterm.reset();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2303,6 +2303,10 @@ Terminal.prototype.index = function() {
|
|||||||
this.y--;
|
this.y--;
|
||||||
this.scroll();
|
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--;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user