on master help sign in
Merge pull request #161 from seagreen/is-shutdown

Add isShutdown field to Vty.

commit3a8dc678658d2d04906ea6596d13e7e0d607b80f authorJonathan Daugherty <cygnus@foobox.com> dateMon 15 Oct 2018, 13:36 (8 years ago) parent8207c1457342ae
1 file changed+5−1
src/Graphics/Vty.hs+5−1
src/Graphics/Vty.hs+5−1
@@ -94,8 +94,9 @@ data Vty = Vty
9494 -- | Clean up after vty. A call to this function is necessary to
9595 -- cleanly restore the terminal state before application exit. The
9696 -- above methods will throw an exception if executed after this is
97− -- executed.
97+ -- executed. Idempotent.
9898 , shutdown :: IO ()
99+ , isShutdown :: IO Bool
99100 }
100101
101102-- | Create a Vty handle. At most one handle should be created at a time
@@ -125,6 +126,8 @@ intMkVty input out = do
125126 releaseDisplay out
126127 releaseTerminal out
127128
129+ let shutdownStatus = atomically $ readTVar shutdownVar
130+
128131 lastPicRef <- newIORef Nothing
129132 lastUpdateRef <- newIORef Nothing
130133
@@ -175,4 +178,5 @@ intMkVty input out = do
175178 , outputIface = out
176179 , refresh = innerRefresh
177180 , shutdown = shutdownIo
181+ , isShutdown = shutdownStatus
178182 }