diff --git a/core/ansi_escape_parser.js b/core/ansi_escape_parser.js index 542e11d5..7f60c438 100644 --- a/core/ansi_escape_parser.js +++ b/core/ansi_escape_parser.js @@ -27,7 +27,7 @@ function ANSIEscapeParser(options) { this.graphicRendition = {}; this.parseState = { - re: /(?:\x1b)(\x5b?)([?=;0-9]*?)([78ABCDEfHJLmMsSTuUYZ])/g, // eslint-disable-line no-control-regex + re: /(?:\x1b)(?:(?:\x5b([?=;0-9]*?)([ABCDEfHJLmMsSTuUYZ]))|([78DEHM]))/g, // eslint-disable-line no-control-regex }; options = miscUtil.valueWithDefault(options, { @@ -257,7 +257,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]*?)([78ABCDEfHJLmMsSTuUYZ])/g, // eslint-disable-line no-control-regex + re: /(?:\x1b)(?:(?:\x5b([?=;0-9]*?)([ABCDEfHJLmMsSTuUYZ]))|([78DEHM]))/g, // eslint-disable-line no-control-regex stop: false, }; }; @@ -294,10 +294,13 @@ function ANSIEscapeParser(options) { parseMCI(buffer.slice(pos, match.index)); } - opCode = match[3]; - args = match[2].split(';').map(v => parseInt(v, 10)); // convert to array of ints + opCode = match[2]; + args = match[1].split(';').map(v => parseInt(v, 10)); // convert to array of ints - if(_.isNil(match[1])) { + // Handle the case where there is no bracket + if(!(_.isNil(match[3]))) { + opCode = match[3]; + args = []; // no bracket switch(opCode) { // save cursor position @@ -311,13 +314,13 @@ function ANSIEscapeParser(options) { // scroll up case 'D': - escape('S', [1]); + escape('S', args); break; // move to next line case 'E': // functonality is the same as ESC [ E - escape(opCode, [1]); + escape(opCode, args); break; // create a tab at current cursor position @@ -327,7 +330,7 @@ function ANSIEscapeParser(options) { // scroll down case 'M': - escape('T', [1]); + escape('T', args); break; } }