From 17c9edab23a2371d7b553aa5d0ffe8f1d41b0bc1 Mon Sep 17 00:00:00 2001 From: Jason Woofenden Date: Wed, 30 Jan 2013 22:44:13 -0500 Subject: [PATCH] add csi_J, fix csi_K(2) --- terminal.coffee | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/terminal.coffee b/terminal.coffee index 11c79e0..f3ed817 100644 --- a/terminal.coffee +++ b/terminal.coffee @@ -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: -> -- 1.7.10.4