We want Parley to implement types and methods that Masonry and other editors will be able to use to create a text-editing widget, or to handle selection in non-editable text.
After some discussion we've settled on the following:
A TextMovement enum representing different possible changes to a text edit's selection and content. Possible variants might be eg MoveLeft, MoveToNextWord, SelectToNextParagraph, RemovePreviousWord, etc.
A function that maps a String, a cursor position(/span) and a TextMovement to a StringDiff and position(/span). That function essentially tells you "if you do that, here's how the text will change and where your cursor will be next".
Later down the road, once we want to implement spans, a function that maps a span and a StringDiff to an optional span.
We want Parley to implement types and methods that Masonry and other editors will be able to use to create a text-editing widget, or to handle selection in non-editable text.
After some discussion we've settled on the following:
MoveLeft
,MoveToNextWord
,SelectToNextParagraph
,RemovePreviousWord
, etc.Possible signatures:
We night use Parley's Cursor type instead of byte offsets in these interfaces.