summaryrefslogtreecommitdiff
path: root/js/matrix.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/matrix.js')
-rw-r--r--js/matrix.js46
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
}