Method: Textbringer::Buffer#goto_line

Defined in:
lib/textbringer/buffer.rb

#goto_line(n) ⇒ Object



529
530
531
532
533
534
535
536
537
538
539
540
541
542
# File 'lib/textbringer/buffer.rb', line 529

def goto_line(n)
  pos = point_min
  i = 1
  while i < n && pos < @contents.bytesize
    pos = @contents.index("\n", pos)
    break if pos.nil?
    i += 1
    pos += 1
  end
  @point = gap_to_user(pos)
  @current_line = i
  @current_column = 1
  @goal_column = nil
end