diff options
| author | timb <opuscule@gmail.com> | 2015-05-23 20:18:16 -0600 |
|---|---|---|
| committer | timb <opuscule@gmail.com> | 2015-05-23 20:18:16 -0600 |
| commit | 462b2ed2fa649be9cf345a2ead175979de0106a6 (patch) | |
| tree | f910ea689d57bf9be853a47aefbdab640d574f59 | |
| parent | 36591f5b1a70f562c8f581eb6731d5ddb7b50823 (diff) | |
keep lex css focus when building (eg try backspace in canvas or pressing up on brush size control)
| -rw-r--r-- | js/lex.js | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -11,14 +11,21 @@ function Lex (x,y) { this.bg = colors.black this.char = " " this.opacity = 1 + this.focused = false } Lex.prototype.build = function(){ this.span.className = this.css() this.span.innerHTML = this.html() } Lex.prototype.css = function(){ - if (this.opacity == 0) return "transparent f" + color_alphabet[mod(this.fg,16)] - return "f" + color_alphabet[mod(this.fg,16)] + "b" + color_alphabet[mod(this.bg,16)] + return ( + this.focused ? + "focused " : "" + ) + ( + this.opacity === 0 ? + "transparent f" + color_alphabet[mod(this.fg,16)] : + "f" + color_alphabet[mod(this.fg,16)] + "b" + color_alphabet[mod(this.bg,16)] + ) } Lex.prototype.html = function(){ return this.char == " " ? " " : this.char || " " @@ -107,10 +114,12 @@ Lex.prototype.isClear = function(){ Lex.prototype.focus = function(){ if (focused) focused.blur() this.span.classList.add('focused') + this.focused = true focused = this } Lex.prototype.blur = function(){ this.span.classList.remove('focused') + this.focused = false focused = null this.onBlur && this.onBlur() } |
