Got questions, comments, patches, etc.?
Contact Jason Woofenden
gitweb
/
watch-my-terminal.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix csi_H (off-by-one error)
[watch-my-terminal.git]
/
terminal.coffee
diff --git
a/terminal.coffee
b/terminal.coffee
index
37d3971
..
d5830c5
100644
(file)
--- a/
terminal.coffee
+++ b/
terminal.coffee
@@
-92,11
+92,11
@@
class Terminal
when '\x0a', '\x0b' # lf, vertical tab (same thing)
@wrap_to_next_line()
else
when '\x0a', '\x0b' # lf, vertical tab (same thing)
@wrap_to_next_line()
else
+ if @x >= @width
+ @wrap_to_next_line()
@text[@y][@x] = c
@attributes[@y][@x] = @a
@x += 1
@text[@y][@x] = c
@attributes[@y][@x] = @a
@x += 1
- if @x is @width
- @wrap_to_next_line()
return
set_attribute_bits: (mask, value) ->
return
set_attribute_bits: (mask, value) ->
@@
-114,11
+114,9
@@
class Terminal
# set cursor position (one based)
csi_H: (row, column) ->
# set cursor position (one based)
csi_H: (row, column) ->
- row = 0 + @fix_esc_arg row, 1
- column = 0 + @fix_esc_arg column, 1
-
- # convert to 0 base
- column -= 1
+ # handle blank/missing args and convert to 0 base
+ row = @fix_esc_arg(row, 1) - 1
+ column = @fix_esc_arg(column, 1) - 1
#clamp values
if column < 0
#clamp values
if column < 0
@@
-160,6
+158,7
@@
class Terminal
@attributes[row][i] = @a
else
console.log "confusing arg for csi_J: #{direction}"
@attributes[row][i] = @a
else
console.log "confusing arg for csi_J: #{direction}"
+ return
# clear (some or all of) current line
csi_K: (direction) ->
# clear (some or all of) current line
csi_K: (direction) ->
@@
-169,7
+168,12
@@
class Terminal
@text[@y][i] = ' '
@attributes[@y][i] = @a
when '1' # erase to left
@text[@y][i] = ' '
@attributes[@y][i] = @a
when '1' # erase to left
- for i in [0..@x]
+ # @x can equal @width (after printing to right-most column)
+ if @x < @width
+ max = @x
+ else
+ max = @width - 1
+ for i in [0..max]
@text[@y][i] = ' '
@attributes[@y][i] = @a
when '2' # erase whole line
@text[@y][i] = ' '
@attributes[@y][i] = @a
when '2' # erase whole line
@@
-178,6
+182,7
@@
class Terminal
@attributes[@y][i] = @a
else
console.log "confusing arg for csi_K: #{direction}"
@attributes[@y][i] = @a
else
console.log "confusing arg for csi_K: #{direction}"
+ return
# misc
csiq_h: ->
# misc
csiq_h: ->