Minor updates to ansi parser

This commit is contained in:
Bryan Ashby 2016-04-28 23:05:01 -06:00
parent 1a689805b5
commit aadc7a347b
1 changed files with 8 additions and 21 deletions

View File

@ -1,22 +1,17 @@
/* jslint node: true */ /* jslint node: true */
'use strict'; 'use strict';
var miscUtil = require('./misc_util.js'); const miscUtil = require('./misc_util.js');
var ansi = require('./ansi_term.js'); const ansi = require('./ansi_term.js');
var events = require('events'); const events = require('events');
var util = require('util'); const util = require('util');
var _ = require('lodash'); const _ = require('lodash');
exports.ANSIEscapeParser = ANSIEscapeParser; exports.ANSIEscapeParser = ANSIEscapeParser;
var CR = 0x0d; const CR = 0x0d;
var LF = 0x0a; const LF = 0x0a;
//
// Resources, Specs, etc.
//
// * https://github.com/M-griffin/EtherTerm/blob/master/ansiParser.cpp
function ANSIEscapeParser(options) { function ANSIEscapeParser(options) {
var self = this; var self = this;
@ -44,14 +39,6 @@ function ANSIEscapeParser(options) {
this.termWidth = miscUtil.valueWithDefault(options.termWidth, 80); this.termWidth = miscUtil.valueWithDefault(options.termWidth, 80);
this.trailingLF = miscUtil.valueWithDefault(options.trailingLF, 'default'); this.trailingLF = miscUtil.valueWithDefault(options.trailingLF, 'default');
function getArgArray(array) {
var i = array.length;
while(i--) {
array[i] = parseInt(array[i], 10);
}
return array;
}
self.moveCursor = function(cols, rows) { self.moveCursor = function(cols, rows) {
self.column += cols; self.column += cols;
self.row += rows; self.row += rows;
@ -235,7 +222,7 @@ function ANSIEscapeParser(options) {
} }
opCode = match[2]; opCode = match[2];
args = getArgArray(match[1].split(';')); args = match[1].split(';').map(v => parseInt(v, 10)); // convert to array of ints
escape(opCode, args); escape(opCode, args);