changed handling of regex
This commit is contained in:
parent
855fabe34d
commit
8029521399
|
@ -27,7 +27,7 @@ function ANSIEscapeParser(options) {
|
||||||
this.graphicRendition = {};
|
this.graphicRendition = {};
|
||||||
|
|
||||||
this.parseState = {
|
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, {
|
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]*?)([78ABCDEfHJLmMsSTuUYZ])/g, // eslint-disable-line no-control-regex
|
re: /(?:\x1b)(?:(?:\x5b([?=;0-9]*?)([ABCDEfHJLmMsSTuUYZ]))|([78DEHM]))/g, // eslint-disable-line no-control-regex
|
||||||
stop: false,
|
stop: false,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -294,10 +294,13 @@ function ANSIEscapeParser(options) {
|
||||||
parseMCI(buffer.slice(pos, match.index));
|
parseMCI(buffer.slice(pos, match.index));
|
||||||
}
|
}
|
||||||
|
|
||||||
opCode = match[3];
|
opCode = match[2];
|
||||||
args = match[2].split(';').map(v => parseInt(v, 10)); // convert to array of ints
|
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
|
// no bracket
|
||||||
switch(opCode) {
|
switch(opCode) {
|
||||||
// save cursor position
|
// save cursor position
|
||||||
|
@ -311,13 +314,13 @@ function ANSIEscapeParser(options) {
|
||||||
|
|
||||||
// scroll up
|
// scroll up
|
||||||
case 'D':
|
case 'D':
|
||||||
escape('S', [1]);
|
escape('S', args);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// move to next line
|
// move to next line
|
||||||
case 'E':
|
case 'E':
|
||||||
// functonality is the same as ESC [ E
|
// functonality is the same as ESC [ E
|
||||||
escape(opCode, [1]);
|
escape(opCode, args);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// create a tab at current cursor position
|
// create a tab at current cursor position
|
||||||
|
@ -327,7 +330,7 @@ function ANSIEscapeParser(options) {
|
||||||
|
|
||||||
// scroll down
|
// scroll down
|
||||||
case 'M':
|
case 'M':
|
||||||
escape('T', [1]);
|
escape('T', args);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue