aboutsummaryrefslogtreecommitdiff
path: root/src/Chelleport
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Chelleport.hs2
-rw-r--r--src/Chelleport/View.hs15
2 files changed, 10 insertions, 7 deletions
diff --git a/src/Chelleport.hs b/src/Chelleport.hs
index 8cc02c7..6486b4a 100644
--- a/src/Chelleport.hs
+++ b/src/Chelleport.hs
@@ -24,7 +24,7 @@ run config = do
runAppWithCtx :: (MonadIO m) => DrawContext -> AppM m x -> m x
runAppWithCtx ctx = (`runReaderT` ctx) . runAppM
--- TODO: Make event handling independent of state
+-- TODO: Make event handling independent of state?
eventHandler :: State -> SDL.Event -> Maybe AppAction
eventHandler state event =
case SDL.eventPayload event of
diff --git a/src/Chelleport/View.hs b/src/Chelleport/View.hs
index 314aa39..369b93d 100644
--- a/src/Chelleport/View.hs
+++ b/src/Chelleport/View.hs
@@ -27,13 +27,16 @@ getSearchText state (ModeSearchData {searchInputText, searchFilteredWords, searc
renderSearchView :: (MonadDraw m) => State -> ModeSearchData -> m ()
renderSearchView state searchData@(ModeSearchData {searchFilteredWords, searchHighlightedIndex}) = do
renderGridLines state
+ mapM_ highlightWord $ zip [0 ..] searchFilteredWords
+ drawSearchText
+ where
+ highlightWord (index, OCRMatch {matchStartX, matchStartY, matchEndX, matchEndY}) = do
+ setDrawColor $ if searchHighlightedIndex == index then colorAccent else colorLightGray
+ fillRectVertices (matchStartX, matchStartY) (matchEndX, matchEndY)
- forM_ (zip [0 ..] searchFilteredWords) $ \(index, OCRMatch {matchStartX, matchStartY, matchEndX, matchEndY}) -> do
- setDrawColor $ if searchHighlightedIndex == index then colorAccent else colorLightGray
- fillRectVertices (matchStartX, matchStartY) (matchEndX, matchEndY)
-
- (w, h) <- windowSize
- void $ drawText (w `div` 2, 5 + h `div` 2) searchingTextStyle (Text.pack $ getSearchText state searchData)
+ drawSearchText = do
+ (w, h) <- windowSize
+ void $ drawText (w `div` 2, 5 + h `div` 2) searchingTextStyle (Text.pack $ getSearchText state searchData)
renderHintsView :: (MonadDraw m) => State -> ModeHintsData -> m ()
renderHintsView state (ModeHintsData {stateGrid, stateKeySequence, stateIsMatched}) = do