From ea145ddf5289c1f12d01a39ceb2935ddce8b31a0 Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Tue, 3 Jun 2008 16:54:59 +0000 Subject: add setCompletionFunction in GF.System.Readline --- src-3.0/GF/System/UseReadline.hs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src-3.0/GF/System/UseReadline.hs') diff --git a/src-3.0/GF/System/UseReadline.hs b/src-3.0/GF/System/UseReadline.hs index c84b9d7f4..c4a8f9239 100644 --- a/src-3.0/GF/System/UseReadline.hs +++ b/src-3.0/GF/System/UseReadline.hs @@ -12,9 +12,9 @@ -- Use GNU readline ----------------------------------------------------------------------------- -module GF.System.UseReadline (fetchCommand) where +module GF.System.UseReadline (fetchCommand, setCompletionFunction) where -import System.Console.Readline (readline, addHistory) +import System.Console.Readline fetchCommand :: String -> IO (String) fetchCommand s = do @@ -23,3 +23,12 @@ fetchCommand s = do Nothing -> return "q" Just s -> do addHistory s return s + +setCompletionFunction :: Maybe (String -> String -> Int -> IO [String]) -> IO () +setCompletionFunction Nothing = setCompletionEntryFunction Nothing +setCompletionFunction (Just fn) = setCompletionEntryFunction (Just my_fn) + where + my_fn prefix = do + s <- getLineBuffer + p <- getPoint + fn s prefix p -- cgit v1.2.3