mirror of https://github.com/nodejs/node.git
add home/end support in rxvt and readline tests
parent
c209e57e50
commit
fd3e84499e
|
@ -361,10 +361,14 @@ Interface.prototype._ttyWrite = function (b) {
|
|||
this.cursor++;
|
||||
this.output.write('\x1b[0C');
|
||||
}
|
||||
} else if ((b[1] === 91 || b[1] === 79) && b[2] === 72) { // home
|
||||
} else if ((b[1] === 91 && b[2] === 72) ||
|
||||
(b[1] === 79 && b[2] === 72) ||
|
||||
(b[1] === 91 && b[2] === 55)) { // home
|
||||
this.cursor = 0;
|
||||
this._refreshLine();
|
||||
} else if ((b[1] === 91 || b[1] === 79) && b[2] === 70) { // end
|
||||
} else if ((b[1] === 91 && b[2] === 70) ||
|
||||
(b[1] === 79 && b[2] === 70) ||
|
||||
(b[1] === 91 && b[2] === 56)) { // end
|
||||
this.cursor = this.line.length;
|
||||
this._refreshLine();
|
||||
} else if (b[1] === 91 && b[2] === 65) { // up arrow
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
common = require("../common");
|
||||
assert = common.assert;
|
||||
var readline = require("readline");
|
||||
|
||||
var key = {
|
||||
xterm: {
|
||||
home: [27, 91, 72],
|
||||
end: [27, 91, 70]
|
||||
},
|
||||
gnome: {
|
||||
home: [27, 79, 72],
|
||||
end: [27, 79, 70]
|
||||
},
|
||||
rxvt: {
|
||||
home: [27, 91, 55],
|
||||
end: [27, 91, 56]
|
||||
}
|
||||
};
|
||||
|
||||
var fakestream = {
|
||||
fd: 1,
|
||||
write: function(bytes) {
|
||||
}
|
||||
};
|
||||
|
||||
var rl = readline.createInterface(fakestream, function (text) {
|
||||
return [[], ""];
|
||||
});
|
||||
|
||||
rl.write('foo');
|
||||
assert.equal(3, rl.cursor);
|
||||
rl.write(key.xterm.home);
|
||||
assert.equal(0, rl.cursor);
|
||||
rl.write(key.xterm.end);
|
||||
assert.equal(3, rl.cursor);
|
||||
rl.write(key.rxvt.home);
|
||||
assert.equal(0, rl.cursor);
|
||||
rl.write(key.rxvt.end);
|
||||
assert.equal(3, rl.cursor);
|
||||
rl.write(key.gnome.home);
|
||||
assert.equal(0, rl.cursor);
|
||||
rl.write(key.gnome.end);
|
||||
assert.equal(3, rl.cursor);
|
Loading…
Reference in New Issue