aboutsummaryrefslogtreecommitdiff
path: root/src/Chelleport
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2024-12-28 14:53:58 +0530
committerAkshay Nair <phenax5@gmail.com>2024-12-28 14:53:58 +0530
commit568923344f0941b2771459dd8dbe935ac971a968 (patch)
tree54a07e8a3c25c85b299fe9d9273620972f03b508 /src/Chelleport
parentb8c389eac5f875fc7ae9a5ab9ac446d24a079448 (diff)
downloadchelleport-568923344f0941b2771459dd8dbe935ac971a968.tar.gz
chelleport-568923344f0941b2771459dd8dbe935ac971a968.zip
Allow clicking with enter
Diffstat (limited to 'src/Chelleport')
-rw-r--r--src/Chelleport/AppState.hs3
-rw-r--r--src/Chelleport/Types.hs24
2 files changed, 14 insertions, 13 deletions
diff --git a/src/Chelleport/AppState.hs b/src/Chelleport/AppState.hs
index 4c8e0a8..fe397e8 100644
--- a/src/Chelleport/AppState.hs
+++ b/src/Chelleport/AppState.hs
@@ -9,6 +9,7 @@ import Chelleport.Types
import Chelleport.Utils (cIntToInt, clamp, intToCInt, isEmpty, itemAt)
import Control.Monad (replicateM_)
import Data.Char (toLower)
+import Data.Default (Default (def))
import Data.Maybe (isJust)
import qualified Text.Fuzzy as Fuzzy
@@ -16,7 +17,7 @@ initialState :: (Monad m) => Configuration -> m (State, Maybe AppAction)
initialState config = do
let cells = either error id $ generateGrid 0 (rows, columns) hintKeys
let action = Just $ SetMode $ configMode config
- pure (defaultAppState {stateGrid = cells}, action)
+ pure (def {stateGrid = cells}, action)
where
rows = 9
columns = 16
diff --git a/src/Chelleport/Types.hs b/src/Chelleport/Types.hs
index cc1a4c3..3deb4a8 100644
--- a/src/Chelleport/Types.hs
+++ b/src/Chelleport/Types.hs
@@ -52,18 +52,18 @@ data State = State
}
deriving (Show, Eq)
-defaultAppState :: State
-defaultAppState =
- State
- { stateGrid = [],
- stateKeySequence = "",
- stateIsMatched = False,
- stateIsShiftPressed = False,
- stateIsDragging = False,
- stateRepetition = 1,
- stateIsModeInitialized = False,
- stateMode = ModeHints
- }
+instance Default State where
+ def =
+ State
+ { stateGrid = [],
+ stateKeySequence = "",
+ stateIsMatched = False,
+ stateIsShiftPressed = False,
+ stateIsDragging = False,
+ stateRepetition = 1,
+ stateIsModeInitialized = False,
+ stateMode = ModeHints
+ }
data Direction = DirUp | DirDown | DirLeft | DirRight
deriving (Show, Eq)