Add scrollToBottom
This commit is contained in:
@@ -1315,6 +1315,14 @@ Terminal.prototype.scrollPages = function(pageCount) {
|
|||||||
this.scrollDisp(pageCount * (this.rows - 1));
|
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.
|
* Writes text to the terminal.
|
||||||
* @param {string} text The text to write to the terminal.
|
* @param {string} text The text to write to the terminal.
|
||||||
|
|||||||
@@ -147,6 +147,40 @@ describe('xterm.js', function() {
|
|||||||
assert.equal(xterm.ydisp, startYDisp);
|
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() {
|
describe('evaluateKeyEscapeSequence', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user