diff options
| author | bjorn <bjorn@bringert.net> | 2008-09-15 13:33:40 +0000 |
|---|---|---|
| committer | bjorn <bjorn@bringert.net> | 2008-09-15 13:33:40 +0000 |
| commit | aecf9597eb071fa36d17cee83f7d98b0e3c8506a (patch) | |
| tree | d8af15c9cc19a393fb75d2f1f474d71d96958e28 /src/server/MainFastCGI.hs | |
| parent | 3a7888e66008f1df2e68474c94f94c82f6042383 (diff) | |
Added partial word completion to fastcgi server and update GWT UI accordingly.
Diffstat (limited to 'src/server/MainFastCGI.hs')
| -rw-r--r-- | src/server/MainFastCGI.hs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/server/MainFastCGI.hs b/src/server/MainFastCGI.hs index d3c223c92..f4b6a920f 100644 --- a/src/server/MainFastCGI.hs +++ b/src/server/MainFastCGI.hs @@ -10,6 +10,7 @@ import Text.JSON import qualified Codec.Binary.UTF8.String as UTF8 (encodeString) import Control.Monad +import Data.Char import qualified Data.Map as Map import Data.Maybe @@ -128,12 +129,17 @@ complete' pgf input mcat mfrom = complete :: PGF -> PGF.Language -> PGF.Category -> String -> [String] complete pgf from cat input = - let ws = words input - prefix = "" -- FIXME + let (ws,prefix) = tokensAndPrefix input state0 = PGF.initState pgf from cat state = foldl PGF.nextState state0 ws compls = PGF.getCompletions state prefix - in Map.keys compls + in [unwords (ws++[c]) ++ " " | c <- Map.keys compls] + +tokensAndPrefix :: String -> ([String],String) +tokensAndPrefix s | not (null s) && isSpace (last s) = (words s, "") + | null ws = ([],"") + | otherwise = (init ws, last ws) + where ws = words s linearize' :: PGF -> Maybe PGF.Language -> PGF.Tree -> [(PGF.Language,String)] linearize' pgf mto tree = |
