add escape function for tag text.

This commit is contained in:
Christopher Jeffrey 2014-04-26 05:57:37 -05:00
parent 737c88d7e5
commit 4bc910bd5b
3 changed files with 21 additions and 0 deletions

View File

@ -37,6 +37,11 @@ blessed.helpers = {
tryRead: blessed.tput.tryRead
};
Object.keys(widget.helpers).forEach(function(key) {
blessed.helpers[key] = widget.helpers[key];
blessed[key] = widget.helpers[key];
});
/**
* Expose
*/

View File

@ -6368,6 +6368,19 @@ var wideChars = new RegExp('(['
+ '\\uffe8-\\uffee'
+ '])', 'g');
/**
* Helpers
*/
var helpers = {};
// Escape text for tag-enabled elements.
helpers.escape = function(text) {
return text.replace(/[{}]/g, function(ch) {
return ch === '{' ? '{open}' : '{close}';
});
};
/**
* Expose
*/
@ -6400,3 +6413,5 @@ exports.Loading = exports.loading = Loading;
exports.Listbar = exports.listbar = Listbar;
exports.DirManager = exports.dirmanager = DirManager;
exports.Passbox = exports.passbox = Passbox;
exports.helpers = helpers;

View File

@ -15,6 +15,7 @@ var box = blessed.box({
wrap: false,
tags: true,
content: fs.readFileSync(__filename, 'utf8')
// content: '{red-bg}' + blessed.escape('{{{{{}{bold}x{/bold}}') + '{/red-bg}'
});
box.focus();