mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-06-06 04:37:12 +02:00
Revert "Fix word wrap crash reported by user when pipe codes are in play"
This reverts commit 0a486d290f
.
This commit is contained in:
parent
1261af00c3
commit
aecc24079f
2 changed files with 5 additions and 14 deletions
|
@ -218,6 +218,8 @@ function stringToNullTermBuffer(s, options = { encoding : 'utf8', maxBufLen : -1
|
|||
}
|
||||
|
||||
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');
|
||||
|
||||
//
|
||||
|
@ -273,23 +275,12 @@ function renderSubstr(str, start, length) {
|
|||
//
|
||||
// See also https://github.com/chalk/ansi-regex/blob/master/index.js
|
||||
//
|
||||
function renderStringLength(s, options = { pipe : true, ansi : true } ) {
|
||||
function renderStringLength(s) {
|
||||
let m;
|
||||
let pos;
|
||||
let len = 0;
|
||||
|
||||
let re;
|
||||
if(options.pipe && options.ansi) {
|
||||
re = ANSI_OR_PIPE_REGEXP;
|
||||
} else if(options.pipe) {
|
||||
re = PIPE_REGEXP;
|
||||
} else if(options.ansi) {
|
||||
re = ANSI.getFullMatchRegExp();
|
||||
} else {
|
||||
// no options - just return string length.
|
||||
return s.length;
|
||||
}
|
||||
|
||||
const re = ANSI_OR_PIPE_REGEXP;
|
||||
re.lastIndex = 0; // we recycle the rege; reset
|
||||
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue