@@ -52,6 +52,7 @@ import Graphics.Vty.Picture
52import Graphics.Vty.Image
52import Graphics.Vty.Image
53import Graphics.Vty.Attributes
53import Graphics.Vty.Attributes
55+import Control.Monad (when)
55import Control.Concurrent.STM
56import Control.Concurrent.STM
57import Data.IORef
58import Data.IORef
@@ -115,10 +116,16 @@ mkVty appConfig = do
115intMkVty :: Input -> Output -> IO Vty
116intMkVty :: Input -> Output -> IO Vty
116intMkVty input out = do
117intMkVty input out = do
117 reserveDisplay out
118 reserveDisplay out
120+ shutdownVar <- atomically $ newTVar False
118 let shutdownIo = do
121 let shutdownIo = do
122+ alreadyShutdown <- atomically $ readTVar shutdownVar
123+ when (not alreadyShutdown) $ do
124+ atomically $ writeTVar shutdownVar True
119− shutdownInput input
125+ shutdownInput input
120− releaseDisplay out
126+ releaseDisplay out
121− releaseTerminal out
127+ releaseTerminal out
122 lastPicRef <- newIORef Nothing
129 lastPicRef <- newIORef Nothing
123 lastUpdateRef <- newIORef Nothing
130 lastUpdateRef <- newIORef Nothing