Add support for tear line and origin line style

This commit is contained in:
Bryan Ashby 2020-12-28 17:04:11 -07:00
parent 4533dc3e01
commit d568cb993d
No known key found for this signature in database
GPG Key ID: B49EB437951D2542
3 changed files with 44 additions and 7 deletions

View File

@ -19,6 +19,7 @@ This document attempts to track **major** changes and additions in ENiGMA½. For
* Added ability to pass an `env` value (map) to `abracadabra` doors. See [Local Doors](./docs/modding/local-doors.md]). * 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`. * `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, the next for the '>' character, and finally the quoted text). 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. * 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, the next for the '>' character, and finally the quoted text). 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.
* FSE in *view* mode can now stylize tear lines and origin lines via `tearLineStyle` and `originStyle` `config` values in the same manor as `quoteStyleLevel`.
## 0.0.11-beta ## 0.0.11-beta
* Upgraded from `alpha` to `beta` -- The software is far along and mature enough at this point! * Upgraded from `alpha` to `beta` -- The software is far along and mature enough at this point!

View File

@ -544,6 +544,15 @@
"|00|08", "|00|08",
"|00|03", "|00|03",
] ]
tearLineStyle: [
"|00|08",
"|00|02",
]
originStyle: [
"|00|08",
"|00|06",
"|00|03",
]
} }
0: { 0: {

View File

@ -437,6 +437,16 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul
} else { } else {
msg = stripAnsiControlCodes(msg); // start clean msg = stripAnsiControlCodes(msg); // start clean
const styleToArray = (style, len) => {
if (!Array.isArray(style)) {
style = [ style ];
}
while (style.length < len) {
style.push(style);
}
return style;
};
// //
// In *View* mode, if enabled, do a little prep work so we can stylize: // In *View* mode, if enabled, do a little prep work so we can stylize:
// - Quote indicators // - Quote indicators
@ -444,14 +454,8 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul
// - Origins // - Origins
// //
if (this.menuConfig.config.quoteStyleLevel1) { if (this.menuConfig.config.quoteStyleLevel1) {
let styleL1 = this.menuConfig.config.quoteStyleLevel1;
// can be a single style to cover 'XX> TEXT' or an array to cover 'XX', '>', and TEXT // can be a single style to cover 'XX> TEXT' or an array to cover 'XX', '>', and TEXT
if (!Array.isArray(styleL1)) { const styleL1 = styleToArray(this.menuConfig.config.quoteStyleLevel1, 3);
styleL1 = [ styleL1 ];
}
while (styleL1.length < 3) {
styleL1.push(styleL1);
}
const QuoteRegex = /^ ([A-Za-z0-9]{1,2})>([ ]+)([^\r\n]*\r?\n)/gm; const QuoteRegex = /^ ([A-Za-z0-9]{1,2})>([ ]+)([^\r\n]*\r?\n)/gm;
msg = msg.replace(QuoteRegex, (m, initials, spc, text) => { msg = msg.replace(QuoteRegex, (m, initials, spc, text) => {
@ -461,6 +465,29 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul
}); });
} }
if (this.menuConfig.config.tearLineStyle) {
// '---' and TEXT
const style = styleToArray(this.menuConfig.config.tearLineStyle, 2);
const TearLineRegex = /^--- (.+)$(?![\s\S]*^--- .+$)/m;
msg = msg.replace(TearLineRegex, (m, text) => {
return pipeToAnsi(
`${style[0]}--- ${style[1]}${text}${bodyMessageView.styleSGR1}`
);
});
}
if (this.menuConfig.config.originStyle) {
const style = styleToArray(this.menuConfig.config.originStyle, 3);
const OriginRegex = /^([ ]{1,2})\* Origin: (.+)$/m;
msg = msg.replace(OriginRegex, (m, spc, text) => {
return pipeToAnsi(
`${spc}${style[0]}* ${style[1]}Origin: ${style[2]}${text}${bodyMessageView.styleSGR1}`
);
});
}
bodyMessageView.setText(msg); bodyMessageView.setText(msg);
} }
} }