|
System.Console.Editline.Readline | Portability | non-portable (requires libedit) | Stability | provisional | Maintainer | judah.jacobson@gmail.com |
|
|
|
Description |
This module provides a subset of the functions from
System.Console.Readline, which is distributed in the readline package.
However, because this package links against editline
(http://www.thrysoee.dk/editline/) 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:
readEvalPrintLoop :: IO ()
readEvalPrintLoop = do
maybeLine <- readline "% "
case maybeLine of
Nothing -> return () -- EOF / control-d
Just "exit" -> return ()
Just line -> do addHistory line
putStrLn $ "The user input: " ++ (show line)
readEvalPrintLoop
|
|
Synopsis |
|
|
|
Documentation |
|
|
:: String | prompt
| -> IO (Maybe String) | returns the line the user input, or Nothing if EOF is encountered.
| readline is similar to System.IO.getLine, but with rich edit
functionality and history capability. readline will read a line
from the terminal and return it, using prompt 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.
|
|
|
|
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.
|
|
|
:: FilePath | The file to read.
| -> IO Bool | | Read in a history file. Returns False on failure
(for example, if the file does not exist).
|
|
|
|
:: FilePath | The file to write.
| -> IO Bool | | Write out a history file. Returns False if there was a problem writing the file.
|
|
|
|
Clear the history.
|
|
|
Stifle the history list, remembering only a certain number of entries.
|
|
|
Stop stifling the history, returning the previous amount the history was
stifled by.
|
|
|
Check whether the history is stifled or not. True if stifled, False if not.
|
|
|
Get the maximum number of history entries, returning 0 if the history is
unstifled.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Produced by Haddock version 2.4.2 |