Added scrolling.

This commit is contained in:
Nathan Byrd 2023-09-20 23:00:32 +00:00
parent f3c9afc684
commit 826db2d718
2 changed files with 20 additions and 0 deletions

View File

@ -86,6 +86,20 @@ function ANSIEscapeParser(options) {
}; };
self.positionUpdated = function () { self.positionUpdated = function () {
if(self.row > self.termHeight) {
if(this.savedPosition) {
this.savedPosition.row -= self.row - self.termHeight;
}
self.emit('scroll', self.row - self.termHeight);
self.row = self.termHeight;
}
else if(self.row < 1) {
if(this.savedPosition) {
this.savedPosition.row -= self.row - 1;
}
self.emit('scroll', -(self.row - 1));
self.row = 1;
}
self.emit('position update', self.row, self.column); self.emit('position update', self.row, self.column);
}; };

View File

@ -316,6 +316,12 @@ function display(client, art, options, cb) {
} }
}); });
ansiParser.on('scroll', (scrollY) => {
_.forEach(mciMap, (mciInfo) => {
mciInfo.position[0] -= scrollY;
});
});
ansiParser.on('literal', literal => client.term.write(literal, false)); ansiParser.on('literal', literal => client.term.write(literal, false));
ansiParser.on('control', control => client.term.rawWrite(control)); ansiParser.on('control', control => client.term.rawWrite(control));