From 82d612b7c37b432bc4abd8e158d6fe076d391ddc Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Wed, 25 Dec 2024 00:17:52 +0530 Subject: Add and to walk through matches --- src/Chelleport/View.hs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/Chelleport/View.hs') 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 () -- cgit v1.3.1