Ejemplo n.º 1
0
class VoiceDevCommands(MergeRule):
    pronunciation = "voice dev commands"

    mapping = {

        # Dragonfly Snippets
        # this first command is probably the most useful one
        "dev key [<modifier>] <combined_button_dictionary>":
            R(Text('Key("%(modifier)s%(combined_button_dictionary)s")'),
            rdescript="DragonflyDev: Snippet for creating a full Key action"),
        "dev key":
            R(Text('Key("")') + Key("left:2"), rdescript="DragonflyDev: Snippet for Key Action"),
        "dev text":
            R(Text('Text("")') + Key("left:2"), rdescript="DragonflyDev: Snippet for Text Action"),
        "dev pause":
            R(Text('Pause("")') + Key("left:2"), rdescript="DragonflyDev: Snippet for Pause Action"),
        "dev function":
            R(Text("Function()") + Key("left")),
        "dev repeat":
            R(Text(" * Repeat(extra='n')"), rdescript="DragonflyDev: Snippet for Repeat"),
        "dev choice":
            R(Text('Choice("", {') + Pause("10") + Key("enter, up, right:4"),
              rdescript="DragonflyDev: Snippet for the Choice Extra"),
        "dev mouse [<mouse_button>]":
            R(Function(type_mouse), rdescript="DragonflyDev: Snippet for Mouse Click Command"),
        "dev mouse current [position]":
            R(Function(type_mouse_current),
              rdescript="DragonflyDev: Snippet for Making a Command for Clicking at the Current Cursor Position"),
        "dev execute": R(Key("end")+Text(".execute()"),
            rdescript="call 'execute' method at end of line"),

        # Caster Snippets
        "dev bring app":
            R(Text("BringApp()") + Key("left"), rdescript="CasterDev: Snippet for Bring App"),
        "dev descript":
            R(Text(' rdescript="MyGrammar: "') + Key("left"), rdescript="CasterDev: Add the rdescript"),

        # Snippets for emulating Dragonfly or Caster recognition.
        "dev mimic [<text>]":
            R(Function(type_mimic),
              rdescript="DragonflyDev: Snippet for Mimic"),
        "dev playback [<text>]": # This command has been inconsistent.
            # maybe because it's automatically putting in two of each parable character e.g. brackets
            R(Function(type_playback),
              rdescript="DragonflyDev: Snippet for Playback"),
        "dev split dictation [<text>]":
            R(Function(type_split_dictation),
              rdescript="DragonflyDev: Puts Quotes Around Each Word and Separated by Commas"),

        # Dragonfly Development: Standard dragonfly commands
        "command [<spec>] key":
            R(Text('"%(spec)s": Key(""),') + Key("left:3"),
              rdescript="DragonflyDev: Automatically Create Key Command with Given Spec"),
        "command [<spec>] key repeat":
            R(Text('"%(spec)s [<n>]": Key("") * Repeat(extra="n"),') + Key("left:23"),
              rdescript="DragonflyDev: Automatically Create Repeatable Key Command with Given Spec"),
        "command [<spec>] text":
            R(Text('"%(spec)s": Text(""),') + Key("left:3"),
              rdescript="DragonflyDev: Automatically Create Text Command with Given Spec"),
        "command [<spec>] [bring] app":
            R(Text('"%(spec)s": BringApp(),') + Key("left"),
              rdescript="DragonflyDev: Automatically Create Bring App with Given Spec"),
        "command [<spec>] function":
            R(Text('"%(spec)s": Function()') + Key("left"),
              rdescript="DragonflyDev: Automatically Create Function Command with Given Spec"),
        "command [<spec>] mimic [<text>]":
            R(Text('"%(spec)s": ,') + Key("left") + Function(type_mimic),
              rdescript="DragonflyDev: Automatically Create Mimic Command with Given Spec"),
        "command [<spec>] playback [<text>]":# This command has been inconsistent.
                                             # maybe because it's automatically putting in two of each parable character e.g. bracket
                                             # might have to adjust it depending on the editor
            R(Text('"%(spec)s": ,') + Key("left") + Function(type_playback),
              rdescript="DragonflyDev: Automatically Create Playback Command with Given Spec"),
        "command [<spec>] mouse [<mouse_button>]": # for some reason the above command is not putting in the left click by default.
                                                   # perhaps someone can fix this
            R(Text('"%(spec)s": ,') + Key("left") + Function(
                type_mouse_current_position_button, extra={"mouse_button"}),
                rdescript="DragonflyDev: Automatically Create a Command to Click at the Current Mouse Position with Given Spec"),


        # Caster Development: commands uses the caster standard format with the R and rdescript.
        # Use Editors 'find and replace' to edit 'MyGrammar' to application or grammar name.
        # maybe somebody knows how to make it so that you can tab through the relevant places
        "commander [<spec>] key":
            R(Text('"%(spec)s": R(Key(""), rdescript="MyGrammar: "') + Key("right, comma") +
              Key("left:18"),
              rdescript="CasterDev: Automatically Create Key Command with Given Spec"),
        "commander [<spec>] key repeat":
            R(Text('"%(spec)s [<n>]": R(Key(""), rdescript="MyGrammar: "') + Key("right") +
              Text(" * Repeat(extra='n'),") + Key("left:38"),
              rdescript="CasterDev: Automatically Create Repeatable Key Command with Given Spec"),
        "commander [<spec>] text":
            R(Text('"%(spec)s": R(Text(""), rdescript="MyGrammar: "') + Key("right, comma") +
              Key("left:18"),
              rdescript="CasterDev: Automatically Create Text Command with Given Spec"),
        "commander [<spec>] [bring] app":
            R(Text('"%(spec)s": R(BringApp(), rdescript="MyGrammar: "') + Key("right, comma") +
              Key("left:17"),
              rdescript="CasterDev: Automatically Create Bing App Command with Given Spec"),
        "commander [<spec>] function":
            R(Text('"%(spec)s": R(Function(), rdescript="MyGrammar: "') + Key("right, comma") +
              Key("left:17"),
              rdescript="CasterDev: Automatically Create Function Command with Given Spec"),
        "commander [<spec>] mimic [<text>]":
            R(Text('"%(spec)s": R(') + Function(type_mimic) + Text(', rdescript="MyGrammar: "') +
              Key("right, comma, left:3"),
              rdescript="CasterDev: Automatically Create Mimic Command with Given Spec"),
        "commander [<spec>] mouse [<mouse_button>]":
            R(Text('"%(spec)s": R(') + Function(type_mouse_current_position_button,
              extra={"mouse_button"}) + Key("right") + Text(', rdescript=""') + Key("right, comma, left:3"),
              rdescript="CasterDev: Automatically Create Command to Click at Current Mouse Position with Given Spec"),
            # I couldn't get "commander [<spec>] playback [<text>]" to work
            # "commander [<spec>] playback [<text>]": Text('"%(spec)s": R(')
            #   + Function(type_playback) + Key("down:2") + Text(", rdescript=''") + Key("right, comma, left:3"),
    }

    extras = [
        new_modifier_choice_object,
        Choice("combined_button_dictionary",
               Navigation.combined_button_dictionary),
        Dictation("text"),
        Dictation("dict"),
        Dictation("spec"),
        Choice("mouse_button", {
            "left": "left",
            "right": "right",
            "middle": "middle",
        }),
        Choice("left_right", {
            "left": "left",
            "right": "right",
        }),
        Choice("up_down", {
            "up": "up",
            "down": "down",
        }),
        IntegerRefST("distance_1", 1, 500),
        IntegerRefST("distance_2", 1, 500),
    ]
    defaults = {"spec": "", "dict": "", "text": "", "mouse_button": ""}
Ejemplo n.º 2
0
Archivo: dev.py Proyecto: pimp22/Caster
class StackTest(MappingRule):
    '''test battery for the ContextStack'''

    mapping = {
        "close last tag":
        ContextSeeker([
            L(S(["cancel"], None),
              S(["html spoken"], close_last_spoken, use_spoken=True),
              S(["span", "div"], close_last_rspec, use_rspec=True))
        ]),
        "html":
        R(Text("<html>"), rspec="html spoken"),
        "divider":
        R(Text("<div>"), rspec="div"),
        "span":
        R(Text("<span>"), rspec="span"),
        "backward seeker [<text>]":
        ContextSeeker([
            L(S(["ashes"], Text("ashes1 [%(text)s] ")),
              S(["bravery"], Text("bravery1 [%(text)s] "))),
            L(S(["ashes"], Text("ashes2 [%(text)s] ")),
              S(["bravery"], Text("bravery2 [%(text)s] ")))
        ]),
        "forward seeker [<text>]":
        ContextSeeker(forward=[
            L(S(["ashes"], Text("ashes1 [%(text)s] ")),
              S(["bravery"], Text("bravery1 [%(text)s] "))),
            L(S(["ashes"], Text("ashes2 [%(text)s] ")),
              S(["bravery"], Text("bravery2 [%(text)s] ")))
        ]),
        "asynchronous test":
        AsynchronousAction([
            L(S(["ashes", "charcoal"], print_time, None),
              S(["bravery"], Text, "bravery1"))
        ],
                           time_in_seconds=0.2,
                           repetitions=20,
                           finisher=Text(FINISHER_TEXT),
                           blocking=False),
        "ashes":
        RegisteredAction(Text("ashes _ "), rspec="ashes"),
        "bravery":
        RegisteredAction(Text("bravery _ "), rspec="bravery"),
        "charcoal <text> [<n>]":
        R(Text("charcoal _ %(text)s"), rspec="charcoal"),
        "test confirm action":
        ConfirmAction(Key("a"),
                      rdescript="Confirm Action Test",
                      instructions="some words here"),
        "test box action":
        BoxAction(lambda data: _abc(data),
                  rdescript="Test Box Action",
                  box_type=settings.QTYPE_DEFAULT,
                  log_failure=True),
    }
    extras = [Dictation("text"), Dictation("text2"), IntegerRefST("n", 1, 5)]
    defaults = {"text": "", "text2": ""}
Ejemplo n.º 3
0
class Go(MergeRule):

    mapping = {
        SymbolSpecs.IF:
        R(Text("if  {}") + Key("left, enter, up, end, left:2")),
        SymbolSpecs.ELSE:
        R(Text("else {}") + Key("left, enter, up")),
        #
        SymbolSpecs.SWITCH:
        R(Text("switch  {}") + Key("left, enter, up, end, left:2")),
        SymbolSpecs.CASE:
        R(Text("case :") + Key("left")),
        SymbolSpecs.DEFAULT:
        R(Text("default:") + Key("enter")),
        SymbolSpecs.BREAK:
        R(Text("break")),
        #
        SymbolSpecs.WHILE_LOOP:
        R(Text("for  {}") + Key("left, enter, up, end, left:2")),
        SymbolSpecs.FOR_LOOP:
        R(
            Text("for i := 0; i<; i++ {}") +
            Key("left, enter, up, end, left:7")),
        SymbolSpecs.FOR_EACH_LOOP:
        R(Text("for  := range  {}") + Key("left, enter, up, home, right:4")),
        #
        SymbolSpecs.TO_INTEGER:
        R(Text("strconv.Atoi()") + Key("left")),
        SymbolSpecs.TO_STRING:
        R(Text("strconv.Itoa()") + Key("left")),
        #
        SymbolSpecs.AND:
        R(Text(" && ")),
        SymbolSpecs.OR:
        R(Text(" || ")),
        SymbolSpecs.NOT:
        R(Text("!")),
        #
        SymbolSpecs.SYSOUT:
        R(Text("fmt.Println()") + Key("left")),
        #
        SymbolSpecs.IMPORT:
        R(Text("import ()") + Key("left, enter")),
        #
        SymbolSpecs.FUNCTION:
        R(Text("func ")),
        SymbolSpecs.CLASS:
        R(Text("type  struct {}") + Key("left, enter, up, home, right:5")),
        #
        SymbolSpecs.COMMENT:
        R(Text("//")),
        SymbolSpecs.LONG_COMMENT:
        R(Text("/**/") + Key("left, left")),
        #
        SymbolSpecs.NULL:
        R(Text("nil")),
        #
        SymbolSpecs.RETURN:
        R(Text("return ")),
        #
        SymbolSpecs.TRUE:
        R(Text("true")),
        SymbolSpecs.FALSE:
        R(Text("false")),
        #
        "[type] (inter | integer)":
        R(Text("int")),
        "[type] boolean":
        R(Text("bool")),
        "[type] string":
        R(Text("string")),
        "assign":
        R(Text(" := ")),
        "(function | funk) main":
        R(Text("func main() {}") + Key("left, enter")),
        "make map":
        R(Text("make(map[])") + Key("left:2")),
        "package":
        R(Text("package ")),
    }

    extras = []
    defaults = {}
Ejemplo n.º 4
0
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 = {}
Ejemplo n.º 5
0
Archivo: dev.py Proyecto: pimp22/Caster
def close_last_spoken(spoken):
    first = spoken[0]
    Text("</" + first + ">").execute()
Ejemplo n.º 6
0
def _apply(n):
    if n != 0:
        Text("stash@{" + str(int(n)) + "}").execute()
Ejemplo n.º 7
0
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 = {}
Ejemplo n.º 8
0
def github_checkoutupdate_pull_request(new):
    # Function to fetch a PR
    try:
        Key("c-l/20").execute()
        url = read_selected_without_altering_clipboard()
        if url[0] == 0:
            split_string = url[1].split("/pull/")
            repo_url = split_string[0]
            pr_name = split_string[1].split("/")[0]
            CONFIG = load_toml_file(
                settings.SETTINGS["paths"]["GIT_REPO_LOCAL_REMOTE_PATH"])
            if not CONFIG:
                # logger.warn("Could not load bringme defaults")
                raise Exception(
                    "Could not load " +
                    settings.SETTINGS["paths"]["GIT_REPO_LOCAL_REMOTE_PATH"])

            items = rebuild_local_remote_items(CONFIG)
            if repo_url in items:
                local_directory = items[repo_url][0]
                local_directory = local_directory.replace("\\", "\\\\")
                directory_command = "cd " + local_directory
                TERMINAL_PATH = settings.SETTINGS["paths"]["TERMINAL_PATH"]
                AHK_PATH = settings.SETTINGS["paths"]["AHK_PATH"]
                ahk_installed = os.path.isfile(AHK_PATH)
                print "AHK_PATH = " + AHK_PATH
                if TERMINAL_PATH != "":
                    load_terminal = True  # set default value
                    # ready fetch command string to be appended to
                    fetch_command = ""
                    # find the equivalent ahk script with the same name as this one
                    ahk_script = __file__.replace(".pyc", ".ahk").replace(
                        ".py", ".ahk")
                    pattern_match = "MINGW64"  # the string we expect to find in the title of git bash when loaded
                    # if autohotkey is installed
                    if ahk_installed:
                        # open the script which checks that git bash window is open or not
                        p = Popen(
                            [AHK_PATH, ahk_script, "exists", pattern_match],
                            stdout=PIPE)
                        # retrieve the output from the ahk script
                        stdout, stderr = p.communicate()
                        # terminates the ahk script if not already done so
                        p.terminate()

                        # if an existing git bash window has been activated
                        if stdout == pattern_match + " activated":
                            # set the first portion of the fetch command
                            fetch_command += directory_command + " && "
                            load_terminal = False
                            print "Msg:" + ahk_script + " has activated window: " + pattern_match
                        # if an existing git bash window is not already open
                        elif stdout == pattern_match + " does not exist":
                            print "Msg:" + ahk_script + " has found no window: " + pattern_match
                            print "Load new instance of: " + pattern_match
                        else:
                            print "Error:" + ahk_script + " neither returned 'activated' nor 'does not exist'"
                            print "Fallback: load new instance of :" + pattern_match
                    if load_terminal:
                        # open up a new git bash terminal
                        terminal = Popen(TERMINAL_PATH, cwd=local_directory)
                        # if autohotkey is installed
                        if ahk_installed:
                            # open the script which checks that git bash windoow is ready or not for input
                            p = Popen([
                                AHK_PATH, ahk_script, "create", pattern_match
                            ],
                                      stdout=PIPE)
                            # retrieve the output from the AHK script
                            stdout, stderr = p.communicate()
                            # terminates the ahk script if not already done so
                            p.terminate()
                            # if the git bash terminal is not ready
                            if stdout != pattern_match + " ready":
                                raise Exception(
                                    "Error: git terminal took too long to load for script:"
                                    + ahk_script)
                        else:  # otherwise await the default number of seconds for the terminal to load
                            time.sleep(
                                settings.SETTINGS["gitbash"]["loading_time"])
                    else:
                        # Remove any text that's there in the existing terminal
                        Key("end/10, c-u/10").execute()
                    # adds to the fetch command string that which will fetch from the particular repository in question
                    fetch_command += "git fetch " + repo_url + ".git pull/" + pr_name + "/head"
                    # if fetching from a new pull request
                    if new:
                        branch_name_base = repo_url.replace(
                            "https://github.com/", "")
                        checkout_command = "git checkout -b " + branch_name_base + "/pull/" + pr_name + " FETCH_HEAD"
                        # type in the full command into the git bash window
                        Text(fetch_command + " && " +
                             checkout_command).execute()
                    else:  # otherwise if it is an update to an existing pull request
                        branch_name_base = repo_url.replace(
                            "https://github.com/", "")
                        checkout_command = "git checkout " + branch_name_base + "/pull/" + pr_name
                        # type in the full command into the git bash window
                        Text(fetch_command + " && " +
                             checkout_command).execute()
                        Key("enter").execute(
                        )  # checkout is safe enough so will run this
                        merge_command = "git merge FETCH_HEAD"
                        # allow time for the fetch commands complete before typing in the next one
                        time.sleep(
                            settings.SETTINGS["gitbash"]["fetching_time"])
                        Text(merge_command).execute()
                else:
                    raise Exception(
                        'TERMINAL_PATH in <user_dir>/.caster/data/settings.toml is not set'
                    )
            else:
                raise Exception(
                    "Repository URL: " + repo_url + " not found in " +
                    settings.SETTINGS["paths"]["GIT_REPO_LOCAL_REMOTE_PATH"])
    except Exception as e:
        print(e)
Ejemplo n.º 9
0
class ChromeRule(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|previous) tab [<n>]|tab (left|lease) [<n>]":
            R(Key("cs-tab")) * 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"),
        "find (back|prev|prior|previous) [match] [<n>]":
            R(Key("cs-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")),
        "[show chrome] task manager":
            R(Key("s-escape")),
        "(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")),
        "tab <m>|<nth> tab":
            R(Key("c-%(m)s%(nth)s")),
        "last tab":
            R(Key("c-9")),
        "second last tab":
            R(Key("c-9, cs-tab")),
        "switch focus [<n>]":
            R(Key("f6/20")) * Repeat(extra="n"),
        "[toggle] bookmark bar":
            R(Key("cs-b")),
        "switch user":
            R(Key("cs-m")),
        "focus notification":
            R(Key("a-n")),
        "allow notification":
            R(Key("as-a")),
        "deny notification":
            R(Key("as-a")),
        "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")),
        "[show] (extensions|plugins)":
            R(Key("a-f/20, l, e/15, enter")),
        "more tools":
            R(Key("a-f/5, l")),
    }
    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 BrowserSharedCommands(object):

    @staticmethod
    def merge_dictionaries(x, y):
        z = x.copy()
        z.update(y)
        return z

    chromeAndFirefoxMapping = {
        browser_shared.OPEN_NEW_WINDOW:
            R(Key("c-n")),
        browser_shared.OPEN_NEW_INCOGNITO_WINDOW:
            R(Key("cs-n")),
        browser_shared.NEW_TAB_N_TIMES:
            R(Key("c-t") * Repeat(extra="n")),
        browser_shared.REOPEN_TAB_N_TIMES:
            R(Key("cs-t")) * Repeat(extra="n"),
        browser_shared.CLOSE_TAB_N_TIMES:
            R(Key("c-w")) * Repeat(extra='n'),
        browser_shared.CLOSE_WINDOW:
            R(Key("cs-w")),
        browser_shared.NEXT_TAB_N_TIMES:
            R(Key("c-tab")) * Repeat(extra="n"),
        browser_shared.OPEN_NEW_TAB_BASED_ON_CURSOR:
            R(Mouse("middle") + Pause("20") + Key("c-tab")),
        browser_shared.GO_BACK_N_TIMES:
            R(Key("a-left/20")) * Repeat(extra="n"),
        browser_shared.GO_FORWARD_N_TIMES:
            R(Key("a-right/20")) * Repeat(extra="n"),
        browser_shared.ZOOM_IN_N_TIMES:
            R(Key("c-plus/20")) * Repeat(extra="n"),
        browser_shared.ZOOM_OUT_N_TIMES:
            R(Key("c-minus/20")) * Repeat(extra="n"),
        browser_shared.ZOOM_RESET_DEFAULT:
            R(Key("c-0")),
        browser_shared.FORCE_HARD_REFRESH:
            R(Key("c-f5")),
        browser_shared.FIND_NEXT_MATCH:
            R(Key("c-g/20")) * Repeat(extra="n"),
        browser_shared.FIND_PREVIOUS_MATCH:
            R(Key("cs-g/20")) * Repeat(extra="n"),
        # requires an extension in some browsers such as chrome
        browser_shared.TOGGLE_CARET_BROWSING:
            R(Key("f7")),
        browser_shared.GO_TO_HOMEPAGE:
            R(Key("a-home")),
        browser_shared.SHOW_HISTORY:
            R(Key("c-h")),
        browser_shared.SELECT_ADDRESS_BAR:
            R(Key("c-l")),
        browser_shared.SHOW_DOWNLOADS:
            R(Key("c-j")),
        browser_shared.ADD_BOOKMARK:
            R(Key("c-d")),
        browser_shared.BOOKMARK_ALL_TABS:
            R(Key("cs-d")),
        browser_shared.SHOW_BOOKMARKS:
            R(Key("cs-o")),
        browser_shared.TOGGLE_FULL_SCREEN:
            R(Key("f11")),
        browser_shared.SHOW_PAGE_SOURCE:
            R(Key("c-u")),
        browser_shared.DEBUG_RESUME:
            R(Key("f8")),
        browser_shared.DEBUG_STEP_OVER:
            R(Key("f10")),
        browser_shared.DEBUG_STEP_INTO:
            R(Key("f11")),
        browser_shared.DEBUG_STEP_OUT:
            R(Key("s-f11")),
        browser_shared.DUPLICATE_TAB:
            R(Key("a-d,a-c,c-t/15,c-v/15, enter")),
        browser_shared.DUPLICATE_WINDOW:
            R(Key("a-d,a-c,c-n/15,c-v/15, enter")),
        browser_shared.SHOW_MENU:
            R(Key("a-f")),
        browser_shared.SHOW_SETTINGS:
            R(Key("a-f/5, s")),
        browser_shared.SHOW_TASK_MANAGER:
            R(Key("s-escape")),
        browser_shared.CLEAR_BROWSING_DATA:
            R(Key("cs-del")),
        browser_shared.SHOW_DEVELOPER_TOOLS:
            R(Key("cs-i")),
        browser_shared.CHECKOUT_PR:
            R(Function(github_automation.github_checkoutupdate_pull_request, new=True)),
        browser_shared.UPDATE_PR:
            R(Function(github_automation.github_checkoutupdate_pull_request, new=False)),
        "IRC identify":
            R(Text("/msg NickServ identify PASSWORD")),
    }
Ejemplo n.º 11
0
class VSCodeNonCcrRule(MappingRule):
    mapping = {
        # Moving around a file
        "[(go to | jump | jump to)] line <n>":
        R(Key("c-g") + Text("%(n)d") + Key("enter")),
        "<action> [line] <ln1> [by <ln2>]":
        R(Function(navigation.action_lines)),
        "go back <n>":
        R(Key("a-left") * Repeat(extra='n')),
        "go forward [<n>]":
        R(Key("a-right")) * Repeat(extra="n"),

        # Display
        # note that most of these can be turned on/off with the same command
        "[toggle] full screen":
        R(Key("sa-enter")),
        "toggle orientation":
        R(Key("sa-0")),
        "zoom in [<n>]":
        R(Key("c-equal") * Repeat(extra='n')),
        "zoom out [<n>]":
        R(Key("c-minus") * Repeat(extra='n')),
        "sidebar":
        R(Key("c-b")),
        "explorer":
        R(Key("cs-e")),
        "source control":
        R(Key("cs-g")),
        "keyboard shortcuts":
        R(Key("c-k, c-s")),
        "key mappings":
        R(Key("c-k, c-s:2")),
        "settings":
        R(Key("a-f, p, s, enter"),
          rdescript="VS Code: User/workspace Settings"),
        "snippets":
        R(Key("a-f, p, s:2, enter"), rdescript="VS Code: User Snippets"),
        "extensions":
        R(Key("cs-x")),
        "search details":
        R(Key("cs-j")),
        "output panel":
        R(Key("cs-u")),
        "markdown preview":
        R(Key("cs-v")),
        "markdown preview side":
        R(Key("c-k, v")),
        "Zen mode":
        # note: use esc esc to exit
        R(Key("c-k, z")),

        # File Management
        "copy path":
        R(Key("c-k, p")),
        "[open] command palette":
        R(Key("cs-p"), rdescript="VS Code: Command Palette"),
        "(open file | go to [tab]) [<text>]":
        R(Key("c-p") + Text("%(text)s"),
          rdescript="VS Code: Go to File without using dialogbox"),
        "open dialogue":
        R(Key("c-o"), rdescript="VS Code: open file dialogbox"),
        "open folder":
        R(Key("c-k, c-o"), rdescript="VS Code: Open folder"),
        "Save and close":
        R(Key("c-s/10, c-w")),
        "new file":
        R(Key("c-n")),
        "new window":
        R(Key("cs-n")),
        "close window":
        R(Key("a-f4")),
        "close workspace":
        R(Key("c-k, f")),
        "close editor":
        R(Key("c-f4")),
        "save as":
        R(Key("cs-s")),
        "save all":
        R(Key("c-k, s")),
        "next tab [<n>]":
        R(Key("c-pgdown") * Repeat(extra='n')),
        "previous tab [<n>]":
        R(Key("c-pgup") * Repeat(extra='n')),
        "close tab [<n>]":
        R(Key("c-f4/20") * Repeat(extra='n')),
        "(recent | R) tab [<n>]":
        R(Key("c-tab") * Repeat(extra='n')),
        "reopen tab [<n>]":
        R(Key("cs-t") * Repeat(extra='n')),
        "Exit preview":
        R(Key("space, c-z")),
        "keep preview open":
        R(Key("c-k, enter")),
        "windows explorer here":
        R(Key("c-k, r")),
        "show active file in new window":
        R(Key("c-k, o")),

        # Search
        "(search | find)":
        R(Key("c-f")),
        "replace":
        R(Key("c-h")),
        "find in files":
        R(Key("cs-f")),
        "replace in files":
        R(Key("cs-h")),
        "next find":
        R(Key("f3")),
        "(prior | previous) find":
        R(Key("s-f3")),
        "select all occurrences":
        R(Key("a-enter")),
        "toggle case sensitive":
        R(Key("a-c"), rdescript="VS Code: Toggle Find Case Sensitive"),
        "toggle regex":
        R(Key("a-r"), rdescript="VS Code: Toggle Find Regular Expressions"),
        "toggle whole word":
        R(Key("a-w"), rdescript="VS Code: Toggle Find Whole Word"),
        "(find | jump [to]) next <text>":
        R(Function(_find_nth_token, n=1, direction="forward")),
        "(find | jump [to]) previous <text>":
        R(Function(_find_nth_token, n=1, direction="reverse")),
        "show all symbols":
        R(Key("c-t")),
        "go to symbol":
        R(Key("cs-o")),

        # Editor Management
        "close editor":
        R(Key("c-w")),
        "close folder":
        R(Key("c-k, f")),
        "split editor":
        R(Key("c-backslash")),
        "next pane":
        R(Key("c-k, c-right")),
        "(prior | previous | un) pane":
        R(Key("c-k, c-right")),
        "shift group left":
        R(Key("c-k, left"),
          rdescript=
          "VS Code: Shift Current Group of Tabs to the Left E.g. Swap with Pane to the Left"
          ),
        "shift group right":
        R(Key("c-k, right"),
          rdescript=
          "VS Code: Shift Current Group of Tabs to the Right E.g. Swap with Pane to the Right"
          ),
        "<nth> tab":
        R(Key("c-%(nth)s")),

        # Languages Editing
        "go to definition":
        R(Key("f12")),
        "go to required definition":
        R(Key("c-f12:2, c-right:5, left/50, f12")),
        "peak definition":
        R(Key("a-f12")),
        "trigger parameter hints":
        R(Key("cs-space")),
        "format that":
        R(Key("c-k, c-f")),
        "(definition to side | side def)":
        R(Key("c-k, f12")),
        "show references":
        R(Key("s-f12")),
        "rename symbol":
        R(Key("f2")),
        "(trim white)":
        R(Key("c-k, c-x")),
        "change file language":
        R(Key("c-k, m")),

        # Debugging
        "debug":
        R(Key("cs-d")),
        "[toggle] breakpoint":
        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")),
        "stopper":
        R(Key("s-f5")),
        "continue":
        R(Key("f5"), rdescript="VS Code: Start/Continue"),
        "(show hover|mouse hover|hover mouse)":
        R(Key("c-k, c-i"),
          rdescript=
          "Show the little box as if you are hovering your mouse over the place where the cursor (As opposed to the mouse pointer) currently is"
          ),
        "[show] problems [panel]":
        R(Key("cs-m")),
        "next error":
        R(Key("f8")),  # doesn't seem to be working properly
        "(prior | previous) error":
        R(Key("s-f8")),
        "toggle tab moves focus":
        R(Key("c-m")),

        # Integrated Terminal
        "[show] terminal":
        R(Key("c-backtick")),
        "new terminal":
        R(Key("cs-backtick")),
        "terminal scroll up":
        R(Key("c-up")),
        "terminal scroll down":
        R(Key("c-down")),
        "terminal page up":
        R(Key("s-pgup")),
        "terminal page down":
        R(Key("s-pgdown")),

        # Collapsing
        "(fold | collapse) region":
        R(Key("cs-lbracket")),
        "(unfold | uncollapse) region":
        R(Key("cs-rbracket")),
        "(fold | collapse) [all] subregions":
        R(Key("c-k, c-lbracket")),
        "(unfold | uncollapse) [all] subregions":
        R(Key("c-k, c-rbracket")),
        "(fold | collapse) [all] regions":
        R(Key("c-k, c-0")),
        "(unfold | uncollapse) [all] regions":
        R(Key("c-k, c-j")),
        "toggle word wrap":
        R(Key("a-z")),
        "run this line":
        R(Key("csa-l")),
        "join line":
        R(Key("csa-j")),

        # requires gitlens extension
        "toggle blame":
        R(Key("cs-g, b")),
        "lens commit details":
        R(Key("cs-g, c")),
        "lens file history":
        R(Key("cs-g, h")),
        "lens repo status":
        R(Key("cs-g, s")),
        "toggle git lens":
        R(Key("cs-g, s-b")),

        # requires bookmark extension
        "mark (prev | prior | previous)":
        R(Key("ca-j")),
        "mark next":
        R(Key("ca-l")),
    }
    extras = [
        Dictation("text"),
        Dictation("mim"),
        IntegerRefST("ln1", 1, 1000),
        IntegerRefST("ln2", 1, 1000),
        IntegerRefST("n", 1, 1000),
        Choice("action", navigation.actions),
        Choice(
            "nth", {
                "first": "1",
                "second": "2",
                "third": "3",
                "fourth": "4",
                "fifth": "5",
                "sixth": "6",
            }),
    ]
    defaults = {"n": 1, "ln2": "", "mim": "", "text": ""}
Ejemplo n.º 12
0
def capitalize(text):
    output = str(text).title()
    Text(output).execute()
Ejemplo n.º 13
0
class OutlookRule(MappingRule):
    mapping = {
        # create new thing
        "new (appointment | event)":
        R(Key("sc-a")),
        "new contact":
        R(Key("cs-c")),
        "new folder":
        R(Key("cs-e")),
        "advanced (search| find)":
        R(Key("cs-f")),
        "new office document":
        R(Key("cs-h")),
        "(inbox | go to inbox)":
        R(Key("cs-i")),
        "new journal entry":
        R(Key("cs-j")),
        "new task":
        R(Key("cs-k")),
        "new contact group":
        R(Key("cs-l")),
        "(new message| new mail)":
        R(Key("cs-m")),
        "new note":
        R(Key("cs-n")),
        "open the new search folder window":
        R(Key("cs-p")),
        "new meeting request":
        R(Key("cs-q")),
        "new task request":
        R(Key("cs-u")),

        # new message window
        "to field":
        R(Key("a-dot")),
        "c c field":
        R(Key("a-c")),
        "subject [field]":
        R(Key("a-u")),
        "subject <text>":
        R(Key("a-u") + Function(capitalize) + Key("tab")),
        "attach file":
        R(Key("n, a, f")),
        "add to dictionary":
        R(Key("s-f10/2, a")),
        "click send message":
        R(Key("a-s")),  # be careful
        "find and replace":
        R(Key("c-h")),
        "check names":
        R(Key("c-k")),
        "spell check":
        R(Key("f7")),
        "save as":
        R(Key("f12")),  # only in mail view

        # folders pane
        "expand [that]":
        R(Key("asterisk")),
        "collapse [that]":
        R(Key("minus")),

        # folders navigation
        # some of these may be user dependent, depends on the order of your folders
        # which you can inspect by pressing control y
        # also I think some of these are built into Dragon
        "[go to] sent mail":
        R(Key("c-y/10, s, enter")),
        "go to drafts":
        R(Key("c-y/10, d, enter")),
        "go to trash":
        R(Key("c-y/10, t, enter")),
        "go to spam":
        R(Key("c-y/10, s:2, enter")),
        "go to starred":
        R(Key("c-y/10, s:3, enter")),
        "go to important":
        R(Key("c-y/10, i:2, enter")),
        "go to outbox":
        R(Key("cs-o")),

        # center pane
        "sort by [<sort_by>]":
        R(Key("a-v/5, a, b/5, %(sort_by)s")),
        "reverse sort":
        R(Key("a-v, r, s")),
        "block sender":
        R(Key("a-h/3, j/3, b")),
        "search [bar] [<dict>]":
        R(Key("c-e") + Text("%(dict)s")),
        "(message list | messages)":
        R(Key("tab:3")),
        "(empty | clear) search [bar]":
        R(Key("c-e, c-a, del/3, escape")),
        # from the search bar to get the focus into the messages is three tabs
        # pressing escape also seems to work.
        "refresh [mail]":
        R(Key("f9")),

        # reading pane
        "open attachment":
        R(Key("s-tab, enter")),
        "[open] attachment menu":
        R(Key("s-tab, right")),
        "next message [<n>]":
        R(Key("s-f6/10, down")) * Repeat(extra='n'),
        "(prior | previous) message [<n>]":
        R(Key("s-f6/20, up")) * Repeat(extra='n'),
        "[select] next link":
        R(Key("tab")),
        "[select] (previous | prior) link":
        R(Key("s-tab")),

        # calendar
        "workweek [view]":
        R(Key("ca-2")),
        "full week [view]":
        R(Key("ca-3")),
        "month view":
        R(Key("ca-4")),

        # message shortcuts
        "reply [<dict>]":
        R(Key("c-r") + Text("%(dict)s")),
        "reply all [<dict>]":
        R(Key("cs-r") + Text("%(dict)s")),
        "forward":
        R(Key("c-f")),
        "Mark as read":
        R(Key("c-q")),
        "Mark as unread":
        R(Key("c-u")),
        "(folder | go to folder)":
        R(Key("c-y")),

        # navigation
        "next pane [<n>]":
        R(Key("f6")) * Repeat(extra='n'),
        "(un|prior|previous) pane [<n>]":
        R(Key("s-f6")) * Repeat(extra='n'),
        "mail view":
        R(Key("c-1")),
        "calendar":
        R(Key("c-2")),
        "contacts":
        R(Key("c-3")),
        "tasks":
        R(Key("c-4")),
        "go to notes":
        R(Key("c-5")),
        "folder list":
        R(Key("c-6")),
        "find contact":
        R(Key("f11")),
        "address book":
        R(Key("cs-a")),
        "next open message":
        R(Key("c-dot")),
        "(prior | previous) open message":
        R(Key("c-comma")),
        "previous view":
        R(Key("a-left")),
        "next view":
        R(Key("a-right")),

        # misc
        "[go] back":
        R(Key("a-left")),
    }
    extras = [
        Dictation("dict"),
        Dictation("text"),
        IntegerRefST("n", 1, 100),
        Choice(
            "sort_by", {
                "date": "d",
                "from": "f",
                "to": "t",
                "size": "s",
                "subject": "j",
                "type": "t",
                "attachments": "c",
                "account": "o",
            }),
    ]
    defaults = {"n": 1, "dict": "", "text": "", "sort_by": ""}
Ejemplo n.º 14
0
class SublimeRule(MappingRule):
    mapping = {
        "new file":
        R(Key("c-n")),
        "new window":
        R(Key("cs-n")),
        "open file":
        R(Key("c-o")),
        "open folder":
        R(Key("f10, f, down:2, enter")),
        "open recent":
        R(Key("f10, f, down:3, enter")),
        "save as":
        R(Key("cs-s")),
        #
        "comment line":
        R(Key("c-slash")),
        "comment block":
        R(Key("cs-slash")),
        "outdent lines":
        R(Key("c-lbracket")),
        "join lines":
        R(Key("c-j")),
        "match bracket":
        R(Key("c-m")),
        #
        "(select | sell) all":
        R(Key("c-a")),
        "(select | sell) scope [<n2>]":
        R(Key("cs-space") * Repeat(extra="n2")),
        "(select | sell) brackets [<n2>]":
        R(Key("cs-m") * Repeat(extra="n2")),
        "(select | sell) indent":
        R(Key("cs-j")),
        #
        "find":
        R(Key("c-f")),
        "get all":
        R(Key("a-enter")),
        "replace":
        R(Key("c-h")),
        "replace all":
        R(Key("ca-enter")),
        "paste from history":
        R(Key("c-k,c-v")),
        "edit lines":
        R(Key("cs-l")),
        "edit next [<n3>]":
        R(Key("c-d/10")) * Repeat(extra="n3"),
        "edit only next [<n3>]":
        R(Key("c-k,c-d/10")) * Repeat(extra="n3"),
        "edit up [<n3>]":
        R(Key("ac-up")) * Repeat(extra="n3"),
        "edit down [<n3>]":
        R(Key("ac-down")) * Repeat(extra="n3"),
        "edit all":
        R(Key("a-f3")),
        #
        "transform upper":
        R(Key("c-k, c-u")),
        "transform lower":
        R(Key("c-k, c-l")),
        #
        "line <ln1>":
        R(Key("c-g/10") + Text("%(ln1)s") + Key("enter")),
        "<action> [line] <ln1> [by <ln2>]":
        R(Function(navigation.action_lines)),
        "[move] line down [<n3>]":
        R(Key("cs-down") * Repeat(extra='n3')),
        "[move] line up [<n3>]":
        R(Key("cs-up") * Repeat(extra='n3')),
        #
        "go to file":
        R(Key("c-p")),
        "go to <dict> [<filetype>]":
        R(Key("c-p") + Text("%(dict)s" + "%(filetype)s") + Key("enter")),
        "file back [<n2>]":
        R(Key("c-p") + Key("down") * Repeat(extra="n2") + Key("enter")),
        #
        "go to word":
        R(Key("c-semicolon")),
        "go to symbol":
        R(Key("c-r")),
        "go to [symbol in] project":
        R(Key("cs-r")),
        "go to that":
        R(Store() + Key("cs-r") + Retrieve() + Key("enter")),
        "find that in project":
        R(Store() + Key("cs-f") + Retrieve() + Key("enter")),
        "find that":
        R(Store() + Key("c-f") + Retrieve() + Key("enter")),
        "command pallette":
        R(Key("cs-p")),
        #
        "go back [<n2>]":
        R(Key("a-minus") * Repeat(extra="n2")),
        "go forward [<n2>]":
        R(Key("a-plus") * Repeat(extra="n2")),
        "next modification":
        R(Key("c-dot")),
        "previous modification":
        R(Key("c-comma")),
        #
        "fold":
        R(Key("cs-lbracket")),
        "unfold":
        R(Key("cs-rbracket")),
        "unfold all":
        R(Key("c-k, c-j")),
        "fold [level] <n2>":
        R(Key("c-k, c-%(n2)s")),
        #
        "full screen":
        R(Key("f11")),
        "toggle side bar":
        R(Key("c-k, c-b")),
        "show key bindings":
        R(Key("f10, p, right, k")),
        "show at center":
        R(Key("c-k,c-c")),
        "zoom in [<n2>]":
        R(Key("c-equal") * Repeat(extra="n2")),
        "zoom out [<n2>]":
        R(Key("c-minus") * Repeat(extra="n2")),
        #
        "(set | add) bookmark":
        R(Key("c-f2")),
        "next bookmark":
        R(Key("f2")),
        "previous bookmark":
        R(Key("s-f2")),
        "clear bookmarks":
        R(Key("cs-f2")),
        #
        "set mark":
        R(Key("c-k,c-space")),
        "select mark":
        R(Key("c-k,c-a")),
        "swap with mark":
        R(Key("c-k,c-x")),
        "delete mark":
        R(Key("c-k,c-w")),
        #
        "build it":
        R(Key("c-b")),
        "build with":
        R(Key("cs-b")),
        "build <nth>":
        R(Key("c-s,a-%(nth)s,c-b")),
        "build [<nth>] last":
        R(Key("c-s,a-1") + Key("c-pageup") * Repeat(extra="nth") + Key("c-b")),
        #
        "record macro":
        R(Key("c-q")),
        "play [back] macro [<n3>]":
        R(Key("cs-q/10")),
        "(new | create) snippet":
        R(Key("ac-n")),
        #
        "close tab":
        R(Key("c-w")),
        "next tab":
        R(Key("c-pgdown")),
        "previous tab":
        R(Key("c-pgup")),
        "<nth> tab":
        R(Key("a-%(nth)s")),
        "[<nth>] last tab":
        R(Key("a-1") + Key("c-pageup") * Repeat(extra="nth")),
        "column <cols>":
        R(Key("as-%(cols)s")),
        "focus <panel>":
        R(Key("c-%(panel)s")),
        "move <panel>":
        R(Key("cs-%(panel)s")),
        #
        "open terminal":
        R(Key("cs-t")),
        "open console":
        R(Key("c-`")),
    }
    extras = [
        Dictation("dict"),
        ShortIntegerRef("ln1", 1, 1000),
        ShortIntegerRef("ln2", 1, 1000),
        ShortIntegerRef("n2", 1, 9),
        ShortIntegerRef("n3", 1, 21),
        Choice("action", navigation.actions),
        Choice(
            "nth", {
                "first": "1",
                "second": "2",
                "third": "3",
                "fourth": "4",
                "fifth": "5",
                "sixth": "6",
                "seventh": "7",
                "eighth": "8",
                "ninth": "9",
            }),
        Choice("cols", {
            "one": "1",
            "two": "2",
            "three": "3",
            "grid": "5",
        }),
        Choice("panel", {
            "one": "1",
            "left": "1",
            "two": "2",
            "right": "2",
        }),
        Choice(
            "filetype", {
                "pie | python": "py",
                "mark [down]": "md",
                "tech": "tex",
                "tommel": "toml",
            }),
    ]
    defaults = {
        "ln2": "",
        "n2": 1,
        "n3": 1,
        "file type": "",
        "nth": "1",
    }
Ejemplo n.º 15
0
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()
Ejemplo n.º 16
0
class CLI(MergeRule):
    pronunciation = "CLI"
    mapping = {
        "giddy": R(Text("git ")),
        "CD": R(Text("cd ")),
        "parent": R(Text("../")),
        "list files": R(Text("ls ")),
        "move file": R(Text("mv ")),
        "copy file": R(Text("cp ")),
        "remove file": R(Text("rm ")),
        "make directory": R(Text("mkdir ")),
        "NPM": R(Text("npm ")),
        "neon release": R(Text("neon build --release")),
        "cargo build release": R(Text("cargo build --release")),
        "cargo test release": R(Text("cargo test --release")),
        "cargo run release": R(Text("cargo run --release")),
        "cargo format": R(Text("cargo fmt")),
        "pseudo-": R(Text("sudo ")),
        " enough": R(Text("dnf ")),
        "previous command": R(Key("c-p")),
        "exit shall": R(Key("c-d")),
        "interrupt": R(Key("c-c")),
    }
Ejemplo n.º 17
0
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}
Ejemplo n.º 18
0
class WebexTeamsRule(MappingRule):
    # See https://help.webex.com/en-us/7wr87q/Keyboard-Navigation-and-Shortcuts-for-Cisco-Webex-Teams
    mapping = {
        # Navigation - Primary
        "show spaces":
        R(Key("c-1")),
        "show teams":
        R(Key("c-2")),
        "show calls":
        R(Key("c-3")),
        "show meetings":
        R(Key("c-4")),
        "help":
        R(Key("f1")),
        "create space":
        R(Key("cs-n")),
        "contact person [<person>]":
        R(Key("c-n") + Text("%(person)s")),
        "(search | find)":
        R(Key("c-f")),

        # Navigation - Primary - Filtering
        # There does not appear to be a hotkey to reset filters at this time
        #"show all":
        #    R(Key("sa-?")),
        "show drafts":
        R(Key("sa-d")),
        "show favorites":
        R(Key("cs-u")),
        "show flags":
        R(Key("sa-f")),
        "show mentions all":
        R(Key("cs-l")),
        "show mentions me":
        R(Key("cs-o")),
        "show notifications":
        R(Key("sa-n")),
        "show unread":
        R(Key("sa-r")),

        # Navigation - Space
        # Note - A number of space navigation items do not have documented hotkeys
        "add (person | people) [<person>]":
        R(Key("cs-p") + Text("%(person)s")),
        "create whiteboard":
        R(Key("cs-b")),
        "show whiteboards":
        R(Key("cs-w")),
        "leave space":
        R(Key("cs-e")),
        "(search | find) space":
        R(Key("cs-j")),

        # Navigation - Extra
        "previous (space | item) [<nnavi10>]":
        R(Key("a-up")) * Repeat(extra="nnavi10"),
        "next (space | item) [<nnavi10>]":
        R(Key("a-down")) * Repeat(extra="nnavi10"),

        # Messaging
        "attach":
        R(Key("c-o")),
        "emoji":
        R(Key("w-.")),
        "gif | jeff":
        R(Key("c-g")),
        "toggle markdown":
        R(Key("c-m")),
        "new-line":
        R(Key("s-enter")),
        "personal meeting link":
        R(Key("sa-p")),
        "send":
        R(Key("enter")),

        # Formatting - Non-markdown
        "strong | bold":
        R(Key("c-b")),
        "emphasis | italicize":
        R(Key("c-i")),
        "underline":
        R(Key("c-u")),
        "(number | numbered) list":
        R(Key("sa-o")),
        "(bullet | bulletted) list":
        R(Key("sa-u")),
        "heading one":
        R(Key("sa-1")),
        "heading two":
        R(Key("sa-2")),
        "heading three":
        R(Key("sa-3")),

        # Formatting - markdown
        # Use "markdown" rule
    }
    exported = True
    extras = [
        ShortIntegerRef("nnavi10", 1, 11),
        Dictation("person"),
    ]
    defaults = {
        "nnavi10": 1,
        "person": "",
    }
Ejemplo n.º 19
0
def binary_string(digit, amount):
    return Text(str(digit) * amount).execute()
Ejemplo n.º 20
0
class CSharp(MergeRule):
    pronunciation = "C sharp"

    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("foreach (TOKEN in Collection)")),
        #
        SymbolSpecs.TO_INTEGER:
        R(Text("Convert.ToInt32()") + Key("left")),
        SymbolSpecs.TO_FLOAT:
        R(Text("Convert.ToDouble()") + Key("left")),
        SymbolSpecs.TO_STRING:
        R(Text("Convert.ToString()") + Key("left")),
        #
        SymbolSpecs.AND:
        R(Text("&&")),
        SymbolSpecs.OR:
        R(Text("||")),
        SymbolSpecs.NOT:
        R(Text("!")),
        #
        SymbolSpecs.SYSOUT:
        R(Text("Console.WriteLine()") + Key("left")),

        #
        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
        "using":
        R(Text("using")),
        "enum":
        R(Text("enum TOKEN {}") + Key("left")),
        "struct":
        R(Text("struct TOKEN {}") + Key("left")),
        "interface":
        R(Text("interface TOKEN {}") + Key("left")),
        "public":
        R(Text("public ")),
        "private":
        R(Text("private ")),
        "static":
        R(Text("static ")),
        "internal":
        R(Text("internal ")),
        "cast integer":
        R(Text("(int)") + Key("left")),
        "cast double":
        R(Text("(double)") + Key("left")),
        "constant":
        R(Text("const")),
        "array":
        R(Mimic("brackets")),
        "list":
        R(Text("List<>") + Key("left")),
        "var":
        R(Text("var TOKEN = TOKEN;")),
        "(lambda|goes to)":
        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("()?t:f") + (Key("left") * 5)),
    }

    extras = []
    defaults = {}
Ejemplo n.º 21
0
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 = {}
Ejemplo n.º 22
0
def symbol_letters(big, symbol):
    if big:
        symbol = symbol.title()
    Text(str(symbol)).execute()
Ejemplo n.º 23
0
from unittest import TestCase

from castervoice.lib.actions import Text
from castervoice.lib.merge.selfmod.tree_rule.invalid_tree_node_path_error import InvalidTreeNodePathError
from castervoice.lib.merge.selfmod.tree_rule.tree_node import TreeNode

_TN = TreeNode
_TEST_NODES = _TN("zero", Text("L-0"), [
            _TN("one alpha", Text("L-1A"), [
                    _TN("two alpha", Text("L-2A"), [
                            _TN("three alpha", Text("L-3A")),
                            _TN("three bravo", Text("L-3B")),
                            _TN("three charlie", Text("L-3C"))
                        ]),
                    _TN("two bravo", Text("L-2B"))
                ]),
            _TN("one bravo", Text("L-1B")),
            _TN("one charlie", Text("L-1C"))
    ])


class TestTreeNode(TestCase):

    def test_get_nodes_along_path_success_depth_0(self):
        nodes = TreeNode.get_nodes_along_path([_TEST_NODES], [])

        self.assertEqual(1, len(nodes))
        self.assertSetEqual(set(["zero"]),
                            set([tn.get_spec() for tn in nodes]))

    def test_get_nodes_along_path_success_depth_1(self):
Ejemplo n.º 24
0
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": "",
    }
Ejemplo n.º 25
0
Archivo: dev.py Proyecto: pimp22/Caster
def close_last_rspec(rspec):
    Text("</" + rspec + ">").execute()
Ejemplo n.º 26
0
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}
Ejemplo n.º 27
0
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": ""}
Ejemplo n.º 28
0
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": ""}
Ejemplo n.º 29
0
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": "",
    }
Ejemplo n.º 30
0
def type_mouse_current_position_button(mouse_button="left"):
    first_part_of_string = 'Mouse("[%d, %d], ' % get_cursor_position()
    second_part_of_string = '%s' % mouse_button
    full_string = first_part_of_string + second_part_of_string
    Text(full_string).execute()