diff options
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | chelleport.cabal | 1 | ||||
| -rw-r--r-- | src/Chelleport/AppState.hs | 3 |
3 files changed, 4 insertions, 2 deletions
@@ -6,7 +6,7 @@ Control your mouse pointer entirely with your keyboard. ## Modes - **Labelled Hints mode (default. `ctrl+t`)**: Displays a grid overlay on your screen, where each cell is labeled with a unique two-key combination. Press the corresponding keys to move the cursor to the desired cell. -- **Text Search mode (`ctrl+s`)**: Uses OCR to identify and highlight words on the screen, allowing you to search for text and move the cursor directly to matching text. +- **Text Search mode (`ctrl+s`)**: Uses OCR to identify and highlight words on the screen, allowing you to fuzzy search for text and move the cursor directly to matching text. --- diff --git a/chelleport.cabal b/chelleport.cabal index e06cbc6..24ee97f 100644 --- a/chelleport.cabal +++ b/chelleport.cabal @@ -75,6 +75,7 @@ library lib-chelleport build-depends: bytestring, file-embed == 0.0.16.0, + fuzzy == 0.1.1.0, sdl2-ttf == 2.1.3, vector == 0.13.1.0, X11 == 1.10.3 diff --git a/src/Chelleport/AppState.hs b/src/Chelleport/AppState.hs index 697e9c4..72a1afe 100644 --- a/src/Chelleport/AppState.hs +++ b/src/Chelleport/AppState.hs @@ -11,6 +11,7 @@ import Control.Monad (replicateM_) import Data.Char (toLower) import Data.List (isInfixOf) import Data.Maybe (fromMaybe, isJust) +import qualified Text.Fuzzy as Fuzzy initialState :: (Monad m) => m (State, Maybe AppAction) initialState = do @@ -67,7 +68,7 @@ update state@(State {stateMode = ModeSearch {searchWords, searchInputText}}) (Ha mode = stateMode state filterMatches text | isEmpty text = searchWords - | otherwise = filter (isInfixOf text . map toLower . matchText) searchWords + | otherwise = Fuzzy.original <$> Fuzzy.filter text searchWords "" "" matchText False -- Increment highlighted index for search mode update state (IncrementHighlightIndex n) = do |
