Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- charWidth :: Char -> Int
- data TextZipper = TextZipper {}
- mapZipper :: (Char -> Char) -> TextZipper -> TextZipper
- appendEnd :: [Text] -> Text -> [Text]
- left :: TextZipper -> TextZipper
- leftN :: Int -> TextZipper -> TextZipper
- shiftLeftN :: TextZipper -> TextZipper
- leftWord :: TextZipper -> TextZipper
- shiftLeftWord :: TextZipper -> TextZipper
- right :: TextZipper -> TextZipper
- rightN :: Int -> TextZipper -> TextZipper
- shiftRightN :: TextZipper -> TextZipper
- rightWord :: TextZipper -> TextZipper
- rightLeftWord :: TextZipper -> TextZipper
- deselect :: TextZipper -> TextZipper
- up :: TextZipper -> TextZipper
- down :: TextZipper -> TextZipper
- pageUp :: Int -> TextZipper -> TextZipper
- pageDown :: Int -> TextZipper -> TextZipper
- home :: TextZipper -> TextZipper
- end :: TextZipper -> TextZipper
- top :: TextZipper -> TextZipper
- insertChar :: Char -> TextZipper -> TextZipper
- insert :: Text -> TextZipper -> TextZipper
- deleteSelection :: TextZipper -> TextZipper
- deleteLeft :: TextZipper -> TextZipper
- deleteRight :: TextZipper -> TextZipper
- deleteLeftWord :: TextZipper -> TextZipper
- tab :: Int -> TextZipper -> TextZipper
- value :: TextZipper -> Text
- empty :: TextZipper
- fromText :: Text -> TextZipper
- data TextAlignment
- type OffsetMapWithAlignment = Map Int (Int, Int)
- data DisplayLines = DisplayLines {}
- goToDisplayLinePosition :: Bool -> Int -> Int -> DisplayLines -> TextZipper -> TextZipper
- displayLinesWithAlignment :: TextAlignment -> Int -> TextZipper -> DisplayLines
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.
data TextZipper Source #
TextZipper | |
|
Instances
IsString TextZipper Source # | |
Defined in Potato.Data.Text.Zipper2 fromString :: String -> TextZipper # | |
Show TextZipper Source # | |
Defined in Potato.Data.Text.Zipper2 showsPrec :: Int -> TextZipper -> ShowS # show :: TextZipper -> String # showList :: [TextZipper] -> ShowS # | |
Eq TextZipper Source # | |
Defined in Potato.Data.Text.Zipper2 (==) :: TextZipper -> TextZipper -> Bool # (/=) :: TextZipper -> TextZipper -> Bool # |
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 TextAlignment Source #
Text alignment type
Instances
Show TextAlignment Source # | |
Defined in Potato.Data.Text.Zipper2 showsPrec :: Int -> TextAlignment -> ShowS # show :: TextAlignment -> String # showList :: [TextAlignment] -> ShowS # | |
Eq TextAlignment Source # | |
Defined in Potato.Data.Text.Zipper2 (==) :: TextAlignment -> TextAlignment -> Bool # (/=) :: TextAlignment -> TextAlignment -> Bool # |
data DisplayLines Source #
Information about the document as it is displayed (i.e., post-wrapping)
Instances
Show DisplayLines Source # | |
Defined in Potato.Data.Text.Zipper2 showsPrec :: Int -> DisplayLines -> ShowS # show :: DisplayLines -> String # showList :: [DisplayLines] -> ShowS # | |
Eq DisplayLines Source # | |
Defined in Potato.Data.Text.Zipper2 (==) :: DisplayLines -> DisplayLines -> Bool # (/=) :: DisplayLines -> DisplayLines -> Bool # |
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 #
:: 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