| Portability | non-portable (requires libedit) |
|---|---|
| Stability | experimental |
| Maintainer | judah.jacobson@gmail.com |
| Safe Haskell | Safe-Infered |
System.Console.Editline
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
Documentation
Arguments
| :: String | The name of the calling program; used when reading the
|
| -> IO EditLine |
Initialize the line editor.
reset :: EditLine -> IO ()Source
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)Source
Read a line of input from the terminal. Returns Nothing if no characters were read or if an error occured.