1
0
Fork 0

property display:

- make interval and color configurable
- use bigger font
- display strings containing \n in one line
This commit is contained in:
mfranz 2008-05-14 12:04:54 +00:00
parent ee8b517246
commit af38cc7c63

View file

@ -35,9 +35,10 @@
# convert string for output; replaces tabs by spaces, and skips # convert string for output; replaces tabs by spaces, and skips
# delimiters and the voice part in "{text|voice}" constructions # delimiters and the voice part in "{text|voice}" constructions
# #
var sanitize = func(s) { var sanitize = func(s, newline = 0) {
var r = ""; var r = "";
var skip = 0; var skip = 0;
s ~= "";
for (var i = 0; i < size(s); i += 1) { for (var i = 0; i < size(s); i += 1) {
var c = s[i]; var c = s[i];
if (c == `\t`) if (c == `\t`)
@ -48,6 +49,8 @@ var sanitize = func(s) {
skip = 1; skip = 1;
elsif (c == `}`) elsif (c == `}`)
skip = 0; skip = 0;
elsif (c == `\n` and newline)
r ~= "\\n";
elsif (!skip) elsif (!skip)
r ~= chr(c); r ~= chr(c);
} }
@ -182,7 +185,9 @@ var property_display = {
}); });
me.window = window.new(x, y, lines, 0); me.window = window.new(x, y, lines, 0);
me.window.align = "left"; me.window.align = "left";
me.window.font = "HELVETICA_12"; me.window.font = "HELVETICA_14";
me.interval = 0.5;
me.color = [1, 1, 0.5, 1];
me.loopid = 0; me.loopid = 0;
me.reset(); me.reset();
}, },
@ -200,14 +205,15 @@ var property_display = {
foreach (var n; me.nodes) { foreach (var n; me.nodes) {
if ((val = n.getValue()) == nil) if ((val = n.getValue()) == nil)
val = "nil"; val = "nil";
append(me.window.lines, [n.getName() ~ " = " ~ val, 1, 1, 0.5, 1]); append(me.window.lines, [n.getName() ~ " = " ~ sanitize(val, 1),
me.color[0], me.color[1], me.color[2], me.color[3]]);
} }
me.window.show(); me.window.show();
}, },
_loop_ : func(id) { _loop_ : func(id) {
id != me.loopid and return; id != me.loopid and return;
me.update(); me.update();
settimer(func { me._loop_(id) }, 0.5); settimer(func { me._loop_(id) }, me.interval);
}, },
}; };