From c0c262c971e2de7eb88382a9104b94c0d9460706 Mon Sep 17 00:00:00 2001 From: Nathan Byrd Date: Wed, 20 Sep 2023 23:30:01 +0000 Subject: [PATCH] Added insert and delete rows --- core/art.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/core/art.js b/core/art.js index f6c0c4d9..114800ee 100644 --- a/core/art.js +++ b/core/art.js @@ -322,6 +322,29 @@ function display(client, art, options, cb) { }); }); + ansiParser.on('insert line', (row, numLines) => { + _.forEach(mciMap, (mciInfo) => { + if (mciInfo.position[0] >= row) { + mciInfo.position[0] += numLines; + } + }); + }); + + ansiParser.on('delete line', (row, numLines) => { + _.forEach(mciMap, (mciInfo, mapKey) => { + if (mciInfo.position[0] >= row) { + if(mciInfo.position[0] < row + numLines) { + // unlike scrolling, the rows are actually gone, + // so we need to delete any MCI's that are in them + delete mciMap[mapKey]; + } + else { + mciInfo.position[0] -= numLines; + } + } + }); + }); + ansiParser.on('literal', literal => client.term.write(literal, false)); ansiParser.on('control', control => client.term.rawWrite(control));