X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=client.coffee;h=282b7428bbf660124228a76db7c174875db772f2;hb=20b6a8c3e134b91c2eb0ed9b0cdeda6cd8efe111;hp=cf973f85a8f174be5ed6c2c2dceb2ff17c8314bb;hpb=39e9d94e9556527642a06b39b1d14e35c0533d23;p=watch-my-terminal.git diff --git a/client.coffee b/client.coffee index cf973f8..282b742 100644 --- a/client.coffee +++ b/client.coffee @@ -58,7 +58,7 @@ $ -> $body = $('body') $body.css backgroundColor: "##{palette[0]}", color: "##{palette[7]}" - socket = io.connect('http://localhost') + socket = io.connect('/') color_to_css = (i) -> # handle inverse bit @@ -77,13 +77,13 @@ $ -> return 'background-' + color_to_css(i ^ 0x080000) stylize = (txt, style) -> - if (txt.length == 0 or style == 0x000007) - return txt + return '' if txt.length is 0 + return $('').text txt if style is 0x000007 css = '' - 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 & 0x100000 # invisible + css += 'font-weight: bold; ' if style & 0x010000 + css += 'text-decoration: underline; ' if style & 0x020000 + css += 'font-style: italic; ' if style & 0x200000 # italic + css += 'opacity: 0; ' 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) @@ -92,6 +92,14 @@ $ -> redraw_again = false redraw_now = -> $body.children().remove() + # cursor can be just off the right side, but we draw it on the last column in that case + if term.x >= term.width + cursor_x = term.width - 1 + else + cursor_x = term.x + # invert the cursor TODO: make it blink + if term.cursor_visible + term.attributes[term.y][cursor_x] ^= 0x080000 for i in [0...term.text.length] div = $('
') txt = '' @@ -106,6 +114,8 @@ $ -> if txt.length div.append(stylize(txt, a)) $body.append(div) + if term.cursor_visible + term.attributes[term.y][cursor_x] ^= 0x080000 # limit to 50fps redraw = -> @@ -131,9 +141,4 @@ $ -> socket.on 'init', (v) -> term = terminal.new(v.width, v.height) - term.x = v.x - term.y = v.y - term.a = v.a - term.text = v.text - term.attributes = v.attributes - redraw() + update v.text