module Network.UI.Kafka.Keyboard (
keyboardLoop
) where
import Network.UI.Kafka (ExitAction, LoopAction, Sensor, TopicConnection, producerLoop)
import Network.UI.Kafka.Types (Event(KeyEvent))
import System.IO (BufferMode(NoBuffering), hSetBuffering, hSetEcho, stdin)
keyboardLoop :: TopicConnection
-> Sensor
-> IO (ExitAction, LoopAction)
keyboardLoop topicConnection sensor =
do
hSetBuffering stdin NoBuffering
hSetEcho stdin False
producerLoop topicConnection sensor
. fmap (: [])
$ KeyEvent
<$> getChar
<*> return Nothing
<*> return Nothing
<*> return Nothing