Added additional vt100 codes

This commit is contained in:
Nathan Byrd 2023-09-20 13:44:54 +00:00
parent 5712645299
commit 855fabe34d
1 changed files with 27 additions and 9 deletions

View File

@ -27,7 +27,7 @@ function ANSIEscapeParser(options) {
this.graphicRendition = {}; this.graphicRendition = {};
this.parseState = { this.parseState = {
re: /(?:\x1b)(\x5b?)([?=;0-9]*?)([ABCDEfHJLmMsSTuUYZ])/g, // eslint-disable-line no-control-regex re: /(?:\x1b)(\x5b?)([?=;0-9]*?)([78ABCDEfHJLmMsSTuUYZ])/g, // eslint-disable-line no-control-regex
}; };
options = miscUtil.valueWithDefault(options, { options = miscUtil.valueWithDefault(options, {
@ -257,7 +257,7 @@ function ANSIEscapeParser(options) {
self.parseState = { self.parseState = {
// ignore anything past EOF marker, if any // ignore anything past EOF marker, if any
buffer: input.split(String.fromCharCode(0x1a), 1)[0], buffer: input.split(String.fromCharCode(0x1a), 1)[0],
re: /(?:\x1b)(\x5b?)([?=;0-9]*?)([ABCDEfHJLmMsSTuUYZ])/g, // eslint-disable-line no-control-regex re: /(?:\x1b)(\x5b?)([?=;0-9]*?)([78ABCDEfHJLmMsSTuUYZ])/g, // eslint-disable-line no-control-regex
stop: false, stop: false,
}; };
}; };
@ -300,23 +300,41 @@ function ANSIEscapeParser(options) {
if(_.isNil(match[1])) { if(_.isNil(match[1])) {
// no bracket // no bracket
switch(opCode) { switch(opCode) {
// save cursor position
case '7':
escape('s', args);
break;
// restore cursor position
case '8':
escape('u', args);
break;
// scroll up // scroll up
case 'D': case 'D':
opCode = 'S'; escape('S', [1]);
args = [1]; break;
// move to next line
case 'E':
// functonality is the same as ESC [ E
escape(opCode, [1]);
break;
// create a tab at current cursor position
case 'H':
literal('\t');
break; break;
// scroll down // scroll down
case 'M': case 'M':
opCode = 'T'; escape('T', [1]);
args = [1];
break; break;
} }
} }
else {
escape(opCode, args);
}
escape(opCode, args);
//self.emit('chunk', match[0]);
self.emit('control', match[0], opCode, args); self.emit('control', match[0], opCode, args);
} }
} while (0 !== re.lastIndex); } while (0 !== re.lastIndex);