Added F and G

This commit is contained in:
Nathan Byrd 2023-09-20 21:40:59 +00:00
parent 372d84f572
commit f3c9afc684
1 changed files with 21 additions and 2 deletions

View File

@ -28,7 +28,7 @@ function ANSIEscapeParser(options) {
this.graphicRendition = {}; this.graphicRendition = {};
this.parseState = { this.parseState = {
re: /(?:\x1b)(?:(?:\x5b([?=;0-9]*?)([ABCDEfHJLmMsSTuUYZ]))|([78DEHM]))/g, // eslint-disable-line no-control-regex re: /(?:\x1b)(?:(?:\x5b([?=;0-9]*?)([ABCDEFGfHJLmMsSTuUYZ]))|([78DEHM]))/g, // eslint-disable-line no-control-regex
}; };
options = miscUtil.valueWithDefault(options, { options = miscUtil.valueWithDefault(options, {
@ -266,7 +266,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]))|([78DEHM]))/g, // eslint-disable-line no-control-regex re: /(?:\x1b)(?:(?:\x5b([?=;0-9]*?)([ABCDEFGfHJLmMsSTuUYZ]))|([78DEHM]))/g, // eslint-disable-line no-control-regex
stop: false, stop: false,
}; };
}; };
@ -425,6 +425,25 @@ function ANSIEscapeParser(options) {
} }
break; break;
// reverse line feed
case 'F':
arg = isNaN(args[0]) ? 1 : args[0];
if(this.row - arg < 1) {
this.emit('scroll', -(arg - this.row));
self.moveCursor(0, 1 - this.row);
}
else {
self.moveCursor(0, -arg);
}
break;
// absolute horizontal cursor position
case 'G':
arg = isNaN(args[0]) ? 1 : args[0];
self.column = Math.max(1, arg);
self.positionUpdated();
break;
case 'f': // horiz & vertical case 'f': // horiz & vertical
case 'H': // cursor position case 'H': // cursor position
//self.row = args[0] || 1; //self.row = args[0] || 1;