Closed LexiconCode closed 6 months ago
This should be examined with some pytest test scripts in either https://github.com/dictation-toolbox/natlink/tree/master/pythonsrc/tests or in https://github.com/dictation-toolbox/natlinkcore/tree/main/tests (this latter directory seems preferable to me).
Possibly I have a way to work around the deactivate issue.
Quick and dirty, and not able to test just now, as (1) I work on Dragon 15 (2) I have no test environment ready. But here it runs as it seems. See attached my komodo file (.vcl and generated .py).
In my scripts komodo_vcl.py with modified "activate_rule", seems to be running fine with Dragon 15. Note the switch dpi16trick!
When you want to try, please patch attached natlinkutils.py into the natlinkcore directory
The changes are in attached image.
With these changes I got (again with Dragon 15) the things running.
def activate_rule(self, rule, window, status):
current = self.rule_state.get(rule)
active = (current == window)
if status == active: return
print(f'current: {current}, window: {window}, active: {active}, status: {status}, activeRules: {list(self.activeRules.keys())}')
if current:
print(f'current: {current}, deactivate rule {rule}')
self.deactivate(rule, dpi16trick=True)
self.rule_state[rule] = None
if status:
try:
print(f'new: {window}, activate rule {rule}')
self.activate(rule, window)
self.rule_state[rule] = window
except natlink.BadWindow:
pass #
reloading module: komodo_vcl loading module: natspeak_vcl
current: None, window: 131534, active: False, status: True, activeRules: [] new: 131534, activate rule sequence
current: None, window: 131534, active: False, status: True, activeRules: ['sequence'] new: 131534, activate rule sequence_set2
current: 131534, window: 131534, active: True, status: False, activeRules: ['sequence', 'sequence_set2'] current: 131534, deactivate rule sequence_set2
current: None, window: 131534, active: False, status: True, activeRules: ['sequence'] new: 131534, activate rule sequence_set2
current: 131534, window: 131534, active: True, status: False, activeRules: ['sequence', 'sequence_set2'] current: 131534, deactivate rule sequence_set2
Greetings, Quintijn
natlinkutils - Copy.txt
komodo_vcl - Copy.txt
komodo - Copy.vcl.txt
And I should study markdown...
I made good progress to solving this issue, in a way, that the code also works for Dragon 15 (and therefore probably back to 13).
I will do a few more testing, and then make a new version of natlinkcore. (a pip install --upgrade natlinkcore will do)
Succes seems to be there!!!
I am about to accept my own PR into the natlinkcore repository...
All committed to natlinkcore, new pip release natlinkcore 5.3.8
I think we can safely close this issue as solved!!!
mdbridge (Mark) "There is a Dragon bug where deactivating one rule of a grammar can deactivate all the rules of that grammar. I have worked around this in Vocola 2.9 by first determining if any deactivation's are needed, and if so deactivating all rules in that case before doing any activations. I expect this bug also affects dragonfly."