-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | A text editor zipper library
--   
--   This library provides a zipper and API for editing text.
@package text-zipper
@version 0.10


-- | This module provides a two-dimensional 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., <a>String</a>, <a>Text</a>,
--   etc.). As a result, the most general way to create a text zipper is to
--   use <a>mkZipper</a> and provide all of the functions required to
--   manipulate the underlying text data.
--   
--   Implementations using <a>Text</a> and <a>String</a> are provided.
module Data.Text.Zipper
data 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.
mkZipper :: (Monoid a) => (Char -> a) -> (Int -> a -> a) -> (Int -> a -> a) -> (a -> Int) -> (a -> Char) -> (a -> a) -> (a -> Bool) -> (a -> [a]) -> (a -> [Char]) -> [a] -> Maybe Int -> TextZipper a

-- | Construct a zipper from <a>Text</a> values.
textZipper :: [Text] -> Maybe Int -> TextZipper Text

-- | Construct a zipper from list values.
stringZipper :: [String] -> Maybe Int -> TextZipper String

-- | Empty a zipper.
clearZipper :: (Monoid a) => TextZipper a -> TextZipper a

-- | Construct a zipper from vectors of characters.
vectorZipper :: [Vector Char] -> Maybe Int -> TextZipper (Vector Char)

-- | Get the text contents of the zipper.
getText :: (Monoid a) => TextZipper a -> [a]

-- | The line of text on which the zipper's cursor currently resides.
currentLine :: (Monoid a) => TextZipper a -> a

-- | Get the cursor position of the zipper; returns <tt>(row, col)</tt>.
--   <tt>row</tt> ranges from <tt>[0..num_rows-1]</tt> inclusive;
--   <tt>col</tt> ranges from <tt>[0..length of current line]</tt>
--   inclusive. Column values equal to line width indicate a cursor that is
--   just past the end of a line of text.
cursorPosition :: TextZipper a -> (Int, Int)

-- | Return the lengths of the lines in the zipper.
lineLengths :: (Monoid a) => TextZipper a -> [Int]

-- | Get the line limit, if any, for a zipper.
getLineLimit :: TextZipper a -> Maybe Int

-- | Move the cursor to the specified row and column. Invalid cursor
--   positions will be ignored. Valid cursor positions range as described
--   for <a>cursorPosition</a>.
moveCursor :: (Monoid a) => (Int, Int) -> TextZipper a -> TextZipper a

-- | 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).
moveRight :: (Monoid a) => TextZipper a -> TextZipper a

-- | 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).
moveLeft :: (Monoid a) => TextZipper a -> TextZipper a

-- | 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.
moveUp :: (Monoid a) => TextZipper a -> TextZipper a

-- | 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.
moveDown :: (Monoid a) => TextZipper a -> TextZipper a

-- | Move the cursor to the end of the current line.
gotoEOL :: (Monoid a) => TextZipper a -> TextZipper a

-- | Move the cursor to the beginning of the current line.
gotoBOL :: (Monoid a) => TextZipper a -> TextZipper a

-- | Get the Char on which the cursor currently resides. If the cursor is
--   at the end of the text or the text is empty return <tt>Nothing</tt>.
currentChar :: TextZipper a -> Maybe Char

-- | Get the Char after the cursor position. If the cursor is at the end of
--   a line return the first character of the next line, or if that one is
--   empty as well, return <tt>Nothing</tt>.
nextChar :: (Monoid a) => TextZipper a -> Maybe Char

-- | Get the Char before the cursor position. If the cursor is at the
--   beginning of the text, return <tt>Nothing</tt>
previousChar :: (Monoid a) => TextZipper a -> Maybe Char

-- | Insert a character at the current cursor position.
--   
--   If the character is a newline, break the current line.
--   
--   If the character is non-printable, ignore it.
--   
--   Otherwise insert the character and move the cursor one position to the
--   right.
insertChar :: (Monoid a) => Char -> TextZipper a -> TextZipper a

-- | Insert many characters at the current cursor position. Move the cursor
--   to the end of the inserted text.
insertMany :: (Monoid a) => a -> TextZipper a -> TextZipper a

-- | Delete the character preceding the cursor position, and move the
--   cursor backwards by one character.
deletePrevChar :: (Eq a, Monoid a) => TextZipper a -> TextZipper a

-- | 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.
deleteChar :: (Monoid a) => TextZipper a -> TextZipper a

-- | Insert a line break at the current cursor position.
breakLine :: (Monoid a) => TextZipper a -> TextZipper a

-- | 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.
killToEOL :: (Monoid a) => TextZipper a -> TextZipper a

-- | Remove all text from the cursor position to the beginning of the
--   current line.
killToBOL :: Monoid a => TextZipper a -> TextZipper a

-- | Transpose the character before the cursor with the one at the cursor
--   position and move the cursor one position to the right. If the cursor
--   is at the end of the current line, transpose the current line's last
--   two characters.
transposeChars :: (Monoid a) => TextZipper a -> TextZipper a
instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Data.Text.Zipper.TextZipper a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Text.Zipper.TextZipper a)
instance GHC.Show.Show a => GHC.Show.Show (Data.Text.Zipper.TextZipper a)

module Data.Text.Zipper.Generic
class Monoid a => GenericTextZipper a
singleton :: GenericTextZipper a => Char -> a
drop :: GenericTextZipper a => Int -> a -> a
take :: GenericTextZipper a => Int -> a -> a
length :: GenericTextZipper a => a -> Int
last :: GenericTextZipper a => a -> Char
init :: GenericTextZipper a => a -> a
null :: GenericTextZipper a => a -> Bool
lines :: GenericTextZipper a => a -> [a]
toList :: GenericTextZipper a => a -> [Char]
textZipper :: GenericTextZipper a => [a] -> Maybe Int -> TextZipper a
instance Data.Text.Zipper.Generic.GenericTextZipper [GHC.Types.Char]
instance Data.Text.Zipper.Generic.GenericTextZipper Data.Text.Internal.Text
instance Data.Text.Zipper.Generic.GenericTextZipper (Data.Vector.Vector GHC.Types.Char)


-- | Implements word movements.
--   
--   Copyright (c) Hans-Peter Deifel
module Data.Text.Zipper.Generic.Words

-- | Move one word to the left.
--   
--   A word is defined as a consecutive string not satisfying isSpace. This
--   function always leaves the cursor at the beginning of a word (except
--   at the very start of the text).
moveWordLeft :: GenericTextZipper a => TextZipper a -> TextZipper a

-- | Move one word to the right.
--   
--   A word is defined as a consecutive string not satisfying isSpace. This
--   function always leaves the cursor at the end of a word (except at the
--   very end of the text).
moveWordRight :: GenericTextZipper a => TextZipper a -> TextZipper a

-- | Delete the previous word.
--   
--   Does the same as <a>moveWordLeft</a> but deletes characters instead of
--   simply moving past them.
deletePrevWord :: (Eq a, GenericTextZipper a) => TextZipper a -> TextZipper a

-- | Delete the next word.
--   
--   Does the same as <a>moveWordRight</a> but deletes characters instead
--   of simply moving past them.
deleteWord :: GenericTextZipper a => TextZipper a -> TextZipper a
