Minor cleanup related stuff

This commit is contained in:
Bryan Ashby 2017-09-01 17:42:47 -06:00
parent 3c40cb0766
commit de46c28305
4 changed files with 10 additions and 17 deletions

View File

@ -169,7 +169,7 @@ ClientTerminal.prototype.pipeWrite = function(s, spec, cb) {
var conv = { var conv = {
enigma : enigmaToAnsi, enigma : enigmaToAnsi,
renegade : renegadeToAnsi, renegade : renegadeToAnsi,
}[spec] || enigmaToAnsi; }[spec] || renegadeToAnsi;
this.write(conv(s, this), null, cb); // null = use default for |convertLineFeeds| this.write(conv(s, this), null, cb); // null = use default for |convertLineFeeds|
}; };

View File

@ -23,6 +23,8 @@ exports.pipeToAnsi = exports.renegadeToAnsi = renegadeToAnsi;
// * fromWWIV(): <ctrl-c><0-7> // * fromWWIV(): <ctrl-c><0-7>
// * fromSyncronet(): <ctrl-a><colorCode> // * fromSyncronet(): <ctrl-a><colorCode>
// See http://wiki.synchro.net/custom:colors // See http://wiki.synchro.net/custom:colors
// :TODO: rid of enigmaToAnsi() -- never really use. Instead, create bbsToAnsi() that supports renegade, PCB, WWIV, etc...
function enigmaToAnsi(s, client) { function enigmaToAnsi(s, client) {
if(-1 == s.indexOf('|')) { if(-1 == s.indexOf('|')) {
return s; // no pipe codes present return s; // no pipe codes present
@ -31,7 +33,7 @@ function enigmaToAnsi(s, client) {
var result = ''; var result = '';
var re = /\|([A-Z\d]{2}|\|)/g; var re = /\|([A-Z\d]{2}|\|)/g;
var m; var m;
var lastIndex = 0; var lastIndex = 0;
while((m = re.exec(s))) { while((m = re.exec(s))) {
var val = m[1]; var val = m[1];
@ -65,18 +67,18 @@ function enigmaToAnsi(s, client) {
} }
result += s.substr(lastIndex, m.index - lastIndex) + attr; result += s.substr(lastIndex, m.index - lastIndex) + attr;
} }
lastIndex = re.lastIndex; lastIndex = re.lastIndex;
} }
result = (0 === result.length ? s : result + s.substr(lastIndex)); result = (0 === result.length ? s : result + s.substr(lastIndex));
return result; return result;
} }
function stripEnigmaCodes(s) { function stripEnigmaCodes(s) {
return s.replace(/\|[A-Z\d]{2}/g, ''); return s.replace(/\|[A-Z\d]{2}/g, '');
} }
function enigmaStrLen(s) { function enigmaStrLen(s) {

View File

@ -63,7 +63,7 @@ const _ = require('lodash');
// * // *
var SPECIAL_KEY_MAP_DEFAULT = { const SPECIAL_KEY_MAP_DEFAULT = {
'line feed' : [ 'return' ], 'line feed' : [ 'return' ],
exit : [ 'esc' ], exit : [ 'esc' ],
backspace : [ 'backspace' ], backspace : [ 'backspace' ],
@ -503,10 +503,6 @@ function MultiLineEditTextView(options) {
return new Array(self.getRemainingTabWidth(col)).join(expandChar); return new Array(self.getRemainingTabWidth(col)).join(expandChar);
}; };
this.getStringLength = function(s) {
return self.isPreviewMode() ? colorCodes.enigmaStrLen(s) : s.length;
};
this.wordWrapSingleLine = function(s, tabHandling, width) { this.wordWrapSingleLine = function(s, tabHandling, width) {
if(!_.isNumber(width)) { if(!_.isNumber(width)) {
width = self.dimens.width; width = self.dimens.width;
@ -555,10 +551,6 @@ function MultiLineEditTextView(options) {
this.setAnsiWithOptions = function(ansi, options, cb) { this.setAnsiWithOptions = function(ansi, options, cb) {
function setLines(text) { function setLines(text) {
/*
self.setTextLines( strUtil.splitTextAtTerms(text), 0 );
self.cursorStartOfDocument();
*/
text = strUtil.splitTextAtTerms(text); text = strUtil.splitTextAtTerms(text);
let index = 0; let index = 0;

View File

@ -15,7 +15,6 @@ const pathWithTerminatingSeparator = require('../core/file_util.js').pathWithTe
const Log = require('../core/logger.js').log; const Log = require('../core/logger.js').log;
const Errors = require('../core/enig_error.js').Errors; const Errors = require('../core/enig_error.js').Errors;
const FileEntry = require('../core/file_entry.js'); const FileEntry = require('../core/file_entry.js');
const enigmaToAnsi = require('../core/color_codes.js').enigmaToAnsi;
// deps // deps
const async = require('async'); const async = require('async');