+ dest = @x
+ while dest < @width - chars
+ @text[@y][dest] = @text[@y][dest + chars]
+ @attributes[@y][dest] = @attributes[@y][dest + chars]
+ dest += 1
+ # clear the space moved out of
+ x = @width - chars
+ while x < @width
+ @text[@y][x] = ' '
+ @attributes[@y][x] = @a
+ x += 1
+
+ # set modes not starting with "?"
+ csi_h: (args...) ->
+ for i in args
+ arg = @fix_esc_arg i, ''
+ switch arg
+ when '0' # error (ignored
+ return
+ when '2' # KAM -- keyboard action
+ return
+ when '4' # put cursor in "INSERT" mode
+ return
+ when '12' # turn local echo off (or on?)
+ return
+ # TODO when '20' LNM linefeed/newline
+ else
+ log "Unimplemented arg for csi_h: #{arg}"
+ # set modes starting with "?"
+ csiq_h: (args...) ->
+ for i in args
+ arg = @fix_esc_arg i, ''
+ switch arg
+ when '1' # mode ?1
+ # numlock on
+ return
+ when '25'
+ @cursor_visible = true
+ when '1000'
+ # x11 normal mouse tracking
+ return
+ when '1049'
+ if @saved_normal_screen?
+ log "ignoring request to switch to the alt screen because we're already on the alt screen"
+ return
+ @saved_normal_screen = x: @x, y: @y, text: @text, attributes: @attributes
+ @text = []
+ @attributes = []
+ for y in [0...@height]
+ @text[y] = []
+ @attributes[y] = []
+ for x in [0...@width]
+ @text[y].push ' '
+ @attributes[y].push 0x07
+ else
+ log "Unimplemented arg for csiq_h: #{arg}"
+ return
+
+ # reset (turn off) modes
+ # note that modes starting with ? call csiq_l, not this
+ csi_l: ->
+ for i in arguments
+ arg = @fix_esc_arg i, ''
+ switch arg
+ when '0' # error (ignored
+ return
+ when '2' # KAM -- keyboard action
+ return
+ when '4' # put cursor in "REPLACE" mode
+ return
+ when '12' # turn local echo on (or off?)
+ return
+ # TODO when '20' LNM linefeed/newline
+
+ # reset (turn off) modes starting with ?
+ # in st source, these are priv=true
+ csiq_l: ->
+ args = []
+ for i in arguments
+ arg = @fix_esc_arg i, ''
+ switch arg
+ when '1' # mode ?1 reset
+ # numlock off
+ return
+ when '12' # mode ?12
+ # stop blinking the cursor (ignored)
+ return
+ when '25' # mode ?25 reset
+ @cursor_visible = false
+ when '0', '2', '3', '4', '8', '18', '19', '42', '12'
+ # st ignores all of these
+ return
+ when '9', '1000', '1002', '1003', '1004', '1006'
+ # mouse reporting and such (ignored)
+ return
+ when '1049'
+ if not @saved_normal_screen?
+ log "ignoring request to switch to the normal screen because we're already on the normal screen"
+ return
+ @x = @saved_normal_screen.x
+ @y = @saved_normal_screen.y
+ @text = @saved_normal_screen.text
+ @attributes = @saved_normal_screen.attributes
+ @saved_normal_screen = null
+ else
+ log "Unimplemented arg for csiq_l: #{arg}"
+ return