Using the terminal
package, my code basically looks like this:
main :: IO ()
main = withTerminal $ runTerminalT $ do
eraseInDisplay EraseAll
hideCursor
setAutoWrap False
forever $ do
calculate
updateScreen
If the user exits this program with Ctrl-C, the terminal settings (in this concrete case, the hidden cursor) remain. I am looking for a lightweight way to restore the terminal settings as they were before running the program. By lightweight, I mean something that I can just wrap around the whole runTerminalT
shebang, instead of having to manually call checkInterrupt
at various parts of my code etc.