Web.Util.TextCursor
- Package
- purescript-textcursor
- Repository
- MonoidMusician/purescript-textcursor
#TextCursor Source
newtype TextCursorThe TextCursor type represents text selection within an input element.
It consists of three regions of text: the text before the cursor, the text
selected, and the text after the selection. This allows replacements to
occur while keeping intact the cursor position/selection.
Constructors
TextCursor { after :: String, before :: String, direction :: Direction, selected :: String }
Instances
#mkTextCursor Source
mkTextCursor :: String -> String -> String -> TextCursorCreate a TextCursor from three strings.
#genTextCursor Source
genTextCursor :: forall m. MonadRec m => MonadGen m => m TextCursor#content Source
content :: TextCursor -> StringGet the current text in the field. (Everything before, inside, and after the selection.)
#length Source
length :: TextCursor -> IntGet the content length.
#null Source
null :: TextCursor -> BooleanTest whether there is no content.
#empty Source
empty :: TextCursorAn empty input field. No selection.
#single Source
single :: Setter' TextCursor String -> String -> TextCursorApply a Lens setting a value to an empty TextCursor. When used with
_before, _selected, or _after this will provide a TextCursor with
only one non-empty field.
#_before Source
_before :: Lens' TextCursor StringLens for the text before the selection. Empty if the cursor is at the beginning or the selection starts from the beginning.
#_selected Source
_selected :: Lens' TextCursor StringLens for the text that is selected. Empty if nothing is selected.
#_after Source
_after :: Lens' TextCursor StringLens for the text after the selection. Empty if the cursor or selection reaches the end.
#_all Source
_all :: Traversal' TextCursor StringLens for traversing/setting all three fields.
#atStart Source
atStart :: TextCursor -> BooleanTest whether the cursor or selection touches the start.
#atEnd Source
atEnd :: TextCursor -> BooleanTest whether the cursor or selection reaches the end.
#allSelected Source
allSelected :: TextCursor -> BooleanTest whether the cursor has selected the whole field.
#isCursor Source
isCursor :: TextCursor -> BooleanTest whether the selection is collapsed, i.e. acts like a cursor.
#cursorAtStart Source
cursorAtStart :: TextCursor -> BooleanTest whether the cursor is at the start with no selection.
#cursorAtEnd Source
cursorAtEnd :: TextCursor -> BooleanTest whether the cursor is at the end with no selection.
#isSelection Source
isSelection :: TextCursor -> BooleanTest whether some text is selected.
#selectionAtStart Source
selectionAtStart :: TextCursor -> BooleanTest whether there is a selection that starts at the beginning.
#selectionAtEnd Source
selectionAtEnd :: TextCursor -> BooleanTest whether there is a selection that reaches the end.
#selectAll Source
selectAll :: TextCursor -> TextCursorSelect all of the text in a field.
Note: selection direction is not specified.
#placeCursorAtStart Source
placeCursorAtStart :: TextCursor -> TextCursorPlace the cursor to the start of a field, preserving the overall text content.
#placeCursorAtEnd Source
placeCursorAtEnd :: TextCursor -> TextCursorPlace the cursor to the end of a field, preserving the overall text content.
#modifySelected Source
modifySelected :: (String -> String) -> TextCursor -> TextCursorModify just the selected region with an endomorphism.
#modifyAll Source
modifyAll :: (String -> String) -> TextCursor -> TextCursorMap all three regions of the TextCursor with an endomorphism, performing
a replacement or other transformation such as normalization.
#appendl Source
appendl :: String -> TextCursor -> TextCursorPrepend a string, on the left.
#appendr Source
appendr :: TextCursor -> String -> TextCursorAppend a string, on the right.
#insert Source
insert :: String -> TextCursor -> TextCursorInsert a string at the cursor position. If text is selected, the insertion will be part of the selection. Otherwise it is inserted before the cursor.