summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2022-10-24 20:36:39 -0400
committerAndrew Cady <d@jerkface.net>2022-10-24 20:36:39 -0400
commit89c66649508c2e47b02e4cf2a7f380a0df945b88 (patch)
tree19257e10e31e56da2ffd5c5fa2a8d829f8f32699
parent895c117b266fd59440da6b6a8c340d64289b9ed1 (diff)
rename routine -> session
-rwxr-xr-xrepgoal.hs16
1 files 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)
134data St = St { 134data St = St {
135 _lifts :: [LiftRecord], 135 _lifts :: [LiftRecord],
136 _week :: WeekSelection, 136 _week :: WeekSelection,
137 _routines :: NESeq (Set Text), 137 _sessions :: NESeq (Set Text),
138 _selectedRoutine :: Int 138 _selectedSession :: Int
139} 139}
140makeLenses ''St 140makeLenses ''St
141 141
@@ -174,7 +174,7 @@ lookup' i seq = fromJust $ NESeq.lookup (i `mod` NESeq.length seq) seq
174drawUI :: St -> [Widget ()] 174drawUI :: St -> [Widget ()]
175drawUI st = [vCenter $ vBox [hCenter oneRepMaxTable, header, withVScrollBarHandles $ withVScrollBars OnRight $ viewport () Vertical $ hCenter lastSetTable]] 175drawUI st = [vCenter $ vBox [hCenter oneRepMaxTable, header, withVScrollBarHandles $ withVScrollBars OnRight $ viewport () Vertical $ hCenter lastSetTable]]
176 where 176 where
177 lifts' = filter ((flip Set.member $ view routines st & lookup' (view selectedRoutine st)) . liftName) (view lifts st) 177 lifts' = filter ((flip Set.member $ view sessions st & lookup' (view selectedSession st)) . liftName) (view lifts st)
178 lastSetTable = renderTable $ table $ map (padLeftRight 1 . str) ["Lift", "Set", "Goal", "Done", "Rest"] : concatMap (toLiftRows (view week st)) lifts' 178 lastSetTable = renderTable $ table $ map (padLeftRight 1 . str) ["Lift", "Set", "Goal", "Done", "Rest"] : concatMap (toLiftRows (view week st)) lifts'
179 header = str $ "Week " ++ case (view week st) of Week1 -> "1"; Week2 -> "2"; Week3 -> "3" 179 header = str $ "Week " ++ case (view week st) of Week1 -> "1"; Week2 -> "2"; Week3 -> "3"
180 oneRepMaxTable = renderTable $ table $ map (padLeftRight 1 . str) ["Lift", "Achieved Best", "Computed 1RM"] : map toRow lifts' 180 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
215succ' x | x == maxBound = minBound 215succ' x | x == maxBound = minBound
216succ' x = succ x 216succ' x = succ x
217 217
218clipSelectedRoutine :: St -> St 218clipSelectedSession :: St -> St
219clipSelectedRoutine st = st & selectedRoutine %~ maybeReset 219clipSelectedSession st = st & selectedSession %~ maybeReset
220 where 220 where
221 len = view (routines . to NESeq.length) st 221 len = view (sessions . to NESeq.length) st
222 maybeReset n | n < 0 = len 222 maybeReset n | n < 0 = len
223 maybeReset n | n < len = n 223 maybeReset n | n < len = n
224 maybeReset _ | otherwise = 0 224 maybeReset _ | otherwise = 0
@@ -229,8 +229,8 @@ handleEvent st e = case e of
229 VtyEvent (V.EvKey V.KDown _) -> M.vScrollBy (M.viewportScroll ()) 5 >> continue st 229 VtyEvent (V.EvKey V.KDown _) -> M.vScrollBy (M.viewportScroll ()) 5 >> continue st
230 VtyEvent (V.EvKey V.KUp _) -> M.vScrollBy (M.viewportScroll ()) (-5) >> continue st 230 VtyEvent (V.EvKey V.KUp _) -> M.vScrollBy (M.viewportScroll ()) (-5) >> continue st
231 VtyEvent (V.EvKey (V.KChar 'w') _) -> continue $ st & week %~ succ' 231 VtyEvent (V.EvKey (V.KChar 'w') _) -> continue $ st & week %~ succ'
232 VtyEvent (V.EvKey (V.KChar 'n') _) -> continue $ st & selectedRoutine %~ (+1) & clipSelectedRoutine 232 VtyEvent (V.EvKey (V.KChar 'n') _) -> continue $ st & selectedSession %~ (+1) & clipSelectedSession
233 VtyEvent (V.EvKey (V.KChar 'p') _) -> continue $ st & selectedRoutine %~ (subtract 1) & clipSelectedRoutine 233 VtyEvent (V.EvKey (V.KChar 'p') _) -> continue $ st & selectedSession %~ (subtract 1) & clipSelectedSession
234 VtyEvent _ -> continue st 234 VtyEvent _ -> continue st
235 AppEvent _ -> continue st 235 AppEvent _ -> continue st
236 _ -> continue st 236 _ -> continue st