class Get(MergeRule): mapping = { "get <git_command> [<name>]": Function(git), } extras = [ Choice( "git_command", { "clone": "clone", "add": "add", "all": "all", "commit": 'commit', "pull": "pull", "push": "push", "checkout": "checkout", "And it": "init", "merge": "merge", "delete": "delete", "stash": "stash", "stash apply": "stash apply", "status": "status" }), Dictation("name") ] defaults = {}
class HardwareRule(MappingRule): mapping = { "volume <volume_mode> [<n>]": R(Function(navigation.volume_control, extra={'n', 'volume_mode'})), "change monitor": R(Key("w-p") + Pause("100") + Function(change_monitor)) } extras = [ IntegerRefST("n", 1, 50), Choice("volume_mode", { "mute": "mute", "up": "up", "down": "down" }) ] defaults = {"n": 1, "volume_mode": "setsysvolume"}
class CasterRule(MappingRule): mapping = { # update management ToDo: Fully implement castervoice PIP install #"update caster": # R(_DependencyUpdate([_PIP, "install", "--upgrade", "castervoice"])), "reboot caster": R(Function(utilities.reboot)), "update dragonfly": R(_DependencyUpdate([_PIP, "install", "--upgrade", "dragonfly2"])), # ccr de/activation "enable c c r": R(Function(lambda: control.nexus().set_ccr_active(True))), "disable c c r": R(Function(lambda: control.nexus().set_ccr_active(False))), }
class HMCDirectoryRule(MergeRule): mapping = { # specific to directory browser "browse": R(Function(hmc_directory_browse, nexus=_NEXUS), rdescript="Browse Computer") }
def execute_rule(*rule_names): def _exec_function(**kwargs): for name in rule_names: executable = kwargs.get(name) _executeRecursive(executable) return Function(_exec_function)
def start_math(): math_commands.clear() math_commands.update({ 'square root': Text(r'\sqrt'), 'sine': Text(r'\sin'), 'cosine': Text(r'\cos'), 'tangent': Text(r'\tan'), 'exponential': Text(r'\exp'), 'log': Text(r'\ln'), 'end math': Function(lambda: math_commands.clear()), "psi": Text(r"\psi"), "phi": Text(r"\phi"), "big psi": Text(r"\Psi"), "pi": Text(r"\pi"), "gamma": Text(r"\gamma"), "foxtrot": Text(r" f"), "india": Text(r" i"), "j": Text(r" j"), "k": Text(r" k"), "x": Text(r" x"), "y": Text(r" y"), "z": Text(r" z"), 'squared': Text('^2'), 'plus': Text('+'), 'minus': Text('-'), 'cross': Text(r'\times'), 'times': Text(r'\times'), 'dot product': Text(r'\dot'), 'fraction': Text(r'\frac{}{}') + Key('left:3'), # 'to the <nth>': Text('^%(nth)s'), })
class HMCHistoryRule(MappingRule): mapping = { # specific to macro recorder "check <n>": R(Function(hmc_checkbox)), "check from <n> to <n2>": R(Function(hmc_recording_check_range)), "exclude <n>": R(Function(hmc_recording_exclude)), "[make] repeatable": R(Function(hmc_recording_repeatable)) } extras = [ ShortIntegerRef("n", 1, 25), ShortIntegerRef("n2", 1, 25), ]
def construct_activation_rule(self): m = {} for t in self._transformers: enable_action = \ Function(lambda: self._transformers_config.set_transformer_active(t.get_class_name(), True)) disable_action = \ Function(lambda: self._transformers_config.set_transformer_active(t.get_class_name(), False)) m["enable {} transformer".format(t.get_pronunciation())] = enable_action m["disable {} transformer".format(t.get_pronunciation())] = disable_action class TransformersActivationRule(MappingRule): mapping = m details = RuleDetails(name="transformers runner transformers activator rule", watch_exclusion=True) return TransformersActivationRule, details
def prepare_for_merger(self): """ The OrderedDict is an optimization for Kaldi engine, won't make a difference to other engines. This is also the appropriate place to add the "list available commands" command, since this happens post-merge. :return: MergeRule """ unordered_specs = set(self._mapping.keys()) ordered_specs = sorted(unordered_specs) ordered_dict = collections.OrderedDict() for spec in ordered_specs: ordered_dict[spec] = self._mapping[spec] act = available_commands_tracker.get_instance() act.set_available_commands("\n".join(ordered_specs)) # TODO: bring back metarule ordered_dict["list available commands"] = Function(lambda: printer.out(act.get_available_commands())) extras_copy = self.get_extras() defaults_copy = self.get_defaults() class PreparedRule(MappingRule): mapping = ordered_dict extras = extras_copy defaults = defaults_copy return PreparedRule()
class CommandRule(MappingRule): mapping = { # Window handling. "next tab [<t>]": Key("c-tab/40:%(t)d"), "preev tab [<t>]": Key("cs-tab/40:%(t)d"), "close tab": Key("c-w"), # Edit "[shoreline | show] line <w> [<x>] [<y>] [<z>]": Key("f5/30, s-tab, up:2, down:2, tab") + Function(utils.printNumber) + Key("enter, escape"), "(shoreline | show | toggle) line numbers": Key("cas-l"), "hide line numbers": Key("cas-k"), } extras = [ Integer("t", 1, 50), Integer("w", 0, 10), Integer("x", 0, 10), Integer("y", 0, 10), Integer("z", 0, 10), ] defaults = { "t": 1, }
class HardwareRule(MappingRule): mapping = { # Windows 10 changes volume by increments 2 "volume <volume_mode> [<n_volume>]": R(Key("%(volume_mode)s") * Repeat(extra="n_volume")), "media <multimedia_control> [<n_media>]": R(Key("%(multimedia_control)s") * Repeat(extra="n_media")), "change monitor": R(Key("w-p") + Pause("100") + Function(change_monitor)) } extras = [ IntegerRefST("n_media", 1, 15), IntegerRefST("n_volume", 1, 50), Choice("multimedia_control", { "next": "tracknext", "back": "trackprev", "play|pause": "playpause", }), Choice("volume_mode", { "mute|unmute": "volumemute", "up": "volumeup", "down": "volumedown", }) ] defaults = { "n_volume": 1, "n_media": 1, "volume_mode": "setsysvolume", }
class Again(MappingRule): mapping = { "again (<n> [(times|time)] | do)": R(Function(lambda n: Again._create_asynchronous(n)), show=False), # pylint: disable=E0602 } extras = [IntegerRefST("n", 1, 50)] defaults = {"n": 1} @staticmethod def _repeat(utterance): Playback([(utterance, 0.0)]).execute() return False @staticmethod def _create_asynchronous(n): if len(_history) == 0: return last_utterance_index = 2 if settings.WSR: # ContextStack adds the word to history before executing it if len(_history) == 1: return last_utterance_index = 2 utterance = [ 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)))] AsynchronousAction(forward, rdescript="Repeat Last Action", time_in_seconds=0.2, repetitions=int(n), blocking=False).execute()
class UnicodeAlphabet(MergeRule): pronunciation = "unicode alphabet" __name__ = "unicode alphabet" mapping = { "[<big>] <letter> [<accent>]": R(Function(write_letter, extra={"big", "letter", "accent"}), rdescript="Spell"), } extras = [ get_alphabet_choice("letter"), Choice("big", { "big": "big", }), Choice( "accent", { "grave": u'\u0300', "acute": u'\u0301', "circumflex": u'\u0302', "tilde": u'\u0303', "caron": u'\u030C', "ring": u'\u030A', "diaresis": u'\u0308', #perhaps others, cedilla or ogonek #"said Hilda": u'\u0327', #"organic": u'\u0328', }), ] defaults = { "big": "", }
class VisualStudioGlobalRule(MappingRule): mapping = { 'save all': Key('cs-s'), "go to definition": Key("f12"), '(show|find) [all] (usages|references)': Key("a-f7"), 'peek definition': Key('a-f12'), '(show params|param info)': Key('cs-space'), '(show type|quick info)': visual_studio_action('Quick Info'), 'show (type|class) (view|hierarchy)': Key('cs-c'), 'show call hierarchy': Key('ca-k'), '(format|reformat) [document]': visual_studio_action('Reformat Document'), '(format|reformat) selection': visual_studio_action('Reformat Selection'), '[toggle] [line] comment': visual_studio_action('Toggle Line Comment'), '[toggle] block comment': visual_studio_action('Toggle Block Comment'), 'suggest': Key('c-dot'), '(cell|select) [<n>]': Function(execute_select, offset=1), 'show error': visual_studio_action('Quick Info'), 'rename': visual_studio_action('Rename'), 'extract variable': Key('c-dot'), 'close tab': Key('c-f4'), 'git commit': Key('c-0,g'), 'next diff': Key('c-f8'), 'previous diff': Key('cs-f8'), } extras = [ IntegerRef('n', 1, 10, default=1), LetterRef('letter'), ]
class CommandRule(MappingRule): mapping = { #"[go to | show] project window": Key("a-1"), # Search. "replace": Key("c-h"), "show find": Key("c-f"), "find <text>": Key("c-f/25") + Text("%(text)s"), # "find next": Key("f3"), # "find (prev | previous)": Key("s-f3"), "find in files": Key("cs-f"), # Code. "[shoreline | show] line <w> [<x>] [<y>] [<z>]": Key("c-g/25") + Function(printNumber)+ Key("enter"), "show white space": Key("cs-w"), # Window handling. "new tab": Key("c-n"), "next tab [<t>]": Key("c-tab:%(t)d"), "(preev | previous) tab [<t>]": Key("cs-tab:%(t)d"), "close tab": Key("c-w"), "(full-screen | full screen)": Key("f11"), } extras = [ Integer("t", 1, 50), Dictation("text"), IntegerRef("n", 1, 50000), Integer("w", 0, 10), Integer("x", 0, 10), Integer("y", 0, 10), Integer("z", 0, 10) ] defaults = { "t": 1, }
def refresh(self, *args): '''args: spec, text''' aliases = utilities.load_toml_relative("config/aliases.toml") if not Var.key in aliases: aliases[Var.key] = {} if len(args) > 0: aliases[Var.key][args[0]] = args[1] utilities.save_toml_relative(aliases, "config/aliases.toml") mapping = {} for spec in aliases[Var.key]: mapping["var " + spec] = Text(str(aliases[Var.key][spec])) mapping["delete variable " + spec] = Function(self.delete, spec=spec) mapping["variable <s> [brunt]"] = Function(lambda s: self.alias(s)) mapping["delete variables"] = Function(self.delete_all) self.reset(mapping)
def refresh(self, *args): '''args: spec, text''' aliases = utilities.load_toml_relative("config/aliases.toml") if not Alias.key in aliases: aliases[Alias.key] = {} if len(args) > 0: aliases[Alias.key][args[0]] = args[1] utilities.save_toml_relative(aliases, "config/aliases.toml") mapping = {} for spec in aliases[Alias.key]: mapping[spec] = Function(utilities.paste_string, content=str(aliases[Alias.key][spec])) mapping["delete alias " + spec] = Function(self.delete, spec=spec) mapping["alias <s>"] = Function(lambda s: self.alias(s)) mapping["delete aliases"] = Function(self.delete_all) self.reset(mapping)
class CommandRule(MappingRule): mapping = { # Window handling. "next tab [<t>]": Key("c-tab/40:%(t)d"), "(preev | previous) tab [<t>]": Key("cs-tab/40:%(t)d"), "close tab": Key("c-w"), # Edit "[shoreline | show] line <w> [<x>] [<y>] [<z>]": Key("f5/30") + Function(printNumber) + Key("enter, escape"), } extras = [ Integer("t", 1, 50), Integer("w", 0, 10), Integer("x", 0, 10), Integer("y", 0, 10), Integer("z", 0, 10), ] defaults = { "t": 1, }
def construct_commands(mapping, extras=None): """ Constructs a list of BoundCompound objects from a mapping and an extras dict. Also automatically converts all callables to dragonfly Function objects, allowing e.g. mapping = {"foo [<n>]": lambda n: foo(n),} """ children = [] assert isinstance(mapping, dict) for spec, value in mapping.items(): if callable(value): value = Function(value) try: assert isinstance(spec, string_types) c = BoundCompound(spec, extras=extras, value=value) children.append(c) except Exception as e: logger.error( "Exception raised while processing '%s', command will be skipped.", spec) logger.exception(e) return children
def __init__(self, spec, action, args={}, **kwargs): """ :param string spec: The spec for this command, from which `intros <intros>` will be determined. :param action: The action to be executed when this command is said. :type action: a dragonfly action_ :param dict args: Provides a way to add to or modify the extras dictionary. The args dictionary has keys of name strings, items of function callbacks. The callbacks are supplied a single parameter of a dictionary of extras, and their return value is assigned to the extra named by the key. When the ``action`` is executed, it will then have these final values available to it. :param \*\*kwargs: Passed to `FluidRule`, except ``"name"`` and ``"spec"`` ignored. """ if isinstance(action, ActionBase) or not six.callable(action): self.action = action self._is_call = False else: self.action = Function(action) self._is_call = True self.args = args kwargs["spec"] = spec kwargs["name"] = self._autogenerate_name(spec) FluidRule.__init__(self, **kwargs)
class PycharmGlobalRule(MappingRule): mapping = { 'save all': Key('c-s'), "go to definition": Key("c-b"), '(show|find) usages': Key("a-f7"), 'highlight usages': Key("cs-f7"), 'peek definition': Key('cs-i'), '(show|peek) docs': Key('c-q'), '(show params|param info)': Key('c-p'), 'show type': Key('cs-p'), 'show type hierarchy': Key('c-h'), 'show call hierarchy': Key('ca-h'), "reformat": Key('ca-l'), "reformat line": Key('escape,V,ca-l,escape'), 'comment': Key('c-slash'), 'suggest': Key('a-enter'), '(cell|select) [<n>]': Function(execute_select, offset=1), 'show error': Key('c-f1'), 'run program': Key('s-f10'), 'run dot dot dot': Key('as-f10'), 'execute selection [in console]': Key('as-e'), 'kill program': Key('c-f2'), 'debug program': Key('s-f9'), 'debug dot dot dot': Key('as-f9'), 'toggle breakpoint': Key('c-f8'), 'step out': Key('s-f8'), 'step over': Key('f8'), 'step into': Key('f7'), 'resume program': Key('f9'), 'rename': Key('s-f6'), 'extract variable': Mimic('kay') + Mimic('insert') + Key('ca-v'), 'new (file|dot dot dot)': Key('a-f/20,a-insert'), 'panel <n>': Key('a-%(n)d'), 'close tab': Key('c-f4'), 'close (all but this|others)': pycharm_action('close others'), 'close left': pycharm_action('close all to the left'), 'close right': pycharm_action('close all to the right'), 'unsplit': pycharm_action('unsplit'), 'git commit': Key('c-k'), 'git pull': Key('a-s/20,a-u'), 'git push': Key('cs-k'), 'show diff': Key('c-d'), 'next diff': Key('f7'), 'next section': Key('tab'), 'previous section': Key('s-tab'), 'previous diff': Key('s-f7'), 'compare next file': Key('a-right'), 'compare previous file': Key('a-left'), 'menu <letter>': Key('a-%(letter)s'), 'hide menu': Key('s-escape'), 'fold all': Key('cs-npsub'), '(expand|unfold) all': Key('cs-npadd'), 'fold': Key('c-npsub'), '(expand|unfold)': Key('c-npadd'), 'open file': Key('a-n/10,f'), } extras = [ IntegerRef('n', 1, 10, default=1), LetterRef('letter'), ]
class ScrollingRule(MappingRule): mapping = { '[<speed>] start <scroll_action>': Function(start_scrolling), 'faster': Function(scroll_faster), 'slower': Function(scroll_slower), 'stop': Function(stop_scrolling), } extras = [ IntegerRef('speed', min=1, max=10, default=3), Choice('scroll_action', choices={ 'scrolling [down]': ScrollType.WHEEL_DOWN, 'scrolling up': ScrollType.WHEEL_UP, 'paging [down]': ScrollType.PAGE_DOWN, 'paging up': ScrollType.PAGE_UP, }, default=ScrollType.WHEEL_DOWN), ]
def __init__(self, name=None, mapping=None, extras=None, defaults=None, exported=None, ID=None, composite=None, compatible=None, mcontext=None, mwith=None): self.ID = ID if ID is not None else MergeRule._get_next_id() self.compatible = {} if compatible is None else compatible '''composite is the IDs of the rules which this MergeRule is composed of: ''' self.composite = composite if composite is not None else set([self.ID]) self._mcontext = self.__class__.mcontext if self._mcontext is None: self._mcontext = mcontext self._mwith = self.__class__.mwith if self._mwith is None: self._mwith = mwith if mapping is not None: mapping["display available commands"] = Function( lambda: self._display_available_commands()) MappingRule.__init__(self, name, mapping, extras, defaults, exported)
def process_command(self, proc): # Process the output from the command. RunCommand.process_command(self, proc) # Only reboot dragon if the command was successful and online_mode is true # 'pip install ...' may exit successfully even if there were connection errors. if proc.wait() == 0 and update: Function(utilities.reboot).execute()
class GeneralRule(MappingRule): mapping = { "tab": Key("tab"), "enter": Key("enter"), "dictate <text>": Text("%(text)s"), "(dictate | type | say) snake [case] <text>": Function( lambda text: transform(text, snake_case)), "(dictate | type | say) pascal [case] <text>": Function( lambda text: transform(text, pascal_case)), "(dictate | type | say) kebab [case] <text>": Function( lambda text: transform(text, kebab_case)), "(dictate | type | say) camel [case] <text>": Function( lambda text: transform(text, camel_case)), } extras = [Dictation("text")]
class core(MergeRule): non = coreNon pronunciation = CORE["pronunciation"] mapping = { "[<big>] <letter>": Function(alphabet), CORE["numbers_prefix"] + " <numbers>": Text("%(numbers)s"), "<punctuation>": Key("%(punctuation)s"), "(<direction> | <modifier> [<direction>]) [(<n50> | <extreme>)]": Function(navigation.text_nav), "<repeatable_key> [<n>]": Key("%(repeatable_key)s") * Repeat(extra="n"), "<non_repeatable_key>": Key("%(non_repeatable_key)s"), CORE["dictation_prefix"] + " <text>": Function(lambda text: Text(str(text).lower()).execute()), "shift click": Key("shift:down") + Mouse("left") + Key("shift:up"), } extras = [ Dictation("text"), IntegerRef("n", 1, 10), IntegerRef("n50", 1, 50), IntegerRefMF("numbers", 0, CORE["numbers_max"]), Choice("big", {CORE["capitals_prefix"]: True}), Choice("letter", CORE[_LETTERS]), Choice("punctuation", CORE["punctuation"]), Choice("repeatable_key", CORE["repeatable_keys"]), Choice("non_repeatable_key", CORE["non_repeatable_keys"]), Choice("direction", CORE[_DIRECTIONS]), Choice("modifier", CORE["modifiers"]), Choice("extreme", {CORE["extreme"]: True}), ] defaults = { "big": False, "extreme": False, "n": 1, "n50": 1, "direction": "left", "modifier": "", }
class CommandRule(MappingRule): mapping = { "initialize repository": Text( "git init" )+Key("enter"), "add": R(Key("g, i, t, space, a, d, d, space, dot, enter"), rdescript="GIT: Add All"), "status": R(Key( "g, i, t, space, s, t, a, t, u, s, enter" ), rdescript="GIT: Status"), "commit": R(Key( "g, i, t, space, c, o, m, m, i, t, space, minus, a, m, space, apostrophe, apostrophe, left"), rdescript="GIT: Commit"), "bug fix commit <n>": R(Mimic("commit")+Text("fixes #%(n)d ")+Key("backspace"), rdescript="GIT: Bug Fix Commit"), "reference commit <n>": R(Mimic("commit")+Text("refs #%(n)d ")+Key("backspace"), rdescript="GIT: Reference Commit"), "checkout": R(Text( "git checkout " ), rdescript="GIT: Check Out"), "merge": R(Text( "git merge " ), rdescript="GIT: Merge"), "merge tool": R(Text( "git mergetool")+Key("enter"), rdescript="GIT: Merge Tool"), "fetch": R(Text( "git fetch" )+Key("enter"), rdescript="GIT: Fetch"), "(get push | push)":R(Text( "git push" )+Key("enter"), rdescript="GIT: Push"), "pull": R(Text( "git pull" )+Key("enter"), rdescript="GIT: Pull"), "CD up": R(Text( "cd .." )+Key("enter"), rdescript="GIT: Up Directory"), "CD": R(Text( "cd " ), rdescript="GIT: Navigate Directory"), "list": R(Text( "ls" )+Key("enter"), rdescript="GIT: List"), "make directory": R(Text( "mkdir " ), rdescript="GIT: Make Directory"), "undo [last] commit": R(Text("git reset --soft HEAD~1")+Key("enter"), rdescript="GIT: Undo Commit"), "undo changes": R(Text("git reset --hard")+Key("enter"), rdescript="GIT: Undo Since Last Commit"), "stop tracking [file]": R(Text("git rm --cached FILENAME"), rdescript="GIT: Stop Tracking"), "preview remove untracked": R(Text("git clean -nd")+Key("enter"), rdescript="GIT: Preview Remove Untracked"), "remove untracked": R(Text("git clean -fd")+Key("enter"), rdescript="GIT: Remove Untracked"), "visualize": R(Text("gitk")+Key("enter"), rdescript="GIT: gitk"), "visualize file": R(Text("gitk -- PATH"), rdescript="GIT: gitk Single File"), "visualize all": R(Text("gitk --all")+Key("enter"), rdescript="GIT: gitk All Branches"), "exit": R(Text( "exit" )+Key("enter"), rdescript="GIT: Exit"), "stash": R(Text("git stash")+Key("enter"), rdescript="GIT: Stash"), "stash apply [<n>]":R(Text("git stash apply")+Function(apply), rdescript="GIT: Stash Apply"), "stash list": R(Text("git stash list")+Key("enter"), rdescript="GIT: Stash List"), "stash branch": R(Text("git stash branch NAME"), rdescript="GIT: Stash Branch"), "cherry pick": R(Text("git cherry-pick "), rdescript="GIT: Cherry Pick"), "abort cherry pick":R(Text("git cherry-pick --abort"), rdescript="GIT: Abort Cherry Pick"), "GUI | gooey": R(Text("git gui")+Key("enter"), rdescript="GIT: gui"), "blame": R(Text("git blame PATH -L FIRSTLINE,LASTLINE"), rdescript="GIT: Blame"), "gooey blame": R(Text("git gui blame PATH"), rdescript="GIT: GUI Blame"), "search recursive": R(Text("grep -rinH \"PATTERN\" *"), rdescript="GREP: Search Recursive"), "search recursive count": R(Text("grep -rinH \"PATTERN\" * | wc -l"), rdescript="GREP: Search Recursive Count"), "search recursive filetype": R(Text("find . -name \"*.java\" -exec grep -rinH \"PATTERN\" {} \\;"), rdescript="GREP: Search Recursive Filetype"), "to file": R(Text(" > FILENAME"), rdescript="Bash: To File"), } extras = [ IntegerRef("n", 1, 10000), ] defaults ={"n": 0}
class UpperCaseSQL(MergeRule): pronunciation = "upper case sequel" mapping = { "select": R(Text("SELECT "), rdescript="SQL: Select"), "select top [<n>]": R(Text("SELECT TOP ") + Function(_render_number), rdescript="SQL: Select Top"), "select all": R(Text("SELECT * "), rdescript="SQL: Select All"), "from": R(Key("enter") + Text("FROM "), rdescript="SQL: From"), "where": R(Key("enter") + Text("WHERE "), rdescript="SQL: Where"), "group by": R(Key("enter") + Text("GROUP BY "), rdescript="SQL: Group By"), "order by": R(Key("enter") + Text("ORDER BY "), rdescript="Order By"), "ascending": R(Text(" ASC "), rdescript="SQL: Ascending"), "descending": R(Text(" DESC "), rdescript="SQL: Descending"), "left join": R(Key("enter") + Text("LEFT JOIN "), rdescript="SQL: Left Join"), "inner join": R(Key("enter") + Text("INNER JOIN "), rdescript="SQL: Inner Join"), "join": R(Text(" JOIN "), rdescript="SQL: Join"), "insert into": R(Text(" INSERT INTO "), rdescript="SQL: Insert"), "update": R(Text(" UPDATE TOKEN SET "), rdescript="SQL: Update"), "delete": R(Text("DELETE "), rdescript="SQL: Delete"), "like": R(Text(" LIKE '%%'") + Key("left/5:2"), rdescript="SQL: Like"), "union": R(Text(" UNION "), rdescript="SQL: Union"), "alias as": R(Text(" AS "), rdescript="SQL: Alias As"), "is null": R(Text(" IS NULL "), rdescript="SQL: Is Null"), "is not null": R(Text(" IS NOT NULL "), rdescript="SQL: Is Not Null"), "declare": R(Text(" DECLARE @ "), rdescript="SQL: Is Not Null"), "fun max": R(Text(" MAX() ") + Key("left/5:2"), rdescript="SQL: Max"), "fun count": R(Text(" COUNT() ") + Key("left/5:2"), rdescript="SQL: Count"), "int": R(Text(" INT "), rdescript="SQL: Count"), "var char | far char": R(Text(" VARCHAR() ") + Key("left:2"), rdescript="SQL: Count"), } extras = [ IntegerRefST("n", 1, 10000), ] defaults = {"n": 0}
def __init__(self, executable=None, title=None, time_in_seconds=1, repetitions=15, rdescript="unnamed command (SFW)", blocking=False): assert executable != None or title != None, "SuperFocusWindow needs executable or title" def attempt_focus(): for win in Window.get_all_windows(): w = win found_match = True if title != None: found_match = title in w.title if found_match and executable != None: found_match = executable in w.executable if found_match: try: # this is still broken win32gui.SetWindowPos( w.handle, win32con.HWND_NOTOPMOST, 0, 0, 0, 0, win32con.SWP_NOMOVE + win32con.SWP_NOSIZE) win32gui.SetWindowPos( w.handle, win32con.HWND_TOPMOST, 0, 0, 0, 0, win32con.SWP_NOMOVE + win32con.SWP_NOSIZE) win32gui.SetWindowPos( w.handle, win32con.HWND_NOTOPMOST, 0, 0, 0, 0, win32con.SWP_SHOWWINDOW + win32con.SWP_NOMOVE + win32con.SWP_NOSIZE) Key("alt").execute() time.sleep(0.5) win32gui.SetForegroundWindow(w.handle) w.set_foreground() except Exception: utilities.report("Unable to set focus:\ntitle: " + w.title + "\nexe: " + w.executable) break # do not assume that it worked success = SuperFocusWindow.focus_was_success(title, executable) if not success: if title != None: print "title failure: ", title, w.title if executable != None: print "executable failure: ", executable, w.executable, executable in w.executable return success forward = [L(S(["cancel"], attempt_focus))] AsynchronousAction.__init__( self, forward, time_in_seconds=time_in_seconds, repetitions=repetitions, rdescript=rdescript, blocking=blocking, finisher=Function(control.nexus().intermediary.text, message="SuperFocus Complete") + Key("escape")) self.show = False
class Numbers(MergeRule): pronunciation = CCRMerger.CORE[2] mapping = { "word number <wn>": R(Function(alphanumeric.word_number, extra="wn"), rdescript="Number As Word"), "numb <wnKK>": R(Function(alphanumeric.numbers2, extra="wnKK"), rspec="number", rdescript="Number"), } extras = [ IntegerRefST("wn", 0, 10), IntegerRefST("wnKK", 0, 1000000), ] defaults = {}