From 4dd8460f6a45d7956455ef9b39b33126c1b40e15 Mon Sep 17 00:00:00 2001 From: Julie Lala Date: Wed, 3 Dec 2014 22:02:34 -0500 Subject: fix arrows and printing backslashes --- js/app.js | 8 ++++---- js/lex.js | 3 +++ js/matrix.js | 26 +++++++++++++++++++++++--- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/js/app.js b/js/app.js index bebfec2..f42507a 100644 --- a/js/app.js +++ b/js/app.js @@ -77,19 +77,19 @@ function bind () { return case 38: // up e.preventDefault() - current_canvas.focusLex(focused.y + direction[0], focused.x + direction[1]) + current_canvas.focusLex(focused.y - 1, focused.x + 0) break case 40: // down e.preventDefault() - current_canvas.focusLex(focused.y + direction[0], focused.x + direction[1]) + current_canvas.focusLex(focused.y + 1, focused.x + 0) break case 37: // left e.preventDefault() - current_canvas.focusLex(focused.y + direction[0], focused.x + direction[1]) + current_canvas.focusLex(focused.y + 0, focused.x - 1) break case 39: // right e.preventDefault() - current_canvas.focusLex(focused.y + direction[0], focused.x + direction[1]) + current_canvas.focusLex(focused.y + 0, focused.x + 1) break // default: // if (focused) { focused.key(undefined, e.keyCode) } diff --git a/js/lex.js b/js/lex.js index e6f1f67..1dc07a0 100644 --- a/js/lex.js +++ b/js/lex.js @@ -34,6 +34,9 @@ Lex.prototype.sanitize = function(){ var fgOnly = false Lex.prototype.mirc = function(){ var char = this.char || " " + if (parseInt(char)) { + char = "\x02\x02" + char + } if (fgOnly) { return "\x03" + (this.fg&15) + char } diff --git a/js/matrix.js b/js/matrix.js index 98c132d..9809865 100644 --- a/js/matrix.js +++ b/js/matrix.js @@ -122,7 +122,7 @@ Matrix.prototype.mirc = function () { Matrix.prototype.irssi = function(){ var txt = this.mirc() .replace(/\%/g, '%%') - .replace(/\\/g, '\\\\') + .replace(/\\/g, '\\x5C') .replace(/\"/g, '\\\"') .replace(/\'/g, '\\\'') .replace(/\`/g, '\\\`') @@ -130,9 +130,29 @@ Matrix.prototype.irssi = function(){ .replace(/\s+$/g, '\n') .replace(/^\n+/, '') .replace(/\n/g, '\\n') - .replace(/\x03/g, '\\x03'); + .replace(/\x02/g, '\\x02') + .replace(/\x03/g, '\\x03') +console.log(txt.length) + var escaped_txt = "", kode + for (var i = 0; i < txt.length; i++) { + kode = txt.charCodeAt(i) + if (kode > 0x7f) { + kode = kode.toString(16) + switch (kode.length) { + case 2: + kode = "0" + kode + case 3: + kode = "0" + kode + } + escaped_txt += "\\u" + kode + } + else { + escaped_txt += txt[i] + } + } + // .replace(/\x03/g, '\\x03'); // console.log(txt) - return '/exec -out printf "' + txt + '"\n' + return '/exec -out printf "' + escaped_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) -- cgit v1.2.3-70-g09d2