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


-- | Bindings to the editline library (libedit).
--   
--   This package contains bindings to the BSD editline library
--   (<a>http://www.thrysoee.dk/editline/</a>). It provides a basic
--   interface to the editline API for reading lines of input from the
--   user.
--   
--   Additionally, a readline compatibility module is included which
--   provides a subset of the functions from the readline package.
@package editline
@version 0.2.1.1


-- | This module provides a subset of the functions from
--   <a>System.Console.Readline</a>, which is distributed in the readline
--   package. However, because this package links against editline
--   (<a>http://www.thrysoee.dk/editline/</a>) instead of readline,
--   programs using this module are not required to be distributed under
--   the GPL.
--   
--   An example of a typical use of the readline API with history
--   functionality is illustrated in the following read, eval, print loop:
--   
--   <pre>
--   readEvalPrintLoop :: IO ()
--   readEvalPrintLoop = do
--     maybeLine &lt;- readline "% "
--     case maybeLine of 
--      Nothing     -&gt; return () -- EOF / control-d
--      Just "exit" -&gt; return ()
--      Just line -&gt; do addHistory line
--                      putStrLn $ "The user input: " ++ (show line)
--                      readEvalPrintLoop
--   </pre>
module System.Console.Editline.Readline

-- | readline is similar to <a>getLine</a>, but with rich edit
--   functionality and history capability. readline will read a line from
--   the terminal and return it, using <i>prompt</i> as a prompt. If prompt
--   is the empty string, no prompt is issued. The line returned has the
--   final newline removed, so only the text of the line remains. A blank
--   line returns the empty string. If EOF is encountered while reading a
--   line, and the line is empty, Nothing is returned. If an EOF is read
--   with a non-empty line, it is treated as a newline.
readline :: String -> IO (Maybe String)

-- | Add this command to the history. This allows users to search backward
--   through history with C-r and step through with up and down arrows,
--   among other things.
addHistory :: String -> IO ()

-- | Read in a history file. Returns <a>False</a> on failure (for example,
--   if the file does not exist).
readHistory :: FilePath -> IO Bool

-- | Write out a history file. Returns <a>False</a> if there was a problem
--   writing the file.
writeHistory :: FilePath -> IO Bool

-- | Clear the history.
clearHistory :: IO ()

-- | Stifle the history list, remembering only a certain number of entries.
stifleHistory :: Int -> IO ()

-- | Stop stifling the history, returning the previous amount the history
--   was stifled by.
unstifleHistory :: IO Int

-- | Check whether the history is stifled or not. True if stifled, False if
--   not.
historyIsStifled :: IO Bool

-- | Get the maximum number of history entries, returning 0 if the history
--   is unstifled.
historyMaxEntries :: IO Int
getLineBuffer :: IO String
getPoint :: IO Int
setPoint :: Int -> IO ()
getEnd :: IO Int
setEnd :: Int -> IO ()
getPrompt :: IO String
getLibraryVersion :: IO String
getTerminalName :: IO String
setReadlineName :: String -> IO ()
getInStream :: IO Handle
getOutStream :: IO Handle
setStartupHook :: Maybe (IO ()) -> IO ()
setRedisplayFunction :: Maybe (IO ()) -> IO ()
type Callback = Int -> Char -> IO Int
addDefun :: String -> Callback -> Maybe Char -> IO ()
bindKey :: Char -> Callback -> IO ()
parseAndBind :: String -> IO ()
readInitFile :: String -> IO ()
redisplay :: IO ()
readKey :: IO Char
stuffChar :: Char -> IO Bool
initialize :: IO ()
resetTerminal :: Maybe String -> IO ()
callbackHandlerInstall :: String -> (String -> IO ()) -> IO (IO ())
callbackReadChar :: IO ()
complete :: Int -> Char -> IO Int
completionMatches :: String -> (String -> IO [String]) -> IO (Maybe (String, [String]))
filenameCompletionFunction :: String -> IO [String]
usernameCompletionFunction :: String -> IO [String]
setCompletionEntryFunction :: Maybe (String -> IO [String]) -> IO ()
setAttemptedCompletionFunction :: Maybe (String -> Int -> Int -> IO (Maybe (String, [String]))) -> IO ()
getCompletionQueryItems :: IO Int
setCompletionQueryItems :: Int -> IO ()
getBasicWordBreakCharacters :: IO String
setBasicWordBreakCharacters :: String -> IO ()
getCompleterWordBreakCharacters :: IO String
setCompleterWordBreakCharacters :: String -> IO ()
getCompleterQuoteCharacters :: IO String
setCompleterQuoteCharacters :: String -> IO ()
getSpecialPrefixes :: IO String
setSpecialPrefixes :: String -> IO ()
getCompletionAppendCharacter :: IO (Maybe Char)
setCompletionAppendCharacter :: Maybe Char -> IO ()
setInhibitCompletion :: Bool -> IO ()
getInhibitCompletion :: IO Bool
setAttemptedCompletionOver :: Bool -> IO ()
getAttemptedCompletionOver :: IO Bool


-- | A Haskell binding to the editline library. For more information about
--   that library, see <a>http://www.thrysoee.dk/editline/</a>.
--   
--   The following example illustrates using this library to write a loop
--   that will process input until it reaches EOF or a Ctrl-D is typed.
--   
--   <pre>
--   editlineLoop :: IO ()
--    editlineLoop = do
--       prog &lt;- System.Environment.getProgName
--       el &lt;- elInit prog
--       setPrompt el (return "input: ")
--       setEditor el Vi
--       let loop = do
--            maybeLine &lt;- elGets el
--            case maybeLine of
--                Nothing -&gt; return () -- ctrl-D
--                Just line -&gt; do
--                    let line' = init line -- remove trailing '\n'
--                    putStrLn $ "User input: " ++ show line'
--                    loop
--       loop
--    
--   </pre>
module System.Console.Editline
data EditLine

-- | Initialize the line editor.
elInit :: String -> IO EditLine

-- | Reset the terminal and the parser. This should be called after an
--   error which may have upset the terminal's state.
reset :: EditLine -> IO ()

-- | Read a line of input from the terminal. Returns Nothing if no
--   characters were read or if an error occured.
elGets :: EditLine -> IO (Maybe String)

-- | Set a function that will determine the prompt string.
setPrompt :: EditLine -> IO String -> IO ()
data Editor
Vi :: Editor
Emacs :: Editor

-- | Set the editor keymap mode.
setEditor :: EditLine -> Editor -> IO ()
