Safe Haskell  None 

This module provides a twodimensional text zipper data structure. This structure represents a body of text and an editing cursor which can be moved throughout the text, along with a set of editing transformations.
Text zippers are generalized over the set of data types that might
be used to store lists of characters (e.g., String
, Text
,
etc.). As a result, the most general way to create a text zipper
is to use mkZipper
and provide all of the functions required to
manipulate the underlying text data.
A default implementation using Text
is provided and is used
elsewhere in this library.
 data TextZipper a
 mkZipper :: Monoid a => (Char > a) > (Int > a > a) > (Int > a > a) > (a > Int) > (a > Char) > (a > a) > (a > Bool) > [a] > TextZipper a
 textZipper :: [Text] > TextZipper Text
 getText :: Monoid a => TextZipper a > [a]
 currentLine :: Monoid a => TextZipper a > a
 cursorPosition :: TextZipper a > (Int, Int)
 lineLengths :: Monoid a => TextZipper a > [Int]
 moveCursor :: Monoid a => (Int, Int) > TextZipper a > TextZipper a
 insertChar :: Monoid a => Char > TextZipper a > TextZipper a
 breakLine :: Monoid a => TextZipper a > TextZipper a
 killToEOL :: Monoid a => TextZipper a > TextZipper a
 gotoEOL :: Monoid a => TextZipper a > TextZipper a
 gotoBOL :: Monoid a => TextZipper a > TextZipper a
 deletePrevChar :: (Eq a, Monoid a) => TextZipper a > TextZipper a
 deleteChar :: Monoid a => TextZipper a > TextZipper a
 moveRight :: Monoid a => TextZipper a > TextZipper a
 moveLeft :: Monoid a => TextZipper a > TextZipper a
 moveUp :: Monoid a => TextZipper a > TextZipper a
 moveDown :: Monoid a => TextZipper a > TextZipper a
Documentation
data TextZipper a Source
Eq a => Eq (TextZipper a)  
Show a => Show (TextZipper a) 
Construction and extraction
:: Monoid a  
=> (Char > a)  A singleton constructor. 
> (Int > a > a) 

> (Int > a > a) 

> (a > Int)  
> (a > Char) 

> (a > a) 

> (a > Bool) 

> [a]  The initial lines of text. 
> TextZipper a 
Create a zipper using a custom text storage type. Takes the initial text as well as all of the functions necessary to manipulate the underlying text values.
textZipper :: [Text] > TextZipper TextSource
Construct a zipper from Text
values.
getText :: Monoid a => TextZipper a > [a]Source
Get the text contents of the zipper.
currentLine :: Monoid a => TextZipper a > aSource
The line of text on which the zipper's cursor currently resides.
cursorPosition :: TextZipper a > (Int, Int)Source
Get the cursor position of the zipper; returns (row, col)
.
row
ranges from [0..num_rows1]
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 a => TextZipper a > [Int]Source
Return the lengths of the lines in the zipper.
Navigation functions
moveCursor :: Monoid a => (Int, Int) > TextZipper a > TextZipper aSource
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 a => Char > TextZipper a > TextZipper aSource
Insert a character at the current cursor position. Move the cursor one position to the right.
breakLine :: Monoid a => TextZipper a > TextZipper aSource
Insert a line break at the current cursor position.
killToEOL :: Monoid a => TextZipper a > TextZipper aSource
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 a => TextZipper a > TextZipper aSource
Move the cursor to the end of the current line.
gotoBOL :: Monoid a => TextZipper a > TextZipper aSource
Move the cursor to the beginning of the current line.
deletePrevChar :: (Eq a, Monoid a) => TextZipper a > TextZipper aSource
Delete the character preceding the cursor position, and move the cursor backwards by one character.
deleteChar :: Monoid a => TextZipper a > TextZipper aSource
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 a => TextZipper a > TextZipper aSource
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 a => TextZipper a > TextZipper aSource
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).
moveUp :: Monoid a => TextZipper a > TextZipper aSource
Move the cursor up by one row. If there no are rows above the current one, move to the first position of the current row. If the row above is shorter, move to the end of that row.
moveDown :: Monoid a => TextZipper a > TextZipper aSource
Move the cursor down by one row. If there are no rows below the current one, move to the last position of the current row. If the row below is shorter, move to the end of that row.