Files
abacus/src/Abacus/App/Actions.hs

44 lines
1.2 KiB
Haskell

{-|
Module : Abacus.App.Actions
Description : Transformations on the applicaiton state
Copyright : (C) Jonathan Lamothe
License : AGPL-3.0-or-later
Maintainer : jonathan@jlamothe.net
Stability : experimental
Portability : POSIX
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public
License along with this program. If not, see
<https://www.gnu.org/licenses/>.
-}
module Abacus.App.Actions (moveUp, moveDown) where
import Lens.Micro.Platform ((^.), (&), (%~))
import Abacus
import Abacus.App.Types
-- Moves the cursor up
moveUp :: AppState -> AppState
moveUp = rungNum %~ (max 0 . pred)
-- Moves the cursor down
moveDown :: AppState -> AppState
moveDown s = s & rungNum %~
(min (pred $ getNumRungs $ s^.abacus) . succ)
--jl