diff --git a/core/ansi_escape_parser.js b/core/ansi_escape_parser.js index 55dc9a82..974399c8 100644 --- a/core/ansi_escape_parser.js +++ b/core/ansi_escape_parser.js @@ -86,6 +86,20 @@ function ANSIEscapeParser(options) { }; 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); }; diff --git a/core/art.js b/core/art.js index 2145f5ad..f6c0c4d9 100644 --- a/core/art.js +++ b/core/art.js @@ -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('control', control => client.term.rawWrite(control));