mirror of
https://git.proxmox.com/git/mirror_xterm.js
synced 2025-11-01 03:40:49 +00:00
Add scrollToBottom
This commit is contained in:
parent
941e57a218
commit
e5d130b698
@ -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.
|
||||
|
||||
34
test/test.js
34
test/test.js
@ -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() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user