From 04ba17324e1eef0797ff633eaa63c81be1912d20 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Wed, 22 Jan 2020 21:23:32 -0500 Subject: [PATCH] centre menus horizontally --- src/Mtlstats/Menu.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Menu.hs b/src/Mtlstats/Menu.hs index c2caa12..4e4db16 100644 --- a/src/Mtlstats/Menu.hs +++ b/src/Mtlstats/Menu.hs @@ -46,6 +46,7 @@ import Mtlstats.Actions import qualified Mtlstats.Actions.NewGame.GoalieInput as GI import Mtlstats.Actions.EditStandings import Mtlstats.Config +import Mtlstats.Format import Mtlstats.Types import Mtlstats.Types.Menu import Mtlstats.Util @@ -89,7 +90,11 @@ menuStateController menuFunc = Controller -- | The draw function for a 'Menu' drawMenu :: Menu a -> C.Update C.CursorMode drawMenu m = do - C.drawString $ show m + (_, cols) <- C.windowSize + let + width = fromIntegral $ pred cols + menuText = map (centre width) $ lines $ show m + C.drawString $ unlines menuText return C.CursorInvisible -- | The event handler for a 'Menu'