diff options
Diffstat (limited to 'js/matrix.js')
| -rw-r--r-- | js/matrix.js | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/js/matrix.js b/js/matrix.js index 73c2992..4366eaa 100644 --- a/js/matrix.js +++ b/js/matrix.js @@ -86,20 +86,39 @@ Matrix.prototype.ascii = function () { var lines = this.aa.map(function(row, y){ var last, line = "" row.forEach(function(lex, x) { + line += lex.ascii() + }) + return line.replace(/\s+$/,"") + }) + var txt = lines.join("\n") + return txt +} +Matrix.prototype.mirc = function () { + var lines = this.aa.map(function(row, y){ + var last, line = "" + row.forEach(function(lex, x) { if (lex.eq(last)) { line += lex.sanitize() } else { - if (x > 0 && last && (last.bg != 1 || last.fg != 0)) line += "\\x03" - line += lex.irc() + if (x > 0 && last && (last.bg != 1 || last.fg != 0)) line += "\x03" + line += lex.mirc() last = lex } }) - if (last && ! last.isClear()) { line += "\\x03" } - return line.replace(/\s+$/,"").replace(/\"/g, '\\\"').replace(/\`/g, '\\\`') + if (last && ! last.isClear()) { line += "\x03" } + return line.replace(/\s+$/,"") }).filter(function(line){ return line.length > 0 }) - var txt = '/exec -out printf "' + lines.join("\\n") + '"\n' - return txt + return lines.join("\n") +} +Matrix.prototype.irssi = function(){ + var txt = this.mirc() + .replace(/\%/g, '%%') + .replace(/\"/g, '\\\"') + .replace(/\`/g, '\\\`') + .replace(/\\n/g, '\\n') + .replace(/\x03/g, '\\x03') + return '/exec -out printf "' + txt + '"\n' } Matrix.prototype.expand = function(i){ var w = this.w = clamp(this.w+i, 1, 9), h = this.h = clamp(this.h+i, 1, 9) @@ -111,5 +130,5 @@ Matrix.prototype.expand = function(i){ this.rebuild() } Matrix.prototype.contract = function(i){ - brush.expand(-i) + this .expand(-i) } |
