on master help sign in
Input: add a new field, restoreInputState
812e873Jonathan Daugherty
src/Graphics/Vty/Input.hs+5−1
@@ -163,11 +163,15 @@ inputForConfig config@Config{ termName = Just termName
163 atomically $ writeTChan (input^.eventChannel) (EvResize e e)
163 atomically $ writeTChan (input^.eventChannel) (EvResize e e)
164 _ <- installHandler windowChange pokeIO Nothing
164 _ <- installHandler windowChange pokeIO Nothing
165 _ <- installHandler continueProcess pokeIO Nothing
165 _ <- installHandler continueProcess pokeIO Nothing
166+
167+ let restore = unsetAttrs
168+
166 return $ input
169 return $ input
167 { shutdownInput = do
170 { shutdownInput = do
168 shutdownInput input
171 shutdownInput input
169 _ <- installHandler windowChange Ignore Nothing
172 _ <- installHandler windowChange Ignore Nothing
170 _ <- installHandler continueProcess Ignore Nothing
173 _ <- installHandler continueProcess Ignore Nothing
171− unsetAttrs
174+ restore
175+ , restoreInputState = restoreInputState input >> restore
172 }
176 }
173inputForConfig config = (<> config) <$> standardIOConfig >>= inputForConfig
177inputForConfig config = (<> config) <$> standardIOConfig >>= inputForConfig
src/Graphics/Vty/Input/Loop.hs+8−2
@@ -52,9 +52,14 @@ data Input = Input
52 -- 'nextEvent' this will not refresh the display if the next event
52 -- 'nextEvent' this will not refresh the display if the next event
53 -- is an 'EvResize'.
53 -- is an 'EvResize'.
54 _eventChannel :: TChan Event
54 _eventChannel :: TChan Event
55− -- | Shuts down the input processing. This should return the
55+ -- | Shuts down the input processing. As part of shutting down the
56− -- terminal input state to before he input initialized.
56+ -- input, this should also restore the input state.
57 , shutdownInput :: IO ()
57 , shutdownInput :: IO ()
58+ -- | Restore the terminal's input state to what it was prior
59+ -- to configuring input for Vty. This should be done as part of
60+ -- 'shutdownInput' but is exposed in case you need to access it
61+ -- directly.
62+ , restoreInputState :: IO ()
58 -- | Changes to this value are reflected after the next event.
63 -- | Changes to this value are reflected after the next event.
59 , _configRef :: IORef Config
64 , _configRef :: IORef Config
60 -- | input debug log
65 -- | input debug log
@@ -235,6 +240,7 @@ initInput config classifyTable = do
235 applyConfig fd config
240 applyConfig fd config
236 stopSync <- newEmptyMVar
241 stopSync <- newEmptyMVar
237 input <- Input <$> atomically newTChan
242 input <- Input <$> atomically newTChan
243+ <*> pure (return ())
238 <*> pure (return ())
244 <*> pure (return ())
239 <*> newIORef config
245 <*> newIORef config
240 <*> maybe (return Nothing)
246 <*> maybe (return Nothing)