@@ -19,6 +19,7 @@ import Graphics.Vty.Input.Events
1919
2020import Control.Applicative
2121import Control.Concurrent
22+import Control.Concurrent.STM
2223import Control.Exception (mask, try, SomeException)
2324import Control.Lens
2425import Control.Monad (when, mzero, forM_)
@@ -43,7 +44,7 @@ import Text.Printf (hPrintf)
4344data Input = Input
4445 { -- | Channel of events direct from input processing. Unlike 'nextEvent' this will not refresh
4546 -- the display if the next event is an 'EvResize'.
46− _eventChannel :: Chan Event
47+ _eventChannel :: TChan Event
4748 -- | Shuts down the input processing. This should return the terminal input state to before
4849 -- the input initialized.
4950 , shutdownInput :: IO ()
@@ -96,7 +97,7 @@ addBytesToProcess block = unprocessedBytes <>= block
9697emit :: Event -> InputM ()
9798emit event = do
9899 logMsg $ "parsed event: " ++ show event
99− view eventChannel >>= liftIO . flip writeChan event
100+ view eventChannel >>= liftIO . atomically . flip writeTChan event
100101
101102-- The timing requirements are assured by the VMIN and VTIME set for the device.
102103--
@@ -192,7 +193,7 @@ initInput config classifyTable = do
192193 setFdOption fd NonBlockingRead False
193194 applyConfig fd config
194195 stopSync <- newEmptyMVar
195− input <- Input <$> newChan
196+ input <- Input <$> atomically newTChan
196197 <*> pure (return ())
197198 <*> newIORef config
198199 <*> maybe (return Nothing)