Add scrollToBottom

This commit is contained in:
Daniel Imms 2016-10-09 13:19:08 -07:00
parent 941e57a218
commit e5d130b698
2 changed files with 42 additions and 0 deletions

View File

@ -1315,6 +1315,14 @@ Terminal.prototype.scrollPages = function(pageCount) {
this.scrollDisp(pageCount * (this.rows - 1));
}
Terminal.prototype.scrollToTop = function() {
this.scrollDisp(-this.ydisp);
}
Terminal.prototype.scrollToBottom = function() {
this.scrollDisp(this.ybase - this.ydisp);
}
/**
* Writes text to the terminal.
* @param {string} text The text to write to the terminal.

View File

@ -147,6 +147,40 @@ describe('xterm.js', function() {
assert.equal(xterm.ydisp, startYDisp);
});
});
describe('scrollToTop', function() {
beforeEach(function() {
for (var i = 0; i < xterm.rows * 3; i++) {
xterm.writeln('test');
}
});
it('should scroll to the top', function() {
assert.notEqual(xterm.ydisp, 0);
xterm.scrollToTop();
assert.equal(xterm.ydisp, 0);
});
});
describe('scrollToBottom', function() {
var startYDisp;
beforeEach(function() {
for (var i = 0; i < xterm.rows * 3; i++) {
xterm.writeln('test');
}
startYDisp = (xterm.rows * 2) + 1;
});
it('should scroll to the bottom', function() {
xterm.scrollDisp(-1);
xterm.scrollToBottom();
assert.equal(xterm.ydisp, startYDisp);
xterm.scrollPages(-1);
xterm.scrollToBottom();
assert.equal(xterm.ydisp, startYDisp);
xterm.scrollToTop();
xterm.scrollToBottom();
assert.equal(xterm.ydisp, startYDisp);
});
});
});
describe('evaluateKeyEscapeSequence', function() {