class HandyToolbox::Scroll
Attributes
max_y[R]
screen[R]
top[R]
Public Class Methods
new()
click to toggle source
# File lib/handy_toolbox/scroll.rb, line 7 def initialize @screen = Curses.stdscr @screen.scrollok(true) reset end
Public Instance Methods
down(by = 1)
click to toggle source
# File lib/handy_toolbox/scroll.rb, line 34 def down(by = 1) by = max_top - @top if @top + by > max_top if by > 0 screen.scrl(by) @top += by end end
fits_into_pane?(y)
click to toggle source
# File lib/handy_toolbox/scroll.rb, line 22 def fits_into_pane?(y) (y - top) >= 0 && (y - top) < screen.maxy end
reset()
click to toggle source
# File lib/handy_toolbox/scroll.rb, line 13 def reset @top = 0 @max_y = 0 end
to(index)
click to toggle source
# File lib/handy_toolbox/scroll.rb, line 42 def to(index) if index != top if index >= 0 && index <= max_top by = index - top screen.scrl(by) @top = index elsif index < 0 to_first elsif index > max_top to_last end end end
to_first()
click to toggle source
# File lib/handy_toolbox/scroll.rb, line 56 def to_first to(0) end
to_last()
click to toggle source
# File lib/handy_toolbox/scroll.rb, line 60 def to_last to(max_top) end
up(by = 1)
click to toggle source
# File lib/handy_toolbox/scroll.rb, line 26 def up(by = 1) by = @top if @top - by < 0 if by > 0 screen.scrl(-by) @top -= by end end
update(max_y)
click to toggle source
# File lib/handy_toolbox/scroll.rb, line 18 def update(max_y) @max_y = max_y end
Private Instance Methods
max_top()
click to toggle source
# File lib/handy_toolbox/scroll.rb, line 66 def max_top max_y - (screen.maxy - 1) end