class AnsiSys::Cursor
Constants
- CODE_LETTERS
Escape sequence codes processed in this Class
Attributes
cur_col[R]
cur_row[R]
max_col[RW]
max_row[RW]
Public Class Methods
new(cur_col = 1, cur_row = 1, max_col = 80, max_row = 25)
click to toggle source
# File lib/ansisys.rb, line 160 def initialize(cur_col = 1, cur_row = 1, max_col = 80, max_row = 25) @cur_col = cur_col @cur_row = cur_row @max_col = max_col @max_row = max_row end
Public Instance Methods
advance!(width = 1)
click to toggle source
changes current location for a character with width to be echoed
# File lib/ansisys.rb, line 212 def advance!(width = 1) r = nil @cur_col += width if @cur_col > @max_col line_feed! r = "\n" end return r end
apply_code!(letter, *pars)
click to toggle source
applies self an escape sequence code that ends with letter as String and with some pars as Integers
# File lib/ansisys.rb, line 169 def apply_code!(letter, *pars) case letter when 'A' @cur_row -= pars[0] ? pars[0] : 1 @cur_row = @max_row if @max_row and @cur_row > @max_row when 'B' @cur_row += pars[0] ? pars[0] : 1 @cur_row = @max_row if @max_row and @cur_row > @max_row when 'C' @cur_col += pars[0] ? pars[0] : 1 when 'D' @cur_col -= pars[0] ? pars[0] : 1 when 'E' @cur_row += pars[0] ? pars[0] : 1 @cur_col = 1 @max_row = @cur_row if @max_row and @cur_row > @max_row when 'F' @cur_row -= pars[0] ? pars[0] : 1 @cur_col = 1 @max_row = @cur_row if @max_row and @cur_row > @max_row when 'G' @cur_col = pars[0] ? pars[0] : 1 when 'H' @cur_row = pars[0] ? pars[0] : 1 @cur_col = pars[1] ? pars[1] : 1 @max_row = @cur_row if @max_row and @cur_row > @max_row when 'f' @cur_row = pars[0] ? pars[0] : 1 @cur_col = pars[1] ? pars[1] : 1 @max_row = @cur_row if @max_row and @cur_row > @max_row end if @cur_row < 1 @cur_row = 1 end if @cur_col < 1 @cur_col = 1 elsif @cur_col > @max_col @cur_col = @max_col end return self end
fit!(width = 1)
click to toggle source
check if a character with width fits within the maximum columns, feed a line if not
# File lib/ansisys.rb, line 224 def fit!(width = 1) r = nil if @cur_col + width > @max_col + 1 line_feed! r = "\n" end return r end
line_feed!()
click to toggle source
feed a line
# File lib/ansisys.rb, line 234 def line_feed! @cur_col = 1 @cur_row += 1 @max_row = @cur_row if @max_row and @cur_row > @max_row end