class LaTeX(MergeRule): pronunciation = "latex" mapping = { SymbolSpecs.COMMENT: R(Text("%")), "begin <element>": R( back_curl("begin", "%(element)s") + Key("enter:2") + back_curl("end", "%(element)s") + Key("up")), # "[use] package [<packages>]": R(back_curl("usepackage", "%(packages)s")), "[use] package bib latex": R(back_curl("usepackage[style=authoryear]", "biblatex")), # "symbol [<big>] <symbol>": R( Text("\\") + Function(symbol_letters, extra={"big", "symbol"}) + Text(" ")), # "insert <command>": R(back_curl("%(command)s", "")), "insert <commandnoarg>": R(Text("\\%(commandnoarg)s ")), "insert quote": R(Text("``\'\'") + Key("left:2")), # "super script": R(Text("^") + Key("lbrace, rbrace, left")), "subscript": R(Text("_") + Key("lbrace, rbrace, left")), "math fraction": R( Text("\\") + Text("frac") + Key("lbrace, rbrace, lbrace, rbrace, space, left:4")), } extras = [ Choice( "packages", { "math tools": "mathtools", "graphic ex": "graphicx", "wrap figure": "wrapfig", }), Choice( "element", { "center": "center", "columns": "columns", "description": "description", "document": "document", "(enumerate | numbered list)": "enumerate", "equation": "equation", "figure": "figure", "flush left": "flushleft", "flush right": "flushright", "frame": "frame", "list": "list", "mini page": "minipage", "quotation": "quotation", "quote": "quote", "table": "table", "title page": "titlepage", "verbatim": "verbatim", "verse": "verse", "wrap figure": "wrapfigure", }), Choice( "command", { "author": "author", "[add] bib resource": "addbibresource", "caption": "caption", "chapter": "chapter", "column": "column", "document class": "documentclass", "graphics path": "graphicspath", "[include] graphics": "includegraphics[width=1\\textwidth]", "label": "label", "new command": "newcommand", "paragraph": "paragraph", "paren cite": "parencite", "part": "part", "reference": "ref", "sub paragraph": "subparagraph", "(section | heading)": "section", "sub (section | heading)": "subsection", "sub sub (section | heading)": "subsubsection", "text cite": "textcite", "[text] bold": "textbf", "[text] italics": "textit", "[text] slanted": "textsl", "title": "title", "use theme": "usetheme", }), Choice( "commandnoarg", { "line break": "linebreak", "[list] item": "item", "make title": "maketitle", "new page": "newpage", "page break": "pagebreak", "print bibliography": "printbibliography", "table of contents": "tableofcontents", "text width": "textwidth", }), Choice( "symbol", { "alpha": "alpha", "beater": "beta", "gamma": "gamma", "delta": "delta", "epsilon": "epsilon", "var epsilon": "varepsilon", "zita": "zeta", "eater": "eta", "theta": "theta", "iota": "iota", "kappa": "kappa", "lambda": "lambda", "mu": "mu", "new": "nu", "zee": "xi", "pie": "pi", "row": "rho", "sigma": "sigma", "tau": "tau", "upsilon": "upsilon", "phi": "phi", "chi": "chi", "sigh": "psi", "omega": "omega", # "times": "times", "divide": "div", "intersection": "cap", "union": "cup", "stop": "cdot", "approximate": "approx", "proportional": "propto", "not equal": "neq", "member": "in", "for all": "forall", "partial": "partial", "infinity": "infty", "dots": "dots", # "left arrow": "leftarrow", "right arrow": "rightarrow", "up arrow": "uparrow", "down arrow": "downarrow", # "left": "left(", "right": "right)", }), Choice("big", { "big": True, }), ] defaults = { "big": False, "packages": "", }
class FirefoxRule(MappingRule): mapping = { "(new window|win new)": R(Key("c-n")), "(new incognito window | incognito)": R(Key("cs-n")), "new tab [<n>]|tab new [<n>]": R(Key("c-t") * Repeat(extra="n")), "reopen tab [<n>]|tab reopen [<n>]": R(Key("cs-t")) * Repeat(extra="n"), "close tab [<n>]|tab close [<n>]": R(Key("c-w")) * Repeat(extra='n'), "win close|close all tabs": R(Key("cs-w")), "(next|forward) tab [<n>]|tab (right|sauce) [<n>]": R(Key("c-tab")) * Repeat(extra="n"), "(back|prev|prior|previous) tab [<n>]|tab (left|lease) [<n>]": # control shift tab doesn't work and this appears to be an undocumented workaround R(Key("c-tab/30")) * Repeat(extra="n"), "new tab that": R(Mouse("middle") + Pause("20") + Key("c-tab")), "go (back|prev|prior|previous) [<n>]": R(Key("a-left/20")) * Repeat(extra="n"), "go (next|forward) [<n>]": R(Key("a-right/20")) * Repeat(extra="n"), "zoom in [<n>]": R(Key("c-plus/20")) * Repeat(extra="n"), "zoom out [<n>]": R(Key("c-minus/20")) * Repeat(extra="n"), "zoom reset": R(Key("c-0")), "(hard refresh|super refresh)": R(Key("c-f5")), "find (next|forward) [match] [<n>]": R(Key("c-g/20")) * Repeat(extra="n"), # requires an extension in some browsers such as chrome "[toggle] caret browsing": R(Key("f7")), "[go] home [page]": R(Key("a-home")), "[show] history": R(Key("c-h")), "address bar": R(Key("c-l")), "[show] downloads": R(Key("c-j")), "[add] bookmark": R(Key("c-d")), "bookmark all [tabs]": R(Key("cs-d")), "[show] bookmarks": R(Key("cs-o")), "[toggle] full screen": R(Key("f11")), "(show|view) page source": R(Key("c-u")), "resume": R(Key("f8")), "step over": R(Key("f10")), "step into": R(Key("f11")), "step out": R(Key("s-f11")), "(duplicate tab|tab duple)": R(Key("a-d,a-c,c-t/15,c-v/15, enter")), "(duplicate window|win duple)": R(Key("a-d,a-c,c-n/15,c-v/15, enter")), "[show] (menu | three dots)": R(Key("a-f")), "[show] settings": R(Key("a-f/5, s")), "(clear history|clear browsing data)": R(Key("cs-del")), "[show] developer tools": R(Key("cs-i")), "checkout [this] pull request [locally]": R(Function(github_automation.github_checkoutupdate_pull_request, new=True)), "update [this] pull request [locally]": R(Function(github_automation.github_checkoutupdate_pull_request, new=False)), "IRC identify": R(Text("/msg NickServ identify PASSWORD")), "[toggle] bookmark bar": R(Key("c-b")), "[show] (extensions|plugins)": R(Key("a-a, l, e/15, enter")), "google that": R(Store(remove_cr=True) + Key("c-t") + Retrieve() + Key("enter")), "wikipedia that": R(Store(space="+", remove_cr=True) + Key("c-t") + Text( "https://en.wikipedia.org/w/index.php?search=") + Retrieve() + Key("enter")), } extras = [ Choice("nth", { "first": "1", "second": "2", "third": "3", "fourth": "4", "fifth": "5", "sixth": "6", "seventh": "7", "eighth": "8", }), IntegerRefST("n", 1, 100), IntegerRefST("m", 1, 10) ] defaults = {"n": 1, "m":"", "nth": ""}
class JetbrainsRule(MappingRule): mapping = { "quick fix": R(Key("a-enter")), "(duplicate|duple) %s" % DOWN: R(Key("c-d")), "find action": R(Key("cs-a")), "format [code]": R(Key("ca-l")), "show doc": R(Key("c-q")), "find class": R(Key("c-n")), "build": R(Key("c-f9")), "build and run": R(Key("s-f10")), "%s tab [<n>]|tab %s [<n>]" % (FORWARD, RIGHT): R(Key("a-right/%s" % DELAY)) * Repeat(extra="n"), "%s tab [<n>]|tab %s [<n>]" % (BACK, LEFT): R(Key("a-left/%s" % DELAY)) * Repeat(extra="n"), "(comment|rem) [line]": R(Key("c-slash")), "(uncomment|unrem) [line]": R(Key("cs-slash")), "select ex" : R(Key("c-w")), "select ex down" : R(Key("cs-w")), "find file": R(Key("shift, shift")), "find": R(Key("c-f")), "find next": R(Key("f3")), "find prior": R(Key("f3")), "find %s [match] [<n>]" % FORWARD: R(Key("enter")) * Repeat(extra="n"), "find %s [match] [<n>]" % BACK: R(Key("s-enter")) * Repeat(extra="n"), "replace [here]": R(Key("c-r")), "find [in] (all|files)": R(Key("cs-f")), "replace [in] (all|files)": R(Key("cs-r")), "go [to line] [<n>]": R(Key("c-g/%s" % DELAY) + Text("%(n)s") + Key("enter")), "implement (%s|%s)" % (method, methods): R(Key("c-i")), "override %s" % method: R(Key("c-o")), "run config": R(Key("as-f10")), "[find] (usage|usages)": R(Key("a-f7")), "show (usage|usages)": R(Key("ca-f7")), "[find] (usage|usages) in file": R(Key("c-f7")), "[go to] (source|declaration)": R(Key("c-b")), "[go to] implementation": R(Key("ca-b")), "(skraken|smart kraken)": R(Key("cs-space")), "go %s [<n>]" % FORWARD: R(Key("ca-right")) * Repeat(extra="n"), "go %s [<n>]" % BACK: R(Key("ca-left")) * Repeat(extra="n"), "%s %s [<n>]" % (method, FORWARD): R(Key("a-down")) * Repeat(extra="n"), "%s %s [<n>]" % (method, BACK): R(Key("a-up")) * Repeat(extra="n"), "go block start": R(Key("c-[")), "go block end": R(Key("c-]")), "(%s error|error %s)" % (FORWARD, RIGHT): R(Key("f2")) * Repeat(extra="n"), "(%s error|error %s)" % (BACK, LEFT): R(Key("s-f2")) * Repeat(extra="n"), "[organize|optimize] imports": R(Key("ca-o")) * Repeat(extra="n"), "[move] line %s [<n>]" % UP: R(Key("as-up")) * Repeat(extra="n"), "[move] line %s [<n>]" % DOWN: R(Key("as-down")) * Repeat(extra="n"), "expand [selection] [<n>]": R(Key("c-w")) * Repeat(extra="n"), "shrink [selection] [<n>]": R(Key("cs-w")) * Repeat(extra="n"), "auto indent": R(Key("ca-i")), "close tab [<n>]|tab close [<n>]": R(Key("c-f4/%s" % DELAY)) * Repeat(extra="n"), "run": R(Key("s-f10")), "debug": R(Key("s-f9")), "redo [<n>]": R(Key("cs-z")) * Repeat(extra="n"), "[show] settings": R(Key("ca-s")), "collapse": R(Key("c--")), "uncollapse": R(Key("c-+")), "collapse all": R(Key("cs--")), "uncollapse all": R(Key("cs-+")), # only works if you disable tabs. "close pane [<n>]|pane close [<n>]": R(Key("c-f4/%s" % DELAY)) * Repeat(extra="n"), # refactoring "refactor": R(Key("cas-t")), "rename": R(Key("s-f6")), "inline": R(Key("ca-n")), "(pull|extract)": R(Key("ca-m")), "%s [variable|var]" % extract: R(Key("ca-v")) * Repeat(extra="n"), "%s field" % extract: R(Key("ca-f")) * Repeat(extra="n"), "%s constant" % extract: R(Key("ca-c")) * Repeat(extra="n"), "%s (param|parameter)" % extract: R(Key("ca-p")) * Repeat(extra="n"), # debugging "step over": R(Key("f8")), "step into": R(Key("f7")), "smart step over": R(Key("s-f7")), "step out": R(Key("s-f8")), "toggle breakpoint": R(Key("c-f8")), "view breakpoints": R(Key("cs-f8,cs-f8")), "continue": R(Key("f9")), # window navigation "focus editor": R(Key("escape")), "go tool <n>": R(Key("a-%(n)s")), "[toggle] (term|terminal)": R(Key("a-f12")), # must be bound manually below this point "(kill|delete) %s" % FORWARD: R(Key("a-d,0")), "(kill|delete) %s" % BACK: R(Key("a-d,$")), # jet brains can only split horizontally or vertically "split [pane] %s" % UP: R(Key("cs-s,h")), "split [pane] %s" % DOWN: R(Key("cs-s,h")), "split [pane] %s" % RIGHT: R(Key("cs-s,v")), "split [pane] %s" % LEFT: R(Key("cs-s,v")), "pane %s [<n>]" % UP: R(Key("cs-s,up")) * Repeat(extra="n"), "pane %s [<n>]" % DOWN: R(Key("cs-s,down")) * Repeat(extra="n"), "(pane %s|%s pane) [<n>]" % (RIGHT, RIGHT): R(Key("cs-s,right")) * Repeat(extra="n"), "(pane %s|%s pane) [<n>]" % (LEFT, LEFT): R(Key("cs-s,left")) * Repeat(extra="n"), "file rename | rename file": R(Key("cas-r")), } extras = [ Dictation("text"), Dictation("mim"), ShortIntegerRef("n", 1, 1000), ] defaults = {"n": 1, "mim": ""}
class Navigation(MergeRule): pronunciation = "navigation" mapping = { # "periodic" repeats whatever comes next at 1-second intervals until "terminate" # or "escape" (or your SymbolSpecs.CANCEL) is spoken or 100 tries occur "periodic": ContextSeeker(forward=[ L( S(["cancel"], lambda: None), S(["*"], lambda fnparams: UntilCancelled( Mimic(*filter(lambda s: s != "periodic", fnparams)), 1). execute(), use_spoken=True)) ]), # 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)))], time_in_seconds=0.2, repetitions=50), "jump in": AsynchronousAction( [L(S(["cancel"], context.nav, ["right", "(~[~{~<"]))], time_in_seconds=0.1, repetitions=50), "jump out": AsynchronousAction( [L(S(["cancel"], context.nav, ["right", ")~]~}~>"]))], time_in_seconds=0.1, repetitions=50), "jump back": AsynchronousAction( [L(S(["cancel"], context.nav, ["left", "(~[~{~<"]))], time_in_seconds=0.1, repetitions=50), "jump back in": AsynchronousAction( [L(S(["cancel"], context.nav, ["left", "(~[~{~<"]))], finisher=Key("right"), time_in_seconds=0.1, repetitions=50), # keyboard shortcuts 'save': R(Key("c-s"), rspec="save"), "shift click": R(Key("shift:down") + Mouse("left") + Key("shift:up")), "stoosh [<nnavi500>]": R(Function(navigation.stoosh_keep_clipboard), rspec="stoosh"), "cut [<nnavi500>]": R(Function(navigation.cut_keep_clipboard), rspec="cut"), "spark [<nnavi500>] [(<capitalization> <spacing> | <capitalization> | <spacing>) [(bow|bowel)]]": R(Function(navigation.drop_keep_clipboard), rspec="spark"), "splat [<splatdir>] [<nnavi10>]": R(Key("c-%(splatdir)s"), rspec="splat") * Repeat(extra="nnavi10"), SymbolSpecs.CANCEL: R(Key("escape"), rspec="cancel"), "shackle": R(Key("home/5, s-end"), rspec="shackle"), "(tell | tau) <semi>": R(Function(navigation.next_line), rspec="tell dock"), "(hark | heart) <semi>": R(Function(navigation.previous_line), rspec="hark dock"), "duple [<nnavi50>]": R(Function(navigation.duple_keep_clipboard), rspec="duple"), "Kraken": R(Key("c-space"), rspec="Kraken"), "undo [<nnavi10>]": R(Key("c-z")) * Repeat(extra="nnavi10"), "redo [<nnavi10>]": R( ContextAction( default=Key("c-y") * Repeat(extra="nnavi10"), actions=[ (AppContext(executable=["rstudio", "foxitreader"]), Key("cs-z") * Repeat(extra="nnavi10")), ])), # text formatting "set [<big>] format (<capitalization> <spacing> | <capitalization> | <spacing>) [(bow|bowel)]": R(Function(textformat.set_text_format)), "clear castervoice [<big>] formatting": R(Function(textformat.clear_text_format)), "peek [<big>] format": R(Function(textformat.peek_text_format)), "(<capitalization> <spacing> | <capitalization> | <spacing>) [(bow|bowel)] <textnv> [brunt]": R(Function(textformat.master_format_text)), "[<big>] format <textnv>": R(Function(textformat.prior_text_format)), "<word_limit> [<big>] format <textnv>": R(Function(textformat.partial_format_text)), "hug <enclosure>": R(Function(text_utils.enclose_selected)), "dredge [<nnavi10>]": R(Key("alt:down, tab/20:%(nnavi10)d, alt:up"), rdescript="Core: switch to most recent Windows"), # Ccr Mouse Commands "kick [<nnavi3>]": R(Function(navigation.left_click)) * Repeat(extra="nnavi3"), "psychic": R(Function(navigation.right_click)), "(kick double|double kick)": R(Function(navigation.left_click) * Repeat(2)), "squat": R(Function(navigation.left_down)), "bench": R(Function(navigation.left_up)), # special keystroke commands "(lease wally | latch) [<nnavi10>]": R(Key("home:%(nnavi10)s")), "(ross wally | ratch) [<nnavi10>]": R(Key("end:%(nnavi10)s")), "sauce wally [<nnavi10>]": R(Key("c-home:%(nnavi10)s")), "dunce wally [<nnavi10>]": R(Key("c-end:%(nnavi10)s")), "bird [<nnavi500>]": R(Key("c-left:%(nnavi500)s")), "firch [<nnavi500>]": R(Key("c-right:%(nnavi500)s")), "brick [<nnavi500>]": R(Key("s-left:%(nnavi500)s")), "frick [<nnavi500>]": R(Key("s-right:%(nnavi500)s")), "blitch [<nnavi500>]": R(Key("cs-left:%(nnavi500)s")), "flitch [<nnavi500>]": R(Key("cs-right:%(nnavi500)s")), "<button_dictionary_500_no_prefix_no_modifier> [<nnavi500>]": R(Key("%(button_dictionary_500_no_prefix_no_modifier)s") * Repeat(extra='nnavi500'), rdescript= "press buttons from button_dictionary_500_no_prefix_no_modifier"), "<modifier> <button_dictionary_500_modifier> [<nnavi500>]": R(Key("%(modifier)s%(button_dictionary_500_modifier)s") * Repeat(extra='nnavi500'), rdescript= "press modifiers plus buttons from button_dictionary_500_modifier"), "<modifier> <button_dictionary_1_modifier>": R(Key("%(modifier)s%(button_dictionary_1_modifier)s"), rdescript= "press modifiers plus buttons from button_dictionary_1_modifier"), } tell_commands_dict = { "dock": ";", "doc": ";", "sink": "", "com": ",", "deck": ":" } tell_commands_dict.update(_tpd) button_dictionary_500_no_prefix_no_modifier = { "tabby": "tab", "clear": "backspace", "deli": "del", "shock": "enter", "lease": "left", "ross": "right", "sauce": "up", "dunce": "down", "page (down | dunce)": "pgdown", "page (up | sauce)": "pgup", } button_dictionary_500_modifier = { key: value for key, value in keyboard_support.button_dictionary_1.items() if value in [ "backspace", "del", "enter", "left", "right", "up", "down", "pgdown", "pgup" ] } button_dictionary_1_modifier = { key: value for key, value in keyboard_support.button_dictionary_1.items() if value in ["home", "end"] } extras = [ ShortIntegerRef("nnavi10", 1, 11), ShortIntegerRef("nnavi3", 1, 4), ShortIntegerRef("nnavi50", 1, 50), ShortIntegerRef("nnavi500", 1, 500), Dictation("textnv"), Choice("enclosure", _dtpd), Choice( "capitalization", { "yell": 1, "tie": 2, "gerrish": 3, "sing": 4, "laws": 5, "say": 6, "cop": 7, "slip": 8, }), Choice( "spacing", { "gum": 1, "gun": 1, "spine": 2, "snake": 3, "pebble": 4, "incline": 5, "dissent": 6, "descent": 6, }), Choice("semi", tell_commands_dict), Choice("word_limit", { "single": 1, "double": 2, "triple": 3, "Quadra": 4 }), navigation_support.TARGET_CHOICE, Choice("extreme", { "Wally": "way", }), Choice("big", { "big": True, }), Choice("splatdir", { "lease": "backspace", "ross": "delete", }), keyboard_support.modifier_choice_object, Choice("button_dictionary_500_no_prefix_no_modifier", button_dictionary_500_no_prefix_no_modifier), Choice("button_dictionary_500_modifier", button_dictionary_500_modifier), Choice("button_dictionary_1_modifier", button_dictionary_1_modifier) ] defaults = { "nnavi500": 1, "nnavi50": 1, "nnavi10": 1, "nnavi3": 1, "textnv": "", "capitalization": 0, "spacing": 0, "extreme": None, "big": False, "splatdir": "backspace", }
class NavigationNon(MappingRule): pronunciation = "navigation companion" mapping = { "<direction> <time_in_seconds>": AsynchronousAction( [L(S(["cancel"], Key("%(direction)s"), consume=False))], repetitions=1000, blocking=False), "erase multi clipboard": R(Function(navigation.erase_multi_clipboard)), "find": R(Key("c-f")), "find next [<n>]": R(Key("f3"))*Repeat(extra="n"), "find prior [<n>]": R(Key("s-f3"))*Repeat(extra="n"), "find everywhere": R(Key("cs-f")), "replace": R(Key("c-h")), "F<function_key>": R(Key("f%(function_key)s")), "[show] context menu": R(Key("s-f10")), "lean": R(Function(navigation.right_down)), "hoist": R(Function(navigation.right_up)), "kick mid": R(Function(navigation.middle_click)), "shift right click": R(Key("shift:down") + Mouse("right") + Key("shift:up")), "curse <direction> [<direction2>] [<nnavi500>] [<dokick>]": R(Function(navigation.curse)), "scree <direction> [<nnavi500>]": R(Function(navigation.wheel_scroll)), "colic": R(Key("control:down") + Mouse("left") + Key("control:up")), "garb [<nnavi500>]": R(Mouse("left") + Mouse("left") + Function( navigation.stoosh_keep_clipboard)), "drop [<nnavi500>]": R(Mouse("left") + Mouse("left") + Function( navigation.drop_keep_clipboard, capitalization=0, spacing=0)), "sure stoosh": R(Key("c-c")), "sure cut": R(Key("c-x")), "sure spark": R(Key("c-v")), "refresh": R(Key("c-r")), "maxiwin": R(Key("w-up")), "move window": R(Key("a-space, r, a-space, m")), "window (left | lease) [<n>]": R(Key("w-left"))*Repeat(extra="n"), "window (right | ross) [<n>]": R(Key("w-right"))*Repeat(extra="n"), "monitor (left | lease) [<n>]": R(Key("sw-left"))*Repeat(extra="n"), "monitor (right | ross) [<n>]": R(Key("sw-right"))*Repeat(extra="n"), "(next | prior) window": R(Key("ca-tab, enter")), "switch (window | windows)": R(Key("ca-tab"))*Repeat(extra="n"), "next tab [<n>]": R(Key("c-pgdown"))*Repeat(extra="n"), "prior tab [<n>]": R(Key("c-pgup"))*Repeat(extra="n"), "close tab [<n>]": R(Key("c-w/20"))*Repeat(extra="n"), "elite translation <text>": R(Function(alphabet_support.elite_text)), } extras = [ Dictation("text"), Dictation("mim"), IntegerRefST("function_key", 1, 13), IntegerRefST("n", 1, 50), IntegerRefST("nnavi500", 1, 500), Choice("time_in_seconds", { "super slow": 5, "slow": 2, "normal": 0.6, "fast": 0.1, "superfast": 0.05 }), navigation_support.get_direction_choice("direction"), navigation_support.get_direction_choice("direction2"), navigation_support.TARGET_CHOICE, Choice("dokick", { "kick": 1, "psychic": 2 }), Choice("wm", { "ex": 1, "tie": 2 }), ] defaults = { "n": 1, "mim": "", "nnavi500": 1, "direction2": "", "dokick": 0, "text": "", "wm": 2 }
class VisualStudioRule(MappingRule): mapping = { "next tab [<n>]": R(Key("ca-pgdown")) * Repeat(extra="n"), "prior tab [<n>]": R(Key("ca-pgup")) * Repeat(extra="n"), "close tab [<n>]": R(Key("c-f4/20")) * Repeat(extra="n"), "(list | show) documents": R(Key("a-w, w")), "[focus] document (window | pane)": R(Key("a-w, w, enter")), "solution explorer": R(Key("ca-l")), "team explorer": R(Key("c-backslash, c-m")), "source control explorer": R(Key("c-q") + Text("Source Control Explorer") + Key("enter")), "quick launch": R(Key("c-q")), "go to line": R(Key("c-g")), "comment line": R(Key("c-k, c-c")), "comment block": R(Key("c-k, c-c")), "(un | on) comment line": R(Key("c-k/50, c-u")), "(un | on) comment block": R(Key("c-k/50, c-u")), "[toggle] full screen": R(Key("sa-enter")), "(set | toggle) bookmark": R(Key("c-k, c-k")), "next bookmark": R(Key("c-k, c-n")), "prior bookmark": R(Key("c-k, c-p")), "collapse to definitions": R(Key("c-m, c-o")), "toggle [section] outlining": R(Key("c-m, c-m")), "toggle all outlining": R(Key("c-m, c-l")), "[toggle] break point": R(Key("f9")), "step over [<n>]": R(Key("f10/50") * Repeat(extra="n")), "step into": R(Key("f11")), "step out [of]": R(Key("s-f11")), "(resume | go debug)": R(Key("f5")), "run tests": R(Key("c-r, t")), "run all tests": R(Key("c-r, a")), "build solution": R(Key("cs-b")), "get latest [version]": R(Key("a-f, r, l")), "(show | view) history": R(Key("a-f, r, h")), "compare (files | versions)": R(Key("a-f, r, h")), "undo (checkout | pending changes)": R(Key("a-f, r, u")), "[open] [go to] work item": R(Key("a-m, g")), "[add] [new] linked work item": R(Key("sa-l")), "go back": R(Key("c--")), "go forward": R(Key("cs--")), "go to definition": R(Key("f12")), "show refs": R(Key("a-2")), } extras = [ Dictation("text"), Dictation("mim"), IntegerRefST("n", 1, 1000), ] defaults = {"n": 1, "mim": ""}
class MainRule(MergeRule): @staticmethod def generate_ccr_choices(nexus): choices = {} for ccr_choice in nexus.merger.global_rule_names(): choices[ccr_choice] = ccr_choice return Choice("name", choices) @staticmethod def generate_sm_ccr_choices(nexus): choices = {} for ccr_choice in nexus.merger.selfmod_rule_names(): choices[ccr_choice] = ccr_choice return Choice("name2", choices) mapping = { # update management # "update caster": # R(DependencyUpdate([pip, "install", "--upgrade", "castervoice"])), # "update dragonfly": # R(DependencyUpdate([pip, "install", "--upgrade", "dragonfly2"])), # hardware management "volume <volume_mode> [<n>]": R(Function(navigation.volume_control, extra={'n', 'volume_mode'})), "change monitor": R(Key("w-p") + Pause("100") + Function(change_monitor)), # passwords # mouse alternatives "legion [<monitor>]": R(Function(navigation.mouse_alternates, mode="legion", nexus=_NEXUS)), "rainbow [<monitor>]": R(Function(navigation.mouse_alternates, mode="rainbow", nexus=_NEXUS)), "douglas [<monitor>]": R(Function(navigation.mouse_alternates, mode="douglas", nexus=_NEXUS)), # ccr de/activation "<enable> <name>": R(Function(_NEXUS.merger.global_rule_changer(), save=True)), "<enable> <name2>": R(Function(_NEXUS.merger.selfmod_rule_changer(), save=True)), "enable caster": R(Function(_NEXUS.merger.merge, time=MergeInf.RUN, name="numbers")), "disable caster": R(Function(_NEXUS.merger.ccr_off)), } extras = [ IntegerRefST("n", 1, 50), Dictation("text"), Dictation("text2"), Dictation("text3"), Choice("enable", { "enable": True, "disable": False }), Choice("volume_mode", { "mute": "mute", "up": "up", "down": "down" }), generate_ccr_choices.__func__(_NEXUS), generate_sm_ccr_choices.__func__(_NEXUS), IntegerRefST("monitor", 1, 10) ] defaults = { "n": 1, "nnv": 1, "text": "", "volume_mode": "setsysvolume", "enable": -1 }
class CustomGitBashRule(MappingRule): pronunciation = "custom get bash" mapping = { "initialize repository": Text("git init") + Key("enter"), "log": Key("g, i, t, space, l, o, g") + Key("enter"), "Re-base": Key("g, i, t, space, r, e, b, a, s, e, space"), "Re-base interactive": Key("g, i, t, space, r, e, b, a, s, e, space, minus, i, space, H, E, A, D, ~" ), "add": R(Key("g, i, t, space, a, d, d, space, minus, p"), rdescript="GIT: Add All"), "status": R(Key("g, i, t, space, s, t, a, t, u, s, enter"), rdescript="GIT: Status"), "reset": R(Key( "g, i, t, space, r, e, s, e, t, space, minus, minus, s, o, f, t, space, H, E, A, D, ~" ), rdescript="GIT: Reset"), "commit": R(Key( "g, i, t, space, c, o, m, m, i, t, space, minus, 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"), "check out new branch": R(Text("git checkout -b feature/SWOPS-"), rdescript="GIT: Check Out New Branch"), "difference": R(Text("git diff") + Key('enter'), rdescript="GIT: Diff"), "branch": R(Text("git branch") + Key("enter"), rdescript="GIT: Branch"), "remote": R(Text("git remote "), rdescript="GIT: Remote"), "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 "), rdescript="GIT: Push"), "(get push origin | push origin)": R(Text("git push -u origin "), rdescript="GIT: Push Origin"), "pull": R(Text("git pull") + Key("enter"), rdescript="GIT: Pull"), "dirrup": R(Text("cd ../ ; ls;") + Key("enter"), rdescript="GIT: Up Directory"), "list": R(Text("ls "), rdescript="GIT: List"), "list all": R(Text("ls -la "), rdescript="GIT: List all"), "Moved or": # move dir R(Text("mv "), rdescript="GIT: Move"), "make directory": R(Text("mkdir "), rdescript="GIT: Make Directory"), "abort": R(Key("c-c "), rdescript="GIT: Abort"), "undo [last] commit": R(Text("git reset --soft HEAD~1") + Key("enter"), rdescript="GIT: Undo Commit"), "(undo changes | reset hard)": R(Text("git reset --hard") + Key("enter"), rdescript="GIT: Undo or Reset 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 "), 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"), "search": R(Key("c-r"), rdescript="Bash: To File"), # Specific Commands "remove directory [<text>]": R(Text("rm -rf ") + Text("%(text)s"), rdescript="GIT: Navigate To Caster Directory"), "CD [<text>]": R(Text("cd ") + Text("%(text)s") + Text("; ls") + Key("left") + Key("left") + Key("left") + Key("left"), rdescript="GIT: Navigate To Caster Directory"), "CD Castor": R(Text("cd /c/NatLink/NatLink/MacroSystem/caster") + Key("enter"), rdescript="GIT: Navigate To Caster Directory"), "CD custom Castor": R(Text("cd /c/NatLink/NatLink/MacroSystem/caster/user") + Key("enter"), rdescript="GIT: Navigate To Caster Directory"), "checkout develop": R(Text("git checkout develop") + Key("enter"), rdescript="GIT: Check Out"), # "Mungo": # R(Text("mongo "), rdescript="GIT: Check Out"), "Clear": R(Text("clear") + Key("enter"), rdescript="GIT: Check Out"), "Cat": R(Text("cat "), rdescript="GIT: Check Out"), "SSH [<text>]": R(Text("ssh ") + Text("%(text)s"), rdescript="GIT: ssh"), "pseudo": R(Text("sudo "), rdescript="GIT: Check Out"), "apt get install": R(Text("apt-get install "), rdescript="GIT: Check Out"), "next tab": R(Key("c-tab"), rdescript="switch tab"), "pytest": R(Text("pytest -s -vv"), rdescript="run pytest"), "activate environment": R(Text("source .venv/bin/activate") + Key("enter"), rdescript="activate virtual environment"), } extras = [ ShortIntegerRef("n", 1, 10000), Dictation("text"), ] defaults = {"n": 0, "text": ""}
class MSTeamsRule(MappingRule): name = "microsoft teams" mapping = { # General "search": R(Key("c-e")), "keyboard shortcuts": R(Key("c-.")), "settings": R(Key("c-comma")), "help": R(Key("f1")), "commands": R(Key("c-slash")), "filter": R(Key("cs-f")), "go to": R(Key("c-g")), "new chat": R(Key("c-n")), # Navigation "activity": R(Key("c-1")), "chat": R(Key("c-2")), "teams": R(Key("c-3")), "calendar": R(Key("c-4")), "calls": R(Key("c-5")), "files": R(Key("c-6")), "shifts": R(Key("c-7")), "previous item [<nnavi10>]": R(Key("a-up")) * Repeat(extra="nnavi10"), "next item [<nnavi10>]": R(Key("a-down")) * Repeat(extra="nnavi10"), "previous team": R(Key("cs-up")), "next team": R(Key("cs-down")), "previous section": R(Key("cs-f6")), "next section": R(Key("c-f6")), # Messaging "focus compose": R(Key("c")), "expand compose": R(Key("cs-x")), "send": R(Key("c-enter")), "attach": R(Key("c-o")), "new-line": R(Key("s-enter")), "reply": R(Key("r")), # meetings calls and calendar "Accept [video] call": R(Key("cs-a")), "Accept [audio] call": R(Key("cs-s")), "decline [call]": R(Key("cs-d")), "start audio call": R(Key("cs-c")), "Start video call": R(Key("cs-u")), "toggle mute": R(Key("cs-m")), "screen share": R(Key("cs-e")), "toggle video": R(Key("cs-o")), "sharing toolbar": R(Key("cs-space")), "decline screen share": R(Key("cs-d")), "Accept screen share": R(Key("cs-a")), "Schedule meeting": R(Key("as-n")), "go to current time": R(Key("a-.")), "go to previous (day | week)": R(Key("ca-left")), "go to next (day | week)": R(Key("ca-right")), "View day": R(Key("ca-1")), "View workweek": R(Key("ca-2")), "View week": R(Key("ca-3")), } exported = True extras = [IntegerRefST("nnavi10", 1, 11)] defaults = {"nnavi10": 1}
class GitBashRule(MappingRule): GIT_ADD_ALL = "g, i, t, space, a, d, d, space, minus, A" GIT_COMMIT = "g, i, t, space, c, o, m, m, i, t, space, minus, m, space, quote, quote, left" mapping = { "(git|get) base": Text("git "), "(git|get) (initialize repository|init)": Text("git init"), "(git|get) add": R(Key("g, i, t, space, a, d, d, space, dot")), "(git|get) add all": R(Key(GIT_ADD_ALL)), "(git|get) commit all": R(Key("%s, ;, space, %s" % (GIT_ADD_ALL, GIT_COMMIT))), "(git|get) status": R(Key("g, i, t, space, s, t, a, t, u, s")), "(git|get) commit": R(Key(GIT_COMMIT)), "(git|get) bug fix commit <n>": R(Mimic("get", "commit") + Text("fixes #%(n)d ") + Key("backspace")), "(git|get) reference commit <n>": R(Mimic("get", "commit") + Text("refs #%(n)d ") + Key("backspace")), "(git|get) checkout": R(Text("git checkout ")), "(git|get) branch": R(Text("git branch ")), "(git|get) remote": R(Text("git remote ")), "(git|get) merge": R(Text("git merge ")), "(git|get) merge tool": R(Text("git mergetool")), "(git|get) fetch": R(Text("git fetch ")), "(git|get) push": R(Text("git push ")), "(git|get) pull": R(Text("git pull ")), "CD up": R(Text("cd ..")), "CD": R(Text("cd ")), "list": R(Text("ls")), "make directory": R(Text("mkdir ")), "undo [last] commit | (git|get) reset soft head": R(Text("git reset --soft HEAD~1")), "(undo changes | (git|get) reset hard)": R(Text("git reset --hard")), "stop tracking [file] | (git|get) remove": R(Text("git rm --cached ")), "preview remove untracked | (git|get) clean preview": R(Text("git clean -nd")), "remove untracked | (git|get) clean untracked": R(Text("git clean -fd")), "(git|get) visualize": R(Text("gitk")), "(git|get) visualize file": R(Text("gitk -- PATH")), "(git|get) visualize all": R(Text("gitk --all")), "(git|get) stash": R(Text("git stash")), "(git|get) stash apply [<n>]": R(Text("git stash apply") + Function(_apply)), "(git|get) stash list": R(Text("git stash list")), "(git|get) stash branch": R(Text("git stash branch NAME")), "(git|get) cherry pick": R(Text("git cherry-pick ")), "(git|get) (abort cherry pick | cherry pick abort)": R(Text("git cherry-pick --abort")), "(git|get) (GUI | gooey)": R(Text("git gui")), "(git|get) blame": R(Text("git blame PATH -L FIRSTLINE,LASTLINE")), "(git|get) gooey blame": R(Text("git gui blame PATH")), "search recursive": R(Text("grep -rinH \"PATTERN\" *")), "search recursive count": R(Text("grep -rinH \"PATTERN\" * | wc -l")), "search recursive file type": R(Text("find . -name \"*.java\" -exec grep -rinH \"PATTERN\" {} \\;")), "to file": R(Text(" > FILENAME")), } extras = [ IntegerRefST("n", 1, 10000), ] defaults = {"n": 0}
class EclipseCCR(MergeRule): pronunciation = "eclipse jump" mapping = { #Line Ops "configure": R( Paste(ec_con.analysis_chars) + Key("left:2/5, c-f/20, backslash, rbracket, enter") + Function(ec_con.analyze_for_configure)), "jump in [<n>]": R( Key("c-f, a-o") + Paste(r"[\(\[\{\<]") + Function(ec_con.regex_on) + Key("enter:%(n)d/5, escape, right")), "jump out [<n>]": R( Key("c-f, a-o") + Paste(r"[\)\] \}\>]") + Function(ec_con.regex_on) + Key("enter:%(n)d/5, escape, right")), "jump back [<n>]": R( Key("c-f/5, a-b") + Paste(r"[\)\]\}\>]") + Function(ec_con.regex_on) + Key("enter:%(n)d/5, escape, left")), "[go to] line <n>": R( Key("c-l") + Pause("50") + Text("%(n)d") + Key("enter") + Pause("50")), "shackle <n> [<back>]": R( Key("c-l") + Key("right, cs-left") + Function(ec_con.lines_relative)), } extras = [ Dictation("text"), IntegerRefST("n", 1, 1000), Boolean("back"), ] defaults = {"n": 1, "back": False}
def action_lines(action, ln1, ln2, go_to_line="c-g", select_line_down="s-down", wait="", upon_arrival=""): num_lines = max(int(ln2)-int(ln1)+1, int(ln1)-int(ln2)+1) if ln2 else 1 top_line = min(int(ln2), int(ln1)) if ln2 else int(ln1) command = Key(go_to_line) + Text(str(top_line)) + Key("enter%s, %s%s%s:%s, %s" % (wait, upon_arrival, select_line_down, wait, str(num_lines), action)) command.execute()
class RStudioRule(MappingRule): mapping = { "new file": R(Key("cs-n")), "open file": R(Key("c-o")), "open recent project": R(Key("a-f, j")), "open project": R(Key("a-f, n, enter")), "save all": R(Key("ac-s")), "select all": R(Key("c-a")), "find": R(Key("c-f")), "[go to] line <ln1>": R(Key("as-g") + Pause("10") + Text("%(ln1)s") + Key("enter")), "<action> [line] <ln1> [by <ln2>]": R( Function(navigation.action_lines, go_to_line="as-g/10", select_line_down="s-down", wait="/3", upon_arrival="home, ")), "focus console": R(Key("c-2")), "focus main": R(Key("c-1")), "next tab": R(Key("c-f12")), "first tab": R(Key("cs-f11")), "previous tab": R(Key("c-f11")), "last tab": R(Key("cs-f12")), "close tab": R(Key("c-w")), "run line": R(Key("c-enter")), "run document": R(Key("ac-r")), "comment (line | selected)": R(Key("cs-c")), "next plot": R(Key("ac-f12")), "previous plot": R(Key("ac-f11")), "(help | document) that": R(Store() + Key("c-2, question") + Retrieve() + Key("enter, c-3")), "glimpse that": R(Store() + Key("c-2") + Retrieve() + Key("space, percent, rangle, percent") + Text(" glimpse()") + Key("enter/50, c-1")), "vee table that": R(Store() + Key("c-2") + Text("library(vtable)") + Key("enter/50") + Retrieve() + Key("space, percent, rangle, percent") + Text(" vtable()") + Key("enter/50, c-1")), } extras = [ ShortIntegerRef("ln1", 1, 10000), ShortIntegerRef("ln2", 1, 10000), Choice("action", navigation.actions), ] defaults = {"ln2": ""}
class Rust(MergeRule): pronunciation = "rust" mapping = { SymbolSpecs.IF: R(Text("if {}") + Key("left/5:3")), SymbolSpecs.ELSE: R(Text("else {}") + Key("left/5:3")), # SymbolSpecs.SWITCH: R(Text("match ")), SymbolSpecs.CASE: R(Text(" => ")), SymbolSpecs.BREAK: R(Text("break;")), SymbolSpecs.DEFAULT: R(Text("_")), # SymbolSpecs.DO_LOOP: R(Text("while {TOKEN;TOKEN}{}")), SymbolSpecs.WHILE_LOOP: R(Text("while TOKEN {}") + Key("left")), "for loop [of <a> [in <n>]]": R(Text("for %(a)s in 0..%(n)d {}") + Key("left")), SymbolSpecs.FOR_EACH_LOOP: R(Text("for TOKEN in TOKEN {}") + Key("left")), # SymbolSpecs.TO_INTEGER: R(Text("parse::<i32>().unwrap()")), SymbolSpecs.TO_FLOAT: R(Text("parse::<f64>().unwrap()")), SymbolSpecs.TO_STRING: R(Text("to_string()")), # SymbolSpecs.AND: R(Text(" && ")), SymbolSpecs.OR: R(Text(" || ")), SymbolSpecs.NOT: R(Text("!")), # SymbolSpecs.SYSOUT: R(Text("println!()") + Key("left")), # SymbolSpecs.IMPORT: R(Text("use ")), # # function moved to ncmap SymbolSpecs.CLASS: R(Text("struct ")), # SymbolSpecs.COMMENT: R(Text("// ")), SymbolSpecs.LONG_COMMENT: R(Text("/// ")), # SymbolSpecs.NULL: R(Text("None")), # SymbolSpecs.RETURN: R(Text("return ")), # SymbolSpecs.TRUE: R(Text("true")), SymbolSpecs.FALSE: R(Text("false")), # Rust specific "value some": R(Text("Some()") + Key("left")), "enumerate for loop [of <a> [in <n>]]": R(Text("for (%(a)s, TOKEN) in (0..%(n)d).enumerate() {}") + Key("left")), "enumerate for each [<a> <b>]": R(Text("for (%(a)s, %(b)s) in TOKEN.enumerate() {}") + Key("left")), "bind [<mutability>]": R(Text("let %(mutability)s")), "of type": R(Text(": ")), "[<signed>] integer [<ibits>]": R(Text("%(signed)s%(bits)s ")), "float [<fbits>]": R(Text("f%(fbits)s ")), "boolean": R(Text("bool ")), "string": R(Text("String ")), "array [of] size <n>": R(Text("[TOKEN; %(n)d]")), "macro vector": R(Text("vec![]") + Key("left")), "refer to [<mutability>]": R(Text("&%(mutability)s")), "lifetime": R(Text("'")), "static": R(Text("static ")), "self": R(Text("self")), "brace pan": R(Key("escape, escape, end, left, enter, enter, up, tab")), "enum": R(Text("enum ")), "await": R(Text(".await")), "async": R(Text("async ")), "clone": R(Text(".clone()")), "name space": R(Key("colon, colon")), } extras = [ Choice("ibits", { "eight": "8", "sixteen": "16", "thirty two": "32", "sixty four": "64" }), Choice("fbits", { "thirty two": "32", "sixty four": "64" }), Choice("signed", {"unsigned": "u"}), Choice("mutability", {"mute ah | mute": "mut "}), IntegerRefST("n", 0, 1000), alphabet_support.get_alphabet_choice("a"), alphabet_support.get_alphabet_choice("b"), ] defaults = {"bits": "32", "signed": "i", "mutability": "", "a": "i", "b": "j", "n": 1}
class Haxe(MergeRule): pronunciation = "hacks" mapping = { SymbolSpecs.IF: R(Key("i, f, lparen, rparen, left")), SymbolSpecs.ELSE: R(Key("e, l, s, e")), # SymbolSpecs.SWITCH: R(Text("switch(){\ncase : TOKEN;\ndefault: TOKEN;") + Key("up,up,left,left")), SymbolSpecs.CASE: R(Text("case :") + Key("left")), SymbolSpecs.BREAK: R(Text("break;")), SymbolSpecs.DEFAULT: R(Text("default: ")), # SymbolSpecs.DO_LOOP: R(Text("do TOKEN while()") + Key("left, enter:2")), SymbolSpecs.WHILE_LOOP: R(Text("while ()") + Key("left")), SymbolSpecs.FOR_LOOP: R(Text("for (i in 0...TOKEN)")), SymbolSpecs.FOR_EACH_LOOP: R(Text("for (TOKEN in TOKEN)")), # SymbolSpecs.TO_INTEGER: R(Text("Std.int()") + Key("left")), SymbolSpecs.TO_FLOAT: R(Text("Std.parseFloat()") + Key("left")), SymbolSpecs.TO_STRING: R(Text("Std.string()") + Key("left")), # SymbolSpecs.AND: R(Text("&&")), SymbolSpecs.OR: R(Text("||")), SymbolSpecs.NOT: R(Text("!")), # SymbolSpecs.SYSOUT: R(Text("trace()") + Key("left")), # SymbolSpecs.FUNCTION: R(Text("function ")), SymbolSpecs.CLASS: R(Text("class ")), # SymbolSpecs.COMMENT: R(Text("//")), SymbolSpecs.LONG_COMMENT: R(Text("/**/") + Key("left, left")), # SymbolSpecs.NULL: R(Text("null")), # SymbolSpecs.RETURN: R(Text("return ")), # SymbolSpecs.TRUE: R(Text("true")), SymbolSpecs.FALSE: R(Text("false")), # Haxe specific "import": R(Text("import ")), "new new": R(Text("new ")), "instance of": R(Text("Std.is()") + Key("left")), "anon funk": R(Text("->")), "map of": R(Text("Map<TOKEN, TOKEN>()")), "array of": R(Text("Array<TOKEN>()") + Key("left")), "far | variable": R(Text("var ")), "boolean": R(Text("Bool ")), "integer": R(Text("Int ")), "double": R(Text("Float ")), "dynamic": R(Text("Dynamic")), "void": R(Text("Void")), "string": R(Text("String ")), "public": R(Text("public ")), "private": R(Text("private ")), "static": R(Text("static ")), "this": R(Text("this")), "safe cast": R(Text("cast (TOKEN, TOKEN)")), "get class": R(Text("Type.getClass()") + Key("left")), "get name": R(Text("Type.getClassName()") + Key("left")) } extras = [] defaults = {}
class SSMSRule(MappingRule): mapping = { # There doesn't seem to be a hotkey for sequential tab navigation in SSMS, but something is better than nothing... "next tab [<n>]": R(Key("c-tab")) * Repeat(extra="n"), "prior tab [<n>]": R(Key("cs-tab")) * Repeat(extra="n"), "close tab [<n>]": R(Key("c-f4/20")) * Repeat(extra="n"), "go to line": R(Key("c-g")), "comment line": R(Key("c-k, c-c")), "comment block": R(Key("c-k, c-c")), "(un | on) comment line": R(Key("c-k/50, c-u")), "(un | on) comment block": R(Key("c-k/50, c-u")), "[toggle] full screen": R(Key("sa-enter")), "(set | toggle) bookmark": R(Key("c-k, c-k")), "next bookmark": R(Key("c-k, c-n")), "prior bookmark": R(Key("c-k, c-p")), "[toggle] break point": R(Key("f9")), "step over [<n>]": R(Key("f10/50") * Repeat(extra="n")), "step into": R(Key("f11")), "step out [of]": R(Key("s-f11")), "resume": R(Key("f5")), } extras = [ Dictation("text"), Dictation("mim"), ShortIntegerRef("n", 1, 1000), ] defaults = {"n": 1, "mim": ""}
def volume_control(n, volume_mode): for i in range(0, int(n)): Key("volume" + str(volume_mode)).execute()
class VHDL(MergeRule): pronunciation = "VHDL" mapping = { SymbolSpecs.COMMENT: R(Text("-- ")), SymbolSpecs.IF: R( Text("if () then ") + Key("enter,enter") + Text("end if;") + Key("home,up,up")), SymbolSpecs.ELSE: R(Key("e,l,s,e,enter")), "alternate": R(Key("e,l,s,i, f,space,T,O,K,E,N,space,t,h,e,n,enter,tab")), SymbolSpecs.CASE: R(Text("case TOKEN is") + Key("enter,tab")), "when": R(Text("when ")), SymbolSpecs.FOR_LOOP: R(Text("for in to loop") + Key("left:12")), "generate": R(Text("GENERATE")), "Output": R(Text("out")), "Standard Logic": R(Text("std_logic")), "Standard Logic Vector": R(Text("std_logic_vector")), "Constant": R(Text("constant : ") + Key("left,left")), "Signal": R(Text("signal : ") + Key("left,left")), "integer": R(Text("integer TOKEN to TOKEN")), "type": R(Text("type :") + Key("left")), # Operators "Not Equal": R(Text("/=")), SymbolSpecs.NOT: R(Text("not")), SymbolSpecs.OR: R(Text("or")), "not and": R(Text("nand")), "XOR": R(Text("xor")), "X NOR": R(Text("xnor")), "Assignment": R(Text(" <= ") + Key("left")), "Association": R(Text(' => ') + Key("left")), "Concatenate": R(Text(" & ")), "Down To": R(Text("downto")), "Up To": R(Text("upto")), "Input": R(Text("in")), "binary [<amount>] <digit>": R(Function(binary_string)), #VHDL specific "length": R(Text("length'")), SymbolSpecs.TO_INTEGER: R(Text("to_integer()") + Key("left")), "converts to signed": R(Text("signed()") + Key("left")), "converts to unsigned": R(Text("unsigned()") + Key("left")), "converts to unsigned specific": R(Text("conv_unsigned(,)") + Key("left:2")), "converts to integer specific": R(Text("conv_integer(,)") + Key("left:2")), } extras = [ ShortIntegerRef("amount", 1, 128), Choice("digit", { "(zero|zeros)": 0, "(one|once)": 1 }), ShortIntegerRef("digit", 0, 2) ] defaults = {}
class JiraRule(MappingRule): mapping = { # Global Shortcuts "go to dashboards": R(Key("g") + Key("d")), "go to projects": R(Key("g") + Key("p")), "go to boards": R(Key("g") + Key("a")), "go to issues": R(Key("g") + Key("i")), # This requires a plugin "go to tempo [teams]": R(Key("g") + Key("t")), # This requires a plugin "go to portfolio": R(Key("p") + Key("v")), "quick search": R(Key("slash")), "create issue": R(Key("c")), "submit [form]": R(Key('as-s')), # Navigating Issues "view issue": R(Key("o")), "next (issue | item) [<nnavi10>]": R(Key("j")) * Repeat(extra="nnavi10"), "previous (issue | item) [<nnavi10>]": R(Key("k")) * Repeat(extra="nnavi10"), # Issue Actions "edit issue": R(Key("e")), "(action | actions)": R(Key(".")), # Opens the action menu and attempts the given action. If the action does not exist the menu remains open. # Depending on the context the verb "edit" is more natural "(action | edit) <action>": R( Key(".") + Pause("20") + Text("%(action)s") + Pause("20") + Key("enter")), # JIRA contains dedicated hotkeys for some operations. However, the above action command makes them redundant. # - assign issue # - comment issue # - edit issue labels # - log time # - assign to me "share issue": R(Key("s")), # Board Shortcuts "go to backlog": R(Key("1")), "go to sprint": R(Key("2")), "go to reports": R(Key("3")), "toggle details": R(Key("t")), "toggle presentation [mode]": R(Key("z")), "toggle swim lanes": R(Key("minus")), "send to top": R(Key("s") + Key("t")), "send to bottom": R(Key("s") + Key("b")), } exported = True extras = [ ShortIntegerRef("nnavi10", 1, 11), Dictation("action"), ] defaults = { "nnavi10": 1, "action": "", }
class CPP(MergeRule): pronunciation = "C plus plus" mapping = { SymbolSpecs.IF: R(Key("i, f, lparen, rparen, leftbrace, enter,up,left")), SymbolSpecs.ELSE: R(Key("e, l, s, e, leftbrace, enter")), # SymbolSpecs.SWITCH: R( Text("switch(){\ncase : break;\ndefault: break;") + Key("up,up,left,left")), SymbolSpecs.CASE: R(Text("case :") + Key("left")), SymbolSpecs.BREAK: R(Text("break;")), SymbolSpecs.DEFAULT: R(Text("default: ")), # SymbolSpecs.DO_LOOP: R(Text("do {}") + Key("left, enter:2")), SymbolSpecs.WHILE_LOOP: R(Text("while ()") + Key("left")), SymbolSpecs.FOR_LOOP: R(Text("for (int i=0; i<TOKEN; i++)")), SymbolSpecs.FOR_EACH_LOOP: R(Text("for_each (TOKEN, TOKEN, TOKEN);")), # SymbolSpecs.TO_INTEGER: R(Text("(int)")), SymbolSpecs.TO_FLOAT: R(Text("(double)")), SymbolSpecs.TO_STRING: R(Text("std::to_string()") + Key("left")), # SymbolSpecs.AND: R(Text("&&")), SymbolSpecs.OR: R(Text("||")), SymbolSpecs.NOT: R(Text("!")), # SymbolSpecs.SYSOUT: R(Text("cout <<")), # SymbolSpecs.IMPORT: R(Text("#include")), # SymbolSpecs.FUNCTION: R(Text("TOKEN TOKEN(){}") + Key("left")), SymbolSpecs.CLASS: R(Text("class TOKEN{}") + Key("left")), # SymbolSpecs.COMMENT: R(Text("//")), SymbolSpecs.LONG_COMMENT: R(Text("/**/") + Key("left, left")), # SymbolSpecs.NULL: R(Text("null")), # SymbolSpecs.RETURN: R(Text("return")), # SymbolSpecs.TRUE: R(Text("true")), SymbolSpecs.FALSE: R(Text("false")), # C++ specific "public": R(Text("public ")), "private": R(Text("private ")), "static": R(Text("static ")), "final": R(Text("final ")), "static cast integer": R(Text("static_cast<int>()") + Key("left")), "static cast double": R(Text("static_cast<double>()") + Key("left")), "([global] scope | name)": R(Text("::")), "Vic": R(Text("vector")), "pushback": R(Text("push_back")), "standard": R(Text("std")), "constant": R(Text("const")), "array": R(Mimic("brackets")), #http://www.learncpp.com/cpp-tutorial/67-introduction-to-pointers/ "(reference to | address of)": R(Text("&")), "(pointer | D reference)": R(Text("*")), "member": R(Text("->")), "new new": R(Text("new ")), "integer": R(Text("int ")), "double": R(Text("double ")), "character": R(Text("char ")), "big integer": R(Text("Integer")), "string": R(Text("string ")), "ternary": R(Text("()?;") + (Key("left") * 3)), } extras = [] defaults = {}
class IERule(MappingRule): mapping = { "address bar": R(Key("a-d")), "new (folder|directory)": R(Key("cs-n")), "new file": R(Key("a-f, w, t")), "(show | file | folder) properties": R(Key("a-enter")), "(get|go) up": R(Key("a-up")), "(get|go) back": R(Key("a-left")), "(get|go) forward": R(Key("a-right")), "search [<text>]": R(Key("a-d, tab:1") + Text("%(text)s")), "(navigation | nav | left) pane": R(Key("a-d, tab:2")), "(center pane | (file | folder) (pane | list))": R(Key("a-d, tab:3")), # for the sort command below, # once you've selected the relevant heading for sorting using the arrow keys, press enter "sort [headings]": R(Key("a-d, tab:4")), } extras = [ Dictation("text"), IntegerRefST("n", 1, 1000), ] defaults = {"n": 1}
class SlackRule(MergeRule): pronunciation = "Slack" mapping = { "(up | hoch)": R(Key("a-up")), "(down | runter)": R(Key("a-down")), "(next message | naechste nachricht)": R(Key("as-up")), "(previous message | vorherige nachricht)": R(Key("as-down")), "edit": R(Key("up")), "(new line | neue zeile)": R(Key("s-enter")), "(bold | fett)": R(Text("**") + Key("left")), "(emphasize | hervorheben)": R(Text("__") + Key("left")), "(search | suche)": R(Key("c-f")), "(block quote | zitat)": R(Text("> ")), "(mention | erwaehnen)": R(Text("@")), "(short code | kurzer code)": R(Text("```") + Key("left")), "(insert code | code einfuegen)": R( Text("```") + Key("backspace") + Text("```") + Key("s-enter") + Key("s-enter") + Text("```") + Key("backspace") + Key("backspace") + Text("```") + Text("```") + Key("backspace") + Key("backspace") + Key("backspace") + Key("up")), }
class fmanRule(MappingRule): mapping = { "copy": R(Key("f5")), "deselect": R(Key("c-d")), "edit": R(Key("f4")), "explorer": R(Key("f10")), # Set these yourself and add them to the Choice at the bottom # Requires the favourites plug-in "go <fav>": R(Key("c-0") + Pause("15") + Text("%(fav)s") + Key("enter")), "go see": R(Key("c-p") + Pause("15") + Text("c") + Key("enter")), "go to": R(Key("c-p")), "move": R(Key("f6")), "new file": R(Key("s-f4")), "new folder": R(Key("f7")), "open left": R(Key("c-left")), "open right": R(Key("c-right")), "properties": R(Key("a-enter")), "refresh": R(Key("c-r")), "rename": R(Key("s-f6")), "search": R(Key("cs-f")), "set favourite": R(Key("s-f")), "show favourites": R(Key("c-0")), "(show | hide) hidden": R(Key("c-dot")), "sort [by] name": R(Key("c-f1")), "sort [by] size": R(Key("c-f2")), "sort [by] (modified | date)": R(Key("c-f3")), "(stoosh | copy) path": R(Key("f11")), "terminal": R(Key("f9")), "command pallette": R(Key("cs-p")), } extras = [ IntegerRefST("num", 1, 4), Choice("fav", { "example favourite": "ef", }), ] defaults = { "num": 1, }
def move_until_phrase(direction, before_after, phrase, number_of_lines_to_search, occurrence_number, dictation_versus_character): if direction == "up" or direction == "down": number_of_lines_to_search, direction = deal_with_up_down_directions( direction, number_of_lines_to_search) application = get_application() if not before_after: # default to whatever is closest to the cursor if direction == "left": before_after = "after" if direction == "right": before_after = "before" selected_text = select_text_and_return_it(direction, number_of_lines_to_search, application) if not selected_text: return phrase = str(phrase) match_index = get_start_end_position(selected_text, phrase, direction, occurrence_number, dictation_versus_character) if match_index: left_index, right_index = match_index else: # phrase not found deal_with_phrase_not_found(selected_text, application, direction) return if application == "texstudio": # Approach 1: Unselect text by pressing left and then right. A little slower but works in Texstudio Key("left, right").execute() # unselect text if direction == "left": # cursor is at the left side of the previously selected text if before_after == "before": selected_text_to_the_left_of_phrase = selected_text[: left_index] multiline_offset_correction = selected_text_to_the_left_of_phrase.count( "\r\n") offset = left_index - multiline_offset_correction if before_after == "after": selected_text_to_the_left_of_phrase = selected_text[: right_index] multiline_offset_correction = selected_text_to_the_left_of_phrase.count( "\r\n") offset = right_index - multiline_offset_correction Key("right:%d" % offset).execute() if direction == "right": # cursor is at the left side of the previously selected text if before_after == "before": selected_text_to_the_right_of_phrase = selected_text[ left_index:] if before_after == "after": selected_text_to_the_right_of_phrase = selected_text[ right_index:] multiline_offset_correction = selected_text_to_the_right_of_phrase.count( "\r\n") if before_after == "before": offset = len( selected_text) - left_index - multiline_offset_correction if before_after == "after": offset = len( selected_text) - right_index - multiline_offset_correction Key("left:%d" % offset).execute() else: # Approach 2: unselect using arrow keys rather than pasting over the existing text. (a little faster) does not work texstudio if right_index < round(len(selected_text)) / 2: # it's faster to approach phrase from the left Key("left").execute( ) # unselect text and place cursor on the left side of selection if before_after == "before": offset_correction = selected_text[:left_index].count("\r\n") offset = left_index - offset_correction if before_after == "after": offset_correction = selected_text[:right_index].count("\r\n") offset = right_index - offset_correction Key("right:%d" % offset).execute() else: # it's faster to approach phrase from the right Key("right").execute( ) # unselect text and place cursor on the right side of selection if before_after == "before": offset_correction = selected_text[left_index:].count("\r\n") offset = len(selected_text) - left_index - offset_correction if before_after == "after": offset_correction = selected_text[right_index:].count("\r\n") offset = len(selected_text) - right_index - offset_correction Key("left:%d" % offset).execute()
class CSS(MergeRule): pronunciation = "css" mapping = { #Macros "selector": R(Text("{}") + Key("left/10:1") + Key("enter")), "property": R(Text(":;") + Key("left/10:1")), #Measurements "<ln1> pixel | <ln1> PX": R(Text("%(ln1)spx")), "<ln1> percentage | <ln1> percent": R(Text("%(ln1)s") + Key("s-5")), "<ln1> centimeter | <ln1> CM": R(Text("%(ln1)scm")), "<ln1> inch | <ln1> IN": R(Text("%(ln1)sin")), "<ln1> millimeter | <ln1> MM": R(Text("%(ln1)smm")), "<ln1> pica | <ln1> PC": R(Text("%(ln1)spc")), "<ln1> point | <ln1> PT": R(Text("%(ln1)spt")), "<ln1> CH": R(Text("%(ln1)sch")), "<ln1> EM": R(Text("%(ln1)sem")), "<ln1> EX": R(Text("%(ln1)sex")), "<ln1> REM": R(Text("%(ln1)srem")), "<ln1> viewport height | <ln1> VH": R(Text("%(ln1)svh")), "<ln1> viewport width | <ln1> VW": R(Text("%(ln1)svw")), "<ln1> millisecond | <ln1> MS": R(Text("%(ln1)sms")), "<ln1> second | <ln1> S": R(Text("%(ln1)ss")), #background "background image": R(Text("background-image:;") + Key("left/10:1")), "background position": R(Text("background-position:;") + Key("left/10:1")), "background size": R(Text("background-size:;") + Key("left/10:1")), "background repeat": R(Text("background-repeat:;") + Key("left/10:1")), "background attachment": R(Text("background-attachment:;") + Key("left/10:1")), "background origin": R(Text("background-origin:;") + Key("left/10:1")), "background clip": R(Text("background-clip:;") + Key("left/10:1")), "background color": R(Text("background-color:;") + Key("left/10:1")), "background attachment": R(Text("background-attachment:;") + Key("left/10:1")), "background origin": R(Text("background-origin:;") + Key("left/10:1")), "background clip": R(Text("background-clip:;") + Key("left/10:1")), #border "border": R(Text("border:;") + Key("left/10:1")), "border top": R(Text("border-top:;") + Key("left/10:1")), "border bottom": R(Text("border-bottom:;") + Key("left/10:1")), "border left": R(Text("border-left:;") + Key("left/10:1")), "border right": R(Text("border-right:;") + Key("left/10:1")), "border width": R(Text("border-width:;") + Key("left/10:1")), "border style": R(Text("border-style:;") + Key("left/10:1")), "border color": R(Text("border-color:;") + Key("left/10:1")), "border break": R(Text("border-break:;") + Key("left/10:1")), "border image": R(Text("border-image:;") + Key("left/10:1")), "border radius": R(Text("border-radius:;") + Key("left/10:1")), #box model "box shadow": R(Text("box-shadow:;") + Key("left/10:1")), "border-box": R(Text("border-box")), "height": R(Text("height:;") + Key("left/10:1")), "width": R(Text("width:;") + Key("left/10:1")), "min height": R(Text("min-height:;") + Key("left/10:1")), "max height": R(Text("max-height:;") + Key("left/10:1")), "min width": R(Text("min-width:;") + Key("left/10:1")), "max width": R(Text("max-width:;") + Key("left/10:1")), "padding box": R(Text("padding-box")), "content box": R(Text("content-box")), "margin": R(Text("margin:;") + Key("left/10:1")), "margin top": R(Text("margin-top:;") + Key("left/10:1")), "margin bottom": R(Text("margin-bottom:;") + Key("left/10:1")), "margin left": R(Text("margin-left:;") + Key("left/10:1")), "margin right": R(Text("margin-right:;") + Key("left/10:1")), "padding": R(Text("padding:;") + Key("left/10:1")), "padding top": R(Text("padding-top:;") + Key("left/10:1")), "padding bottom": R(Text("padding-bottom:;") + Key("left/10:1")), "padding left": R(Text("padding-left:;") + Key("left/10:1")), "padding right": R(Text("padding-right:;") + Key("left/10:1")), "display": R(Text("display:;") + Key("left/10:1")), "overflow": R(Text("overflow:;") + Key("left/10:1")), "overflow y": R(Text("overflow-y:;") + Key("left/10:1")), "overflow x": R(Text("overflow-x:;") + Key("left/10:1")), "overflow style": R(Text("overflow-style:;") + Key("left/10:1")), "visibility": R(Text("visibility:;") + Key("left/10:1")), "clear": R(Text("clear:;") + Key("left/10:1")), #Font "font": R(Text("font:;") + Key("left/10:1")), "font style": R(Text("font-style:;") + Key("left/10:1")), "font variant": R(Text("font-variant:;") + Key("left/10:1")), "font weight": R(Text("font-weight:;") + Key("left/10:1")), "font size": R(Text("font-size:;") + Key("left/10:1")), "font family": R(Text("font-family:;") + Key("left/10:1")), #text "direction": R(Text("direction:;") + Key("left/10:1")), "hanging punctuation": R(Text("hanging-punctuation:;") + Key("left/10:1")), "letter spacing": R(Text("letter-spacing:;") + Key("left/10:1")), "text outline": R(Text("text-outline:;") + Key("left/10:1")), "unicode bidi": R(Text("unicode-bidi:;") + Key("left/10:1")), "white space": R(Text("white-space:;") + Key("left/10:1")), "white space collapse": R(Text("white-space-collapse:;") + Key("left/10:1")), "punctuation trim": R(Text("punctuation-trim:;") + Key("left/10:1")), "text align": R(Text("text-align:;") + Key("left/10:1")), "text align last": R(Text("text-align-last:;") + Key("left/10:1")), "text decoration": R(Text("text-decoration:;") + Key("left/10:1")), "text shadow": R(Text("text-shadow:;") + Key("left/10:1")), "word break": R(Text("word-break:;") + Key("left/10:1")), "word wrap": R(Text("word-wrap:;") + Key("left/10:1")), "text emphasis": R(Text("text-emphasis:;") + Key("left/10:1")), "text indent": R(Text("text-indent:;") + Key("left/10:1")), "text justify": R(Text("text-justify:;") + Key("left/10:1")), "text transform": R(Text("text-transform:;") + Key("left/10:1")), "text wrap": R(Text("text-wrap:;") + Key("left/10:1")), "word spacing": R(Text("word-spacing:;") + Key("left/10:1")), #column "column count": R(Text("column-count:;") + Key("left/10:1")), "column fill": R(Text("column-fill:;") + Key("left/10:1")), "column gap": R(Text("column-gap:;") + Key("left/10:1")), "column rule": R(Text("column-rule:;") + Key("left/10:1")), "column rule style": R(Text("column-rule-style:;") + Key("left/10:1")), "column": R(Text("column:;") + Key("left/10:1")), "column rule width": R(Text("column-rule-width:;") + Key("left/10:1")), "column span": R(Text("column-span:;") + Key("left/10:1")), "column width": R(Text("column-width:;") + Key("left/10:1")), #colors "color": R(Text("color:;") + Key("left/10:1")), "opacity": R(Text("opacity:;") + Key("left/10:1")), #table "border collapse": R(Text("border-collapse:;") + Key("left/10:1")), "empty cells": R(Text("empty-cells:;") + Key("left/10:1")), "border spacing": R(Text("border-spacing:;") + Key("left/10:1")), "table layout": R(Text("table-layout:;") + Key("left/10:1")), "caption side": R(Text("caption-side:;") + Key("left/10:1")), #List & Markers "list style": R(Text("list-style:;") + Key("left/10:1")), "list style type": R(Text("list-style-type:;") + Key("left/10:1")), "list style position": R(Text("list-style-position:;") + Key("left/10:1")), "list style image": R(Text("list-style-image:;") + Key("left/10:1")), "marker offset": R(Text("marker-offset:;") + Key("left/10:1")), #Animations "animations": R(Text("animations:;") + Key("left/10:1")), "animation name": R(Text("animation-name:;") + Key("left/10:1")), "animation duration": R(Text("animation-duration:;") + Key("left/10:1")), "animation timing function": R(Text("animation-timing-function:;") + Key("left/10:1")), "animation delay": R(Text("animation-delay:;") + Key("left/10:1")), "animation iteration count": R(Text("animation-iteration-count:;") + Key("left/10:1")), "animation direction": R(Text("animation-direction:;") + Key("left/10:1")), "animation play state": R(Text("animation-play-state:;") + Key("left/10:1")), #Transitions "transitions": R(Text("transitions:;") + Key("left/10:1")), "transitions property": R(Text("transitions-property:;") + Key("left/10:1")), "transitions duration": R(Text("transitions-duration:;") + Key("left/10:1")), "transitions timing function": R(Text("transitions-timing-function:;") + Key("left/10:1")), "transitions delay": R(Text("transitions-delay:;") + Key("left/10:1")), "transitions property": R(Text("transitions-property:;") + Key("left/10:1")), #UI "webkit appearance | appearance": R(Text("-webkit-appearance:;") + Key("left/10:1")), "cursor": R(Text("cursor:;") + Key("left/10:1")), "resize": R(Text("resize:;") + Key("left/10:1")), #Pseudo-Class "active": R(Text(":active")), "focus": R(Text(":focus")), "hover": R(Text(":hover")), "link": R(Text(":link")), "disabled": R(Text(":disabled")), "enabled": R(Text(":enabled")), "checked": R(Text(":checked")), "selection": R(Text(":selection")), "lang": R(Text(":lang")), "nth child": R(Text(":nth-child()") + Key("left/10:1")), "nth last child": R(Text(":nth-last-child()") + Key("left/10:1")), "first child": R(Text(":first-child")), "last child": R(Text(":last-child")), "only-child": R(Text(":only-child")), "nth of type": R(Text(":nth-of-type()") + Key("left/10:1")), "nth last of type ": R(Text(":nth-last-of-type() ") + Key("left/10:1")), "last of type": R(Text(":last-of-type")), "first of type": R(Text(":first-of-type")), "only of type": R(Text(":only-of-type")), "empty": R(Text(":empty")), "root": R(Text(":root")), "not": R(Text(":not()") + Key("left/10:1")), "target": R(Text(":target")), "first letter": R(Text("::first-letter")), "first line": R(Text("::first-line")), "before": R(Text("::before")), "after": R(Text("::after")), #Outline "outline": R(Text("outline:;") + Key("left/10:1")), "outline color": R(Text("outline-color:;") + Key("left/10:1")), "outline style": R(Text("outline-style:;") + Key("left/10:1")), "outline width": R(Text("outline-width:;") + Key("left/10:1")), "outline offset": R(Text("outline-offset:;") + Key("left/10:1")), #transform "backface visibility": R(Text("backface-visibility:;") + Key("left/10:1")), "perspective": R(Text("perspective:;") + Key("left/10:1")), "perspective origin": R(Text("perspective-origin:;") + Key("left/10:1")), "transform": R(Text("transform:;") + Key("left/10:1")), "transform style": R(Text("transform-style:;") + Key("left/10:1")), #Positioning "position": R(Text("position:;") + Key("left/10:1")), "clip": R(Text("clip:;") + Key("left/10:1")), "z index": R(Text("z-index:;") + Key("left/10:1")), #flex "flex direction": R(Text("flex-direction:;") + Key("left/10:1")), "flex wrap": R(Text("flex-wrap:;") + Key("left/10:1")), "align items": R(Text("align-items:;") + Key("left/10:1")), "justify content": R(Text("justify-content:;") + Key("left/10:1")), "flex grow": R(Text("flex-grow:;") + Key("left/10:1")), "align self": R(Text("align-self:;") + Key("left/10:1")), "flex shrink": R(Text("flex-shrink:;") + Key("left/10:1")), "flex basis": R(Text("flex-basis:;") + Key("left/10:1")), "order": R(Text("order:;") + Key("left/10:1")), #values "url": R(Text("url()") + Key("left/10:1")), "rgb": R(Text("rgb(,,)") + Key("left/10:3")), "rgba": R(Text("rgba(,,,)") + Key("left/10:4")), } extras = [ IntegerRefST("ln1", 1, 1000), ] defaults = {}
def select_phrase(phrase, direction, number_of_lines_to_search, occurrence_number, dictation_versus_character): if direction == "up" or direction == "down": number_of_lines_to_search, direction = deal_with_up_down_directions( direction, number_of_lines_to_search) application = get_application() selected_text = select_text_and_return_it(direction, number_of_lines_to_search, application) if not selected_text: return phrase = str(phrase) match_index = get_start_end_position(selected_text, phrase, direction, occurrence_number, dictation_versus_character) if match_index: left_index, right_index = match_index else: # phrase not found deal_with_phrase_not_found(selected_text, application, direction) return # Approach 1: paste the selected text over itself rather than simply unselecting. A little slower but works Texstudio # todo: change this so that it unselects by pressing left and then right rather than pasting over the top if application == "texstudio": text_manipulation_paste( selected_text, application ) # yes, this is kind of redundant but it gets the proper pause time multiline_movement_correction = selected_text[right_index:].count( "\r\n") movement_offset = len( selected_text) - right_index - multiline_movement_correction Key("left:%d" % movement_offset).execute() multiline_selection_correction = selected_text[ left_index:right_index].count("\r\n") selection_offset = len(selected_text[left_index:right_index] ) - multiline_selection_correction Key("s-left:%d" % selection_offset).execute() # Approach 2: unselect using arrow keys rather than pasting over the existing text. (a little faster) does not work texstudio else: if right_index < round(len(selected_text)) / 2: # it's faster to approach phrase from the left Key("left").execute( ) # unselect text and place cursor on the left side of selection multiline_movement_offset_correction = selected_text[: left_index].count( "\r\n") movement_offset = left_index - multiline_movement_offset_correction # move to the left side of the phrase Key("right:%d" % movement_offset).execute() # select phrase multiline_selection_offset_correction = selected_text[ left_index:right_index].count("\r\n") selection_offset = len( phrase) - multiline_selection_offset_correction Key("s-right:%d" % selection_offset).execute() else: # it's faster to approach phrase from the right Key("right").execute( ) # unselect text and place cursor on the right side of selection multiline_movement_offset_correction = selected_text[ left_index:].count("\r\n") movement_offset = len( selected_text ) - left_index - multiline_movement_offset_correction # move to the left side of the phrase Key("left:%d" % movement_offset).execute() # select phrase multiline_selection_offset_correction = selected_text[ left_index:right_index].count("\r\n") selection_offset = len( phrase) - multiline_selection_offset_correction Key("s-right:%d" % selection_offset).execute()
def nav(parameters): result = navigate_to_character(str(parameters[0]), str(parameters[1])) if result: Key(str(parameters[0])).execute() return result
def select_until_phrase(direction, phrase, before_after, number_of_lines_to_search, occurrence_number, dictation_versus_character): if direction == "up" or direction == "down": number_of_lines_to_search, direction = deal_with_up_down_directions( direction, number_of_lines_to_search) application = get_application() if not before_after: # default to select all the way through the phrase not just up until it if direction == "left": before_after = "before" if direction == "right": before_after = "after" selected_text = select_text_and_return_it(direction, number_of_lines_to_search, application) if not selected_text: return phrase = str(phrase) match_index = get_start_end_position(selected_text, phrase, direction, occurrence_number, dictation_versus_character) if match_index: left_index, right_index = match_index else: # phrase not found deal_with_phrase_not_found(selected_text, application, direction) return # Approach 1: paste the selected text over itself rather than simply unselecting. A little slower but works Texstudio # todo: change this so that it unselects by pressing left and then right rather than pasting over the top if application == "texstudio": text_manipulation_paste( selected_text, application ) # yes, this is kind of redundant but it gets the proper pause time if direction == "left": if before_after == "before": selected_text_to_the_right_of_phrase = selected_text[ left_index:] multiline_offset_correction = selected_text_to_the_right_of_phrase.count( "\r\n") offset = len( selected_text) - left_index - multiline_offset_correction if before_after == "after": selected_text_to_the_right_of_phrase = selected_text[ right_index:] multiline_offset_correction = selected_text_to_the_right_of_phrase.count( "\r\n") offset = len( selected_text) - right_index - multiline_offset_correction Key("s-left:%d" % offset).execute() if direction == "right": multiline_movement_correction = selected_text.count("\r\n") movement_offset = len( selected_text) - multiline_movement_correction if before_after == "before": multiline_selection_correction = selected_text[: left_index].count( "\r\n") selection_offset = left_index - multiline_movement_correction if before_after == "after": multiline_selection_correction = selected_text[: right_index].count( "\r\n") selection_offset = right_index # move cursor to original position Key("left:%d" % movement_offset).execute() # select text Key("s-right:%d" % selection_offset).execute() # Approach 2: unselect using arrow keys rather than pasting over the existing text. (a little faster) does not work texstudio else: if direction == "left": Key("right").execute( ) # unselect text and move to left side of selection if before_after == "before": multiline_correction = selected_text[left_index:].count("\r\n") offset = len(selected_text) - left_index - multiline_correction if before_after == "after": multiline_correction = selected_text[right_index:].count( "\r\n") offset = len( selected_text) - right_index - multiline_correction Key("s-left:%d" % offset).execute() if direction == "right": Key("left").execute( ) # unselect text and move to the right side of selection if before_after == "before": multiline_correction = selected_text[:left_index].count("\r\n") offset = left_index - multiline_correction if before_after == "after": multiline_correction = selected_text[:right_index].count( "\r\n") offset = right_index - multiline_correction Key("s-right:%d" % offset).execute()
class Keyboard(MappingRule): mapping = { "<modifier> <button_dictionary_1>": R(Key("%(modifier)s%(button_dictionary_1)s"), rdescript="press button: %(modifier)s%(button_dictionary_1)s"), "<hold_release> <button_dictionary_1>": R(Key("%(button_dictionary_1)s:%(hold_release)s"), rdescript="%(hold_release)s button: %(button_dictionary_1)s"), } # These buttons can be used without using the "press" prefix. right_spec = "(right | ross)" left_spec = "(left | lease)" button_dictionary_1 = { "(F{}".format(i) + " | function {})".format(i): "f{}".format(i) for i in range(1, 13) } button_dictionary_1.update(caster_alphabet()) button_dictionary_1.update(_tpd) shift_spec = "(shift | shin)" control_spec = "(control | fly)" alt_spec = "alt" windows_spec = "windows" # in the punctuation dictionary it uses " " which is not the correct dragonfly key name. del button_dictionary_1["[is] less [than] [or] equal [to]"] del button_dictionary_1["[is] equal to"] del button_dictionary_1["[is] greater [than] [or] equal [to]"] ace_key = list(button_dictionary_1.keys())[list( button_dictionary_1.values()).index(' ')] slash_key = list(button_dictionary_1.keys())[list( button_dictionary_1.values()).index('/')] minus_key = list(button_dictionary_1.keys())[list( button_dictionary_1.values()).index('-')] colon_key = list(button_dictionary_1.keys())[list( button_dictionary_1.values()).index(':')] comma_key = list(button_dictionary_1.keys())[list( button_dictionary_1.values()).index(',')] button_dictionary_1.update({ "(tab | tabby)": "tab", "(backspace | clear)": "backspace", "(delete | deli)": "del", "(enter | shock)": "enter", left_spec: "left", right_spec: "right", "(up | sauce)": "up", "(down | dunce)": "down", "page (down | dunce)": "pgdown", "page (up | sauce)": "pgup", ace_key: "space", comma_key: "comma", minus_key: "minus", slash_key: "slash", colon_key: "colon", "zero": "0", "one": "1", "two": "2", "three": "3", "four": "4", "five": "5", "six": "6", "seven": "7", "eight": "8", "nine": "9", shift_spec: "shift", control_spec: "control", alt_spec: "alt", right_spec + " " + shift_spec: "rshift", right_spec + " " + control_spec: "rcontrol", right_spec + " " + alt_spec: "ralt", SymbolSpecs.CANCEL: "escape", "insert": "insert", "pause": "pause", windows_spec: "win", "(apps | popup)": "apps", "print screen": "printscreen", "scroll lock": "scrolllock", "num lock": "numlock", "caps lock": "capslock", "(home | lease wally | latch)": "home", "(end | ross wally | ratch)": "end", # number pad numbers deliberately left off # volume control deliberately left off as these are dealt with in HardwareRule and I don't think there's a use case for modifiers there # track control deliberately left off as these are (or will be) dealt with in HardwareRule and I don't think there's a use case for modifiers there # browser forward/back are deliberately left off. These functions are implemented at the browser rule level }) modifier_choice_object = Choice( "modifier", { control_spec: "c-", shift_spec: "s-", alt_spec: "a-", cat_spec_and_reverse(control_spec, shift_spec) + " | queue": "cs-", cat_spec_and_reverse(control_spec, alt_spec): "ca-", cat_spec_and_reverse(alt_spec, shift_spec): "sa-", cat_spec_and_reverse_3(alt_spec, control_spec, shift_spec): "csa-", windows_spec: "w-", cat_spec_and_reverse(control_spec, windows_spec): "cw-", cat_spec_and_reverse_3(alt_spec, control_spec, windows_spec): "cwa-", cat_spec_and_reverse_3(shift_spec, control_spec, windows_spec): "cws-", cat_spec_and_reverse_3(alt_spec, shift_spec, windows_spec): "wsa-", cat_spec_and_reverse(windows_spec, shift_spec): "ws-", cat_spec_and_reverse(windows_spec, alt_spec): "wa-", # We will leave this as is as it is seldom used "control windows alt shift": "cwas-", "press": "", }) extras = [ modifier_choice_object, Choice("button_dictionary_1", button_dictionary_1), Choice("hold_release", { "hold": "down", "release": "up" }), ] defaults = {"modifier": ""}
def store_and_next(): Key("c-d").execute() _, origin = context.read_selected_without_altering_clipboard(False) stored_values.append(origin) Key("left,right,tab").execute()