Improve experience and add test
- Scroll to bottom on keydown (when scrolled up) - Add test to ensure above behavior
This commit is contained in:
+6
-7
@@ -1352,12 +1352,6 @@ Terminal.prototype.write = function(data) {
|
|||||||
this.refreshStart = this.y;
|
this.refreshStart = this.y;
|
||||||
this.refreshEnd = this.y;
|
this.refreshEnd = this.y;
|
||||||
|
|
||||||
// if (this.ybase !== this.ydisp) {
|
|
||||||
// this.ydisp = this.ybase;
|
|
||||||
// this.emit('scroll', this.ydisp);
|
|
||||||
// this.maxRange();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// apply leftover surrogate high from last write
|
// apply leftover surrogate high from last write
|
||||||
if (this.surrogate_high) {
|
if (this.surrogate_high) {
|
||||||
data = this.surrogate_high + data;
|
data = this.surrogate_high + data;
|
||||||
@@ -2423,6 +2417,11 @@ Terminal.prototype.attachCustomKeydownHandler = function(customKeydownHandler) {
|
|||||||
* @param {KeyboardEvent} ev The keydown event to be handled.
|
* @param {KeyboardEvent} ev The keydown event to be handled.
|
||||||
*/
|
*/
|
||||||
Terminal.prototype.keyDown = function(ev) {
|
Terminal.prototype.keyDown = function(ev) {
|
||||||
|
// Scroll down to prompt, whenever the user presses a key.
|
||||||
|
if (this.ybase !== this.ydisp) {
|
||||||
|
this.scrollToBottom();
|
||||||
|
}
|
||||||
|
|
||||||
if (this.customKeydownHandler && this.customKeydownHandler(ev) === false) {
|
if (this.customKeydownHandler && this.customKeydownHandler(ev) === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -2974,7 +2973,7 @@ Terminal.prototype.updateRange = function(y) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the range of refreshing to the maximyum value
|
* Set the range of refreshing to the maximum value
|
||||||
*/
|
*/
|
||||||
Terminal.prototype.maxRange = function() {
|
Terminal.prototype.maxRange = function() {
|
||||||
this.refreshStart = 0;
|
this.refreshStart = 0;
|
||||||
|
|||||||
@@ -181,6 +181,25 @@ describe('xterm.js', function() {
|
|||||||
assert.equal(xterm.ydisp, startYDisp);
|
assert.equal(xterm.ydisp, startYDisp);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('keyDown', function () {
|
||||||
|
it('should scroll down, when a key is pressed and terminal is scrolled up', function () {
|
||||||
|
var terminal = new Terminal();
|
||||||
|
|
||||||
|
// Do not process the keyDown event, to avoid side-effects
|
||||||
|
terminal.attachCustomKeydownHandler(function () {
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
terminal.ydisp = 0;
|
||||||
|
terminal.ybase = 40;
|
||||||
|
|
||||||
|
terminal.keyDown();
|
||||||
|
|
||||||
|
// Ensure that now the terminal is scrolled to bottom
|
||||||
|
assert.equal(terminal.ydisp, terminal.ybase);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('evaluateKeyEscapeSequence', function() {
|
describe('evaluateKeyEscapeSequence', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user