Copyright | (c) Kwang Yul Seo 2016 |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | kwangyul.seo@gmail.com |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
This module provides a monadic interface to TextZipper
.
- type Edit t a = EditT t Identity a
- data EditT t m a
- execEditT :: (Monoid t, Monad m) => EditT t m a -> TextZipper t -> m (TextZipper t)
- execEdit :: Monoid t => Edit t a -> TextZipper t -> TextZipper t
- clearZipper :: (Monoid t, Monad m) => EditT t m ()
- getText :: (Monoid t, Monad m) => EditT t m [t]
- currentLine :: (Monoid t, Monad m) => EditT t m t
- cursorPosition :: (Monoid t, Monad m) => EditT t m (Int, Int)
- lineLengths :: (Monoid t, Monad m) => EditT t m [Int]
- getLineLimit :: (Monoid t, Monad m) => EditT t m (Maybe Int)
- moveCursor :: (Monoid t, Monad m) => (Int, Int) -> EditT t m ()
- insertChar :: (Monoid t, Monad m) => Char -> EditT t m ()
- breakLine :: (Monoid t, Monad m) => EditT t m ()
- killToBOL :: (Monoid t, Monad m) => EditT t m ()
- killToEOL :: (Monoid t, Monad m) => EditT t m ()
- gotoEOL :: (Monoid t, Monad m) => EditT t m ()
- gotoBOL :: (Monoid t, Monad m) => EditT t m ()
- deletePrevChar :: (Eq t, Monoid t, Monad m) => EditT t m ()
- deleteChar :: (Monoid t, Monad m) => EditT t m ()
- moveRight :: (Monoid t, Monad m) => EditT t m ()
- moveLeft :: (Monoid t, Monad m) => EditT t m ()
- moveUp :: (Monoid t, Monad m) => EditT t m ()
- moveDown :: (Monoid t, Monad m) => EditT t m ()
Documentation
An edit transformer monad
execEditT :: (Monoid t, Monad m) => EditT t m a -> TextZipper t -> m (TextZipper t) Source #
Execute the edit session with the given zipper and return the modified zipper.
execEdit :: Monoid t => Edit t a -> TextZipper t -> TextZipper t Source #
Execute the edit session with the given zipper and return the modified zipper.
Extraction functions
currentLine :: (Monoid t, Monad m) => EditT t m t Source #
The line of text on which the zipper's cursor currently resides.
cursorPosition :: (Monoid t, Monad m) => EditT t m (Int, Int) Source #
Get the cursor position of the zipper; returns (row, col)
.
row
ranges from [0..num_rows-1]
inclusive; col
ranges from
[0..length of current line]
inclusive. Column values equal to
line width indicate a cursor that is just past the end of a line of
text.
lineLengths :: (Monoid t, Monad m) => EditT t m [Int] Source #
Return the lengths of the lines in the zipper.
getLineLimit :: (Monoid t, Monad m) => EditT t m (Maybe Int) Source #
Get the line limit, if any, for a zipper.
Navigation and editing functions
moveCursor :: (Monoid t, Monad m) => (Int, Int) -> EditT t m () Source #
Move the cursor to the specified row and column. Invalid cursor
positions will be ignored. Valid cursor positions range as
described for cursorPosition
.
insertChar :: (Monoid t, Monad m) => Char -> EditT t m () Source #
Insert a character at the current cursor position. Move the cursor one position to the right.
breakLine :: (Monoid t, Monad m) => EditT t m () Source #
Insert a line break at the current cursor position.
killToBOL :: (Monoid t, Monad m) => EditT t m () Source #
Remove all text from the cursor position to the beginning of the current line.
killToEOL :: (Monoid t, Monad m) => EditT t m () Source #
Remove all text from the cursor position to the end of the current line. If the cursor is at the beginning of a line and the line is empty, the entire line will be removed.
gotoEOL :: (Monoid t, Monad m) => EditT t m () Source #
Move the cursor to the end of the current line.
gotoBOL :: (Monoid t, Monad m) => EditT t m () Source #
Move the cursor to the beginning of the current line.
deletePrevChar :: (Eq t, Monoid t, Monad m) => EditT t m () Source #
Delete the character preceding the cursor position, and move the cursor backwards by one character.
deleteChar :: (Monoid t, Monad m) => EditT t m () Source #
Delete the character at the cursor position. Leaves the cursor position unchanged. If the cursor is at the end of a line of text, this combines the line with the line below.
moveRight :: (Monoid t, Monad m) => EditT t m () Source #
Move the cursor right by one position. If the cursor is at the end of a line, the cursor is moved to the first position of the following line (if any).
moveLeft :: (Monoid t, Monad m) => EditT t m () Source #
Move the cursor left by one position. If the cursor is at the beginning of a line, the cursor is moved to the last position of the preceding line (if any).