From f3c9afc684acdc564f76fe1b81dcc3d9b96d291e Mon Sep 17 00:00:00 2001 From: Nathan Byrd Date: Wed, 20 Sep 2023 21:40:59 +0000 Subject: [PATCH] Added F and G --- core/ansi_escape_parser.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/core/ansi_escape_parser.js b/core/ansi_escape_parser.js index 8cc4dbb6..55dc9a82 100644 --- a/core/ansi_escape_parser.js +++ b/core/ansi_escape_parser.js @@ -28,7 +28,7 @@ function ANSIEscapeParser(options) { this.graphicRendition = {}; 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, { @@ -266,7 +266,7 @@ function ANSIEscapeParser(options) { self.parseState = { // ignore anything past EOF marker, if any 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, }; }; @@ -425,6 +425,25 @@ function ANSIEscapeParser(options) { } 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 'H': // cursor position //self.row = args[0] || 1;