JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
display cursor, handle show/hide sequences
[watch-my-terminal.git] / terminal.coffee
index 12d8a74..d371476 100644 (file)
@@ -19,6 +19,7 @@ class Terminal
                @a = 0x000007 # cursor attributes
                @partial = ''
                @saved_normal_screen = null
+               @cursor_visible = true
                @resize width, height
 
        resize: (width, height) ->
@@ -32,7 +33,7 @@ class Terminal
                        @attributes[y] = []
                        for x in [0...width]
                                @text[y].push ' '
-                               @attributes[y].push 0
+                               @attributes[y].push 0x07
 
        # pass data from stdout
        update: (data) ->
@@ -56,7 +57,7 @@ class Terminal
                # 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)
@@ -220,6 +221,8 @@ class Terminal
                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"
@@ -232,7 +235,7 @@ class Terminal
                                                @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
@@ -241,6 +244,8 @@ class Terminal
                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"