stdio works now sort of
This commit is contained in:
63
src/Carrion/Plugin/IO/STDIO.hs
Normal file
63
src/Carrion/Plugin/IO/STDIO.hs
Normal file
@ -0,0 +1,63 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
module Carrion.Plugin.IO.STDIO
|
||||
( initPlugin,
|
||||
processCommand,
|
||||
testThing,
|
||||
tellCommands,
|
||||
) where
|
||||
import Control.Monad.IO.Class
|
||||
import Control.Monad
|
||||
import Control.Concurrent(forkIO)
|
||||
import Control.Concurrent.STM
|
||||
import qualified Data.Text as T
|
||||
import GypsFulvus.PluginStuff(Manhole(..),Sewage(..), InitStatus(..),SewageAutorInfo(..),genericAutorToNSAutor,inspectManhole,regift, stripCommandPrefix')
|
||||
import System.Console.Haskeline
|
||||
import Data.Maybe
|
||||
import qualified Data.List as L
|
||||
import Prelude hiding ((++))
|
||||
|
||||
a ++ b = T.append a b
|
||||
testThing = runInputT defaultSettings loop
|
||||
where
|
||||
loop :: InputT IO ()
|
||||
loop = do
|
||||
minput <- getInputLine "% "
|
||||
case minput of
|
||||
Nothing -> return ()
|
||||
Just "quit" -> return ()
|
||||
Just input -> do outputStrLn $ T.unpack ("Input was: " ++ T.pack input)
|
||||
loop
|
||||
mySignature = GenericStyleAutor "STDIO haskeline" "local" "local"
|
||||
tellCommands = [""]
|
||||
|
||||
stripCommandLocal c m = stripCommandPrefix' c tellCommands m mySignature
|
||||
initPlugin :: Manhole -> IO InitStatus
|
||||
initPlugin manhole = do
|
||||
|
||||
forkIO $ rEPL manhole
|
||||
return GoodInitStatus
|
||||
|
||||
processCommand = undefined
|
||||
|
||||
processUserInputs = undefined
|
||||
processCommandResults = undefined
|
||||
|
||||
rEPL manhole = do
|
||||
let getInputs = runInputT defaultSettings loop
|
||||
fuku :: InputT IO ()
|
||||
fuku = do
|
||||
aresult <- liftIO (inspectManhole manhole)
|
||||
outputStrLn $ T.unpack . getSewage $ aresult
|
||||
fuku
|
||||
loop :: InputT IO ()
|
||||
loop = do
|
||||
minput <- getInputLine "% "
|
||||
case minput of
|
||||
Nothing -> return ()
|
||||
Just "quit" -> return ()
|
||||
Just input -> do liftIO $ regift (Sewage mySignature (T.pack input)) manhole
|
||||
loop
|
||||
getResults = runInputT defaultSettings fuku
|
||||
forkIO $ getInputs
|
||||
forkIO $ getResults
|
||||
return ()
|
Reference in New Issue
Block a user