-
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate tag
user.cursorless_custom_number_small
(#2699)
Community has had a good version of number_small for two years now. Talon grammar tests passed ## Checklist - / ] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [/] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [/] I have not broken the cheatsheet --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Co-authored-by: Pokey Rule <[email protected]>
- Loading branch information
1 parent
a8613a9
commit 8574fc7
Showing
5 changed files
with
23 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,20 @@ | ||
""" | ||
This file allows us to use a custom `number_small` capture. See #1021 for more | ||
info. | ||
DEPRECATED @ 2024-12-21 | ||
This file allows us to use a custom `number_small` capture. See #1021 for more info. | ||
""" | ||
|
||
from talon import Context, Module | ||
from talon import Module, app, registry | ||
|
||
mod = Module() | ||
mod.tag( | ||
"cursorless_custom_number_small", | ||
"This tag causes Cursorless to use the global <number_small> capture", | ||
) | ||
|
||
ctx = Context() | ||
ctx.matches = """ | ||
not tag: user.cursorless_custom_number_small | ||
""" | ||
|
||
|
||
@mod.capture(rule="<number_small>") | ||
def private_cursorless_number_small(m) -> int: | ||
return m.number_small | ||
|
||
|
||
digit_list = "zero one two three four five six seven eight nine".split() | ||
teens = "ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen".split() | ||
tens = "twenty thirty forty fifty sixty seventy eighty ninety".split() | ||
mod.tag("cursorless_custom_number_small", "DEPRECATED!") | ||
|
||
number_small_list = [*digit_list, *teens] | ||
for ten in tens: | ||
number_small_list.append(ten) | ||
number_small_list.extend(f"{ten} {digit}" for digit in digit_list[1:]) | ||
number_small_map = {n: i for i, n in enumerate(number_small_list)} | ||
|
||
mod.list("private_cursorless_number_small", desc="List of small numbers") | ||
# FIXME: Remove type ignore once Talon supports list types | ||
# See https://github.com/talonvoice/talon/issues/654 | ||
ctx.lists["self.private_cursorless_number_small"] = number_small_map.keys() # pyright: ignore [reportArgumentType] | ||
def on_ready(): | ||
if "user.cursorless_custom_number_small" in registry.tags: | ||
print( | ||
"WARNING tag: 'user.cursorless_custom_number_small' is deprecated and should not be used anymore, as Cursorless now uses community number_small" | ||
) | ||
|
||
|
||
@ctx.capture( | ||
"user.private_cursorless_number_small", | ||
rule="{user.private_cursorless_number_small}", | ||
) | ||
def override_private_cursorless_number_small(m) -> int: | ||
return number_small_map[m.private_cursorless_number_small] | ||
app.register("ready", on_ready) |