Skip to content

Commit

Permalink
Use app.notify action
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasArvidsson committed Nov 21, 2024
1 parent 8cd7c21 commit 9e17545
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions cursorless-talon/src/actions/homophones.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from talon import actions, app
from talon import actions

from ..targets.target_types import (
CursorlessExplicitTarget,
Expand All @@ -16,7 +16,7 @@ def cursorless_homophones_action(target: CursorlessExplicitTarget):
try:
updated_texts = list(map(get_next_homophone, texts))
except LookupError as e:
app.notify(str(e))
actions.app.notify(str(e))
return
destination = PrimitiveDestination("to", target)
cursorless_replace_action(destination, updated_texts)
Expand Down
4 changes: 2 additions & 2 deletions cursorless-talon/src/cheatsheet/cheat_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
class Actions:
def private_cursorless_cheat_sheet_show_html():
"""Show new cursorless html cheat sheet"""
app.notify(
actions.app.notify(
'Please first focus an app that supports cursorless, eg say "focus code"'
)

def private_cursorless_cheat_sheet_update_json():
"""Update default cursorless cheatsheet json (for developer use only)"""
app.notify(
actions.app.notify(
'Please first focus an app that supports cursorless, eg say "focus code"'
)

Expand Down
8 changes: 4 additions & 4 deletions cursorless-talon/src/csv_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pathlib import Path
from typing import Callable, Iterable, Optional, TypedDict

from talon import Context, Module, actions, app, fs, settings
from talon import Context, Module, actions, fs, settings

from .conventions import get_cursorless_list_name
from .vendor.inflection import pluralize
Expand Down Expand Up @@ -201,7 +201,7 @@ def check_for_duplicates(filename, default_values):
existing_list_name = results_map[value]["list"]
warning = f"WARNING ({filename}): Value `{value}` duplicated between lists '{existing_list_name}' and '{list_name}'"
print(warning)
app.notify(warning)
actions.app.notify(warning)


def is_removed(value: str):
Expand Down Expand Up @@ -359,7 +359,7 @@ def update_file(
"See release notes for more info: "
"https://github.com/cursorless-dev/cursorless/blob/main/CHANGELOG.md"
)
app.notify("🎉🎉 New cursorless features; see log")
actions.app.notify("🎉🎉 New cursorless features; see log")

return current_values

Expand Down Expand Up @@ -452,7 +452,7 @@ def read_file(
used_identifiers.append(value)

if has_errors:
app.notify("Cursorless settings error; see log")
actions.app.notify("Cursorless settings error; see log")

return result, has_errors

Expand Down
10 changes: 5 additions & 5 deletions cursorless-talon/src/get_grapheme_spoken_form_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Iterator, Mapping
from uu import Error

from talon import app, registry, scope
from talon import registry, scope, actions

from .spoken_forms_output import SpokenFormOutputEntry

Expand All @@ -31,7 +31,7 @@ def get_graphemes_talon_list() -> dict[str, str]:
# We require this capture, and expect it to be defined. We want to show a user friendly error if it isn't present (usually indicating a problem with their community.git setup) and we think the user is going to use Cursorless.
# However, sometimes users use different dictation engines (Vosk, Webspeech) with entirely different/smaller grammars that don't have the capture, and this code will run then, and falsely error. We don't want to show an error in that case because they don't plan to actually use Cursorless.
if "en" in scope.get("language", {}):
app.notify(f"Capture <{grapheme_capture_name}> isn't defined")
actions.app.notify(f"Capture <{grapheme_capture_name}> isn't defined")
print(
f"Capture <{grapheme_capture_name}> isn't defined, which is required by Cursorless. Please check your community setup"
)
Expand All @@ -56,7 +56,7 @@ def generate_lists_from_capture(capture_name) -> Iterator[str]:
# NB: [-1] because the last capture is the active one
rule = registry.captures[capture_name][-1].rule.rule
except Error:
app.notify("Error constructing spoken forms for graphemes")
actions.app.notify("Error constructing spoken forms for graphemes")
print(f"Error getting rule for capture {capture_name}")
return
rule = rule.strip()
Expand All @@ -73,7 +73,7 @@ def generate_lists_from_capture(capture_name) -> Iterator[str]:
component = "user." + component[5:]
yield component
else:
app.notify("Error constructing spoken forms for graphemes")
actions.app.notify("Error constructing spoken forms for graphemes")
print(
f"Unexpected component {component} while processing rule {rule} for capture {capture_name}"
)
Expand All @@ -87,7 +87,7 @@ def get_id_to_talon_list(list_name: str) -> dict[str, str]:
# NB: [-1] because the last list is the active one
return typing.cast(dict[str, str], registry.lists[list_name][-1]).copy()
except Error:
app.notify(f"Error getting list {list_name}")
actions.app.notify(f"Error getting list {list_name}")
return {}


Expand Down
6 changes: 3 additions & 3 deletions cursorless-talon/src/spoken_forms_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pathlib import Path
from typing import TypedDict

from talon import app
from talon import actions

SPOKEN_FORMS_OUTPUT_PATH = Path.home() / ".cursorless" / "state.json"
STATE_JSON_VERSION_NUMBER = 0
Expand All @@ -27,7 +27,7 @@ def init(self):
f"Error creating spoken form dir {SPOKEN_FORMS_OUTPUT_PATH.parent}"
)
print(error_message)
app.notify(error_message)
actions.app.notify(error_message)

def write(self, spoken_forms: list[SpokenFormOutputEntry]):
with open(SPOKEN_FORMS_OUTPUT_PATH, "w", encoding="UTF-8") as out:
Expand All @@ -45,4 +45,4 @@ def write(self, spoken_forms: list[SpokenFormOutputEntry]):
f"Error writing spoken form json {SPOKEN_FORMS_OUTPUT_PATH}"
)
print(error_message)
app.notify(error_message)
actions.app.notify(error_message)

0 comments on commit 9e17545

Please sign in to comment.