summaryrefslogtreecommitdiff
path: root/js/ui/canvas.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/ui/canvas.js')
-rw-r--r--js/ui/canvas.js24
1 files changed, 13 insertions, 11 deletions
diff --git a/js/ui/canvas.js b/js/ui/canvas.js
index 4b595a5..206cbee 100644
--- a/js/ui/canvas.js
+++ b/js/ui/canvas.js
@@ -1,4 +1,4 @@
-var canvas = (function(){
+var canvas = current_canvas = (function(){
var cols = 80
var rows = 24
@@ -11,8 +11,6 @@ var canvas = (function(){
exports.bind = function(){
- var last_point = [0,0]
-
exports.forEach(function(lex, x, y){
if (lex.bound) return
@@ -26,19 +24,23 @@ var canvas = (function(){
dragging = true
current_canvas = canvas
if (drawing) {
- erasing = (e.which == "3" || e.ctrlKey)
- draw(lex, x, y, erasing)
- last_point[0] = x
- last_point[1] = y
+ draw.down(e, lex, point)
+ }
+ else if (selecting) {
+ selection.down(e, lex, point)
+ }
+ else if (filling) {
+ draw.fill(brush, x, y)
}
lex.focus()
})
- lex.span.addEventListener("mousemove", function(){
+ lex.span.addEventListener("mousemove", function(e){
if (! dragging) return
if (drawing) {
- line(lex, last_point, point, erasing)
- last_point[0] = x
- last_point[1] = y
+ draw.move(e, lex, point)
+ }
+ else if (selecting) {
+ selection.move(e, lex, point)
}
lex.focus()
})