Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- type Position = Word
- data TextZipper = TextZipper {
- beforeCursor :: !Text
- afterCursor :: !Text
- cursor :: !Position
- moveCursor :: (Position -> Position) -> TextZipper -> TextZipper
- setCursor :: Position -> TextZipper -> TextZipper
- hasTrailingNewline :: TextZipper -> Bool
- removeTrailingNewline :: Text -> Text
- null :: TextZipper -> Bool
- length :: TextZipper -> Int64
- toText :: TextZipper -> Text
- fromText :: Text -> TextZipper
- fromTextAt :: Text -> Position -> TextZipper
- fromParts :: Text -> Text -> TextZipper
- insert :: Text -> TextZipper -> TextZipper
- splitBefore :: TextZipper -> (TextZipper, Maybe Char)
- splitAfter :: TextZipper -> (TextZipper, Maybe Char)
- deleteBefore :: TextZipper -> TextZipper
- deleteAfter :: TextZipper -> TextZipper
- moveBackward :: TextZipper -> TextZipper
- moveForward :: TextZipper -> TextZipper
- moveStart :: TextZipper -> TextZipper
- moveEnd :: TextZipper -> TextZipper
Documentation
data TextZipper Source #
TextZipper | |
|
Instances
moveCursor :: (Position -> Position) -> TextZipper -> TextZipper Source #
Modify the cursor position, updating the TextZipper
according to the
change.
setCursor :: Position -> TextZipper -> TextZipper Source #
Set the position of the Cursor to a specific value. The state of the TextZipper will be updated to match the new position.
hasTrailingNewline :: TextZipper -> Bool Source #
Whether the TextZipper
has a trailing newline. A trailing newline is
present if the last character of the line is a '\n' character.
removeTrailingNewline :: Text -> Text Source #
Helper function to remove the last character of the provided text iff it is a trailing newline.
null :: TextZipper -> Bool Source #
Whether the provided TextZipper
is empty.
length :: TextZipper -> Int64 Source #
The length of the entire TextZipper
structure.
toText :: TextZipper -> Text Source #
Convert a TextZipper
to Text
. Effectively 'beforeCursor <> afterCursor', but slightly more efficient in edge cases.
fromText :: Text -> TextZipper Source #
Create a TextZipper
from a Text
source, with the cursor at the end of it.
fromTextAt :: Text -> Position -> TextZipper Source #
Create a TextZipper
from a Text
source, with the cursor at the specified position.
fromParts :: Text -> Text -> TextZipper Source #
Create a TextZipper
by concatenating two Text
components, with the cursor between them.
insert :: Text -> TextZipper -> TextZipper Source #
splitBefore :: TextZipper -> (TextZipper, Maybe Char) Source #
splitAfter :: TextZipper -> (TextZipper, Maybe Char) Source #
deleteBefore :: TextZipper -> TextZipper Source #
Delete the first character before the cursor, if any.
deleteAfter :: TextZipper -> TextZipper Source #
Delete the first character after the cursor, if any.
moveBackward :: TextZipper -> TextZipper Source #
Decrement the cursor.
moveForward :: TextZipper -> TextZipper Source #
Increment the cursor.
moveStart :: TextZipper -> TextZipper Source #
Move the cursor to the beginning of the text.
moveEnd :: TextZipper -> TextZipper Source #
Move the cursor to the end of the text.