Method: Ruber::EditorView#move_cursor_by

Defined in:
lib/ruber/editor/editor_view.rb

#move_cursor_by(row, col) ⇒ Boolean

Moves the cursor of the given amount

If the cursor ends up being out of range, nothing is done

Parameters:

  • row (Integer)

    the amount of rows to move the cursor of. If it’s negative, the cursor will be moved upwards, otherwise it’ll be moved downwards

  • col (Integer)

    the amount of columns to move the cursor of. If it’s negative, the cursor will be moved to the left, otherwise it’ll be moved to the right

Returns:

  • (Boolean)

    true if the cursor was moved successfully and false if it was out of range



124
125
126
127
128
129
# File 'lib/ruber/editor/editor_view.rb', line 124

def move_cursor_by row, col
  cur = @view.cursor_position
  cur.line += row
  cur.column += col
  @view.set_cursor_position cur
end