tinytools-0.1.0.3
Safe HaskellSafe-Inferred
LanguageHaskell2010

Potato.Data.Text.Zipper2

Synopsis

Documentation

charWidth :: Char -> Int Source #

Get the display width of a Char. "Full width" and "wide" characters take two columns and everything else takes a single column. See https://www.unicode.org/reports/tr11/ for more information This is implemented using wcwidth from Vty such that it matches what will be displayed on the terminal. Note that this method can change depending on how vty is configed. Please see vty documentation for details.

mapZipper :: (Char -> Char) -> TextZipper -> TextZipper Source #

Map a replacement function over the characters in a TextZipper

left :: TextZipper -> TextZipper Source #

Move the cursor left one character (clearing the selection)

leftN :: Int -> TextZipper -> TextZipper Source #

Move the cursor left by the given number of characters (clearing the selection)

shiftLeftN :: TextZipper -> TextZipper Source #

expand the selection to the left the given number of characters

leftWord :: TextZipper -> TextZipper Source #

Move the cursor to the left one word (clearing the selection)

shiftLeftWord :: TextZipper -> TextZipper Source #

Expand the selection to the left by one word

right :: TextZipper -> TextZipper Source #

Move the cursor right one character (clearing the selection)

rightN :: Int -> TextZipper -> TextZipper Source #

Move the character right by the given number of characters (clearing the selection)

shiftRightN :: TextZipper -> TextZipper Source #

expand the selection to the right the given number of characters

rightWord :: TextZipper -> TextZipper Source #

Move the cursor to the right one word (clearing the selection)

rightLeftWord :: TextZipper -> TextZipper Source #

Expand the selection to the right by one word

deselect :: TextZipper -> TextZipper Source #

Clear the selection and move the cursor to the end of selection

up :: TextZipper -> TextZipper Source #

Move the cursor up one logical line (clearing the selection)

down :: TextZipper -> TextZipper Source #

Move the cursor down one logical line (clearing the selection)

pageUp :: Int -> TextZipper -> TextZipper Source #

Move the cursor up by the given number of lines (clearing the selection)

pageDown :: Int -> TextZipper -> TextZipper Source #

Move the cursor down by the given number of lines (clearing the selection)

home :: TextZipper -> TextZipper Source #

Move the cursor to the beginning of the current logical line (clearing the selection)

end :: TextZipper -> TextZipper Source #

Move the cursor to the end of the current logical line (clearing the selection)

top :: TextZipper -> TextZipper Source #

Move the cursor to the top of the document (clearing the selection)

insertChar :: Char -> TextZipper -> TextZipper Source #

Insert a character at the current cursor position (overwriting the selection)

insert :: Text -> TextZipper -> TextZipper Source #

Insert text at the current cursor position (overwriting the selection)

deleteSelection :: TextZipper -> TextZipper Source #

Delete the selection

deleteLeft :: TextZipper -> TextZipper Source #

Delete the selection or the character to the left of the cursor if there was no selection

deleteRight :: TextZipper -> TextZipper Source #

Delete the selection to the character to the right of the cursor if there was no selection

deleteLeftWord :: TextZipper -> TextZipper Source #

Delete the selection and the word to the left of the cursor and the selection. When deleting the word to the left of the selection, deletes all whitespace until it finds a non-whitespace character, and then deletes contiguous non-whitespace characters.

tab :: Int -> TextZipper -> TextZipper Source #

Insert up to n spaces to get to the next logical column that is a multiple of n

value :: TextZipper -> Text Source #

The plain text contents of the zipper

empty :: TextZipper Source #

The empty zipper

fromText :: Text -> TextZipper Source #

Constructs a zipper with the given contents. The cursor is placed after the contents.

data DisplayLines Source #

Information about the document as it is displayed (i.e., post-wrapping)

Instances

Instances details
Show DisplayLines Source # 
Instance details

Defined in Potato.Data.Text.Zipper2

Eq DisplayLines Source # 
Instance details

Defined in Potato.Data.Text.Zipper2

goToDisplayLinePosition :: Bool -> Int -> Int -> DisplayLines -> TextZipper -> TextZipper Source #

Adjust the cursor and/or selection of the TextZipper by the given display line coordinates If the x coordinate is beyond the startend of a line, the cursor is moved to the startend of that line respectively if add is true, the selection is expanded to the given position if add is false, the selection is cleared and the cursor is moved to the given position

displayLinesWithAlignment Source #

Arguments

:: TextAlignment 
-> Int

Width, used for wrapping

-> TextZipper

The text input contents and cursor state

-> DisplayLines 

Given a TextAlignment, a width and a TextZipper, produce a DisplayLines wrapping happens at word boundaries such that the most possible words fit into each display line if a line can not be wrapped (i.e. it contains a word longer than the display width) then the line is cropped in the middle of the word as necessary