init commit

This commit is contained in:
unknown
2025-08-19 08:06:37 -04:00
commit 2957b5515a
743 changed files with 45495 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
code.language: talonlist
-
# requires user.talon_populate_lists tag. do not use with dragon
list [require] {user.talon_lists}: "list: {talon_lists}"
list [require]: "list: "
+140
View File
@@ -0,0 +1,140 @@
from talon import Context, Module, actions, app, registry
from ..tags.operators import Operators
mod = Module()
ctx_talon = Context()
ctx_talon_python = Context()
ctx_talon_lists = Context()
# restrict all the talon_* lists to when the user.talon_populate_lists tag
# is active to prevent them from being active in contexts where they are not wanted.
# Do not enable this tag with dragon, as it will be unusable.
# with conformer, the latency increase may also be unacceptable depending on your cpu
# see https://github.com/talonhub/community/issues/600
ctx_talon_lists.matches = r"""
tag: user.talon_populate_lists
"""
mod.tag("talon_python", "Tag to activate talon-specific python commands")
mod.tag(
"talon_populate_lists",
"Tag to activate talon-specific lists of actions, scopes, modes etcetera. Do not use this tag with dragon",
)
mod.list("talon_actions")
mod.list("talon_lists")
mod.list("talon_captures")
mod.list("talon_apps")
mod.list("talon_tags")
mod.list("talon_modes")
mod.list("talon_settings")
mod.list("talon_scopes")
mod.list("talon_modes")
ctx_talon.matches = r"""
code.language: talon
"""
ctx_talon_python.matches = r"""
tag: user.talon_python
"""
def on_update_decls(decls):
# todo modes?
for thing in [
"actions",
"lists",
"captures",
"tags",
"apps",
"settings",
"scopes",
"modes",
]:
l = getattr(decls, thing)
ctx_talon_lists.lists[f"user.talon_{thing}"] = (
actions.user.create_spoken_forms_from_list(
l.keys(), generate_subsequences=False
)
)
# print(
# "List: {} \n {}".format(thing, str(ctx_talon_lists.lists[f"user.talon_{thing}"]))
# )
def on_ready():
# print("on_ready")
on_update_decls(registry.decls)
registry.register("update_decls", on_update_decls)
app.register("ready", on_ready)
@mod.action_class
class Actions:
def talon_code_insert_action_call(text: str, selection: str):
"""inserts talon-specific action call"""
actions.user.code_insert_function(text, selection)
def talon_code_enable_tag(tag: str):
"""enables tag in either python or talon files"""
def talon_code_enable_setting(setting: str):
"""asserts setting in either python or talon files"""
@ctx_talon.action_class("user")
class TalonActions:
def talon_code_enable_tag(tag: str):
"""enables tag in either python or talon files"""
actions.user.paste(f"tag(): {tag}")
def talon_code_enable_setting(setting: str):
"""asserts setting in either python or talon files"""
actions.user.paste(f"{setting} = ")
@ctx_talon_python.action_class("user")
class TalonPythonActions:
def talon_code_insert_action_call(text: str, selection: str):
text = f"actions.{text}({selection or ''})"
actions.user.paste(text)
actions.edit.left()
def talon_code_enable_tag(tag: str):
"""enables tag in either python or talon files"""
actions.user.paste(f'ctx.tags = ["{tag}"]')
if not tag:
actions.edit.left()
actions.edit.left()
def talon_code_enable_setting(setting: str):
"""asserts setting in either python or talon files"""
if not setting:
actions.user.insert_between('ctx.settings["', '"] = ')
else:
actions.user.paste(f'ctx.settings["{setting}"] = ')
operators = Operators(
MATH_AND=" and ",
MATH_OR=" or ",
MATH_SUBTRACT=" - ",
MATH_ADD=" + ",
MATH_MULTIPLY=" * ",
MATH_DIVIDE=" / ",
ASSIGNMENT=" = ",
)
@ctx_talon.action_class("user")
class UserActions:
def code_get_operators() -> Operators:
return operators
def code_insert_function(text: str, selection: str):
text += f"({selection or ''})"
actions.user.paste(text)
actions.edit.left()
+14
View File
@@ -0,0 +1,14 @@
code.language: talon
-
tag(): user.code_operators_math
tag(): user.code_operators_assignment
tag(): user.code_comment_line
tag(): user.code_functions_common
# uncomment user.talon_populate_lists tag to activate talon-specific lists of actions, scopes, modes etcetera.
# Do not enable this tag with dragon, as it will be unusable.
# with conformer, the latency increase may also be unacceptable depending on your cpu
# see https://github.com/talonhub/community/issues/600
# tag(): user.talon_populate_lists
#defintion blocks for the context
setting block: insert("settings():\n\t")
@@ -0,0 +1,7 @@
list: user.code_common_function
code.language: talon
-
insert
key
print
repeat
+22
View File
@@ -0,0 +1,22 @@
#Defines commands common to both python and talon files
code.language: talon
code.language: python
and tag: user.talon_python
-
tag set [{user.talon_tags}]:
tag = talon_tags or ""
user.talon_code_enable_tag(tag)
# requires user.talon_populate_lists tag. do not use with dragon
list {user.talon_lists}: "{{{talon_lists}}}"
# requires user.talon_populate_lists tag. do not use with dragon
capture {user.talon_captures}: "<{talon_captures}>"
setting {user.talon_settings}: user.talon_code_enable_setting(talon_settings)
#commands for dictating key combos
key <user.keys> over: "{keys}"
key <user.modifiers> over: "{modifiers}"
action {user.talon_actions}:
user.talon_code_insert_action_call(talon_actions, edit.selected_text())
+22
View File
@@ -0,0 +1,22 @@
code.language: talon
code.language: talonlist
code.language: python
and tag: user.talon_python
-
#context requirements
win require: insert("os: windows\n")
mac require: insert("os: mac\n")
linux require: insert("os: linux\n")
title require: insert("win.title: ")
application [require] [{user.talon_apps}]:
app = "{talon_apps}\n" or ""
insert("app: {app}")
mode require [{user.talon_modes}]:
mode = "{talon_modes}\n" or ""
insert("mode: {mode}")
tag require [{user.talon_tags}]:
tag = "{talon_tags}\n" or ""
insert("tag: {tag}")
host require:
hostname = user.talon_get_hostname()
insert("hostname: {hostname}\n")
@@ -0,0 +1,14 @@
# This file activates talon-specific python commands
# by default, it simply looks for the python tag to be active
# lines 7-11 provide examples to make the activation more specific
# which may be preferred by people who code in other python projects
# app: vscode
# Mac VSCode uses an em-dash
# win.title: /— user/
# win.title: /— community/
# windows VSCode uses an en-dash
# win.title: / - user - Visual Studio Code/
# win.title: / - community - Visual Studio Code/
code.language: python
-
tag(): user.talon_python