From 9c2e2291c8313c54677b0b239282112cf677b67b Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Wed, 22 Jan 2020 08:49:13 -0500 Subject: [PATCH] draw box around title --- src/Mtlstats/Control/TitleScreen.hs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Mtlstats/Control/TitleScreen.hs b/src/Mtlstats/Control/TitleScreen.hs index 3bc8ca6..22fcacf 100644 --- a/src/Mtlstats/Control/TitleScreen.hs +++ b/src/Mtlstats/Control/TitleScreen.hs @@ -33,8 +33,7 @@ import Mtlstats.Types titleScreenC :: Controller titleScreenC = Controller { drawController = const $ do - C.drawString titleText - C.drawString $ unlines + C.drawString $ unlines $ titleText ++ [ "" , "Copyright (C) 1984, 1985, 2019, 2020 Rhéal Lamothe" , "" @@ -48,10 +47,24 @@ titleScreenC = Controller _ -> return True } -titleText :: String -titleText = map blockify $ unlines $ foldl joinBlocks (repeat "") +titleText :: [String] +titleText = box $ map (map blockify) $ foldl joinBlocks (repeat "") [chM, chT, chL, chS, chT, chA, chT, chS] +box :: [String] -> [String] +box strs + = [[tl] ++ replicate width horiz ++ [tr]] + ++ map (\str -> [vert] ++ str ++ [vert]) strs + ++ [[bl] ++ replicate width horiz ++ [br]] + where + width = length $ head strs + tl = chr 0x2554 + tr = chr 0x2557 + bl = chr 0x255a + br = chr 0x255d + horiz = chr 0x2550 + vert = chr 0x2551 + blockify :: Char -> Char blockify = \case '#' -> chr 0x2588