talonvoice / beta

Issue tracker for the private Talon Beta
10 stars 0 forks source link

Add mode changed event(?) #70

Closed knausj85 closed 3 years ago

knausj85 commented 4 years ago

Currently, help.py uses UI events to update & display active contexts -

https://github.com/knausj85/knausj_talon/blob/819d80f794ebd88ad8334d5448185c2c7d4235c7/code/help.py#L424

Since modes can be changed without application/window changes, this doesn't quite suffice.

I'm thinking it makes sense to provide either a mode changed event, or maybe there's room for some sort of generic contextchanged event to replace the usage of ui_events here?

lunixbochs commented 4 years ago

This API isn't final, but one of these might help:

from talon import registry
def commands_updated(_): pass
registry.register('update_commands', commands_update)

from talon import registry
def contexts_updated(): pass
registry.register('post:update_contexts')
knausj85 commented 4 years ago

registry.register('update_commands', commands_update) seems to do the trick, thanks.

Using registry.register('post:update_contexts', contexts_updated) here crashes talon consistently as I switch windows. Since it's not final, I don't know if this merits a bug or not. Can provide log, if desired. RecursionError: maximum recursion depth exceeresults ded while calling a Python object

lunixbochs commented 4 years ago

I'm guessing you do something, like update a list, in there that triggers a context update. Maybe I'll change the semantics of these events to have one specifically for "a context activated or deactivated"

knausj85 commented 4 years ago

You're correct, I do update a list. 👍

knausj85 commented 4 years ago

using the below to update help registry.register("update_commands", commands_updated) and switching to "dictation mode" = any .talon file without an explicit mode: command is still listed in the help, but not actually functional.

Repro:

  1. "command mode"
  2. "help active"
  3. "dictation mode"
  4. Note that a bunch of contexts are still present in registry.active_contexts(), but don't actually work. e.g. formatters

If I add e.g. mode: command to formatters.talon and follow the same steps, formatters are no longer available.

As far as I can tell, registry.active_contexts() isn't correctly updated? Something I'm missing, perhaps?

Might be a little confusing for public release, fwiw. Thinking to allow help in dictation mode.

lunixbochs commented 3 years ago

Context active is not the same thing as command active when it comes to command mode. Closing in favor of https://github.com/talonvoice/beta/issues/100