JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
add csi_L (scroll backwards)
authorJason Woofenden <jason@jasonwoof.com>
Thu, 31 Jan 2013 23:51:45 +0000 (18:51 -0500)
committerJason Woofenden <jason@jasonwoof.com>
Thu, 31 Jan 2013 23:51:45 +0000 (18:51 -0500)
terminal.coffee

index 721ed80..4aa522c 100644 (file)
@@ -233,6 +233,30 @@ class Terminal
                                console.log "confusing arg for csi_K: #{direction}"
                return
        
+       # move lines downwards (arg is how far)
+       csi_L: (lines) ->
+               lines = parseInt @fix_esc_arg lines, '1'
+
+               # move (newly cleared) top line to the bottom of the scrolling region
+               @text = [
+                       @text[0...@y]..., # keep everything above cursor
+                       @text[@scroll_bottom - lines + 1 .. @scroll_bottom]..., # we'll clear these shortly
+                       @text[@y..@scroll_bottom - lines]..., # lines that are moving down
+                       @text[@scroll_bottom + 1 ... @height]... # rest of screen
+               ]
+               @attributes = [
+                       @attributes[0...@y]..., # keep everything above cursor
+                       @attributes[@scroll_bottom - lines + 1 .. @scroll_bottom]..., # we'll clear these shortly
+                       @attributes[@y..@scroll_bottom - lines]..., # lines that are moving down
+                       @attributes[@scroll_bottom + 1 ... @height]... # rest of screen
+               ]
+
+               # clear the lines we scrolled off (and put back in as "new")
+               for y in [@y...@y+lines]
+                       for x in [0...@width]
+                               @text[y][x] = ' '
+                               @attributes[y][x] = 0x07
+
        # misc
        csiq_h: ->
                args = []