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 = $('<div>')
txt = ''
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 = ->
term.a = v.a
term.text = v.text
term.attributes = v.attributes
+ term.cursor_visible = v.cursor_visible
redraw()
sockets.splice i, 1
return
- socket.emit 'init', width: term.width, height: term.height, x: term.x, y: term.y, a: term.a, text: term.text, attributes: term.attributes
+ socket.emit 'init', width: term.width, height: term.height, x: term.x, y: term.y, a: term.a, text: term.text, attributes: term.attributes, cursor_visible: term.cursor_visible
process.stdin.resume()
process.stdin.setEncoding 'utf8'
@a = 0x000007 # cursor attributes
@partial = ''
@saved_normal_screen = null
+ @cursor_visible = true
@resize width, height
resize: (width, height) ->
@attributes[y] = []
for x in [0...width]
@text[y].push ' '
- @attributes[y].push 0
+ @attributes[y].push 0x07
# pass data from stdout
update: (data) ->
# clear top line
for i in [0...@width]
@text[0][i] = ' '
- @attributes[0][i] = 0
+ @attributes[0][i] = 0x07
# move (newly cleared) top line to the bottom
tmp = @text.shift()
@text.push(tmp)
for i in arguments
arg = @fix_esc_arg i, ''
switch arg
+ when '25'
+ @cursor_visible = true
when '1049'
if @saved_normal_screen?
console.log "ignoring request to switch to the alt screen because we're already on the alt screen"
@attributes[y] = []
for x in [0...@width]
@text[y].push ' '
- @attributes[y].push 0
+ @attributes[y].push 0x07
else
console.log "confusing arg for csiq_h: #{arg}"
# unmisc
for i in arguments
arg = @fix_esc_arg i, ''
switch arg
+ when '25'
+ @cursor_visible = false
when '1049'
if not @saved_normal_screen?
console.log "ignoring request to switch to the normal screen because we're already on the normal screen"