Merge pull request #81 from mtlstats/page-break

add page break to report
This commit is contained in:
Jonathan Lamothe 2020-03-12 22:14:40 -04:00 committed by GitHub
commit 7ca66ad801
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 7 deletions

View File

@ -2,6 +2,7 @@
## current ## current
- Ask for database to load on start-up - Ask for database to load on start-up
- Add page break to report file
## 0.14.0 ## 0.14.0
- Fixed a bug that was causing shutouts to not be recorded - Fixed a bug that was causing shutouts to not be recorded

View File

@ -206,7 +206,7 @@ reportC = Controller
C.drawString $ unlines $ slice C.drawString $ unlines $ slice
(s^.scrollOffset) (s^.scrollOffset)
(fromInteger $ pred rows) (fromInteger $ pred rows)
(report (fromInteger $ pred cols) s) (displayReport (fromInteger $ pred cols) s)
return C.CursorInvisible return C.CursorInvisible
, handleController = \e -> do , handleController = \e -> do
case e of case e of
@ -215,7 +215,7 @@ reportC = Controller
C.EventSpecialKey C.KeyHome -> modify $ scrollOffset .~ 0 C.EventSpecialKey C.KeyHome -> modify $ scrollOffset .~ 0
C.EventCharacter '\n' -> do C.EventCharacter '\n' -> do
get >>= liftIO . writeFile reportFilename . unlines . report reportCols get >>= liftIO . writeFile reportFilename . exportReport reportCols
modify backHome modify backHome
_ -> return () _ -> return ()

View File

@ -19,7 +19,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
-} -}
module Mtlstats.Report (report, gameDate) where module Mtlstats.Report (displayReport, exportReport, gameDate) where
import Data.List (sortOn) import Data.List (sortOn)
import qualified Data.Map as M import qualified Data.Map as M
@ -34,21 +34,37 @@ import Mtlstats.Helpers.Player
import Mtlstats.Types import Mtlstats.Types
import Mtlstats.Util import Mtlstats.Util
-- | Generates the report -- | Generates the report displayed on screen
report displayReport
:: Int :: Int
-- ^ The number of columns for the report -- ^ The number of columns for the report
-> ProgState -> ProgState
-- ^ The program state -- ^ The program state
-> [String] -> [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 report width s
= standingsReport width s = standingsReport width s
++ [""] ++ [""]
++ gameStatsReport width s ++ gameStatsReport width s
++ [""] ++ [""]
++ yearToDateStatsReport width s ++ yearToDateStatsReport width s
++ [""]
++ lifetimeStatsReport width s
standingsReport :: Int -> ProgState -> [String] standingsReport :: Int -> ProgState -> [String]
standingsReport width s = fromMaybe [] $ do standingsReport width s = fromMaybe [] $ do