From 8c544b08e8a855635007147cf21e795d74876025 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sat, 22 Nov 2014 18:03:48 -0500 Subject: fixing cursor focus shit --- js/lex.js | 43 ++++++------------------------------------- 1 file changed, 6 insertions(+), 37 deletions(-) (limited to 'js/lex.js') diff --git a/js/lex.js b/js/lex.js index a35829f..56d8280 100644 --- a/js/lex.js +++ b/js/lex.js @@ -1,5 +1,3 @@ -direction = [1,0] - function Lex (x,y) { if (typeof x == "number") { this.y = y @@ -82,40 +80,11 @@ Lex.prototype.demolish = function(){ this.span.parentNode.removeChild(this.span) this.span = null } + + Lex.prototype.key = function(char, keyCode) { - console.log(keyCode, this.y, this.x) - switch (keyCode) { - case 8: - canvas.focusLex(this.y-1, this.x) - focused.char = " " - focused.build() - return - case 13: // return - canvas.focusLex(0, this.x+1) - return - case 38: // up - direction[0] = 0 - direction[1] = -1 - break - case 40: // down - direction[0] = 0 - direction[1] = 1 - break - case 37: // left - direction[0] = -1 - direction[1] = 0 - break - case 39: // right - direction[0] = 1 - direction[1] = 0 - break - default: - if (! char) { return } - this.char = char - this.fg = brush.bg - this.build() - this.blur() - break - } - canvas.focusLex(this.y + direction[0], this.x + direction[1]) + if (! char) { return } + this.char = char + this.fg = brush.bg + this.build() } -- cgit v1.2.3-70-g09d2