xxxxxxxxxx
38
const leftText = 'DREAM YOU LOST';
const rightText = 'TOSS ALL NIGHT';
const spacing = ' ';
let viewport = null;
let didScrollToTop = false;
function setup() {
noCanvas();
frameRate(30);
// set the term's scrollback to the largest possible size
// reference: https://github.com/xtermjs/xterm.js/issues/948
term.setOption('scrollback', 4294967295);
// this is hacky but couldn't figure out a better way to get the container's scrollHeight
viewport = document.getElementsByClassName('xterm-viewport')[0];
}
function draw() {
const leftOffset = int((term.cols - (leftText.length + rightText.length + spacing.length)) / 2);
term.write(ansi.cursor.horizontalAbsolute(leftOffset));
term.write(leftText);
term.write(spacing);
term.write(rightText);
term.write('\r\n\n\n\n');
if (frameCount % 2 === 0) {
term.scrollLines(1);
}
// begin "infinite" scrolling
if (viewport.scrollHeight > windowHeight && !didScrollToTop) {
term.scrollToTop();
didScrollToTop = true;
}
}