Editing: The go method

go Top       # Go to top of file
go Bottom    # Go to bottom
go Line,4    # Go to line 4
go Char,200  # Go to char offset 200
go 200       # "
go Down      # Go down one line
go Up,4      # Go up 4 lines
go 4,Up      # "
go -123      # 123 chars from end
go Line,-5   # 5th line from end
             # et cetera...
       
<< >>



Comments. Here's a sample of the editor API, the go method, which moves the insertion point around in the buffer.

Constants such as Up, Down, and Line are Symbols defined in the module Freeform::EditorConstants, which is conveniently mixed into Freeform::Editor.

Scintilla addresses strictly by character offset. I've added to this so that you can address by line or by line/column if you wish. In addition, I handle negative offsets in a Ruby-like fashion (i.e., as the String and Array classes work, where negative indices are one-based and count backwards from the end).

I've tentatively decided that lines should be one-based rather than zero-based. We expect the first line of a file to be line 1, not line 0. Those who disagree should give feedback.

In the spirit of flexibility, there are also other methods such as down and up, but these simply call the go method with appropriate parameters.

Note that when the method takes a Symbol constant and an integer, it may take them in either order; thus you may say go Down,4 ("go down four lines") or go 4,Down ("go four lines down") as you prefer.