on master help sign in
Merge pull request #161 from seagreen/is-shutdown
3a8dc67Jonathan Daugherty
src/Graphics/Vty.hs+5−1
@@ -94,8 +94,9 @@ data Vty = Vty
94 -- | Clean up after vty. A call to this function is necessary to
94 -- | Clean up after vty. A call to this function is necessary to
95 -- cleanly restore the terminal state before application exit. The
95 -- cleanly restore the terminal state before application exit. The
96 -- above methods will throw an exception if executed after this is
96 -- above methods will throw an exception if executed after this is
97− -- executed.
97+ -- executed. Idempotent.
98 , shutdown :: IO ()
98 , shutdown :: IO ()
99+ , isShutdown :: IO Bool
99 }
100 }
100
101
101-- | Create a Vty handle. At most one handle should be created at a time
102-- | Create a Vty handle. At most one handle should be created at a time
@@ -125,6 +126,8 @@ intMkVty input out = do
125 releaseDisplay out
126 releaseDisplay out
126 releaseTerminal out
127 releaseTerminal out
127
128
129+ let shutdownStatus = atomically $ readTVar shutdownVar
130+
128 lastPicRef <- newIORef Nothing
131 lastPicRef <- newIORef Nothing
129 lastUpdateRef <- newIORef Nothing
132 lastUpdateRef <- newIORef Nothing
130
133
@@ -175,4 +178,5 @@ intMkVty input out = do
175 , outputIface = out
178 , outputIface = out
176 , refresh = innerRefresh
179 , refresh = innerRefresh
177 , shutdown = shutdownIo
180 , shutdown = shutdownIo
181+ , isShutdown = shutdownStatus
178 }
182 }