diff options
| author | timb <opuscule@gmail.com> | 2015-08-11 11:43:42 -0700 |
|---|---|---|
| committer | timb <opuscule@gmail.com> | 2015-08-11 11:43:42 -0700 |
| commit | 4f655ddbae201aecfac7965b91ae1d155d4a0594 (patch) | |
| tree | cb98dceaa349373bb89177f5618ba3ac76caa6b4 /js/matrix.js | |
| parent | 39091f9703c00bcadd369b1c710c75905ff47c2e (diff) | |
show warning when text output is cutoff, never cutoff output when making png
Diffstat (limited to 'js/matrix.js')
| -rw-r--r-- | js/matrix.js | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/js/matrix.js b/js/matrix.js index 6994327..4c8976c 100644 --- a/js/matrix.js +++ b/js/matrix.js @@ -231,10 +231,6 @@ Matrix.prototype.resize_rapper = function(){ // canvas_rapper.style.left = "auto" } } - - -// - Matrix.prototype.ascii = function () { var lines = this.aa.map(function(row, y){ var last, line = "" @@ -246,26 +242,37 @@ Matrix.prototype.ascii = function () { var txt = lines.join("\n") return txt } -Matrix.prototype.mirc = function () { +Matrix.prototype.mirc = function (opts) { + var cutoff = false var lines = this.aa.map(function(row, y){ var last, line = "" row.forEach(function(lex, x) { if (lex.eqColor(last)) { line += lex.sanitize() - } + } else { - // if (x > 0 && last) line += "\x03" line += lex.mirc() last = lex } }) - // if (last && ! last.isClear()) { line += "\x03" } - return line.substr(0,400) - }).filter(function(line){ return line.length > 0 }) - return lines.join("\n") + if (opts && opts.cutoff && line.length > opts.cutoff) { + cutoff = true + return line.substr(0, opts.cutoff) + } + return line + }) + + var txt = lines.filter(function(line){ return line.length > 0 }).join('\n') + + if (cutoff) { + txt = new String(txt) + txt.cutoff = true + } + return txt } -Matrix.prototype.irssi = function(){ - var txt = this.mirc() +Matrix.prototype.irssi = function(opts){ + var mirc = this.mirc(opts) + var txt = mirc // .replace(/\%/g, '%%') .replace(/\\/g, '\\x5C') .replace(/\"/g, '\\\"') @@ -278,9 +285,12 @@ Matrix.prototype.irssi = function(){ .replace(/\n/g, '\\n') .replace(/\x02/g, '\\x02') .replace(/\x03/g, '\\x03') - // console.log(txt.length) - - var escaped_txt = unicode.escapeToEscapedBytes(txt) - - return '/exec -out printf "%b" "' + escaped_txt + '"\n' + + txt = unicode.escapeToEscapedBytes(txt) + txt = '/exec -out printf "%b" "' + txt + '"\n' + if (mirc.cutoff){ + txt = new String(txt) + txt.cutoff = true + } + return txt } |
