X-Git-Url: https://jasonwoof.com/gitweb/?p=watch-my-terminal.git;a=blobdiff_plain;f=client.coffee;h=cf973f85a8f174be5ed6c2c2dceb2ff17c8314bb;hp=cb46305f357c13536d7125170ebda98cbd1c26c8;hb=39e9d94e9556527642a06b39b1d14e35c0533d23;hpb=e5cb729bf87ae7e8a3473a4527af609e49d61321 diff --git a/client.coffee b/client.coffee index cb46305..cf973f8 100644 --- a/client.coffee +++ b/client.coffee @@ -61,14 +61,20 @@ $ -> socket = io.connect('http://localhost') color_to_css = (i) -> - index = 0xff & i + # handle inverse bit + if i & 0x080000 + index = ((i >> 8) & 0xff) + else + index = (i & 0xff) + # lighten the basic 8 colors when they're bold if ((i & 0x10000) and index < 8) index += 8 return 'color: #' + palette[index] + '; ' bg_color_to_css = (i) -> - return 'background-' + color_to_css((i & 0x10000) | ((i & 0xff00) >> 8)) + # xor the inverse bit, to get color_to_css to use the bg color + return 'background-' + color_to_css(i ^ 0x080000) stylize = (txt, style) -> if (txt.length == 0 or style == 0x000007) @@ -77,9 +83,9 @@ $ -> css += 'font-weight: bold; ' if style & 0x10000 css += 'text-decoration: underline; ' if style & 0x20000 css += 'font-style: italic; ' if style & 0x40000 # blink - css += 'text-decoration: line-through; ' if style & 0x80000 # invisible - css += color_to_css(style) if style & 0x000ff - css += bg_color_to_css(style) if style & 0x0ff00 + css += 'text-decoration: line-through; ' if style & 0x100000 # invisible + css += color_to_css(style) if ((style & 0x0800ff) isnt 0x07) + css += bg_color_to_css(style) if (style & 0x08ff00) return $('').text(txt) redraw_wait = false