Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lang/tags/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ def code_type(m) -> str:
mod.setting("code_private_variable_formatter", str)
mod.setting("code_protected_variable_formatter", str)
mod.setting("code_public_variable_formatter", str)
mod.setting(
"code_class_formatter",
type=str,
default="PUBLIC_CAMEL_CASE",
desc="Formatter used when a class/type name is dictated as free text (e.g. 'returns' followed by a spoken class name)",
)


@mod.action_class
Expand Down
17 changes: 16 additions & 1 deletion lang/tags/object_oriented.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from talon import Context, Module, actions
from talon import Context, Module, actions, settings

ctx = Context()
ctx.matches = r"""
tag: user.code_object_oriented
"""

mod = Module()

mod.tag(
Expand All @@ -11,6 +15,17 @@
mod.list("code_common_method", desc="Commonly invoked method, e.g. 'foo' in '.foo()'")


@ctx.capture("user.code_type", rule="{user.code_type} | class <user.text>")
def code_type(m) -> str:
"""Returns a type, allowing dictated text to be used as a class name"""
try:
return m.code_type
except AttributeError:
return actions.user.formatted_text(
m.text, settings.get("user.code_class_formatter")
)


@mod.action_class
class Actions:
def code_operator_object_accessor():
Expand Down