readline-1.0.1.0: An interface to the GNU readline librarySource codeContentsIndex
System.Console.Readline
Portabilitynon-portable (requires libreadline)
Stabilityprovisional
Maintainerlibraries@haskell.org
Description

A Haskell binding to the GNU readline library. The GNU Readline library provides a set of functions for use by applications that allow users to edit command lines as they are typed in. By default, the line editing commands are similar to those of emacs. A vi-style line editing interface is also available.

An example of a typical use of readline 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
readline :: String -> IO (Maybe String)
addHistory :: String -> IO ()
getLineBuffer :: IO String
setLineBuffer :: String -> IO ()
getPoint :: IO Int
setPoint :: Int -> IO ()
getEnd :: IO Int
setEnd :: Int -> IO ()
getMark :: IO Int
setMark :: Int -> IO ()
setDone :: Bool -> IO ()
setPendingInput :: Char -> IO ()
setEraseEmptyLine :: Bool -> IO ()
getPrompt :: IO String
setAlreadyPrompted :: Bool -> IO ()
getLibraryVersion :: IO String
getTerminalName :: IO String
setReadlineName :: String -> IO ()
getInStream :: IO Handle
getOutStream :: IO Handle
setStartupHook :: Maybe (IO ()) -> IO ()
setPreInputHook :: Maybe (IO ()) -> IO ()
setEventHook :: Maybe (IO ()) -> IO ()
setRedisplayFunction :: Maybe (IO ()) -> IO ()
data Keymap
newBareKeymap :: IO Keymap
copyKeymap :: Keymap -> IO Keymap
newKeymap :: IO Keymap
freeKeymap :: Keymap -> IO ()
getKeymap :: IO Keymap
setKeymap :: Keymap -> IO ()
getKeymapByName :: String -> IO Keymap
getKeymapName :: Keymap -> IO (Maybe String)
getExecutingKeymap :: IO Keymap
getBindingKeymap :: IO Keymap
type Callback = Int -> Char -> IO Int
addDefun :: String -> Callback -> Maybe Char -> IO ()
bindKey :: Char -> Callback -> IO ()
bindKeyInMap :: Char -> Callback -> Keymap -> IO ()
unbindKey :: Char -> IO ()
unbindKeyInMap :: Char -> Keymap -> IO ()
unbindCommandInMap :: String -> Keymap -> IO ()
data Entry
= Function Callback
| Macro String
| Keymap Keymap
genericBind :: String -> Entry -> Keymap -> IO ()
parseAndBind :: String -> IO ()
readInitFile :: String -> IO ()
namedFunction :: String -> IO (Maybe Callback)
functionOfKeyseq :: String -> Maybe Keymap -> IO Entry
functionDumper :: Bool -> IO ()
listFunmapNames :: IO ()
funmapNames :: IO [String]
beginUndoGroup :: IO ()
endUndoGroup :: IO ()
data UndoCode
= UndoDelete
| UndoInsert
| UndoBegin
| UndoEnd
addUndo :: UndoCode -> Int -> Int -> String -> IO ()
freeUndoList :: IO ()
doUndo :: IO Bool
modifying :: Int -> Int -> IO ()
redisplay :: IO ()
forcedUpdateDisplay :: IO ()
onNewLine :: IO ()
onNewLineWithPrompt :: IO ()
resetLineState :: IO ()
message :: String -> IO ()
clearMessage :: IO ()
savePrompt :: IO ()
restorePrompt :: IO ()
insertText :: String -> IO ()
deleteText :: Int -> Int -> IO ()
copyText :: Int -> Int -> IO String
killText :: Int -> Int -> IO ()
readKey :: IO Char
stuffChar :: Char -> IO Bool
initialize :: IO ()
resetTerminal :: Maybe String -> IO ()
ding :: IO Bool
displayMatchList :: [String] -> IO ()
callbackHandlerInstall :: String -> (String -> IO ()) -> IO (IO ())
callbackReadChar :: IO ()
setCatchSignals :: Bool -> IO ()
getCatchSignals :: IO Bool
setCatchSigwinch :: Bool -> IO ()
getCatchSigwinch :: IO Bool
cleanupAfterSignal :: IO ()
freeLineState :: IO ()
resetAfterSignal :: IO ()
resizeTerminal :: IO ()
setSignals :: IO ()
clearSignals :: IO ()
completeInternal :: Char -> IO ()
complete :: Int -> Char -> IO Int
possibleCompletions :: Int -> Char -> IO Int
insertCompletions :: 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 ()
setFilenameQuotingFunction :: Maybe (String -> Bool -> Ptr CChar -> IO String) -> IO ()
quoteFilename :: String -> Bool -> Ptr CChar -> IO String
setFilenameDequotingFunction :: Maybe (String -> Maybe Char -> IO String) -> IO ()
setCharIsQuotedP :: Maybe (String -> Int -> IO Bool) -> IO ()
getCompletionQueryItems :: IO Int
setCompletionQueryItems :: Int -> IO ()
getBasicWordBreakCharacters :: IO String
setBasicWordBreakCharacters :: String -> IO ()
getBasicQuoteCharacters :: IO String
setBasicQuoteCharacters :: String -> IO ()
getCompleterWordBreakCharacters :: IO String
setCompleterWordBreakCharacters :: String -> IO ()
getCompleterQuoteCharacters :: IO String
setCompleterQuoteCharacters :: String -> IO ()
getFilenameQuoteCharacters :: IO String
setFilenameQuoteCharacters :: String -> IO ()
getSpecialPrefixes :: IO String
setSpecialPrefixes :: String -> IO ()
getCompletionAppendCharacter :: IO (Maybe Char)
setCompletionAppendCharacter :: Maybe Char -> IO ()
setIgnoreCompletionDuplicates :: Bool -> IO ()
getIgnoreCompletionDuplicates :: IO Bool
setFilenameCompletionDesired :: Bool -> IO ()
getFilenameCompletionDesired :: IO Bool
setFilenameQuotingDesired :: Bool -> IO ()
getFilenameQuotingDesired :: IO Bool
setInhibitCompletion :: Bool -> IO ()
getInhibitCompletion :: IO Bool
setAttemptedCompletionOver :: Bool -> IO ()
getAttemptedCompletionOver :: IO Bool
setIgnoreSomeCompletionsFunction :: Maybe ([String] -> IO [String]) -> IO ()
setDirectoryCompletionHook :: Maybe (String -> IO String) -> IO ()
setCompletionWordBreakHook :: Maybe (IO (Maybe String)) -> IO ()
setCompletionDisplayMatchesHook :: Maybe ([String] -> IO ()) -> IO ()
Documentation
readlineSource
:: Stringprompt
-> IO (Maybe String)returns the line the user input, or Nothing if EOF is encountered.
readline is similar to 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.
addHistory :: String -> IO ()Source
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.
getLineBuffer :: IO StringSource
setLineBuffer :: String -> IO ()Source
getPoint :: IO IntSource
setPoint :: Int -> IO ()Source
getEnd :: IO IntSource
setEnd :: Int -> IO ()Source
getMark :: IO IntSource
setMark :: Int -> IO ()Source
setDone :: Bool -> IO ()Source
setPendingInput :: Char -> IO ()Source
setEraseEmptyLine :: Bool -> IO ()Source
getPrompt :: IO StringSource
setAlreadyPrompted :: Bool -> IO ()Source
getLibraryVersion :: IO StringSource
getTerminalName :: IO StringSource
setReadlineName :: String -> IO ()Source
getInStream :: IO HandleSource
getOutStream :: IO HandleSource
setStartupHook :: Maybe (IO ()) -> IO ()Source
setPreInputHook :: Maybe (IO ()) -> IO ()Source
setEventHook :: Maybe (IO ()) -> IO ()Source
setRedisplayFunction :: Maybe (IO ()) -> IO ()Source
data Keymap Source
newBareKeymap :: IO KeymapSource
copyKeymap :: Keymap -> IO KeymapSource
newKeymap :: IO KeymapSource
freeKeymap :: Keymap -> IO ()Source
getKeymap :: IO KeymapSource
setKeymap :: Keymap -> IO ()Source
getKeymapByName :: String -> IO KeymapSource
getKeymapName :: Keymap -> IO (Maybe String)Source
getExecutingKeymap :: IO KeymapSource
getBindingKeymap :: IO KeymapSource
type Callback = Int -> Char -> IO IntSource
addDefun :: String -> Callback -> Maybe Char -> IO ()Source
bindKey :: Char -> Callback -> IO ()Source
bindKeyInMap :: Char -> Callback -> Keymap -> IO ()Source
unbindKey :: Char -> IO ()Source
unbindKeyInMap :: Char -> Keymap -> IO ()Source
unbindCommandInMap :: String -> Keymap -> IO ()Source
data Entry Source
Constructors
Function Callback
Macro String
Keymap Keymap
genericBind :: String -> Entry -> Keymap -> IO ()Source
parseAndBind :: String -> IO ()Source
readInitFile :: String -> IO ()Source
namedFunction :: String -> IO (Maybe Callback)Source
functionOfKeyseq :: String -> Maybe Keymap -> IO EntrySource
functionDumper :: Bool -> IO ()Source
listFunmapNames :: IO ()Source
funmapNames :: IO [String]Source
beginUndoGroup :: IO ()Source
endUndoGroup :: IO ()Source
data UndoCode Source
Constructors
UndoDelete
UndoInsert
UndoBegin
UndoEnd
addUndo :: UndoCode -> Int -> Int -> String -> IO ()Source
freeUndoList :: IO ()Source
doUndo :: IO BoolSource
modifying :: Int -> Int -> IO ()Source
redisplay :: IO ()Source
forcedUpdateDisplay :: IO ()Source
onNewLine :: IO ()Source
onNewLineWithPrompt :: IO ()Source
resetLineState :: IO ()Source
message :: String -> IO ()Source
clearMessage :: IO ()Source
savePrompt :: IO ()Source
restorePrompt :: IO ()Source
insertText :: String -> IO ()Source
deleteText :: Int -> Int -> IO ()Source
copyText :: Int -> Int -> IO StringSource
killText :: Int -> Int -> IO ()Source
readKey :: IO CharSource
stuffChar :: Char -> IO BoolSource
initialize :: IO ()Source
resetTerminal :: Maybe String -> IO ()Source
ding :: IO BoolSource
displayMatchList :: [String] -> IO ()Source
callbackHandlerInstall :: String -> (String -> IO ()) -> IO (IO ())Source
callbackReadChar :: IO ()Source
setCatchSignals :: Bool -> IO ()Source
getCatchSignals :: IO BoolSource
setCatchSigwinch :: Bool -> IO ()Source
getCatchSigwinch :: IO BoolSource
cleanupAfterSignal :: IO ()Source
freeLineState :: IO ()Source
resetAfterSignal :: IO ()Source
resizeTerminal :: IO ()Source
setSignals :: IO ()Source
clearSignals :: IO ()Source
completeInternal :: Char -> IO ()Source
complete :: Int -> Char -> IO IntSource
possibleCompletions :: Int -> Char -> IO IntSource
insertCompletions :: Int -> Char -> IO IntSource
completionMatches :: String -> (String -> IO [String]) -> IO (Maybe (String, [String]))Source
filenameCompletionFunction :: String -> IO [String]Source
usernameCompletionFunction :: String -> IO [String]Source
setCompletionEntryFunction :: Maybe (String -> IO [String]) -> IO ()Source
setAttemptedCompletionFunction :: Maybe (String -> Int -> Int -> IO (Maybe (String, [String]))) -> IO ()Source
setFilenameQuotingFunction :: Maybe (String -> Bool -> Ptr CChar -> IO String) -> IO ()Source
quoteFilename :: String -> Bool -> Ptr CChar -> IO StringSource
setFilenameDequotingFunction :: Maybe (String -> Maybe Char -> IO String) -> IO ()Source
setCharIsQuotedP :: Maybe (String -> Int -> IO Bool) -> IO ()Source
getCompletionQueryItems :: IO IntSource
setCompletionQueryItems :: Int -> IO ()Source
getBasicWordBreakCharacters :: IO StringSource
setBasicWordBreakCharacters :: String -> IO ()Source
getBasicQuoteCharacters :: IO StringSource
setBasicQuoteCharacters :: String -> IO ()Source
getCompleterWordBreakCharacters :: IO StringSource
setCompleterWordBreakCharacters :: String -> IO ()Source
getCompleterQuoteCharacters :: IO StringSource
setCompleterQuoteCharacters :: String -> IO ()Source
getFilenameQuoteCharacters :: IO StringSource
setFilenameQuoteCharacters :: String -> IO ()Source
getSpecialPrefixes :: IO StringSource
setSpecialPrefixes :: String -> IO ()Source
getCompletionAppendCharacter :: IO (Maybe Char)Source
setCompletionAppendCharacter :: Maybe Char -> IO ()Source
setIgnoreCompletionDuplicates :: Bool -> IO ()Source
getIgnoreCompletionDuplicates :: IO BoolSource
setFilenameCompletionDesired :: Bool -> IO ()Source
getFilenameCompletionDesired :: IO BoolSource
setFilenameQuotingDesired :: Bool -> IO ()Source
getFilenameQuotingDesired :: IO BoolSource
setInhibitCompletion :: Bool -> IO ()Source
getInhibitCompletion :: IO BoolSource
setAttemptedCompletionOver :: Bool -> IO ()Source
getAttemptedCompletionOver :: IO BoolSource
setIgnoreSomeCompletionsFunction :: Maybe ([String] -> IO [String]) -> IO ()Source
setDirectoryCompletionHook :: Maybe (String -> IO String) -> IO ()Source
setCompletionWordBreakHook :: Maybe (IO (Maybe String)) -> IO ()Source
setCompletionDisplayMatchesHook :: Maybe ([String] -> IO ()) -> IO ()Source
Produced by Haddock version 0.9