var canvas = (function(){ var cols = 80 var rows = 24 var exports = new Matrix (cols, rows, function(x,y){ var lex = new Lex (x,y) // lex.build() return lex }) exports.bind = function(){ exports.forEach(function(lex, x, y){ if (lex.bound) return lex.bound = true lex.span.addEventListener('contextmenu', function(e){ e.preventDefault() }) lex.span.addEventListener('mousedown', function(e){ e.preventDefault() dragging = true if (drawing) { erasing = (e.which == "3" || e.ctrlKey) draw(lex, x, y, erasing) } lex.focus() }) lex.span.addEventListener("mousemove", function(){ if (! dragging) return if (drawing) { draw(lex, x, y, erasing) } lex.focus() }) }) } return exports })()