Skip to content

Commit

Permalink
Use SymbolSpecs.CANCEL for all cancelling async actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Dusty Phillips committed Apr 30, 2020
1 parent b1c5af1 commit 2d19ed1
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 12 deletions.
4 changes: 3 additions & 1 deletion castervoice/asynch/hmc_rules/hmc_launch_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from castervoice.lib.ctrl.mgr.rule_details import RuleDetails
from castervoice.lib.merge.state.actions import AsynchronousAction
from castervoice.lib.merge.state.short import R, S, L
from castervoice.rules.ccr.standard import SymbolSpecs



def receive_settings(data):
Expand All @@ -17,7 +19,7 @@ def settings_window():
h_launch.launch(settings.WXTYPE_SETTINGS)
on_complete = AsynchronousAction.hmc_complete(lambda data: receive_settings(data))
AsynchronousAction(
[L(S(["cancel"], on_complete))],
[L(S([SymbolSpecs.CANCEL], on_complete))],
time_in_seconds=1,
repetitions=300,
blocking=False).execute()
Expand Down
3 changes: 2 additions & 1 deletion castervoice/rules/ccr/recording_rules/again.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from castervoice.lib.merge.state.actions import AsynchronousAction
from castervoice.lib.merge.state.short import R, L, S
from castervoice.lib.util import recognition_history
from castervoice.rules.ccr.standard import SymbolSpecs

_history = recognition_history.get_and_register_history(10)

Expand Down Expand Up @@ -38,7 +39,7 @@ def _create_asynchronous(n):
str(x) for x in " ".join(_history[len(_history) - last_utterance_index]).split()
]
if utterance[0] == "again": return
forward = [L(S(["cancel"], lambda: Again._repeat(utterance)))]
forward = [L(S([SymbolSpecs.CANCEL], lambda: Again._repeat(utterance)))]
AsynchronousAction(
forward,
rdescript="Repeat Last Action",
Expand Down
3 changes: 2 additions & 1 deletion castervoice/rules/ccr/recording_rules/alias/base_alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from castervoice.lib.merge.state.actions import AsynchronousAction
from castervoice.lib.merge.state.actions2 import NullAction
from castervoice.lib.merge.state.short import R, S, L
from castervoice.rules.ccr.standard import SymbolSpecs


class BaseAliasRule(BaseSelfModifyingRule):
Expand Down Expand Up @@ -62,7 +63,7 @@ def _alias(self, spec):
on_complete = AsynchronousAction.hmc_complete(
lambda data: self._refresh(data[0].replace("\n", ""), text))
AsynchronousAction(
[L(S(["cancel"], on_complete))],
[L(S([SymbolSpecs.CANCEL], on_complete))],
time_in_seconds=0.5,
repetitions=300,
blocking=False).execute()
Expand Down
3 changes: 2 additions & 1 deletion castervoice/rules/ccr/recording_rules/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from castervoice.lib.merge.state.actions2 import NullAction
from castervoice.lib.merge.state.short import R, L, S
from castervoice.lib.util import recognition_history
from castervoice.rules.ccr.standard import SymbolSpecs


class HistoryRule(BaseSelfModifyingRule):
Expand Down Expand Up @@ -45,7 +46,7 @@ def _record_from_history(self):
# use a response window to get a spec and word sequences for the new macro
h_launch.launch(settings.QTYPE_RECORDING, data=formatted)
on_complete = AsynchronousAction.hmc_complete(lambda data: self._add_recorded_macro(data))
AsynchronousAction([L(S(["cancel"], on_complete))],
AsynchronousAction([L(S([SymbolSpecs.CANCEL], on_complete))],
time_in_seconds=0.5,
repetitions=300,
blocking=False).execute()
Expand Down
13 changes: 7 additions & 6 deletions castervoice/rules/core/navigation_rules/nav.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from castervoice.lib.merge.state.actions2 import UntilCancelled
from castervoice.lib.merge.state.short import S, L, R


_tpd = text_punc_dict()
_dtpd = double_text_punc_dict()

Expand All @@ -49,7 +50,7 @@ class Navigation(MergeRule):
"periodic":
ContextSeeker(forward=[
L(
S(["cancel"], lambda: None),
S([SymbolSpecs.CANCEL], lambda: None),
S(["*"],
lambda fnparams: UntilCancelled(
Mimic(*filter(lambda s: s != "periodic", fnparams)), 1).execute(
Expand All @@ -59,22 +60,22 @@ class Navigation(MergeRule):
# VoiceCoder-inspired -- these should be done at the IDE level
"fill <target>":
R(Key("escape, escape, end"), show=False) +
AsynchronousAction([L(S(["cancel"], Function(context.fill_within_line)))],
AsynchronousAction([L(S([SymbolSpecs.CANCEL], Function(context.fill_within_line)))],
time_in_seconds=0.2, repetitions=50 ),
"jump in":
AsynchronousAction([L(S(["cancel"], context.nav, ["right", "(~[~{~<"]))],
AsynchronousAction([L(S([SymbolSpecs.CANCEL], context.nav, ["right", "(~[~{~<"]))],
time_in_seconds=0.1,
repetitions=50),
"jump out":
AsynchronousAction([L(S(["cancel"], context.nav, ["right", ")~]~}~>"]))],
AsynchronousAction([L(S([SymbolSpecs.CANCEL], context.nav, ["right", ")~]~}~>"]))],
time_in_seconds=0.1,
repetitions=50),
"jump back":
AsynchronousAction([L(S(["cancel"], context.nav, ["left", "(~[~{~<"]))],
AsynchronousAction([L(S([SymbolSpecs.CANCEL], context.nav, ["left", "(~[~{~<"]))],
time_in_seconds=0.1,
repetitions=50),
"jump back in":
AsynchronousAction([L(S(["cancel"], context.nav, ["left", "(~[~{~<"]))],
AsynchronousAction([L(S([SymbolSpecs.CANCEL], context.nav, ["left", "(~[~{~<"]))],
finisher=Key("right"),
time_in_seconds=0.1,
repetitions=50),
Expand Down
5 changes: 3 additions & 2 deletions castervoice/rules/core/navigation_rules/nav2.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from castervoice.lib.merge.additions import IntegerRefST
from castervoice.lib.merge.state.actions import AsynchronousAction
from castervoice.lib.merge.state.short import S, L, R
from castervoice.rules.ccr.standard import SymbolSpecs


class NavigationNon(MappingRule):
Expand All @@ -22,7 +23,7 @@ class NavigationNon(MappingRule):
mapping = {
"<direction> <time_in_seconds>":
AsynchronousAction(
[L(S(["cancel"], Key("%(direction)s"), consume=False))],
[L(S([SymbolSpecs.CANCEL], Key("%(direction)s"), consume=False))],
repetitions=1000,
blocking=False),
"erase multi clipboard":
Expand Down Expand Up @@ -55,7 +56,7 @@ class NavigationNon(MappingRule):
R(Function(navigation.wheel_scroll)),
"scree <direction> <time_in_seconds>":
R(AsynchronousAction(
[L(S(["cancel"], Function(navigation.wheel_scroll, nnavi500=1)))],
[L(S([SymbolSpecs.CANCEL], Function(navigation.wheel_scroll, nnavi500=1)))],
repetitions=1000,
blocking=False)),
"colic":
Expand Down

0 comments on commit 2d19ed1

Please sign in to comment.