JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
implement: csi_@, csi_P, csi_h (aptitude flawless)
authorJason Woofenden <jason@jasonwoof.com>
Fri, 3 Apr 2015 14:23:13 +0000 (10:23 -0400)
committerJason Woofenden <jason@jasonwoof.com>
Fri, 3 Apr 2015 14:23:13 +0000 (10:23 -0400)
terminal.coffee

index fb9d14a..55f092b 100644 (file)
@@ -343,7 +343,7 @@ class Terminal
                                @text[y][x] = ' '
                                @attributes[y][x] = 0x07
 
-       # delete chars (I think this shouldn't move the cursor)
+       # delete chars (without moving the cursor)
        csi_X: (chars) ->
                chars = parseInt @fix_esc_arg chars, '1'
                x = @x
@@ -354,11 +354,59 @@ class Terminal
                        @attributes[@y][x] = @a
                        x += 1
                return
+       "csi_@": (chars) ->
+               chars = parseInt @fix_esc_arg chars, '1'
+               if chars < 1
+                       return
+               if chars > @width - @x
+                       chars = @width - @x
+               else
+                       dest = @width - 1
+                       if dest >= @width
+                               dest = @width - 1
+                       while dest - chars >= @x
+                               @text[@y][dest] = @text[@y][dest - chars]
+                               @attributes[@y][dest] = @attributes[@y][dest - chars]
+                               dest -= 1
+               @csi_X chars # clear
+       csi_P: (chars) ->
+               chars = parseInt @fix_esc_arg chars, '1'
+               if chars < 1
+                       return
+               if chars > @width - @x
+                       chars = @width - @x
+               else
+                       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 arguments
+       csiq_h: (args...) ->
+               for i in args
                        arg = @fix_esc_arg i, ''
                        switch arg
                                when '1' # mode ?1
@@ -392,17 +440,13 @@ class Terminal
                for i in arguments
                        arg = @fix_esc_arg i, ''
                        switch arg
-                               when '0'
-                                       # error (ignored
+                               when '0' # error (ignored
                                        return
-                               when '2'
-                                       # KAM -- keyboard action
+                               when '2' # KAM -- keyboard action
                                        return
-                               when '4'
-                                       # put cursor in "REPLACE" mode
+                               when '4' # put cursor in "REPLACE" mode
                                        return
-                               when '12'
-                                       # turn local echo on (or off?)
+                               when '12' # turn local echo on (or off?)
                                        return
                                # TODO when '20' LNM linefeed/newline
 
@@ -613,7 +657,7 @@ class Terminal
        # "The auxiliary keypad keys will transmit control sequences."
        "esc_=": ->
 
-       # esc (
+       # esc )
        "esc_)": ->
                @alternate_charset = true
        # esc ( 0