Add support for stylizing quote indicators ( XX>)
This commit is contained in:
35
core/fse.js
35
core/fse.js
@@ -21,7 +21,10 @@ const {
|
||||
isAnsi, stripAnsiControlCodes,
|
||||
insert
|
||||
} = require('./string_util.js');
|
||||
const { stripMciColorCodes } = require('./color_codes.js');
|
||||
const {
|
||||
stripMciColorCodes,
|
||||
pipeToAnsi,
|
||||
} = require('./color_codes.js');
|
||||
const Config = require('./config.js').get;
|
||||
const { getAddressedToInfo } = require('./mail_util.js');
|
||||
const Events = require('./events.js');
|
||||
@@ -418,7 +421,7 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul
|
||||
//
|
||||
// Find tearline - we want to color it differently.
|
||||
//
|
||||
const tearLinePos = this.message.getTearLinePosition(msg);
|
||||
const tearLinePos = Message.getTearLinePosition(msg);
|
||||
|
||||
if(tearLinePos > -1) {
|
||||
msg = insert(msg, tearLinePos, bodyMessageView.getSGRFor('text'));
|
||||
@@ -432,7 +435,33 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul
|
||||
}
|
||||
);
|
||||
} else {
|
||||
bodyMessageView.setText(stripAnsiControlCodes(msg));
|
||||
msg = stripAnsiControlCodes(msg); // start clean
|
||||
|
||||
//
|
||||
// In *View* mode, if enabled, do a little prep work so we can stylize:
|
||||
// - Quote indicators
|
||||
// - Tear lines
|
||||
// - Origins
|
||||
//
|
||||
if (this.menuConfig.config.quoteStyleLevel1) {
|
||||
let quoteStyleLevel1 = this.menuConfig.config.quoteStyleLevel1;
|
||||
// can be a single style to cover XX> or an array to cover XX and >
|
||||
if (!Array.isArray(quoteStyleLevel1)) {
|
||||
quoteStyleLevel1 = [ quoteStyleLevel1 ];
|
||||
}
|
||||
if (quoteStyleLevel1.length < 2) {
|
||||
quoteStyleLevel1.push(quoteStyleLevel1);
|
||||
}
|
||||
|
||||
const QuoteRegex = /^ ([A-Za-z0-9]{1,2})>([ ]+)/gm;
|
||||
msg = msg.replace(QuoteRegex, (m, initials, spc) => {
|
||||
return pipeToAnsi(
|
||||
` ${quoteStyleLevel1[0]}${initials}${quoteStyleLevel1[1]}>${bodyMessageView.styleSGR1}${spc}`
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
bodyMessageView.setText(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -790,7 +790,7 @@ module.exports = class Message {
|
||||
return ftnUtil.getQuotePrefix(this[source]);
|
||||
}
|
||||
|
||||
getTearLinePosition(input) {
|
||||
static getTearLinePosition(input) {
|
||||
const m = input.match(/^--- .+$(?![\s\S]*^--- .+$)/m);
|
||||
return m ? m.index : -1;
|
||||
}
|
||||
@@ -886,12 +886,12 @@ module.exports = class Message {
|
||||
}
|
||||
);
|
||||
} else {
|
||||
const QUOTE_RE = /^ ((?:[A-Za-z0-9]{2}> )+(?:[A-Za-z0-9]{2}>)*) */;
|
||||
const QUOTE_RE = /^ ((?:[A-Za-z0-9]{1,2}> )+(?:[A-Za-z0-9]{1,2}>)*) */;
|
||||
const quoted = [];
|
||||
const input = _.trimEnd(this.message).replace(/\x08/g, ''); // eslint-disable-line no-control-regex
|
||||
|
||||
// find *last* tearline
|
||||
let tearLinePos = this.getTearLinePosition(input);
|
||||
let tearLinePos = Message.getTearLinePosition(input);
|
||||
tearLinePos = -1 === tearLinePos ? input.length : tearLinePos; // we just want the index or the entire string
|
||||
|
||||
input.slice(0, tearLinePos).split(/\r\n\r\n|\n\n/).forEach(paragraph => {
|
||||
@@ -910,7 +910,7 @@ module.exports = class Message {
|
||||
|
||||
if(quoted.length > 0) {
|
||||
//
|
||||
// Preserve paragraph seperation.
|
||||
// Preserve paragraph separation.
|
||||
//
|
||||
// FSC-0032 states something about leaving blank lines fully blank
|
||||
// (without a prefix) but it seems nicer (and more consistent with other systems)
|
||||
|
||||
@@ -265,11 +265,10 @@ function MultiLineEditTextView(options) {
|
||||
|
||||
this.getRenderText = function(index) {
|
||||
let text = self.getVisibleText(index);
|
||||
const remain = self.dimens.width - text.length;
|
||||
const remain = self.dimens.width - strUtil.renderStringLength(text);
|
||||
|
||||
if(remain > 0) {
|
||||
text += ' '.repeat(remain + 1);
|
||||
// text += new Array(remain + 1).join(' ');
|
||||
text += ' '.repeat(remain);// + 1);
|
||||
}
|
||||
|
||||
return text;
|
||||
|
||||
Reference in New Issue
Block a user