- Timestamp:
- 05.11.2009 17:26:04 (4 months ago)
- Files:
-
- 1 modified
-
trunk/CMDL/Interface.hs (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/CMDL/Interface.hs
r12622 r12785 36 36 import Data.List 37 37 38 import Control.Concurrent.MVar38 import Data.IORef 39 39 import Control.Monad 40 40 import Control.Monad.Trans (MonadIO(..)) 41 41 42 42 #ifdef HASKELINE 43 shellSettings :: MVarCmdlState -> Settings IO43 shellSettings :: IORef CmdlState -> Settings IO 44 44 shellSettings st = 45 45 Settings { … … 51 51 -- We need an MVar here 52 52 -- because our CmdlState is not a Monad (and we use IO as Monad). 53 cmdlComplete :: MVarCmdlState -> CompletionFunc IO53 cmdlComplete :: IORef CmdlState -> CompletionFunc IO 54 54 cmdlComplete st (left, _) = do 55 state <- liftIO $ read MVarst55 state <- liftIO $ readIORef st 56 56 comps <- liftIO $ cmdlCompletionFn getCommands state $ reverse left 57 57 let (_, nodes) = case i_state $ intState state of … … 66 66 #endif 67 67 68 shellLoop :: MVarCmdlState68 shellLoop :: IORef CmdlState 69 69 -> Bool 70 70 #ifdef HASKELINE … … 75 75 shellLoop st isTerminal = 76 76 do 77 state <- liftIO $ read MVarst77 state <- liftIO $ readIORef st 78 78 let prompt = if isTerminal then generatePrompter state else "" 79 79 #ifdef HASKELINE … … 107 107 Just cm -> checkCom 108 108 cm { cmdDescription = c } newState 109 liftIO $ swapMVarst newState'109 liftIO $ writeIORef st newState' 110 110 shellLoop st isTerminal 111 111 … … 114 114 cmdlRunShell state = do 115 115 isTerminal <- hIsTerminalDevice stdin 116 st <- new MVarstate116 st <- newIORef state 117 117 #ifdef HASKELINE 118 118 runInputT (shellSettings st) $ shellLoop st isTerminal