summaryrefslogtreecommitdiff
path: root/js/matrix.js
diff options
context:
space:
mode:
authorJules <jules@asdf.us>2014-11-30 16:54:12 -0500
committerJules <jules@asdf.us>2014-11-30 16:54:12 -0500
commitcea658bee03c9dc1843916ccd3c49bd67481e3b2 (patch)
treed75b7ca251b87f43422ae2f606071b98cff40458 /js/matrix.js
parentb25804afdf38918c9e205e9acda50bdbfe24cd12 (diff)
parent4f2f5dc5580359bba21150af3ce5d34ad14b3ab4 (diff)
Merge branch 'master' of ghghgh.us:ascii
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..81ced3e 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
}).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)
}