Added additional characters that change position

This commit is contained in:
Nathan Byrd 2023-09-19 01:39:04 +00:00
parent a99b55abb5
commit 5712645299
1 changed files with 25 additions and 0 deletions

View File

@ -12,8 +12,11 @@ const _ = require('lodash');
exports.ANSIEscapeParser = ANSIEscapeParser;
const TAB = 0x09;
const CR = 0x0d;
const LF = 0x0a;
const FF = 0x0c;
const BKSP = 0x08;
function ANSIEscapeParser(options) {
var self = this;
@ -96,6 +99,28 @@ function ANSIEscapeParser(options) {
charCode = text.charCodeAt(pos) & 0xff; // 8bit clean
switch (charCode) {
case TAB:
self.emit('literal', text.slice(start, pos + 1));
start = pos + 1;
self.column += 8 - ((self.column - 1) % 8);
self.positionUpdated();
break;
case BKSP:
self.emit('literal', text.slice(start, pos + 1));
start = pos + 1;
self.column = Math.max(1, self.column - 1);
self.positionUpdated();
break;
case FF:
self.emit('literal', text.slice(start, pos + 1));
start = pos + 1;
self.clearScreen();
break;
case CR:
self.emit('literal', text.slice(start, pos + 1));
start = pos + 1;