From d8e26f2b630c87400d2073cbd6123ffc4624b5f3 Mon Sep 17 00:00:00 2001 From: James Stout Date: Fri, 16 Feb 2024 17:16:08 -0800 Subject: [PATCH] Add new "paste link to" action and improve reliability of homophones command. --- gaze_ocr.talon | 2 +- gaze_ocr_talon.py | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/gaze_ocr.talon b/gaze_ocr.talon index b2b8e1e..9984734 100644 --- a/gaze_ocr.talon +++ b/gaze_ocr.talon @@ -92,7 +92,7 @@ replace [{user.ocr_modifiers}] [seen | scene] with say $: user.insert_adjacent_to_text(timestamped_prose, "after", prose) -phones (seen | scene) $: +phones [word] (seen | scene) $: user.change_text_homophone(timestamped_prose) ocr tracker on: user.connect_ocr_eye_tracker() diff --git a/gaze_ocr_talon.py b/gaze_ocr_talon.py index 16f56bb..4bb59a4 100644 --- a/gaze_ocr_talon.py +++ b/gaze_ocr_talon.py @@ -92,6 +92,7 @@ "copy": "copy", "carve": "cut", "paste to": "paste", + "paste link to": "paste_link", "clear": "delete", "change": "delete", "delete": "delete_with_whitespace", @@ -496,6 +497,10 @@ def perform_ocr_action_generator( actions.edit.cut() elif ocr_action == "paste": actions.edit.paste() + elif ocr_action == "paste_link": + actions.user.hyperlink() + actions.sleep("100ms") + actions.edit.paste() elif ocr_action in ("delete", "delete_with_whitespace"): actions.key("backspace") elif ocr_action == "capitalize": @@ -806,7 +811,10 @@ def change_text_homophone(text: TimestampedText): """Switch the on-screen text to a different homophone.""" def run(): - yield from select_text_generator(text) + # Use click instead of selection because it is more reliable. + yield from move_cursor_to_word_generator(text) + actions.mouse_click(0) + actions.edit.select_word() actions.user.homophones_show_selection() begin_generator(run())