diff options
Diffstat (limited to 'js/ui')
| -rw-r--r-- | js/ui/brush.js | 26 | ||||
| -rw-r--r-- | js/ui/canvas.js | 3 | ||||
| -rw-r--r-- | js/ui/controls.js | 14 | ||||
| -rw-r--r-- | js/ui/keys.js | 7 | ||||
| -rw-r--r-- | js/ui/selection.js | 21 |
5 files changed, 48 insertions, 23 deletions
diff --git a/js/ui/brush.js b/js/ui/brush.js index a055a97..c7cf583 100644 --- a/js/ui/brush.js +++ b/js/ui/brush.js @@ -7,20 +7,6 @@ var brush = (function(){ }) brush.modified = false - - brush.bind = function(){ - brush.forEach(function(lex, x, y){ - if (lex.bound) return - lex.bound = true - - lex.span.addEventListener('mousedown', function(e){ - e.preventDefault() - dragging = true - // lex.fill(lex.fg, lex.bg) - }) - - }) - } brush.bind = function(){ @@ -70,6 +56,18 @@ var brush = (function(){ }) } + brush.expand = function(i){ + var w = this.w = clamp(this.w+i, 1, 9), h = this.h = clamp(this.h+i, 1, 9) + controls.width.char = ""+w + controls.width.build() + controls.height.char = ""+h + controls.height.build() + this.rebuild() + } + brush.contract = function(i){ + this.expand(-i) + } + brush.fg = 0 brush.bg = 1 diff --git a/js/ui/canvas.js b/js/ui/canvas.js index d354c62..e36f1b5 100644 --- a/js/ui/canvas.js +++ b/js/ui/canvas.js @@ -2,6 +2,7 @@ var canvas = current_canvas = (function(){ var cols = 80 var rows = 24 + var last_point = [0,0] var exports = new Matrix (cols, rows, function(x,y){ var lex = new Lex (x,y) @@ -11,8 +12,6 @@ var canvas = current_canvas = (function(){ exports.bind = function(){ - var last_point = [0,0] - exports.forEach(function(lex, x, y){ if (lex.bound) return diff --git a/js/ui/controls.js b/js/ui/controls.js index d575725..aadd3c9 100644 --- a/js/ui/controls.js +++ b/js/ui/controls.js @@ -154,9 +154,10 @@ var controls = (function(){ } controls.canvas_width.char = ""+n controls.canvas_width.build() - canvas.w = n - canvas.rebuild() - canvas.build() + canvas.resize(n, canvas.h) + // canvas.w = n + // canvas.rebuild() + // canvas.build() }) controls.canvas_height.key = int_key(function(n, keyCode){ controls.canvas_height.read() @@ -165,9 +166,10 @@ var controls = (function(){ } controls.canvas_height.char = ""+n controls.canvas_height.build() - canvas.h = n - canvas.rebuild() - canvas.build() + canvas.resize(canvas.w, n) + // canvas.h = n + // canvas.rebuild() + // canvas.build() }) } diff --git a/js/ui/keys.js b/js/ui/keys.js index 7711e9d..d1badf6 100644 --- a/js/ui/keys.js +++ b/js/ui/keys.js @@ -74,7 +74,12 @@ var keys = (function(){ if (focused && char) { var y = focused.y, x = focused.x focused.key(char, e.keyCode) - current_canvas.focusLex(y + direction[0], focused.x + direction[1]) + if (! ('y' in focused && 'x' in focused) ) { + return + } + console.log(focused) + console.log(y, direction[0], x, direction[1]) + current_canvas.focusLex(y + direction[0], x + direction[1]) } }) } diff --git a/js/ui/selection.js b/js/ui/selection.js new file mode 100644 index 0000000..cbeb051 --- /dev/null +++ b/js/ui/selection.js @@ -0,0 +1,21 @@ +var selection = (function(){ + + var selection = new Matrix (1, 1, function(x,y){ + var lex = new Lex (x,y) + lex.build() + return lex + }) + + // in selection mode.. + // - we start by clicking the canvas. this positions the selection, and copies + // the character + // - then we drag down and to the right. this resizes the selection and pushes new + // rows and columns. each of these copies the character underneath. + // - on mouseup, the selection is locked. then.. + // - drag the selection to move it -- this "cuts" it and leaves a blank space on the canvas. + // - shift-drag the selection to copy it + + + return selection + +})() |
