module CursorStep

Overview

Clients are allowed to pick which step Cursor moves with.

CursorStep implementors are objects with (possibly) state that advance cursor from one index to another, influenced by the state mentioned and/or their own opinion on how the motion should happen.

Direct including types

Defined in:

aspis/step.cr

Instance Method Summary

Instance Method Detail

abstract def advance(document : Document, prev : Int, nxt : Int) : Int #

Returns the next cursor index.

prev and nxt are indices belonging to document.

prev index is the previous index (where motion started).

nxt index is the speculative, character-based next index. It might be out of document's bounds.

The latter is usually the index you'd need to change/snap, as a CursorStep implementor. The former is given to you so you can e.g. compute delta or determine the direction of the movement.

The returned index must be in bounds of the document.


[View source]