diff --git a/core/fse.js b/core/fse.js index 32a7bdb3..86170d10 100644 --- a/core/fse.js +++ b/core/fse.js @@ -14,6 +14,7 @@ const StatLog = require('./stat_log.js'); const stringFormat = require('./string_format.js'); const MessageAreaConfTempSwitcher = require('./mod_mixins.js').MessageAreaConfTempSwitcher; const { isAnsi, cleanControlCodes } = require('./string_util.js'); +const Config = require('./config.js').config; // deps const async = require('async'); @@ -324,7 +325,7 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul toUserName : headerValues.to, fromUserName : this.client.user.username, subject : headerValues.subject, - message : this.viewControllers.body.getFormData().value.message, + message : this.viewControllers.body.getFormData().value.message, }; if(this.isReply()) { @@ -333,9 +334,12 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul if(this.replyIsAnsi) { // // 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}`; } } @@ -363,8 +367,9 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul bodyMessageView.setAnsi( this.message.message.replace(/\r?\n/g, '\r\n'), // messages are stored with CRLF -> LF { - prepped : false, - forceLineTerm : true + prepped : false, + forceLineTerm : true, + preserveTextLines : this.message.replyToMsgId ? true : false, } ); } else { @@ -973,8 +978,7 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul var quoteLines = quoteMsgView.getData(); if(quoteLines.trim().length > 0) { - msgView.addText(quoteMsgView.getData() + '\n'); - + msgView.addText(quoteMsgView.getData() + '\n'); } quoteMsgView.setText(''); diff --git a/core/multi_line_edit_text_view.js b/core/multi_line_edit_text_view.js index 469ac4c9..d1cdebd2 100644 --- a/core/multi_line_edit_text_view.js +++ b/core/multi_line_edit_text_view.js @@ -511,12 +511,14 @@ function MultiLineEditTextView(options) { } return wordWrapText( - s, { + s, + { width : width, tabHandling : tabHandling || 'expand', tabWidth : self.tabWidth, tabChar : '\t', - }); + } + ); }; this.setTextLines = function(lines, index, termWithEol) { @@ -551,7 +553,31 @@ function MultiLineEditTextView(options) { this.setAnsiWithOptions = function(ansi, options, cb) { function setLines(text) { + /* 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(); if(cb) { @@ -566,12 +592,13 @@ function MultiLineEditTextView(options) { strUtil.prepAnsi( ansi, { - termWidth : this.client.termWidth, - termHeight : this.client.termHeight, - cols : this.dimens.width, - rows : 'auto', - startCol : this.position.col, - forceLineTerm : options.forceLineTerm, + termWidth : this.client.termWidth, + termHeight : this.client.termHeight, + cols : this.dimens.width, + rows : 'auto', + startCol : this.position.col, + forceLineTerm : options.forceLineTerm, + preserveTextLines : options.preserveTextLines, }, (err, preppedAnsi) => { return setLines(err ? ansi : preppedAnsi);