Compare commits

...
9 Commits
Author SHA1 Message Date
jlamothe a5679cb1fc version 0.17.0 2023-06-02 15:30:44 -04:00
jlamothe bdbf7daf4e Merge pull request 'switch from ncurses to brick' (#1) from brick into dev
Reviewed-on: #1
2023-06-02 15:28:41 -04:00
jlamothe e0efe2657f ynHandler should ignore keypresses with modifier keys 2023-06-02 15:26:22 -04:00
jlamothe 886cf0b243 even more stylistic changes
I hope to God I'm done with these now.
2023-06-01 19:51:04 -04:00
jlamothe 251dc90cea more stylistic changes 2023-06-01 19:06:46 -04:00
jlamothe 17b3f9a03e minor stylistic edits 2023-06-01 18:39:46 -04:00
jlamothe 01457dbe6f removed signature line 2023-06-01 17:18:09 -04:00
jlamothe 134787e1be removed Travis CI configuration file 2023-06-01 17:15:29 -04:00
jlamothe 284a8c6725 various layout fixes 2023-05-31 22:19:18 -04:00
13 changed files with 42 additions and 74 deletions
-40
View File
@@ -1,40 +0,0 @@
# This is the simple Travis configuration, which is intended for use
# on applications which do not require cross-platform and
# multiple-GHC-version support. For more information and other
# options, see:
#
# https://docs.haskellstack.org/en/stable/travis_ci/
#
# Copy these contents into the root directory of your Github project in a file
# named .travis.yml
# Choose a build environment
dist: xenial
# Do not choose a language; we provide our own build tools.
language: generic
# Caching so the next build will be fast too.
cache:
directories:
- $HOME/.stack
# Ensure necessary system libraries are present
addons:
apt:
packages:
- libgmp-dev
before_install:
# Download and unpack the stack executable
- mkdir -p ~/.local/bin
- export PATH=$HOME/.local/bin:$PATH
- travis_retry curl -L https://get.haskellstack.org/stable/linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
install:
# Build dependencies
- stack --no-terminal --install-ghc test --only-dependencies
script:
# Build the package, its tests, and its docs and run the tests
- stack --no-terminal test --haddock --no-haddock-deps
+1 -1
View File
@@ -3,7 +3,7 @@
## current ## current
- updated code to use brick instead of ncurses - updated code to use brick instead of ncurses
## 0.16.1 ## 0.17.0
- Don't automatically start a new game on new season - Don't automatically start a new game on new season
## 0.16.0 ## 0.16.0
+1 -1
View File
@@ -1,5 +1,5 @@
name: mtlstats name: mtlstats
version: 0.16.1 version: 0.17.0
license: GPL-3.0-or-later license: GPL-3.0-or-later
author: "Jonathan Lamothe" author: "Jonathan Lamothe"
maintainer: "jlamothe1980@gmail.com" maintainer: "jlamothe1980@gmail.com"
+2 -5
View File
@@ -26,14 +26,13 @@ import Brick.Main (App (..), halt, showFirstCursor)
import Brick.Types (BrickEvent (VtyEvent), Widget) import Brick.Types (BrickEvent (VtyEvent), Widget)
import Brick.Util (on) import Brick.Util (on)
import Brick.Widgets.Core (fill) import Brick.Widgets.Core (fill)
import Control.Monad.State.Class (gets)
import Graphics.Vty.Attributes.Color (blue, white) import Graphics.Vty.Attributes.Color (blue, white)
import Graphics.Vty.Input.Events import Graphics.Vty.Input.Events
( Event (EvKey) ( Event (EvKey)
, Modifier (MCtrl) , Modifier (MCtrl)
, Key (KChar) , Key (KChar)
) )
import Lens.Micro (to)
import Lens.Micro.Mtl (use)
import Mtlstats.Control import Mtlstats.Control
import Mtlstats.Types import Mtlstats.Types
@@ -57,10 +56,8 @@ draw s =
handler :: Handler () handler :: Handler ()
handler (VtyEvent (EvKey (KChar 'c') [MCtrl])) = halt handler (VtyEvent (EvKey (KChar 'c') [MCtrl])) = halt
handler e = do handler e = do
c <- use (to dispatch) c <- gets dispatch
handleController c e handleController c e
myAttrMap :: AttrMap myAttrMap :: AttrMap
myAttrMap = forceAttrMap (white `on` blue) myAttrMap = forceAttrMap (white `on` blue)
--jl
+2 -1
View File
@@ -24,6 +24,7 @@ module Mtlstats.Control.CreateGoalie (createGoalieC) where
import Brick.Widgets.Core (str) import Brick.Widgets.Core (str)
import Control.Monad.State.Class (gets, modify) import Control.Monad.State.Class (gets, modify)
import Lens.Micro ((^.), (.~), (?~), (%~), to) import Lens.Micro ((^.), (.~), (?~), (%~), to)
import Lens.Micro.Mtl ((.=))
import Mtlstats.Actions import Mtlstats.Actions
import Mtlstats.Format import Mtlstats.Format
@@ -63,7 +64,7 @@ getActiveFlagC :: Controller
getActiveFlagC = Controller getActiveFlagC = Controller
{ drawController = const $ str "Is this goalie active? (Y/N)" { drawController = const $ str "Is this goalie active? (Y/N)"
, handleController = \e -> , handleController = \e ->
modify $ progMode.createGoalieStateL.cgsActiveFlag .~ ynHandler e progMode.createGoalieStateL.cgsActiveFlag .= ynHandler e
} }
confirmCreateGoalieC :: Controller confirmCreateGoalieC :: Controller
+3 -2
View File
@@ -24,6 +24,7 @@ module Mtlstats.Control.CreatePlayer (createPlayerC) where
import Brick.Widgets.Core (str) import Brick.Widgets.Core (str)
import Control.Monad.State.Class (gets, modify) import Control.Monad.State.Class (gets, modify)
import Lens.Micro ((^.), (.~), (?~), (%~), to) import Lens.Micro ((^.), (.~), (?~), (%~), to)
import Lens.Micro.Mtl ((.=), use)
import Mtlstats.Actions import Mtlstats.Actions
import Mtlstats.Format import Mtlstats.Format
@@ -66,7 +67,7 @@ getActiveFlagC :: Controller
getActiveFlagC = Controller getActiveFlagC = Controller
{ drawController = const $ str "Is the player active? (Y/N)" { drawController = const $ str "Is the player active? (Y/N)"
, handleController = \e -> , handleController = \e ->
modify $ progMode.createPlayerStateL.cpsActiveFlag .~ ynHandler e progMode.createPlayerStateL.cpsActiveFlag .= ynHandler e
} }
confirmCreatePlayerC :: Controller confirmCreatePlayerC :: Controller
@@ -84,7 +85,7 @@ confirmCreatePlayerC = Controller
, "Create player: are you sure? (Y/N)" , "Create player: are you sure? (Y/N)"
] ]
, handleController = \e -> do , handleController = \e -> do
cps <- gets (^.progMode.createPlayerStateL) cps <- use $ progMode.createPlayerStateL
let let
success = cps^.cpsSuccessCallback success = cps^.cpsSuccessCallback
failure = cps^.cpsFailureCallback failure = cps^.cpsFailureCallback
+6 -5
View File
@@ -25,9 +25,10 @@ module Mtlstats.Control.EditGoalie (editGoalieC) where
import Brick.Types (Widget) import Brick.Types (Widget)
import Brick.Widgets.Core (str, vBox) import Brick.Widgets.Core (str, vBox)
import Control.Monad.State.Class (gets, modify) import Control.Monad.State.Class (modify)
import Data.Maybe (fromMaybe) import Data.Maybe (fromMaybe)
import Lens.Micro ((^.), (.~), (%~)) import Lens.Micro ((^.))
import Lens.Micro.Mtl ((.=), (%=), use)
import Mtlstats.Actions import Mtlstats.Actions
import Mtlstats.Handlers import Mtlstats.Handlers
@@ -99,10 +100,10 @@ deleteC _ = Controller
in str $ hdr ++ "Are you sure you want to delete this goalie? (Y/N)" in str $ hdr ++ "Are you sure you want to delete this goalie? (Y/N)"
, handleController = \e -> case ynHandler e of , handleController = \e -> case ynHandler e of
Just True -> do Just True -> do
gets (^.progMode.editGoalieStateL.egsSelectedGoalie) >>= mapM_ use (progMode.editGoalieStateL.egsSelectedGoalie) >>= mapM_
(\gid -> modify $ database.dbGoalies %~ dropNth gid) (\gid -> database.dbGoalies %= dropNth gid)
modify edit modify edit
Just False -> modify $ progMode.editGoalieStateL.egsMode .~ EGMenu Just False -> progMode.editGoalieStateL.egsMode .= EGMenu
Nothing -> return () Nothing -> return ()
} }
+6 -5
View File
@@ -23,9 +23,10 @@ module Mtlstats.Control.EditPlayer (editPlayerC) where
import Brick.Types (Widget) import Brick.Types (Widget)
import Brick.Widgets.Core (emptyWidget, str, vBox) import Brick.Widgets.Core (emptyWidget, str, vBox)
import Control.Monad.State.Class (gets, modify) import Control.Monad.State.Class (modify)
import Data.Maybe (fromMaybe) import Data.Maybe (fromMaybe)
import Lens.Micro ((^.), (.~), (%~)) import Lens.Micro ((^.))
import Lens.Micro.Mtl ((.=), (%=), use)
import Mtlstats.Actions import Mtlstats.Actions
import Mtlstats.Handlers import Mtlstats.Handlers
@@ -90,10 +91,10 @@ deleteC _ = Controller
in str $ hdr ++ "Are you sure you want to delete this player? (Y/N)" in str $ hdr ++ "Are you sure you want to delete this player? (Y/N)"
, handleController = \e -> case ynHandler e of , handleController = \e -> case ynHandler e of
Just True -> do Just True -> do
gets (^.progMode.editPlayerStateL.epsSelectedPlayer) >>= mapM_ use (progMode.editPlayerStateL.epsSelectedPlayer) >>= mapM_
(\pid -> modify $ database.dbPlayers %~ dropNth pid) (\pid -> database.dbPlayers %= dropNth pid)
modify edit modify edit
Just False -> modify $ progMode.editPlayerStateL.epsMode .~ EPMenu Just False -> progMode.editPlayerStateL.epsMode .= EPMenu
Nothing -> return () Nothing -> return ()
} }
+6 -2
View File
@@ -24,7 +24,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
module Mtlstats.Control.EditStandings (editStandingsC) where module Mtlstats.Control.EditStandings (editStandingsC) where
import Brick.Types (Widget) import Brick.Types (Widget)
import Brick.Widgets.Core (str, vBox) import Brick.Widgets.Core (vBox)
import Lens.Micro ((^.)) import Lens.Micro ((^.))
import Mtlstats.Format import Mtlstats.Format
@@ -34,6 +34,7 @@ import Mtlstats.Prompt
import Mtlstats.Prompt.EditStandings import Mtlstats.Prompt.EditStandings
import Mtlstats.Types import Mtlstats.Types
import Mtlstats.Types.Menu import Mtlstats.Types.Menu
import Mtlstats.Util
-- | Controller for the edit standings menu -- | Controller for the edit standings menu
editStandingsC :: EditStandingsMode -> Controller editStandingsC :: EditStandingsMode -> Controller
@@ -75,7 +76,10 @@ header s w = let
[ ( "HOME", valsFor home ) [ ( "HOME", valsFor home )
, ( "ROAD", valsFor away ) , ( "ROAD", valsFor away )
] ]
in vBox $ map str (table ++ [""]) ++ [w] in vBox
[ linesToWidget $ table ++ [""]
, w
]
valsFor :: GameStats -> [Int] valsFor :: GameStats -> [Int]
valsFor gs = valsFor gs =
+10 -7
View File
@@ -37,7 +37,7 @@ import Graphics.Vty.Input.Events
, Key (KDown, KHome, KEnter, KUp) , Key (KDown, KHome, KEnter, KUp)
) )
import Lens.Micro ((^.), (.~)) import Lens.Micro ((^.), (.~))
import Lens.Micro.Mtl (use) import Lens.Micro.Mtl ((.=), use)
import Mtlstats.Actions import Mtlstats.Actions
import Mtlstats.Actions.NewGame import Mtlstats.Actions.NewGame
@@ -96,14 +96,14 @@ overtimeFlagC = Controller
{ drawController = \s -> header s $ { drawController = \s -> header s $
str "Did the game go into overtime? (Y/N)" str "Did the game go into overtime? (Y/N)"
, handleController = \e -> , handleController = \e ->
modify $ progMode.gameStateL.overtimeFlag .~ ynHandler e progMode.gameStateL.overtimeFlag .= ynHandler e
} }
verifyDataC :: Controller verifyDataC :: Controller
verifyDataC = Controller verifyDataC = Controller
{ drawController = \s -> let { drawController = \s -> let
gs = s^.progMode.gameStateL gs = s^.progMode.gameStateL
in header s $ vBox $ map str $ in header s $ linesToWidget $
[""] ++ [""] ++
labelTable labelTable
[ ( "Date", gameDate gs ) [ ( "Date", gameDate gs )
@@ -172,7 +172,7 @@ confirmGoalDataC = Controller
[ "" [ ""
, "Is the above information correct? (Y/N)" , "Is the above information correct? (Y/N)"
] ]
in vBox $ map str msg in linesToWidget msg
, handleController = \e -> do , handleController = \e -> do
case ynHandler e of case ynHandler e of
Just True -> modify recordGoalAssists Just True -> modify recordGoalAssists
@@ -201,7 +201,7 @@ getPMinsC = Controller
reportC :: Controller reportC :: Controller
reportC = Controller reportC = Controller
{ drawController = viewport () Vertical . hCenter . vBox . map str . { drawController = viewport () Vertical . hCenter . linesToWidget .
displayReport reportCols displayReport reportCols
, handleController = \e -> do , handleController = \e -> do
scr <- use scroller scr <- use scroller
@@ -239,8 +239,11 @@ monthHeader s w = let
, "NOVEMBER" , "NOVEMBER"
, "DECEMBER" , "DECEMBER"
] ]
in header s $ vBox $ map (hCenter . str) in header s $ vBox
(["MONTH:", ""] ++ table ++ [""]) ++ [w] [ linesToWidgetC $
["MONTH:", ""] ++ table ++ [""]
, w
]
gameGoal :: ProgState -> (Int, Int) gameGoal :: ProgState -> (Int, Int)
gameGoal s = gameGoal s =
+1 -1
View File
@@ -47,7 +47,7 @@ titleScreenC = Controller
] ]
, handleController = \case , handleController = \case
VtyEvent (EvKey _ _) -> modify backHome VtyEvent (EvKey _ _) -> modify backHome
_ -> return () _ -> return ()
} }
titleText :: [String] titleText :: [String]
+1 -1
View File
@@ -27,7 +27,7 @@ import Graphics.Vty.Input.Events (Event (EvKey), Key (KChar))
-- | Handler for a yes/no prompt -- | Handler for a yes/no prompt
ynHandler :: BrickEvent () () -> Maybe Bool ynHandler :: BrickEvent () () -> Maybe Bool
ynHandler (VtyEvent (EvKey (KChar c) _)) = case toUpper c of ynHandler (VtyEvent (EvKey (KChar c) [])) = case toUpper c of
'Y' -> Just True 'Y' -> Just True
'N' -> Just False 'N' -> Just False
_ -> Nothing _ -> Nothing
+3 -3
View File
@@ -77,9 +77,9 @@ promptHandler p (VtyEvent (EvKey KEnter [])) = do
editorW %= clearEditor editorW %= clearEditor
promptAction p val promptAction p val
promptHandler p (VtyEvent (EvKey (KChar c) [])) = promptHandler p (VtyEvent (EvKey (KChar c) [])) =
modify $ editorW %~ promptProcessChar p c editorW %= promptProcessChar p c
promptHandler _ (VtyEvent (EvKey KBS [])) = promptHandler _ (VtyEvent (EvKey KBS [])) =
modify (editorW.editContentsL %~ deletePrevChar) editorW.editContentsL %= deletePrevChar
promptHandler p (VtyEvent (EvKey k m)) = promptHandler p (VtyEvent (EvKey k m)) =
promptSpecialKey p k m promptSpecialKey p k m
promptHandler _ _ = return () promptHandler _ _ = return ()
@@ -243,7 +243,7 @@ selectPrompt params = Prompt
results = spSearch params sStr db results = spSearch params sStr db
when (n < maxFunKeys) $ when (n < maxFunKeys) $
whenJust (nth n results) $ \(sel, _) -> do whenJust (nth n results) $ \(sel, _) -> do
modify $ editorW %~ clearEditor editorW %= clearEditor
spCallback params $ Just sel spCallback params $ Just sel
_ -> return () _ -> return ()
} }