summaryrefslogtreecommitdiff
path: root/js/matrix.js
diff options
context:
space:
mode:
authorJulie Lala <jules@okfoc.us>2014-11-29 19:02:35 -0500
committerJulie Lala <jules@okfoc.us>2014-11-29 19:02:35 -0500
commit698f2aa71ffc1b9e56193c13e6366765134152c9 (patch)
tree072b8e049870877f189135e3a2398387ae6f96fa /js/matrix.js
parent05d359b6cdabc42025881e0a39c00995d8a29394 (diff)
formalizing import/export stuff
Diffstat (limited to 'js/matrix.js')
-rw-r--r--js/matrix.js33
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)
}