module HTk.Kernel.CallWish(
CalledWish,
callWish,
sendCalledWish,
readCalledWish,
destroyCalledWish,
) where
import Foreign.C.String
import Util.WBFiles
import Events.Destructible
import Posixutil.ChildProcess
newtype CalledWish = CalledWish ChildProcess
callWish :: IO CalledWish
callWish =
do
wishPath <- getWishPath
childProcess <- newChildProcess wishPath [
linemode True,
challengeResponse challengeResponsePair,
toolName "wish"
]
return (CalledWish childProcess)
challengeResponsePair :: (String,String)
challengeResponsePair = ("fconfigure stdout -translation lf;if {[info command button] == \"button\"} {puts \"This is wish \"} else {puts \"Is this tclsh?\"}","This is wish \n")
sendCalledWish :: CalledWish -> CStringLen -> IO ()
sendCalledWish (CalledWish childProcess) cStringLen =
sendMsgRaw childProcess cStringLen
readCalledWish :: CalledWish -> IO String
readCalledWish (CalledWish childProcess) = readMsg childProcess
destroyCalledWish :: CalledWish -> IO ()
destroyCalledWish (CalledWish childProcess) = destroy childProcess