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 */
'use strict';
var miscUtil = require('./misc_util.js');
var ansi = require('./ansi_term.js');
const miscUtil = require('./misc_util.js');
const ansi = require('./ansi_term.js');
var events = require('events');
var util = require('util');
var _ = require('lodash');
const events = require('events');
const util = require('util');
const _ = require('lodash');
exports.ANSIEscapeParser = ANSIEscapeParser;
var CR = 0x0d;
var LF = 0x0a;
//
// Resources, Specs, etc.
//
// * https://github.com/M-griffin/EtherTerm/blob/master/ansiParser.cpp
const CR = 0x0d;
const LF = 0x0a;
function ANSIEscapeParser(options) {
var self = this;
@ -44,14 +39,6 @@ function ANSIEscapeParser(options) {
this.termWidth = miscUtil.valueWithDefault(options.termWidth, 80);
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.column += cols;
self.row += rows;
@ -235,7 +222,7 @@ function ANSIEscapeParser(options) {
}
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);