X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=terminal.coffee;h=913d87485b3c3da388b29df276b5bff0a479f16c;hb=4260b6a221b4d36c1611171e658243b03d597dc9;hp=37d3971b4fba9f787c9169b92bfae71d9d85e5a3;hpb=d9b7866716ffba8f58845b7b864d8a0ee1c3d4b1;p=watch-my-terminal.git diff --git a/terminal.coffee b/terminal.coffee index 37d3971..913d874 100644 --- 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 + if @x >= @width + @wrap_to_next_line() @text[@y][@x] = c @attributes[@y][@x] = @a @x += 1 - if @x is @width - @wrap_to_next_line() return set_attribute_bits: (mask, value) -> @@ -169,7 +169,12 @@ class Terminal @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