| editline-0.2.1.0: Bindings to the editline library (libedit). | Contents | Index |
|
System.Console.Editline | Portability | non-portable (requires libedit) | Stability | experimental | Maintainer | judah.jacobson@gmail.com |
|
|
|
Description |
A Haskell binding to the editline library. For more information about that
library, see http://www.thrysoee.dk/editline/.
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.
editlineLoop :: IO ()
editlineLoop = do
prog <- System.Environment.getProgName
el <- elInit prog
setPrompt el (return "input: ")
setEditor el Vi
let loop = do
maybeLine <- elGets el
case maybeLine of
Nothing -> return () -- ctrl-D
Just line -> do
let line' = init line -- remove trailing '\n'
putStrLn $ "User input: " ++ show line'
loop
loop
|
|
Synopsis |
|
|
|
Documentation |
|
data EditLine |
|
elInit |
:: String | The name of the calling program; used when reading the
editrc file to determine which settings to use.
| -> IO EditLine | | Initialize the line editor.
|
|
|
reset :: EditLine -> IO () |
Reset the terminal and the parser. This should be called after an error which
may have upset the terminal's state.
|
|
elGets :: EditLine -> IO (Maybe String) |
Read a line of input from the terminal. Returns Nothing if no characters
were read or if an error occured.
|
|
setPrompt :: EditLine -> IO String -> IO () |
Set a function that will determine the prompt string.
|
|
data Editor |
|
|
setEditor :: EditLine -> Editor -> IO () |
Set the editor keymap mode.
|
|
Produced by Haddock version 2.3.0 |