Add support for stylizing quote indicators ( XX>)

This commit is contained in:
Bryan Ashby 2020-12-26 15:08:37 -07:00
parent f202600571
commit 94d4a52530
No known key found for this signature in database
GPG Key ID: B49EB437951D2542
5 changed files with 46 additions and 10 deletions

View File

@ -18,6 +18,7 @@ This document attempts to track **major** changes and additions in ENiGMA½. For
* Default hash tags can now be set in file areas. Simply supply an array or list of values in a file area block via `hashTags`.
* Added ability to pass an `env` value (map) to `abracadabra` doors. See [Local Doors](./docs/modding/local-doors.md]).
* `dropFileType` is now optional when launching doors with `abracadabra`. It can also be explicitly set to `none`.
* FSE in *view* mode can now stylize quote indicators. Supply `quoteStyleLevel1` in the `config` block. This can be a single string or an array of two strings (one to style the quotee's initials and the next for the '>' character). See the `messageAreaViewPost` menu `config` block in the default `luciano_blocktronics` `theme.hjson` file for an example. An additional level style (e.g. for nested quotes) may be added in the future.
## 0.0.11-beta
* Upgraded from `alpha` to `beta` -- The software is far along and mature enough at this point!

View File

@ -538,6 +538,13 @@
// The 'msg_list' module looks for this entry by default
messageAreaViewPost: {
config: {
quoteStyleLevel1: [
"|00|11",
"|00|08",
]
}
0: {
mci: {
TL1: {

View File

@ -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);
}
}
}

View File

@ -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)

View File

@ -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;