Method: Textbringer::Window#recenter

Defined in:
lib/textbringer/window.rb

#recenterObject



493
494
495
496
497
498
499
500
501
502
503
504
# File 'lib/textbringer/window.rb', line 493

def recenter
  @buffer.save_point do |saved|
    max = (lines - 1) / 2
    count = beginning_of_line_and_count(max)
    while count < max
      break if @buffer.point == 0
      @buffer.backward_char
      count += beginning_of_line_and_count(max - count - 1) + 1
    end
    @buffer.mark_to_point(@top_of_window)
  end
end