* Explicit encoding handling
* Word wrap with ANSI in FSE
This commit is contained in:
parent
b3ce44ae42
commit
2b83630431
12
core/fse.js
12
core/fse.js
|
@ -14,6 +14,7 @@ const StatLog = require('./stat_log.js');
|
||||||
const stringFormat = require('./string_format.js');
|
const stringFormat = require('./string_format.js');
|
||||||
const MessageAreaConfTempSwitcher = require('./mod_mixins.js').MessageAreaConfTempSwitcher;
|
const MessageAreaConfTempSwitcher = require('./mod_mixins.js').MessageAreaConfTempSwitcher;
|
||||||
const { isAnsi, cleanControlCodes } = require('./string_util.js');
|
const { isAnsi, cleanControlCodes } = require('./string_util.js');
|
||||||
|
const Config = require('./config.js').config;
|
||||||
|
|
||||||
// deps
|
// deps
|
||||||
const async = require('async');
|
const async = require('async');
|
||||||
|
@ -333,9 +334,12 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul
|
||||||
if(this.replyIsAnsi) {
|
if(this.replyIsAnsi) {
|
||||||
//
|
//
|
||||||
// Ensure first characters indicate ANSI for detection down
|
// Ensure first characters indicate ANSI for detection down
|
||||||
// the line (other boards/etc.)
|
// the line (other boards/etc.). We also set explicit_encoding
|
||||||
|
// to packetAnsiMsgEncoding (generally cp437) as various boards
|
||||||
|
// really don't like ANSI messages in UTF-8 encoding (they should!)
|
||||||
//
|
//
|
||||||
msgOpts.message = `${ansi.normal()}${msgOpts.message}`;
|
msgOpts.meta = { System : { 'explicit_encoding' : Config.scannerTossers.ftn_bso.packetAnsiMsgEncoding || 'cp437' } };
|
||||||
|
msgOpts.message = `${ansi.reset()}${ansi.eraseData(2)}${ansi.goto(1,1)}${msgOpts.message}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,7 +368,8 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul
|
||||||
this.message.message.replace(/\r?\n/g, '\r\n'), // messages are stored with CRLF -> LF
|
this.message.message.replace(/\r?\n/g, '\r\n'), // messages are stored with CRLF -> LF
|
||||||
{
|
{
|
||||||
prepped : false,
|
prepped : false,
|
||||||
forceLineTerm : true
|
forceLineTerm : true,
|
||||||
|
preserveTextLines : this.message.replyToMsgId ? true : false,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -974,7 +979,6 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul
|
||||||
|
|
||||||
if(quoteLines.trim().length > 0) {
|
if(quoteLines.trim().length > 0) {
|
||||||
msgView.addText(quoteMsgView.getData() + '\n');
|
msgView.addText(quoteMsgView.getData() + '\n');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
quoteMsgView.setText('');
|
quoteMsgView.setText('');
|
||||||
|
|
|
@ -511,12 +511,14 @@ function MultiLineEditTextView(options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return wordWrapText(
|
return wordWrapText(
|
||||||
s, {
|
s,
|
||||||
|
{
|
||||||
width : width,
|
width : width,
|
||||||
tabHandling : tabHandling || 'expand',
|
tabHandling : tabHandling || 'expand',
|
||||||
tabWidth : self.tabWidth,
|
tabWidth : self.tabWidth,
|
||||||
tabChar : '\t',
|
tabChar : '\t',
|
||||||
});
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setTextLines = function(lines, index, termWithEol) {
|
this.setTextLines = function(lines, index, termWithEol) {
|
||||||
|
@ -551,7 +553,31 @@ 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.setTextLines( strUtil.splitTextAtTerms(text), 0 );
|
||||||
|
self.cursorStartOfDocument();
|
||||||
|
*/
|
||||||
|
text = strUtil.splitTextAtTerms(text);
|
||||||
|
|
||||||
|
let index = 0;
|
||||||
|
let wrapped;
|
||||||
|
|
||||||
|
text.forEach(line => {
|
||||||
|
if(strUtil.isAnsiLine(line)) {
|
||||||
|
self.setTextLines( [ line ], index, true); // true=termWithEol
|
||||||
|
index += 1;
|
||||||
|
} else {
|
||||||
|
wrapped = self.wordWrapSingleLine(
|
||||||
|
line, // line to wrap
|
||||||
|
'expand', // tabHandling
|
||||||
|
self.dimens.width
|
||||||
|
).wrapped;
|
||||||
|
|
||||||
|
self.setTextLines(wrapped, index, true); // true=termWithEol
|
||||||
|
index += wrapped.length;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
self.cursorStartOfDocument();
|
self.cursorStartOfDocument();
|
||||||
|
|
||||||
if(cb) {
|
if(cb) {
|
||||||
|
@ -572,6 +598,7 @@ function MultiLineEditTextView(options) {
|
||||||
rows : 'auto',
|
rows : 'auto',
|
||||||
startCol : this.position.col,
|
startCol : this.position.col,
|
||||||
forceLineTerm : options.forceLineTerm,
|
forceLineTerm : options.forceLineTerm,
|
||||||
|
preserveTextLines : options.preserveTextLines,
|
||||||
},
|
},
|
||||||
(err, preppedAnsi) => {
|
(err, preppedAnsi) => {
|
||||||
return setLines(err ? ansi : preppedAnsi);
|
return setLines(err ? ansi : preppedAnsi);
|
||||||
|
|
Loading…
Reference in New Issue