From c1e05401d5c3cf90440e62a3423d2b52cfc46999 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sat, 28 Dec 2024 22:25:13 +0530 Subject: Add to refresh mode (reload ocr results) + fix search mode reset issue --- src/Chelleport.hs | 3 +++ src/Chelleport/AppState.hs | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Chelleport.hs b/src/Chelleport.hs index 4ad20a0..d4c21ed 100644 --- a/src/Chelleport.hs +++ b/src/Chelleport.hs @@ -32,6 +32,9 @@ eventHandler state event = -- Esc: Quit | checkKey [key SDL.KeycodeEscape, pressed] ev -> Just ShutdownApp + -- : Refresh current mode + | checkKey [ctrl, key SDL.KeycodeR, pressed] ev -> + Just $ SetMode $ stateMode state -- : Enable search mode | checkKey [ctrl, key SDL.KeycodeS, pressed] ev -> Just $ SetMode $ ModeSearch def diff --git a/src/Chelleport/AppState.hs b/src/Chelleport/AppState.hs index a304c96..bcb7dce 100644 --- a/src/Chelleport/AppState.hs +++ b/src/Chelleport/AppState.hs @@ -132,7 +132,7 @@ update _ state ResetKeys = do where resetMode (ModeHints hintsData) = ModeHints $ hintsData {stateKeySequence = [], stateIsMatched = False} resetMode (ModeSearch searchData@(ModeSearchData {searchWords})) = - ModeSearch $ searchData {searchWords = searchWords, searchFilteredWords = searchWords} + ModeSearch $ searchData {searchWords = searchWords, searchFilteredWords = searchWords, searchInputText = ""} -- Initialize current mode update flush state InitializeMode = @@ -149,7 +149,7 @@ update flush state InitializeMode = showWindow flush matches <- getWordsInImage screenshot - let updatedSearchData = searchData {searchWords = matches, searchFilteredWords = matches} + let updatedSearchData = searchData {searchWords = matches, searchFilteredWords = matches, searchInputText = ""} pure (state {stateMode = ModeSearch updatedSearchData, stateIsModeInitialized = True}, Nothing) -- Set mode -- cgit v1.3.1