Skip to content

Commit

Permalink
Creates the "find" tag and removes that functionality from "find_and_…
Browse files Browse the repository at this point in the history
…replace" (talonhub#1404)

The idea is to have a separate "find" tag for very basic search
functionality. The reason is that there are many types of applications
that are mostly view only (webbrowsers, pdf readers, etc.). These
applications would not benefit from the full functionality of the
"find_and_replace" tag.

In order not to define some voice commands twice, I made the
"find_and_replace" tag automatically activate the new "find" tag as well
and removed what would have been duplicate definitions.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Nicholas Riley <com-github@sabi.net>
  • Loading branch information
3 people authored Jun 1, 2024
1 parent 18c0aa4 commit 5ebcea7
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 22 deletions.
6 changes: 5 additions & 1 deletion apps/eclipse/eclipse_win.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def split_window():

# splits.py support end

# find_and_replace.py support begin
# find.py support begin

def find(text: str):
"""Triggers find in current editor"""
Expand All @@ -125,6 +125,10 @@ def find_next():
def find_previous():
actions.key("shift-enter")

# find.py support end

# find_and_replace.py support begin

def find_everywhere(text: str):
"""Triggers find across project"""
actions.key("ctrl-h")
Expand Down
6 changes: 5 additions & 1 deletion apps/notepad++/notepad++_win.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def tab_final():
print("Notepad doesn't support this...")
# actions.key("ctrl-numpad_0")

# find_and_replace.py support begin
# find.py support begin

def find(text: str):
"""Triggers find in current editor"""
Expand All @@ -111,6 +111,10 @@ def find_next():
def find_previous():
actions.key("shift-enter")

# find.py support end

# find_and_replace.py support begin

def find_everywhere(text: str):
"""Triggers find across project"""

Expand Down
6 changes: 5 additions & 1 deletion apps/visualstudio/visual_studio.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class UserActions:

# splits.py support end

# find_and_replace.py support begin
# find.py support begin

def find(text: str):
"""Triggers find in current editor"""
Expand All @@ -180,6 +180,10 @@ def find_next():
def find_previous():
actions.key("shift-enter")

# find.py support end

# find_and_replace.py support begin

def find_everywhere(text: str):
"""Triggers find across project"""
actions.key("ctrl-shift-f")
Expand Down
6 changes: 5 additions & 1 deletion apps/vscode/vscode.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def split_number(index: int):

# splits.py support end

# find_and_replace.py support begin
# find.py support begin

def find(text: str):
"""Triggers find in current editor"""
Expand All @@ -294,6 +294,10 @@ def find_next():
def find_previous():
actions.user.vscode("editor.action.previousMatchFindAction")

# find.py support end

# find_and_replace.py support begin

def find_everywhere(text: str):
"""Triggers find across project"""
if is_mac:
Expand Down
3 changes: 2 additions & 1 deletion tags/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ The tags folder has several other subfolders containing various commands:
- `debugger` has commands for use within debuggers such as GDB and WinDbg
- `emoji` has commands for using emojis, emoticons, and kaomoji. In this repository, the tags activating them are only present within the Discord and Slack `.talon` files
- `file_manager` has commands for navigating files and folders within a file explorer or terminal, as described in the top level [README](https://github.com/talonhub/community?tab=readme-ov-file#file-manager-commands)
- `find_and_replace` has commands for finding, selecting, and replacing text
- `find` has simple commands for finding text
- `find_and_replace` has more advanced commands for finding, selecting, and replacing text
- `line_commands` has commands for navigating to and modifying the numbered lines of text within a text editor or IDE
- `messaging` has commands for navigating multi-channel messaging applications
- `multiple_cursors` has commands for managing multiple cursors in a text editor or IDE
Expand Down
16 changes: 16 additions & 0 deletions tags/find/find.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from talon import Module

mod = Module()
mod.tag("find", desc="Tag for enabling generic find commands")


@mod.action_class
class Actions:
def find(text: str):
"""Finds text in current editor"""

def find_next():
"""Navigates to the next occurrence"""

def find_previous():
"""Navigates to the previous occurrence"""
10 changes: 10 additions & 0 deletions tags/find/find.talon
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
tag: user.find
-
hunt this: user.find("")
hunt this (pace | paste):
user.find("")
sleep(25ms)
edit.paste()
hunt this <user.text>: user.find(text)
hunt next: user.find_next()
hunt previous: user.find_previous()
9 changes: 0 additions & 9 deletions tags/find_and_replace/find_and_replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@

@mod.action_class
class Actions:
def find(text: str):
"""Finds text in current editor"""

def find_next():
"""Navigates to the next occurrence"""

def find_previous():
"""Navigates to the previous occurrence"""

def find_everywhere(text: str):
"""Finds text across project"""

Expand Down
10 changes: 2 additions & 8 deletions tags/find_and_replace/find_and_replace.talon
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
tag: user.find_and_replace
-
hunt this: user.find("")
hunt this (pace | paste):
user.find("")
sleep(25ms)
edit.paste()
hunt this <user.text>: user.find(text)
tag(): user.find

hunt all: user.find_everywhere("")
hunt all (pace | paste):
user.find_everywhere("")
Expand All @@ -15,8 +11,6 @@ hunt all <user.text>: user.find_everywhere(text)
hunt case: user.find_toggle_match_by_case()
hunt word: user.find_toggle_match_by_word()
hunt expression: user.find_toggle_match_by_regex()
hunt next: user.find_next()
hunt previous: user.find_previous()
replace this [<user.text>]: user.replace(text or "")
replace all: user.replace_everywhere("")
replace <user.text> all: user.replace_everywhere(text)
Expand Down

0 comments on commit 5ebcea7

Please sign in to comment.