JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
add csi_J, fix csi_K(2)
authorJason Woofenden <jason@jasonwoof.com>
Thu, 31 Jan 2013 03:44:13 +0000 (22:44 -0500)
committerJason Woofenden <jason@jasonwoof.com>
Thu, 31 Jan 2013 03:44:13 +0000 (22:44 -0500)
terminal.coffee

index 11c79e0..f3ed817 100644 (file)
@@ -125,6 +125,27 @@ class Terminal
                else
                        console.log "tried to move cursor to invalid row: #{row}"
 
+       # clear lines (implemented inclusive of the current line)
+       csi_J: (direction) ->
+               switch @fix_esc_arg direction, '0'
+                       when '0' # erase down
+                               for row in [@y...@height]
+                                       for i in [0...@width]
+                                               @text[row][i] = ' '
+                                               @attributes[row][i] = @a
+                       when '1' # erase up
+                               for row in [0..@y]
+                                       for i in [0...@width]
+                                               @text[row][i] = ' '
+                                               @attributes[row][i] = @a
+                       when '2' # erase everything
+                               for row in [0...@height]
+                                       for i in [0...@width]
+                                               @text[row][i] = ' '
+                                               @attributes[row][i] = @a
+                       else
+                               console.log "confusing arg for csi_J: #{direction}"
+
        # clear (some or all of) current line
        csi_K: (direction) ->
                switch @fix_esc_arg direction, '0'
@@ -136,10 +157,12 @@ class Terminal
                                for i in [0...@x]
                                        @text[@y][i] = ' '
                                        @attributes[@y][i] = @a
-                       when '0' # erase whole line
+                       when '2' # erase whole line
                                for i in [0...@width]
                                        @text[@y][i] = ' '
                                        @attributes[@y][i] = @a
+                       else
+                               console.log "confusing arg for csi_K: #{direction}"
 
        # set color, bold, underline, etc
        csi_m: ->