aboutsummaryrefslogtreecommitdiff
path: root/src/Chelleport/View.hs
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2024-12-25 00:17:52 +0530
committerAkshay Nair <phenax5@gmail.com>2024-12-25 00:32:39 +0530
commit82d612b7c37b432bc4abd8e158d6fe076d391ddc (patch)
treeef61b3910e5a54fc0ff581e36392e27150ccf470 /src/Chelleport/View.hs
parent459488a2e777380fcb65e3b4dd355fe525ff77ca (diff)
downloadchelleport-82d612b7c37b432bc4abd8e158d6fe076d391ddc.tar.gz
chelleport-82d612b7c37b432bc4abd8e158d6fe076d391ddc.zip
Add <c-n> and <c-p> to walk through matches
Diffstat (limited to '')
-rw-r--r--src/Chelleport/View.hs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/Chelleport/View.hs b/src/Chelleport/View.hs
index 1a4f1f8..c2e0ff8 100644
--- a/src/Chelleport/View.hs
+++ b/src/Chelleport/View.hs
@@ -12,13 +12,14 @@ import Foreign.C (CInt)
render :: (MonadDraw m) => State -> m ()
render state = case stateMode state of
ModeHints -> renderHintsView state
- ModeSearch {searchFilteredWords} -> renderSearchView state searchFilteredWords
+ ModeSearch {searchFilteredWords, searchHighlightedIndex} ->
+ renderSearchView state searchFilteredWords searchHighlightedIndex
-renderSearchView :: (MonadDraw m) => State -> [OCRMatch] -> m ()
-renderSearchView state matches = do
+renderSearchView :: (MonadDraw m) => State -> [OCRMatch] -> Int -> m ()
+renderSearchView state matches highlightedIndex = do
renderGridLines state
- setDrawColor colorWhite
- forM_ matches $ \(OCRMatch {matchStartX, matchStartY, matchEndX, matchEndY}) -> do
+ forM_ (zip [0 ..] matches) $ \(index, OCRMatch {matchStartX, matchStartY, matchEndX, matchEndY}) -> do
+ setDrawColor $ if highlightedIndex == index then colorAccent else colorLightGray
fillRectVertices (matchStartX, matchStartY) (matchEndX, matchEndY)
renderHintsView :: (MonadDraw m) => State -> m ()