-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added identity modifier. Added head tail modifier to csv (#115)
* Added identity modifier. Added head tail modifier to csv * Update src/modifiers/identity.py Co-authored-by: Pokey Rule <pokey.rule@gmail.com> * Update src/modifiers/modifiers.py Co-authored-by: Pokey Rule <pokey.rule@gmail.com> * Changed identifier on head tail * Update src/modifiers/identity.py Co-authored-by: Pokey Rule <pokey.rule@gmail.com>
- Loading branch information
1 parent
5927398
commit 6acb3ff
Showing
4 changed files
with
41 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,29 @@ | ||
from talon import Context, Module | ||
from talon import Module | ||
from dataclasses import dataclass | ||
|
||
mod = Module() | ||
ctx = Context() | ||
mod.list("cursorless_head_tail", desc="Cursorless modifier for head or tail of line") | ||
|
||
|
||
mod.list("cursorless_head_tail", desc="Cursorless modifier for head or tail of line") | ||
ctx.lists["self.cursorless_head_tail"] = {"head", "tail"} | ||
@dataclass | ||
class HeadTail: | ||
defaultSpokenForm: str | ||
cursorlessIdentifier: str | ||
type: str | ||
|
||
|
||
head_tail_list = [ | ||
HeadTail("head", "extendThroughStartOf", "head"), | ||
HeadTail("tail", "extendThroughEndOf", "tail"), | ||
] | ||
head_tail_map = {i.cursorlessIdentifier: i.type for i in head_tail_list} | ||
head_tail = {i.defaultSpokenForm: i.cursorlessIdentifier for i in head_tail_list} | ||
|
||
|
||
@mod.capture(rule="{user.cursorless_head_tail}") | ||
def cursorless_head_tail(m) -> str: | ||
return {"modifier": {"type": m.cursorless_head_tail}} | ||
def cursorless_head_tail(m) -> dict: | ||
return { | ||
"modifier": { | ||
"type": head_tail_map[m.cursorless_head_tail], | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from talon import Module | ||
|
||
mod = Module() | ||
|
||
|
||
mod.list( | ||
"cursorless_identity", | ||
desc="Cursorless modifier for identity. Use to break inference chain.", | ||
) | ||
|
||
|
||
@mod.capture(rule="{user.cursorless_identity}") | ||
def cursorless_identity(m) -> dict: | ||
return {"modifier": {"type": "identity"}} |
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