aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2024-12-28 22:25:13 +0530
committerAkshay Nair <phenax5@gmail.com>2024-12-28 22:57:53 +0530
commitc1e05401d5c3cf90440e62a3423d2b52cfc46999 (patch)
treec68665ae84a2bd4c289865b2742a8a9752b83197
parent1d617d9db665ee9df209777626752a19496387b4 (diff)
downloadchelleport-c1e05401d5c3cf90440e62a3423d2b52cfc46999.tar.gz
chelleport-c1e05401d5c3cf90440e62a3423d2b52cfc46999.zip
Add <c-r> to refresh mode (reload ocr results) + fix search mode reset issue
-rw-r--r--README.md1
-rw-r--r--TODO.norg3
-rw-r--r--src/Chelleport.hs3
-rw-r--r--src/Chelleport/AppState.hs4
4 files changed, 7 insertions, 4 deletions
diff --git a/README.md b/README.md
index f236564..f529888 100644
--- a/README.md
+++ b/README.md
@@ -60,6 +60,7 @@ Use [sxhkd](https://github.com/baskerville/sxhkd), [shotkey](https://github.com/
- Type the characters in one of the words to move the cursor to it
- Press `ctrl+n` & `ctrl+p` to go to next/previous match respectively
- NOTE: The startup is a little slow currently taking ~1 second to run ocr. Will keep optimizing to get this down.
+- Press `ctrl+r` to reload the OCR results if contents on the page changed
## Feedback and Support
diff --git a/TODO.norg b/TODO.norg
index 591118c..d67c110 100644
--- a/TODO.norg
+++ b/TODO.norg
@@ -6,11 +6,10 @@
* Later
- ( ) Look into making mouse controls (click/mouse down/mouse up) cross-platform
- ( ) Look into making screenshot cross-platform
- - ( ) Lens-ey setup for Mode access
- ( ) Support 4k screen resolution?
* Maybe
- - ( ) Scroll
- ( ) Rethink keybindings
- ( ) Custom configuration?
+ - ( ) Scroll
- ( ) Process mode? Run in bg with root key binding to toggle
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
+ -- <C-r>: Refresh current mode
+ | checkKey [ctrl, key SDL.KeycodeR, pressed] ev ->
+ Just $ SetMode $ stateMode state
-- <C-s>: 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