Skip to content

Commit

Permalink
Add menu choosing helper from pokey_talon (talonhub#1393)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
MartinRykfors and pre-commit-ci[bot] committed Aug 14, 2024
1 parent 8b44a0c commit 7f268fa
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 8 deletions.
7 changes: 6 additions & 1 deletion BREAKING_CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ applied given the delay between changes being submitted and the time they were r
and merged.

---
* 2023-06-06 Deprecate `go marks` command for VSCode. Use 'bar marks' instead.
* 2024-05-30 Deprecate 'drop down <user.number_small>' in favor of overridable 'choose' helper
* 2024-01-27 Deprecate '<user.number_string>' command without a spoken prefix like `numb`.
See `numbers.talon` and `numbers_unprefixed.talon.` If in the future you want to still use
unprefixed numbers, you will need to comment out the
`tag(): user.prefixed_numbers` line in your `settings.talon` file.
* 2023-06-06 Deprecate `go ` command for VSCode. Use 'bar marks' instead.
* 2023-02-04 Deprecate `murder` command for i3wm. Use 'win kill' instead.
* 2022-12-11 Deprecate user.insert_with_history. Just use `user.add_phrase_to_history(text);
insert(text)` instead. See #939.
Expand Down
15 changes: 15 additions & 0 deletions core/homophones/homophones.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,18 @@ def homophones_get(word: str) -> [str] or None:
if word in all_homophones:
return all_homophones[word]
return None


ctx_homophones_open = Context()
ctx_homophones_open.matches = """
tag: user.homophones_open
"""


@ctx_homophones_open.action_class("user")
class UserActions:
def choose(number_small: int):
"""Choose the nth homophone"""
result = actions.user.homophones_select(number_small)
actions.insert(result)
actions.user.homophones_hide()
5 changes: 1 addition & 4 deletions core/homophones/homophones_open.talon
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
tag: user.homophones_open
-
choose <number_small>:
result = user.homophones_select(number_small)
insert(result)
user.homophones_hide()

choose <user.formatters> <number_small>:
result = user.homophones_select(number_small)
insert(user.formatted_text(result, formatters))
Expand Down
14 changes: 14 additions & 0 deletions core/menu_choose/menu_choose.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from talon import Context, Module, actions

mod = Module()


@mod.action_class
class Actions:
def choose(number_small: int):
"""Choose the nth item"""
actions.key(f"down:{number_small-1} enter")

def choose_up(number_small: int):
"""Choose the nth item up"""
actions.key(f"up:{number_small} enter")
3 changes: 3 additions & 0 deletions core/menu_choose/menu_choose.talon
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# pick item from a dropdown
selector <number_small>: user.choose(number_small)
selector up <number_small>: user.choose_up(number_small)
3 changes: 0 additions & 3 deletions plugin/dropdown/dropdown.talon

This file was deleted.

0 comments on commit 7f268fa

Please sign in to comment.