From 89c66649508c2e47b02e4cf2a7f380a0df945b88 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Mon, 24 Oct 2022 20:36:39 -0400 Subject: rename routine -> session --- repgoal.hs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/repgoal.hs b/repgoal.hs index 51820fb..9e96c93 100755 --- a/repgoal.hs +++ b/repgoal.hs @@ -134,8 +134,8 @@ data WeekSelection = Week1 | Week2 | Week3 deriving (Enum, Bounded, Show, Eq) data St = St { _lifts :: [LiftRecord], _week :: WeekSelection, - _routines :: NESeq (Set Text), - _selectedRoutine :: Int + _sessions :: NESeq (Set Text), + _selectedSession :: Int } makeLenses ''St @@ -174,7 +174,7 @@ lookup' i seq = fromJust $ NESeq.lookup (i `mod` NESeq.length seq) seq drawUI :: St -> [Widget ()] drawUI st = [vCenter $ vBox [hCenter oneRepMaxTable, header, withVScrollBarHandles $ withVScrollBars OnRight $ viewport () Vertical $ hCenter lastSetTable]] where - lifts' = filter ((flip Set.member $ view routines st & lookup' (view selectedRoutine st)) . liftName) (view lifts st) + lifts' = filter ((flip Set.member $ view sessions st & lookup' (view selectedSession st)) . liftName) (view lifts st) lastSetTable = renderTable $ table $ map (padLeftRight 1 . str) ["Lift", "Set", "Goal", "Done", "Rest"] : concatMap (toLiftRows (view week st)) lifts' header = str $ "Week " ++ case (view week st) of Week1 -> "1"; Week2 -> "2"; Week3 -> "3" oneRepMaxTable = renderTable $ table $ map (padLeftRight 1 . str) ["Lift", "Achieved Best", "Computed 1RM"] : map toRow lifts' @@ -215,10 +215,10 @@ succ' :: (Enum a, Bounded a, Eq a) => a -> a succ' x | x == maxBound = minBound succ' x = succ x -clipSelectedRoutine :: St -> St -clipSelectedRoutine st = st & selectedRoutine %~ maybeReset +clipSelectedSession :: St -> St +clipSelectedSession st = st & selectedSession %~ maybeReset where - len = view (routines . to NESeq.length) st + len = view (sessions . to NESeq.length) st maybeReset n | n < 0 = len maybeReset n | n < len = n maybeReset _ | otherwise = 0 @@ -229,8 +229,8 @@ handleEvent st e = case e of VtyEvent (V.EvKey V.KDown _) -> M.vScrollBy (M.viewportScroll ()) 5 >> continue st VtyEvent (V.EvKey V.KUp _) -> M.vScrollBy (M.viewportScroll ()) (-5) >> continue st VtyEvent (V.EvKey (V.KChar 'w') _) -> continue $ st & week %~ succ' - VtyEvent (V.EvKey (V.KChar 'n') _) -> continue $ st & selectedRoutine %~ (+1) & clipSelectedRoutine - VtyEvent (V.EvKey (V.KChar 'p') _) -> continue $ st & selectedRoutine %~ (subtract 1) & clipSelectedRoutine + VtyEvent (V.EvKey (V.KChar 'n') _) -> continue $ st & selectedSession %~ (+1) & clipSelectedSession + VtyEvent (V.EvKey (V.KChar 'p') _) -> continue $ st & selectedSession %~ (subtract 1) & clipSelectedSession VtyEvent _ -> continue st AppEvent _ -> continue st _ -> continue st -- cgit v1.2.3