cleanControlCodes -> stripAnsiControlCodes

This commit is contained in:
Bryan Ashby 2018-12-17 22:08:59 -07:00
parent eeaeef9a8c
commit f4088303ca
4 changed files with 9 additions and 11 deletions

View File

@ -18,7 +18,7 @@ const {
MessageAreaConfTempSwitcher MessageAreaConfTempSwitcher
} = require('./mod_mixins.js'); } = require('./mod_mixins.js');
const { const {
isAnsi, cleanControlCodes, isAnsi, stripAnsiControlCodes,
insert insert
} = require('./string_util.js'); } = require('./string_util.js');
const Config = require('./config.js').get; const Config = require('./config.js').get;
@ -400,7 +400,7 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul
} }
); );
} else { } else {
bodyMessageView.setText(cleanControlCodes(msg)); bodyMessageView.setText(stripAnsiControlCodes(msg));
} }
} }
} }
@ -733,7 +733,7 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul
var bodyMessageView = self.viewControllers.body.getView(MciViewIds.body.message); var bodyMessageView = self.viewControllers.body.getView(MciViewIds.body.message);
if(bodyMessageView && _.has(self, 'message.message')) { if(bodyMessageView && _.has(self, 'message.message')) {
//self.setBodyMessageViewText(); //self.setBodyMessageViewText();
bodyMessageView.setText(cleanControlCodes(self.message.message)); bodyMessageView.setText(stripAnsiControlCodes(self.message.message));
} }
} }
break; break;

View File

@ -8,7 +8,7 @@ const Config = require('../../config.js').get;
const { const {
splitTextAtTerms, splitTextAtTerms,
isAnsi, isAnsi,
cleanControlCodes stripAnsiControlCodes
} = require('../../string_util.js'); } = require('../../string_util.js');
const { const {
getMessageConferenceByTag, getMessageConferenceByTag,
@ -218,7 +218,7 @@ exports.getModule = class GopherModule extends ServerModule {
); );
} else { } else {
const cleaned = stripMciColorCodes( const cleaned = stripMciColorCodes(
cleanControlCodes(body, { all : true } ) stripAnsiControlCodes(body, { all : true } )
); );
const prepped = const prepped =
splitTextAtTerms(cleaned) splitTextAtTerms(cleaned)

View File

@ -16,7 +16,7 @@ const Message = require('../../message.js');
const FTNAddress = require('../../ftn_address.js'); const FTNAddress = require('../../ftn_address.js');
const { const {
isAnsi, isAnsi,
cleanControlCodes, stripAnsiControlCodes,
splitTextAtTerms, splitTextAtTerms,
} = require('../../string_util.js'); } = require('../../string_util.js');
const AnsiPrep = require('../../ansi_prep.js'); const AnsiPrep = require('../../ansi_prep.js');
@ -655,7 +655,7 @@ class NNTPServer extends NNTPServerBase {
} }
); );
} else { } else {
message.preparedBody = stripMciColorCodes(cleanControlCodes(message.message, { all : true })); message.preparedBody = stripMciColorCodes(stripAnsiControlCodes(message.message, { all : true }));
return cb(null); return cb(null);
} }
} }

View File

@ -23,7 +23,7 @@ exports.formatByteSizeAbbr = formatByteSizeAbbr;
exports.formatByteSize = formatByteSize; exports.formatByteSize = formatByteSize;
exports.formatCountAbbr = formatCountAbbr; exports.formatCountAbbr = formatCountAbbr;
exports.formatCount = formatCount; exports.formatCount = formatCount;
exports.cleanControlCodes = cleanControlCodes; exports.stripAnsiControlCodes = stripAnsiControlCodes;
exports.isAnsi = isAnsi; exports.isAnsi = isAnsi;
exports.isAnsiLine = isAnsiLine; exports.isAnsiLine = isAnsiLine;
exports.isFormattedLine = isFormattedLine; exports.isFormattedLine = isFormattedLine;
@ -218,8 +218,6 @@ function stringToNullTermBuffer(s, options = { encoding : 'utf8', maxBufLen : -1
} }
const PIPE_REGEXP = /(\|[A-Z\d]{2})/g; const PIPE_REGEXP = /(\|[A-Z\d]{2})/g;
//const ANSI_REGEXP = /[\u001b\u009b][[()#;?]*([0-9]{1,4}(?:;[0-9]{0,4})*)?([0-9A-ORZcf-npqrsuy=><])/g;
//const ANSI_OR_PIPE_REGEXP = new RegExp(PIPE_REGEXP.source + '|' + ANSI_REGEXP.source, 'g');
const ANSI_OR_PIPE_REGEXP = new RegExp(PIPE_REGEXP.source + '|' + ANSI.getFullMatchRegExp().source, 'g'); const ANSI_OR_PIPE_REGEXP = new RegExp(PIPE_REGEXP.source + '|' + ANSI.getFullMatchRegExp().source, 'g');
// //
@ -357,7 +355,7 @@ const ANSI_OPCODES_ALLOWED_CLEAN = [
'm', // color 'm', // color
]; ];
function cleanControlCodes(input, options) { function stripAnsiControlCodes(input, options) {
let m; let m;
let pos; let pos;
let cleaned = ''; let cleaned = '';