diff --git a/assets/js/ui/brush.js b/assets/js/ui/brush.js
index 668538f..6ea07ed 100644
--- a/assets/js/ui/brush.js
+++ b/assets/js/ui/brush.js
@@ -106,3 +106,33 @@ var brush = (function(){
return brush
})()
+
+var custom = (function(){
+
+ var exports = {}
+
+ exports.clone = function (){
+ var new_brush = brush.clone()
+ var rapper = document.createElement("div")
+ rapper.className = "custom"
+ new_brush.append(rapper)
+ custom_rapper.appendChild(rapper)
+ // store in localstorage?
+ rapper.addEventListener("click", function(e){
+ if (e.shiftKey) {
+ rapper.parentNode.removeChild(rapper)
+ delete new_brush
+ } else {
+ // load this brush
+ exports.load(new_brush)
+ }
+ })
+ }
+
+ exports.load = function(new_brush){
+ brush.assign( new_brush )
+ }
+
+ return exports
+
+})()
diff --git a/assets/js/ui/custom.js b/assets/js/ui/custom.js
deleted file mode 100644
index c021679..0000000
--- a/assets/js/ui/custom.js
+++ /dev/null
@@ -1,29 +0,0 @@
-var custom = (function(){
-
- var exports = {}
-
- exports.clone = function (){
- var new_brush = brush.clone()
- var rapper = document.createElement("div")
- rapper.className = "custom"
- new_brush.append(rapper)
- custom_rapper.appendChild(rapper)
- // store in localstorage?
- rapper.addEventListener("click", function(e){
- if (e.shiftKey) {
- rapper.parentNode.removeChild(rapper)
- delete new_brush
- } else {
- // load this brush
- exports.load(new_brush)
- }
- })
- }
-
- exports.load = function(new_brush){
- brush.assign( new_brush )
- }
-
- return exports
-
-})()
diff --git a/assets/js/ui/letters.js b/assets/js/ui/letters.js
deleted file mode 100644
index d745171..0000000
--- a/assets/js/ui/letters.js
+++ /dev/null
@@ -1,89 +0,0 @@
-var letters = (function(){
-
- var last_charset = ""
- var charset_index = 0
- var charsets = [
- 'Basic Latin',
- 'Latin-1 Supplement',
- 'Box Drawing',
- 'Block Elements',
- ]
-
- var letters = new Matrix (1, 1, function(x,y){
- var lex = new Lex (x,y)
- return lex
- })
-
- letters.charset = ""
-
- letters.repaint = function(charset){
- letters.charset = charset = charset || last_charset
- last_charset = charset
- var chars = unicode.block(charset, 32)
- if (chars[0] != " ") chars.unshift(" ")
- if (canvas.vertical) {
- letters.resize( Math.ceil( chars.length / 16 ), 16 )
- }
- else {
- letters.resize( 32, Math.ceil( chars.length / 32 ) )
- }
-
- var i = 0
-
- letters.forEach(function(lex,x,y){
- if (canvas.vertical) { x=x^y;y=x^y;x=x^y }
- var char = chars[i++]
- if (palette.chars.indexOf(brush.char) > 1) {
- lex.bg = brush.fg
- lex.fg = brush.bg
- }
- else {
- lex.bg = colors.black
- lex.fg = brush.fg == fillColor ? colors.black : brush.fg
- }
- lex.char = char
- lex.opacity = 1
- lex.build()
- })
- }
-
- letters.bind = function(){
- letters.forEach(function(lex,x,y){
- if (lex.bound) return
- lex.bound = true
-
- lex.span.addEventListener('mousedown', function(e){
- e.preventDefault()
- if (e.shiftKey) {
- charset_index = (charset_index+1) % charsets.length
- letters.repaint(charsets[charset_index])
- return
- }
- else if (e.ctrlKey || e.which == 3) {
- brush.char = lex.char
- brush.bg = brush.fg
- brush.fg = fillColor
- }
- else {
- brush.char = lex.char
- if (lex.char == " ") {
- brush.bg = brush.fg
- }
- else if (brush.bg != fillColor) {
- brush.fg = brush.bg
- brush.bg = fillColor
- }
- }
- if (! brush.modified) {
- brush.generate()
- }
- palette.repaint()
- })
- lex.span.addEventListener('contextmenu', function(e){
- e.preventDefault()
- })
- })
- }
-
- return letters
-})()
\ No newline at end of file
diff --git a/assets/js/ui/palette.js b/assets/js/ui/paletters.js
similarity index 58%
rename from assets/js/ui/palette.js
rename to assets/js/ui/paletters.js
index 46045eb..09a733f 100644
--- a/assets/js/ui/palette.js
+++ b/assets/js/ui/paletters.js
@@ -1,3 +1,93 @@
+var letters = (function(){
+
+ var last_charset = ""
+ var charset_index = 0
+ var charsets = [
+ 'Basic Latin',
+ 'Latin-1 Supplement',
+ 'Box Drawing',
+ 'Block Elements',
+ ]
+
+ var letters = new Matrix (1, 1, function(x,y){
+ var lex = new Lex (x,y)
+ return lex
+ })
+
+ letters.charset = ""
+
+ letters.repaint = function(charset){
+ letters.charset = charset = charset || last_charset
+ last_charset = charset
+ var chars = unicode.block(charset, 32)
+ if (chars[0] != " ") chars.unshift(" ")
+ if (canvas.vertical) {
+ letters.resize( Math.ceil( chars.length / 16 ), 16 )
+ }
+ else {
+ letters.resize( 32, Math.ceil( chars.length / 32 ) )
+ }
+
+ var i = 0
+
+ letters.forEach(function(lex,x,y){
+ if (canvas.vertical) { x=x^y;y=x^y;x=x^y }
+ var char = chars[i++]
+ if (palette.chars.indexOf(brush.char) > 1) {
+ lex.bg = brush.fg
+ lex.fg = brush.bg
+ }
+ else {
+ lex.bg = colors.black
+ lex.fg = brush.fg == fillColor ? colors.black : brush.fg
+ }
+ lex.char = char
+ lex.opacity = 1
+ lex.build()
+ })
+ }
+
+ letters.bind = function(){
+ letters.forEach(function(lex,x,y){
+ if (lex.bound) return
+ lex.bound = true
+
+ lex.span.addEventListener('mousedown', function(e){
+ e.preventDefault()
+ if (e.shiftKey) {
+ charset_index = (charset_index+1) % charsets.length
+ letters.repaint(charsets[charset_index])
+ return
+ }
+ else if (e.ctrlKey || e.which == 3) {
+ brush.char = lex.char
+ brush.bg = brush.fg
+ brush.fg = fillColor
+ }
+ else {
+ brush.char = lex.char
+ if (lex.char == " ") {
+ brush.bg = brush.fg
+ }
+ else if (brush.bg != fillColor) {
+ brush.fg = brush.bg
+ brush.bg = fillColor
+ }
+ }
+ if (! brush.modified) {
+ brush.generate()
+ }
+ palette.repaint()
+ })
+ lex.span.addEventListener('contextmenu', function(e){
+ e.preventDefault()
+ })
+ })
+ }
+
+ return letters
+})()
+
var palette = (function(){
var palette = new Matrix (32, 2, function(x,y){
diff --git a/index.html b/index.html
index 6fcb175..ebdebf8 100644
--- a/index.html
+++ b/index.html
@@ -99,11 +99,9 @@
-
-
-
+