readline 1.0.1.0 → 1.0.2.0
raw patch · 2 files changed
+45/−45 lines, 2 filesdep ~basenew-uploader
Dependency ranges changed: base
Files
- System/Console/Readline.hsc +42/−42
- readline.cabal +3/−3
System/Console/Readline.hsc view
@@ -1,10 +1,10 @@-{-# OPTIONS -fglasgow-exts #-}+{-# LANGUAGE ForeignFunctionInterface #-} ----------------------------------------------------------------------------- -- | -- Module : System.Console.Readline -- Copyright : (c) unknown -- License : GPL (depends on libreadline, which is GPL)--- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires libreadline)@@ -22,7 +22,7 @@ -- readEvalPrintLoop :: IO () -- readEvalPrintLoop = do -- maybeLine <- readline \"% \"--- case maybeLine of +-- case maybeLine of -- Nothing -> return () -- EOF \/ control-d -- Just \"exit\" -> return () -- Just line -> do addHistory line@@ -38,18 +38,18 @@ module System.Console.Readline ( -------------------------------------------------------------------- -- Basic Behavior.- + readline, -- :: String -> IO (Maybe String) addHistory, -- :: String -> IO ()- + -------------------------------------------------------------------- -- Readline Variables.- + getLineBuffer, -- :: IO String #if HAVE_READLINE_4 setLineBuffer, -- :: String -> IO () #endif- + -- Functions involving point positions are meaningful only when string -- conversion between Haskell and C preserves the length. getPoint, -- :: IO Int@@ -58,7 +58,7 @@ setEnd, -- :: Int -> IO () getMark, -- :: IO Int setMark, -- :: Int -> IO ()- + setDone, -- :: Bool -> IO () setPendingInput, -- :: Char -> IO () #if HAVE_READLINE_4@@ -83,13 +83,13 @@ -- for each character. setRedisplayFunction, -- :: Maybe (IO ()) -> IO () -- Nothing means the original: rl_redisplay.- + -------------------------------------------------------------------- -- Selecting a Keymap.- + -- Keymaps are not garbage collected. They must be explicitly freed -- using freeKeymap.- + Keymap, -- data Keymap newBareKeymap, -- :: IO Keymap copyKeymap, -- :: Keymap -> IO Keymap@@ -101,10 +101,10 @@ getKeymapName, -- :: Keymap -> IO (Maybe String) getExecutingKeymap, -- :: IO Keymap getBindingKeymap, -- :: IO Keymap- + -------------------------------------------------------------------- -- Binding Keys.- + Callback, -- type Callback = Int -> Char -> IO Int addDefun, -- :: String -> Callback -> Maybe Char -> IO () bindKey, -- :: Char -> Callback -> IO ()@@ -121,10 +121,10 @@ genericBind, -- :: String -> Entry -> Keymap -> IO () parseAndBind, -- :: String -> IO () readInitFile, -- :: String -> IO ()- + -------------------------------------------------------------------- -- Associating Function Names and Bindings.- + namedFunction, -- :: String -> IO (Maybe Callback) functionOfKeyseq, -- :: String -> Maybe Keymap -> IO Entry -- rl_invoking_keyseqs and rl_invoking_keyseqs_in_map are not provided@@ -134,10 +134,10 @@ #if HAVE_READLINE_4 funmapNames, -- :: IO [String] #endif- + -------------------------------------------------------------------- -- Allowing Undoing.- + beginUndoGroup, endUndoGroup, -- :: IO () UndoCode(..), -- data UndoCode -- = UndoDelete@@ -148,10 +148,10 @@ freeUndoList, -- :: IO () doUndo, -- :: IO Bool modifying, -- :: Int -> Int -> IO ()- + -------------------------------------------------------------------- -- Redisplay.- + redisplay, -- :: IO () forcedUpdateDisplay, -- :: IO () onNewLine, -- :: IO ()@@ -168,15 +168,15 @@ -------------------------------------------------------------------- -- Modifying Text.- + insertText, -- :: String -> IO () deleteText, -- :: Int -> Int -> IO () copyText, -- :: Int -> Int -> IO String killText, -- :: Int -> Int -> IO ()- + -------------------------------------------------------------------- -- Utility functions.- + readKey, -- :: IO Char stuffChar, -- :: Char -> IO Bool initialize, -- :: IO ()@@ -185,17 +185,17 @@ #if HAVE_READLINE_4 displayMatchList, -- :: [String] -> IO () #endif- + -------------------------------------------------------------------- -- Alternate Interface.- + callbackHandlerInstall, -- :: String -> (String -> IO ()) -> IO (IO ()) -- Returns the cleanup action. callbackReadChar, -- :: IO ()- + -------------------------------------------------------------------- -- Readline Signal Handling.- + #if HAVE_READLINE_4 setCatchSignals, -- :: Bool -> IO () getCatchSignals, -- :: IO Bool@@ -208,10 +208,10 @@ #endif setSignals, -- :: IO () clearSignals, -- :: IO ()- + -------------------------------------------------------------------- -- Completion functions.- + completeInternal, -- :: Char -> IO () complete, -- :: Int -> Char -> IO Int possibleCompletions, -- :: Int -> Char -> IO Int@@ -278,7 +278,7 @@ -- :: Maybe ([String] -> IO ()) -> IO () #endif )- + where ------------------------------------------------------------------------@@ -295,10 +295,10 @@ import Foreign.Marshal.Utils ( maybePeek, maybeWith, withMany ) import Foreign.Marshal.Alloc ( alloca, free ) import Foreign.Marshal.Array ( mallocArray, peekArray0, pokeArray0, withArray0 )-import Foreign.C.Types ( CInt, CChar, CFile )+import Foreign.C.Types ( CInt(..), CChar(..), CFile(..) ) import Foreign.C.String ( newCString, peekCString, withCString, castCharToCChar, castCCharToChar )-import GHC.Handle ( fdToHandle )+import GHC.IO.Handle.FD ( fdToHandle ) {-# CFILES HsReadline_cbits.c #-} @@ -513,7 +513,7 @@ rl_discard_keymap k free km -foreign import ccall unsafe "rl_discard_keymap" +foreign import ccall unsafe "rl_discard_keymap" rl_discard_keymap :: Keymap -> IO () foreign import ccall unsafe "rl_get_keymap"@@ -524,7 +524,7 @@ getKeymapByName :: String -> IO Keymap getKeymapByName name = withCString name rl_get_keymap_by_name-foreign import ccall unsafe +foreign import ccall unsafe rl_get_keymap_by_name :: Ptr CChar -> IO Keymap getKeymapName :: Keymap -> IO (Maybe String)@@ -689,7 +689,7 @@ exportCallback cb = exportCallbackC $ \n key -> liftM fromIntegral (cb (fromIntegral n) (chr (fromIntegral key)))-foreign import ccall "wrapper" +foreign import ccall "wrapper" exportCallbackC :: CallbackC -> IO (FunPtr CallbackC) importCallback :: FunPtr CallbackC -> Callback@@ -724,7 +724,7 @@ UndoInsert -> #const UNDO_INSERT UndoBegin -> #const UNDO_BEGIN UndoEnd -> #const UNDO_END-foreign import ccall unsafe +foreign import ccall unsafe rl_add_undo :: CInt -> CInt -> CInt -> Ptr CChar -> IO () #if HAVE_READLINE_4_2@@ -883,7 +883,7 @@ foreign import ccall unsafe "rl_callback_handler_remove" rl_callback_handler_remove :: IO () -foreign import ccall "rl_callback_read_char" +foreign import ccall "rl_callback_read_char" callbackReadChar :: IO () ------------------------------------------------------------------------@@ -1058,15 +1058,15 @@ #if HAVE_READLINE_5 type StringFunc = IO (Ptr CChar) -foreign import ccall "&" rl_completion_word_break_hook +foreign import ccall "&" rl_completion_word_break_hook :: Ptr (FunPtr StringFunc) -foreign import ccall "wrapper" +foreign import ccall "wrapper" exportStringFunc :: StringFunc -> IO (FunPtr StringFunc) setCompletionWordBreakHook :: Maybe (IO (Maybe String)) -> IO ()-setCompletionWordBreakHook fun = +setCompletionWordBreakHook fun = setFunPtr rl_completion_word_break_hook fun $ \f -> exportStringFunc $ do wordBreaks <- f@@ -1128,7 +1128,7 @@ foreign import ccall "&"rl_filename_dequoting_function :: Ptr (FunPtr Dequoter) -foreign import ccall "wrapper" +foreign import ccall "wrapper" exportDequoter :: Dequoter -> IO (FunPtr Dequoter) type IsQuoted = Ptr CChar -> CInt -> IO CInt@@ -1287,11 +1287,11 @@ foreign import ccall "&" rl_attempted_completion_over :: Ptr CInt getAttemptedCompletionOver :: IO Bool-getAttemptedCompletionOver = +getAttemptedCompletionOver = liftM (/=0) (peek rl_attempted_completion_over) setAttemptedCompletionOver :: Bool -> IO ()-setAttemptedCompletionOver over = +setAttemptedCompletionOver over = poke rl_attempted_completion_over (if over then 1 else 0) foreign import ccall "&" rl_inhibit_completion :: Ptr CInt
readline.cabal view
@@ -1,8 +1,9 @@ name: readline-version: 1.0.1.0+version: 1.0.2.0 license: GPL license-file: LICENSE maintainer: libraries@haskell.org+category: Console synopsis: An interface to the GNU readline library description: More information on readline can be found at@@ -24,10 +25,9 @@ System.Console.Readline System.Console.SimpleLineEditor if flag(split-base)- build-depends: base >= 3, process+ build-depends: base >= 3 && < 5, process else build-depends: base < 3- extensions: CPP include-dirs: include includes: HsReadline.h install-includes: HsReadline.h HsReadlineConfig.h