First commit of "advanced" MCI formatting via theme.hjson entries allowing mini-formatting langauge to apply

Example: {BN!styleFirstLower} in 'text' property
This commit is contained in:
Bryan Ashby
2022-10-05 21:46:13 -06:00
parent 1021226020
commit 065658f6b8
6 changed files with 38 additions and 57 deletions

View File

@@ -11,6 +11,9 @@ const renderSubstr = require('./string_util.js').renderSubstr;
const renderStringLength = require('./string_util.js').renderStringLength;
const pipeToAnsi = require('./color_codes.js').pipeToAnsi;
const stripAllLineFeeds = require('./string_util.js').stripAllLineFeeds;
const getPredefinedMCIFormatObject =
require('./predefined_mci').getPredefinedMCIFormatObject;
const stringFormat = require('./string_format');
// deps
const util = require('util');
@@ -153,6 +156,12 @@ TextView.prototype.setText = function (text, redraw) {
text = text.toString();
}
const formatObj = getPredefinedMCIFormatObject(this.client, text);
if (formatObj) {
// expand before converting
text = stringFormat(text, formatObj);
}
this.text = pipeToAnsi(stripAllLineFeeds(text), this.client); // expand MCI/etc.
if (this.maxLength > 0) {
this.text = renderSubstr(this.text, 0, this.maxLength);