From 82544046ce4a2fb4f37f58dfbe8605800c90f2d9 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 12 Mar 2020 22:09:05 -0400 Subject: [PATCH] add page break to report --- ChangeLog.md | 1 + src/Mtlstats/Control/NewGame.hs | 4 ++-- src/Mtlstats/Report.hs | 26 +++++++++++++++++++++----- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index dbddc58..abd105b 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,6 +2,7 @@ ## current - Ask for database to load on start-up +- Add page break to report file ## 0.14.0 - Fixed a bug that was causing shutouts to not be recorded diff --git a/src/Mtlstats/Control/NewGame.hs b/src/Mtlstats/Control/NewGame.hs index 0dd424b..dcb9922 100644 --- a/src/Mtlstats/Control/NewGame.hs +++ b/src/Mtlstats/Control/NewGame.hs @@ -206,7 +206,7 @@ reportC = Controller C.drawString $ unlines $ slice (s^.scrollOffset) (fromInteger $ pred rows) - (report (fromInteger $ pred cols) s) + (displayReport (fromInteger $ pred cols) s) return C.CursorInvisible , handleController = \e -> do case e of @@ -215,7 +215,7 @@ reportC = Controller C.EventSpecialKey C.KeyHome -> modify $ scrollOffset .~ 0 C.EventCharacter '\n' -> do - get >>= liftIO . writeFile reportFilename . unlines . report reportCols + get >>= liftIO . writeFile reportFilename . exportReport reportCols modify backHome _ -> return () diff --git a/src/Mtlstats/Report.hs b/src/Mtlstats/Report.hs index 7385adc..fd08afc 100644 --- a/src/Mtlstats/Report.hs +++ b/src/Mtlstats/Report.hs @@ -19,7 +19,7 @@ along with this program. If not, see . -} -module Mtlstats.Report (report, gameDate) where +module Mtlstats.Report (displayReport, exportReport, gameDate) where import Data.List (sortOn) import qualified Data.Map as M @@ -34,21 +34,37 @@ import Mtlstats.Helpers.Player import Mtlstats.Types import Mtlstats.Util --- | Generates the report -report +-- | Generates the report displayed on screen +displayReport :: Int -- ^ The number of columns for the report -> ProgState -- ^ The program state -> [String] +displayReport width s + = report width s + ++ [""] + ++ lifetimeStatsReport width s + +-- | Generates the report to be exported to file +exportReport + :: Int + -- ^ The number of columns in the report + -> ProgState + -- ^ The program state + -> String +exportReport width s + = unlines (report width s) + ++ "\f" + ++ unlines (lifetimeStatsReport width s) + +report :: Int -> ProgState -> [String] report width s = standingsReport width s ++ [""] ++ gameStatsReport width s ++ [""] ++ yearToDateStatsReport width s - ++ [""] - ++ lifetimeStatsReport width s standingsReport :: Int -> ProgState -> [String] standingsReport width s = fromMaybe [] $ do