lib/sup/modes/scroll-mode.rb in sup-0.0.6 vs lib/sup/modes/scroll-mode.rb in sup-0.0.7

- old
+ new

@@ -1,10 +1,19 @@ module Redwood class ScrollMode < Mode - attr_reader :status, :topline, :botline + ## we define topline and botline as the top and bottom lines of any + ## content in the currentview. + + ## we left leftcol and rightcol as the left and right columns of any + ## content in the current view. but since we're operating in a + ## line-centric fashion, rightcol is always leftcol + the buffer + ## width. (whereas botline is topline + at most the buffer height, + ## and can be == to topline in the case that there's no content.) + attr_reader :status, :topline, :botline, :leftcol + COL_JUMP = 2 register_keymap do |k| k.add :line_down, "Down one line", :down, 'j', 'J' k.add :line_up, "Up one line", :up, 'k', 'K' @@ -23,10 +32,12 @@ # how many lines do we keep? @twiddles = opts.member?(:twiddles) ? opts[:twiddles] : true super() end + def rightcol; @leftcol + buffer.content_width; end + def draw ensure_mode_validity (@topline ... @botline).each { |ln| draw_line ln } ((@botline - @topline) ... buffer.content_height).each do |ln| if @twiddles @@ -78,10 +89,10 @@ @topline = 0 if @topline < 0 # empty @botline = [@topline + buffer.content_height, lines].min end def resize *a - super *a + super(*a) ensure_mode_validity end protected