summaryrefslogtreecommitdiff
path: root/js/lex.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2014-11-22 18:03:48 -0500
committerJules Laplace <jules@okfoc.us>2014-11-22 18:03:48 -0500
commit8c544b08e8a855635007147cf21e795d74876025 (patch)
tree748622ba33cd618a718a9e7f171366edef92254a /js/lex.js
parentd14b3d777182602093364874ceeccae1d595e3a9 (diff)
fixing cursor focus shit
Diffstat (limited to 'js/lex.js')
-rw-r--r--js/lex.js43
1 files changed, 6 insertions, 37 deletions
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()
}