コード例 #1
0
ファイル: ide.py プロジェクト: akanix42/my-caster-commands
def newJsFile(name):
    send_command("NewJavaScriptFile")
    Text("{name}".format(name = name)).execute()
    Key("enter").execute()
コード例 #2
0
def output_gen_server_command(gen_server_command=None):
    has_command = replace_in_text("GenServer.%s" % gen_server_command)
    does_not_have_command = Text("GenServer")
    command = has_command if gen_server_command is not None else does_not_have_command

    command.execute()
コード例 #3
0
def output_comment(comment, comment_type=None):
    type_output = comment_type + " " if comment_type is not None else ""
    Text("# %s%s" % (type_output, comment)).execute()
コード例 #4
0
 'rename':
 Key('s-f6'),
 # Open terminal
 'termi':
 Key('a-f12'),
 # VCS operations popup (custom shortcut)
 'version control':
 Key('a-f10'),
 # VCS pull (custom shortcut)
 'version pull':
 Key('control:down/3, alt:down/3, rbracket, control:up, alt:up'),
 # Go to line
 '[go] to line':
 Key('c-g'),
 '[go] to line <n>':
 Key('c-g') + Pause('5') + Text('%(n)d') + Key('enter, end'),
 # Move line down/up
 'hamster down':
 Key('alt:down/3') + Key('s-down') + Key('alt:up'),
 'hamster up':
 Key('alt:down/3') + Key('s-up') + Key('alt:up'),
 # Move statement down/up
 'tiger up':
 Key('control:down/3') + Key('s-up') + Key('control:up'),
 'tiger down':
 Key('control:down/3') + Key('s-down') + Key('control:up'),
 # Jumping back/forth in code
 'prev file':
 Key('control:down/3') + Key('tab') + Key('control:up'),
 'prev place':
 Key('alt:down/3') + Key('s-backspace') + Key('alt:up'),
コード例 #5
0
	"font face": "@f+",
	"align items": 'ai',
	"justify content": 'jc',
}

contextCss = AppContext(title=".css")
contextLess = AppContext(title=".less")
context = contextCss | contextLess

grammar = Grammar("css", context=context)

rules = MappingRule(
	name="css",
	mapping={
		# 'height'
		"<prop>": Text("%(prop)s") + Key("tab"),
		# 'height auto'
		"<prop> <text>": Text("%(prop)s") + Key("tab") + Text('%(text)s') + Pause('70') + Key('s-enter'),
		# 'height 100'
		"<prop> <n>": Text("%(prop)s") + Text("%(n)d") + Key("tab") + Pause('70') + Key('s-enter'),
		# 'height 100 percent'
		"<prop> <n> percent": Text("%(prop)s") + Key("tab") + Text("%(n)d%%") + Pause('70') + Key('s-enter'),
		# '100 pixel'
		"<n> pixel": Text("%(n)dpx"),
		# '100 percent'
		"<n> percent": Text("%(n)d%%"),

		"squeeze <text>": Text(".") + Function(dashify_text) + Text(" {") + Key("enter"),
		"dom <element>": Text("%(element)s"),
	},
	extras=[
コード例 #6
0
class Python(MergeRule):
    non = PythonNon

    mapping = {
        SymbolSpecs.IF:
            R(Key("i,f,space,colon,left"), rdescript="Python: If"),
        SymbolSpecs.ELSE:
            R(Text("else:") + Key("enter"), rdescript="Python: Else"),
        #
        # (no switch in Python)
        SymbolSpecs.BREAK:
            R(Text("break"), rdescript="Python: Break"),
        #
        SymbolSpecs.FOR_EACH_LOOP:
            R(Text("for  in :") + Key("left:5"), rdescript="Python: For Each Loop"),
        SymbolSpecs.FOR_LOOP:
            R(Text("for i in range(0, ):") + Key("left:2"),
              rdescript="Python: For i Loop"),
        SymbolSpecs.WHILE_LOOP:
            R(Text("while :") + Key("left"), rdescript="Python: While"),
        # (no do-while in Python)
        #
        SymbolSpecs.TO_INTEGER:
            R(Text("int()") + Key("left"), rdescript="Python: Convert To Integer"),
        SymbolSpecs.TO_FLOAT:
            R(Text("float()") + Key("left"),
              rdescript="Python: Convert To Floating-Point"),
        SymbolSpecs.TO_STRING:
            R(Text("str()") + Key("left"), rdescript="Python: Convert To String"),
        #
        SymbolSpecs.AND:
            R(Text(" and "), rdescript="Python: And"),
        SymbolSpecs.OR:
            R(Text(" or "), rdescript="Python: Or"),
        SymbolSpecs.NOT:
            R(Text("!"), rdescript="Python: Not"),
        #
        SymbolSpecs.SYSOUT:
            R(Text("print()") + Key("left"), rdescript="Python: Print"),
        #
        SymbolSpecs.IMPORT:
            R(Text("import "), rdescript="Python: Import"),
        #
        SymbolSpecs.FUNCTION:
            R(Text("def "), rdescript="Python: Function"),
        SymbolSpecs.CLASS:
            R(Text("class "), rdescript="Python: Class"),
        #
        SymbolSpecs.COMMENT:
            R(Text("#"), rdescript="Python: Add Comment"),
        SymbolSpecs.LONG_COMMENT:
            R(Text("''''''") + Key("left:3"), rdescript="Python: Long Comment"),
        #
        SymbolSpecs.NULL:
            R(Text("None"), rdescript="Python: Null"),
        #
        SymbolSpecs.RETURN:
            R(Text("return "), rdescript="Python: Return"),
        #
        SymbolSpecs.TRUE:
            R(Text("True"), rdescript="Python: True"),
        SymbolSpecs.FALSE:
            R(Text("False"), rdescript="Python: False"),

        # Python specific
        "sue iffae":
            R(Text("if "), rdescript="Python: Short If"),
        "sue shells":
            R(Text("else "), rdescript="Python: Short Else"),
        "from":
            R(Text("from "), rdescript="Python: From"),
        "self":
            R(Text("self"), rdescript="Python: Self"),
        "long not":
            R(Text(" not "), rdescript="Python: Long Not"),
        "it are in":
            R(Text(" in "), rdescript="Python: In"),  #supposed to sound like "iter in"
        "shell iffae | LFA":
            R(Key("e,l,i,f,space,colon,left"), rdescript="Python: Else If"),
        "convert to character":
            R(Text("chr()") + Key("left"), rdescript="Python: Convert To Character"),
        "length of":
            R(Text("len()") + Key("left"), rdescript="Python: Length"),
        "global":
            R(Text("global "), rdescript="Python: Global"),
        "make assertion":
            R(Text("assert "), rdescript="Python: Assert"),
        "list comprehension":
            R(Text("[x for x in TOKEN if TOKEN]"),
              rdescript="Python: List Comprehension"),
        "[dot] (pie | pi)":
            R(Text(".py"), rdescript="Python: .py"),
        "jason":
            R(Text("json"), rdescript="Python: json"),
        "identity is":
            R(Text(" is "), rdescript="Python: is"),
        "yield":
            R(Text("yield "), rdescript="Python: Yield"),
    }

    extras = [
        Dictation("text"),
    ]
    defaults = {}
コード例 #7
0
ファイル: gitbash.py プロジェクト: gitter-badger/caster
class CommandRule(MappingRule):

    mapping = {
        "initialize repository":       Text( "git init" )+Key("enter"),
        "add":              R(Key("g, i, t, space, a, d, d, space, dot, enter"), rdescript="GIT: Add All"),
        "status":           R(Key( "g, i, t, space, s, t, a, t, u, s, enter" ), rdescript="GIT: Status"),
        "commit":           R(Key( "g, i, t, space, c, o, m, m, i, t, space, minus, a, m, space, apostrophe, apostrophe, left"), rdescript="GIT: Commit"),
        "bug fix commit <n>":    R(Mimic("commit")+Text("fixes #%(n)d ")+Key("backspace"), rdescript="GIT: Bug Fix Commit"),
        "reference commit <n>":  R(Mimic("commit")+Text("refs #%(n)d ")+Key("backspace"), rdescript="GIT: Reference Commit"),
        "checkout":         R(Text( "git checkout " ), rdescript="GIT: Check Out"),
        "merge":            R(Text( "git merge " ), rdescript="GIT: Merge"),
        "merge tool":       R(Text( "git mergetool")+Key("enter"), rdescript="GIT: Merge Tool"),
        "fetch":            R(Text( "git fetch" )+Key("enter"), rdescript="GIT: Fetch"),
        
        
        "(get push | push)":R(Text( "git push" )+Key("enter"), rdescript="GIT: Push"),
        "pull":             R(Text( "git pull" )+Key("enter"), rdescript="GIT: Pull"),
        "CD up":            R(Text( "cd .." )+Key("enter"), rdescript="GIT: Up Directory"),
        "CD":               R(Text( "cd " ), rdescript="GIT: Navigate Directory"),
        "list":             R(Text( "ls" )+Key("enter"), rdescript="GIT: List"),
        "make directory":   R(Text( "mkdir " ), rdescript="GIT: Make Directory"),
        
        
        
        "undo [last] commit":       R(Text("git reset --soft HEAD~1")+Key("enter"), rdescript="GIT: Undo Commit"),
        "undo changes":             R(Text("git reset --hard")+Key("enter"), rdescript="GIT: Undo Since Last Commit"),
        "stop tracking [file]":     R(Text("git rm --cached FILENAME"), rdescript="GIT: Stop Tracking"),
        "preview remove untracked": R(Text("git clean -nd")+Key("enter"), rdescript="GIT: Preview Remove Untracked"),
        "remove untracked":         R(Text("git clean -fd")+Key("enter"), rdescript="GIT: Remove Untracked"),
        
        "visualize":        R(Text("gitk")+Key("enter"), rdescript="GIT: gitk"),
        "visualize file":   R(Text("gitk -- PATH"), rdescript="GIT: gitk Single File"),
        "visualize all":    R(Text("gitk --all")+Key("enter"), rdescript="GIT: gitk All Branches"),
        
        "exit":             R(Text( "exit" )+Key("enter"), rdescript="GIT: Exit"),
        
        
        
        "stash":            R(Text("git stash")+Key("enter"), rdescript="GIT: Stash"),
        "stash apply [<n>]":R(Text("git stash apply")+Function(apply), rdescript="GIT: Stash Apply"),
        "stash list":       R(Text("git stash list")+Key("enter"), rdescript="GIT: Stash List"),
        "stash branch":     R(Text("git stash branch NAME"), rdescript="GIT: Stash Branch"),

        "cherry pick":      R(Text("git cherry-pick "), rdescript="GIT: Cherry Pick"),
        "abort cherry pick":R(Text("git cherry-pick --abort"), rdescript="GIT: Abort Cherry Pick"),
        
        "GUI | gooey":      R(Text("git gui")+Key("enter"), rdescript="GIT: gui"),
        "blame":            R(Text("git blame PATH -L FIRSTLINE,LASTLINE"), rdescript="GIT: Blame"),
        "gooey blame":      R(Text("git gui blame PATH"), rdescript="GIT: GUI Blame"),
        
        "search recursive": R(Text("grep -rinH \"PATTERN\" *"), rdescript="GREP: Search Recursive"),
        "search recursive count": R(Text("grep -rinH \"PATTERN\" * | wc -l"), rdescript="GREP: Search Recursive Count"),
        "search recursive filetype": R(Text("find . -name \"*.java\" -exec grep -rinH \"PATTERN\" {} \\;"), rdescript="GREP: Search Recursive Filetype"),
        "to file":          R(Text(" > FILENAME"), rdescript="Bash: To File"),
        }
    extras = [
              IntegerRef("n", 1, 10000),
             ]
    defaults ={"n": 0}
コード例 #8
0
class VisualStudioCodeRule(MergeRule):
    pronunciation = "visual studio code"

    mapping = {
        ### ported from my dragonfly scripts
        # File management
        "[open] command palette":
        R(Key("cs-p"), rdescript="Visual Studio Code: Command Palette"),
        "(Open [file] | Go to [tab]) [<text>]":
        R(Key("c-p") + Text("%(text)s"),
          rdescript="Visual Studio Code: Go To File"),
        "Close tab":
        R(Key("c-w"), rdescript="Visual Studio Code: Close Tab"),
        "Save file":
        R(Key("c-s"), rdescript="Visual Studio Code: Save File"),
        "Save and close":
        R(Key("c-s/10, c-w"),
          rdescript="Visual Studio Code: Save And Close File"),

        # Search
        "(search | find in) [all] (files | codebase)":
        R(Key("cs-f"), rdescript="Visual Studio Code: Find in Codebase"),
        "(search | find) [file]":
        R(Key("c-f"), rdescript="Visual Studio Code: Find in File"),
        "(Find | Jump [to]) next <text>":
        R(Function(findNthToken, n=1, direction="forward"),
          rdescript="Visual Studio Code: Find Next"),
        "(Find | Jump [to]) previous <text>":
        R(Function(findNthToken, n=1, direction="reverse"),
          rdescript="Visual Studio Code: Find Previous"),

        # Tab management
        "nexta [<n>]":
        R(Key("c-pgdown"), rdescript="Visual Studio Code: Next Tab") * Repeat(
            extra="n"
        ),  # These would be next and previous tab but i have a conflict with chrome
        "prexta [<n>]":
        R(Key("c-pgup"), rdescript="Visual Studio Code: Previous Tab") *
        Repeat(extra="n"),
        "Close tab":
        R(Key("c-f4"), rdescript="Visual Studio Code: Close Tab"),
        "Exit preview":
        R(Key("space, c-z"), rdescript="Visual Studio Code: Exit Preview"),

        # moving around a file
        "(go to | jump | jump to) line <n>":
        R(Key("c-g") + Text("%(n)d") + Key("enter"),
          rdescript="Visual Studio Code: Go to Line"),
        "Go to definition":
        R(Key("f12"), rdescript="Visual Studio Code: Go to Definition"),
        "Go to required definition":
        R(Key("c-f12:2, c-right:5, left/50, f12"),
          rdescript="Visual Studio Code: Go to Required Definition"),
        "Go to (top | first line)":
        R(Key("c-home"), rdescript="Visual Studio Code: Go to Top"),
        "Go to ( bottom | last line)":
        R(Key("c-end"), rdescript="Visual Studio Code: Go to Bottom"),
        "ee-ol":
        R(Key("end"), rdescript="Visual Studio Code: End Of Line"),
        "beol":
        R(Key("home"), rdescript="Visual Studio Code: Beginning of Line"),
        "Go back [<n>]":
        R(Key("a-left"), rdescript="Visual Studio Code: Go Back") *
        Repeat(extra="n"),
        "Go forward [<n>]":
        R(Key("a-right"), rdescript="Visual Studio Code: Go Forward") *
        Repeat(extra="n"),

        # Formatting
        "indent [<n>]":
        R(Key("tab"), rdescript="Visual Studio Code: Indent") *
        Repeat(extra="n"),
        "Unindent [<n>]":
        R(Key("s-tab"), rdescript="Visual Studio Code: Unindent") *
        Repeat(extra="n"),
        "Comment":
        R(Key("c-slash"), rdescript="Visual Studio Code: Line Comment"),
        "Block comment":
        R(Key("sa-a"), rdescript="Visual Studio Code: Block Comment"),

        # Window Management
        "[toggle] full screen":
        R(Key("f11"), rdescript="Visual Studio Code:Fullscreen"),
        "[toggle] Zen mode":
        R(Key("c-k/3, z")),

        # Debugging
        "[toggle] breakpoint":
        R(Key("f9"), rdescript="Visual Studio Code:Breakpoint"),
        "step over [<n>]":
        R(Key("f10/50") * Repeat(extra="n"),
          rdescript="Visual Studio Code:Step Over"),
        "step into":
        R(Key("f11"), rdescript="Visual Studio Code:Step Into"),
        "step out [of]":
        R(Key("s-f11"), rdescript="Visual Studio Code:Step Out"),
        "resume":
        R(Key("f5"), rdescript="Visual Studio Code:Resume"),
    }
    extras = [
        Dictation("text"),
        Dictation("mim"),
        IntegerRefST("n", 1, 1000),
    ]
    defaults = {"n": 1, "mim": "", "text": ""}
コード例 #9
0
ファイル: visualstudio.py プロジェクト: tyoung87/caster
class VisualStudioRule(MergeRule):
    pronunciation = "visual studio"

    mapping = {
        "next tab [<n>]":
        R(Key("ca-pgdown"), rdescript="Visual Studio: Next Tab") *
        Repeat(extra="n"),
        "prior tab [<n>]":
        R(Key("ca-pgup"), rdescript="Visual Studio: Previous Tab") *
        Repeat(extra="n"),
        "close tab [<n>]":
        R(Key("c-f4/20"), rdescript="Visual Studio: Close Tab") *
        Repeat(extra="n"),
        "(list | show) documents":
        R(Key("a-w, w"), rdescript="Visual Studio: List Documents"),
        "[focus] document (window | pane)":
        R(Key("a-w, w, enter"),
          rdescript="Visual Studio: Focus Document Pane"),
        "solution explorer":
        R(Key("ca-l"), rdescript="Visual Studio: Solution Explorer"),
        "team explorer":
        R(Key("c-backslash, c-m"), rdescript="Visual Studio: Team Explorer"),
        "source control explorer":
        R(Key("c-q") + Text("Source Control Explorer") + Key("enter"),
          rdescript="Visual Studio: Source Control Explorer"),
        "quick launch":
        R(Key("c-q"), rdescript="Visual Studio: Quick Launch"),
        "go to line":
        R(Key("c-g"), rdescript="Visual Studio: Go To Line"),
        "comment line":
        R(Key("c-k, c-c"), rdescript="Visual Studio: Comment Selection"),
        "comment block":
        R(Key("c-k, c-c"), rdescript="Visual Studio: Comment Block"),
        "(un | on) comment line":
        R(Key("c-k/50, c-u"), rdescript="Visual Studio: Uncomment Selection"),
        "(un | on) comment block":
        R(Key("c-k/50, c-u"), rdescript="Visual Studio: Uncomment Block"),
        "[toggle] full screen":
        R(Key("sa-enter"), rdescript="Visual Studio: Fullscreen"),
        "(set | toggle) bookmark":
        R(Key("c-k, c-k"), rdescript="Visual Studio: Toggle Bookmark"),
        "next bookmark":
        R(Key("c-k, c-n"), rdescript="Visual Studio: Next Bookmark"),
        "prior bookmark":
        R(Key("c-k, c-p"), rdescript="Visual Studio: Previous Bookmark"),
        "collapse to definitions":
        R(Key("c-m, c-o"), rdescript="Visual Studio: Collapse To Definitions"),
        "toggle [section] outlining":
        R(Key("c-m, c-m"),
          rdescript="Visual Studio: Toggle Section Outlining"),
        "toggle all outlining":
        R(Key("c-m, c-l"), rdescript="Visual Studio: Toggle All Outlining"),
        "[toggle] breakpoint":
        R(Key("f9"), rdescript="Visual Studio: Breakpoint"),
        "step over [<n>]":
        R(Key("f10/50") * Repeat(extra="n"),
          rdescript="Visual Studio: Step Over"),
        "step into":
        R(Key("f11"), rdescript="Visual Studio: Step Into"),
        "step out [of]":
        R(Key("s-f11"), rdescript="Visual Studio: Step Out"),
        "resume":
        R(Key("f5"), rdescript="Visual Studio: Resume"),
        "get latest [version]":
        R(Key("a-f, r, l"), rdescript="Visual Studio: Get Latest"),
        "(show | view) history":
        R(Key("a-f, r, h"), rdescript="Visual Studio: Show History"),
        "compare (files | versions)":
        R(Key("a-f, r, h"), rdescript="Visual Studio: Compare..."),
        "undo (checkout | pending changes)":
        R(Key("a-f, r, u"), rdescript="Visual Studio: Undo Pending Changes"),
        "[open] [go to] work item":
        R(Key("a-m, g"), rdescript="Visual Studio: Open Work Item"),
        "[add] [new] linked work item":
        R(Key("sa-l"), rdescript="Visual Studio: New Linked Work Item"),
    }
    extras = [
        Dictation("text"),
        Dictation("mim"),
        IntegerRefST("n", 1, 1000),
    ]
    defaults = {"n": 1, "mim": ""}
コード例 #10
0
class PythonUtilities(MappingRule):
    mapping = {
        # control flow
        "if [<name>] is <comparison>":
        Function(output_if_comparison, construct="if"),
        "if [<name>]":
        Function(output_if, construct="if"),
        "expression if [<name>] is <comparison>":
        Function(output_if_expression_comparison),
        "expression if [<name>]":
        Function(output_if_expression),
        "else if [<name>]":
        Function(output_if, statement_type="elif"),
        "else if [<name>] is <comparison>":
        Function(output_if_comparison, construct="elif"),
        "else":
        Text("else:") + Key("enter"),

        # loops
        "for loop [over <name>]":
        Function(output_for_loop),
        "while loop":
        replace_in_text("while $:"),

        # logic checks
        "check [<name>] is <comparison>":
        Function(output_comparison),

        # declarations/definitions
        "function [<function_name>]":
        Function(output_function),
        "class [<class_name>] [derives from <superclass>]":
        Function(output_class),
        "anonymous function [taking <name>]":
        Function(output_anonymous_function),
        "[<name>] equals":
        Function(output_binding),

        # imports
        "from [<import_name>] import":
        Function(output_from_import),
        "qualified import [<import_name>]":
        Function(output_qualified_import),
        "import dragonfly":
        Text("import dragonfly as dragonfly"),

        # other convenience
        "method [<method_name>] on [<name>]":
        Function(output_method_call),
        "call [<function_name>] on [<name>]":
        Function(output_function_call),
        "string from [<name>]":
        Function(output_wrapped_optional_name, around="str"),
        "length of [<name>]":
        Function(output_wrapped_optional_name, around="len"),
        "pass":
        Text("pass"),
        "[<comment_type>] comment [<comment>]":
        Function(output_comment),
    }

    extras = [
        Dictation("function_name", default=""),
        Dictation("class_name", default=""),
        Dictation("superclass", default=""),
        Dictation("import_name", default=""),
        Dictation("name", default=""),
        Dictation("method_name", default=""),
        comparison_choice("comparison"),
        comment_choice("comment_type"),
        Dictation("comment", default="")
    ]
コード例 #11
0
def output_qualified_import(import_name):
    execute_with_dictation(
        import_name,
        on_dictation=lambda v: Text("import %s as " % format_name(v)),
        on_other=lambda v: replace_in_text("import $ as _"),
    )
コード例 #12
0
def output_comment(comment, comment_type=None):
    if comment_type is None:
        output_text = "# %s" % comment
    else:
        output_text = "# %s %s" % (comment_type, comment)
    Text(output_text).execute()
コード例 #13
0
def output_wrapped_optional_name(name, around):
    execute_with_dictation(
        name,
        on_dictation=lambda v: Text("%s(%s)" % (around, format_name(name))),
        on_other=lambda v: replace_in_text("%s($)" % around))
コード例 #14
0
def output_binding(name):
    execute_with_dictation(
        name,
        on_dictation=lambda v: Text("%s = " % format_name(name)),
        on_other=lambda v: Text(" = "))
コード例 #15
0
def directory_up(n):
    repeat = ['..' for i in range(n)]  # @UnusedVariable
    txt = "cd %s\n" % ("/".join(repeat))
    Text(txt).execute()
コード例 #16
0
        '[<n>] edit out dent': Key('c-[:%(n)d'),

        'edit cut': Key('c-x'),
        'edit copy': Key('c-c'),
        'edit paste': Key('c-v'),
        'edit undo': Key('c-z'),

        'edit comment': Key(r'c-slash'),

        'format document': Key('cs-i'),
        'toggle problem view': Key('cs-m'),
        'problem next': Key('F8'),

        '[<n>] tab right': Key('c-pgdown:%(n)d'),
        '[<n>] tab left': Key('c-pgup:%(n)d'),

        '[<n>] move tab right': Key('cs-pgdown:%(n)d'),
        '[<n>] move tab left': Key('cs-pgup:%(n)d'),

        'find <text>': Key('c-f/20') + Text('%(text)s'),
        'match next': Key('enter'),
        'match previous': Key('s-enter'),
        'go to line [<NNN>]': Key('c-g') + Text('%(NNN)d\n'),
    },
    extras = [
        IntegerRef("n", 1, 20, default=1),
        IntegerRef("NNN", 1, 1000, default=1),
        Dictation("text", default=""),
    ]
)
コード例 #17
0
ファイル: uedit32.py プロジェクト: dilas12345/local
class CommandRule(MappingRule):

    mapping = {
        "menu file":                    Key("a-f"),
        "menu edit":                    Key("a-e"),
        "menu search":                  Key("a-s"),
        "menu project":                 Key("a-p"),
        "menu view":                    Key("a-v"),
        "menu format":                  Key("a-t"),
        "menu column":                  Key("a-l"),
        "menu macro":                   Key("a-m"),
        "menu scripting":               Key("a-i"),
        "menu advance":                 Key("a-a"),
        "menu window":                  Key("a-w"),
        "menu help":                    Key("a-h"),

        # File menu.
        "new file":                     Key("c-n"),
        "open file":                    Key("c-o, s-tab"),
        "open filename <dict>":         Key("c-o") + Text("%(dict)s\n"),
        "close file":                   Key("a-f, c"),
        "close <1to9> files":           Key("a-f, c") * Repeat(extra="1to9"),
        "close window <1to9>":          Key("a-w, %(1to9)d/20, a-f, c"),
        "save file":                    Key("c-s"),
        "save file as":                 Key("a-f, a"),
        "save backup":                  Key("a-f, y"),
        "revert to saved":              Key("a-f, d"),
        "revert to saved force":        Key("a-f, d, enter"),
        "print file":                   Key("c-p"),
        "page setup":                   Key("a-f, g, t"),
        "print setup":                  Key("a-f, g, u"),
        "recent files":                 Key("a-f, l"),
        "recent projects":              Key("a-f, k"),
        "recent project <1to9>":        Key("a-f, k/20, %(1to9)d"),

        # Edit menu.
        "copy file path":               Key("a-e, f"),
        "copy this word":               Key("c-j, c-c"),

        # Search menu.
        "search find":                  Key("c-f"),
        "search find <dict>":           Key("c-f") + Text("%(dict)s\n"),
        "search next":                  Key("f3"),
        "search replace":               Key("c-r"),
        "search replace <dict> with <dict2>": Key("c-r") \
                                        + Text("%(dict)s\t%(dict2)s"),
        "find in files":                Key("a-s, i"),
        "find this word in files":      Key("c-j, a-s, i"),
        "phi phi this word":            Key("c-j, a-s, i/20, enter"),

        # Format menu.
        "convert tabs to spaces":       Key("a-t, s"),
        "format paragraph":             Key("c-t"),
        "paragraph formatting":         Key("a-t, f, s"),

        # Advanced menu.
        "run command":                  Key("c-f9"),
        "run command in window <1to9>": Key("c-s, a-w, %(1to9)d/40, c-f9"),
        "run [command] in window <1to9>": Key("c-s, a-w, %(1to9)d/40, c-f9"),
        "run command menu":             Key("f9"),
        "advanced configuration":       Key("a-a, c"),
        "set tab stop to <1to9> [spaces]": Key("a-a, c/20, home/20, down:7/10, tab/5:8")
                                         + Text("%(1to9)d\t%(1to9)d\n"),

        # Window menu.
        "window <1to9>":                Key("a-w, %(1to9)d"),
        "window list":                  Key("a-w, w"),

        # Miscellaneous shortcuts.
        "center cursor":                Key("a-npmul"),
        "cursor to top":                Key("a-npsub"),
        "cursor to bottom":             Key("a-npadd"),
        "[go to] line <int>":           Key("c-g")
                                         + Text("%(int)d") + Key("enter"),
        "[mark] lines <int> through <int2>":
                                        Key("c-g") + Text("%(int)d\n")
                                         + Key("c-g") + Text("%(int2)d")
                                         + Key("s-enter"),
        }
    extras = [
              Dictation("dict"),
              Dictation("dict2"),
              IntegerRef("1to9", 1, 10),
              NumberRef("int"),
              NumberRef("int2"),
              Choice("zoom",
                    {"75": "7", "100": "1", "page width": "p",
                     "text width": "t", "whole page": "w",
                    }),
             ]
コード例 #18
0
ファイル: dev.py プロジェクト: Digital-ecologist/caster
def close_last_spoken(spoken):
    first = spoken[0]
    Text("</" + first + ">").execute()
コード例 #19
0
ファイル: gitbash.py プロジェクト: gitter-badger/caster
def apply(n):
    if n!=0:
        Text("stash@{"+str(int(n))+"}").execute()
コード例 #20
0
ファイル: dev.py プロジェクト: Digital-ecologist/caster
def close_last_rspec(rspec):
    Text("</" + rspec + ">").execute()
コード例 #21
0
def type_numbers(numbers):
    Text("".join(map(str, numbers))).execute()
コード例 #22
0
ファイル: dev.py プロジェクト: Digital-ecologist/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": ""}
コード例 #23
0
ファイル: unity.py プロジェクト: lahwran/Caster
class UnityRule(MappingRule):
    mapping = {
        "show <window>":
        R(Key("c-%(window)s")),
        "search <searchable> [<dictation>]":
        R(Key("c-%(searchable)s,c-f") + Text("%(dictation)s")),
        "clear <searchable> [search]":
        R(Key("c-%(searchable)s,c-f,backspace")),
        "show console":
        R(Key("cs-c")),
        "max view":
        R(Key("s-space")),
        "(play | stop) game":
        R(Key("c-p")),
        "pause game":
        R(Key("cs-p")),
        "build and run":
        R(Key("c-b")),
        "build settings":
        R(Key("cs-b")),
        "make empty [game object]":
        R(Key("as-n")),
        "add component":
        R(Key("cs-a")),
        "align with view":
        R(Key("cs-f")),
        "move to view":
        R(Key("ca-f")),
        "move [sibling] first":
        R(Key("c-equals")),
        "move [sibling] last":
        R(Key("c-hyphen")),
        "(set active | toggle )":
        R(Key("as-a")),
        "[load] selection [<1to9>]":
        R(Key("cs-%(1to9)s")),
        "store selection [<1to9>]":
        R(Key("ca-%(1to9)s")),
        "rename":
        R(Key("f2")),
    }
    extras = [
        Dictation("dictation"),
        IntegerRef("1to9", 1, 10),
        Choice("searchable", {
            "scene": "1",
            "(hierarchy | hire)": "4",
            "project": "5",
        }),
        Choice(
            "window", {
                "scene": "1",
                "game": "2",
                "inspector": "3",
                "(hierarchy | hire)": "4",
                "project": "5",
                "animation": "6",
                "profiler": "7",
                "audio mixer": "8",
                "asset store": "9",
                "services": "0",
            }),
    ]
    defaults = {"dictation": "", "1to9": "1"}
コード例 #24
0
def text_map_to_action_map(text_map):
    """Converts string values in a map to text actions."""
    return dict(
        (k, Text(v.replace("%", "%%"))) for (k, v) in text_map.iteritems())
コード例 #25
0
        CompoundRule.__init__(self,
                              spec=compound_spec,
                              extras=compound_extras,
                              exported=True)

    def _process_recognition(self, node, extras):  # @UnusedVariable
        series = extras["series"]
        for action in series:
            action.execute()


series_rule = SeriesMappingRule(
    mapping={
        # VBScript specific.
        "variable (dimension|dim)":
        Text("dim "),
        # Closures.
        "angle brackets":
        Text("<>") + Key("left"),
        "brackets":
        Text("[]") + Key("left"),
        "braces":
        Text("{}") + Key("left"),
        "parens":
        Text("()") + Key("left"),
        "quotes":
        Text('""') + Key("left"),
        "single quotes":
        Text("''") + Key("left"),
        # Common terms.
        "lib":
コード例 #26
0
from dragonfly import Config, Section, Item, MappingRule, Grammar, Text, Key, Function, Dictation

import lib.format

config = Config("capistrano")
config.cmd = Section("helpers")
config.cmd.map = Item({
    "cap deploy [with] migrations to <text>":
    Text("SKIP_ASSETS=true RUBBER_ENV=") +
    Function(lib.format.lowercase_text) + Text(" cap deploy:migrations"),
    "cap deploy [with] migrations to <text> with filter":
    Text("SKIP_ASSETS=true RUBBER_ENV=") +
    Function(lib.format.lowercase_text) +
    Text(" cap deploy:migrations FILTER="),
    "cap deploy [with] migrations to <text> with filter roles":
    Text("SKIP_ASSETS=true RUBBER_ENV=") +
    Function(lib.format.lowercase_text) +
    Text(" cap deploy:migrations FILTER_ROLES="),
    "cap deploy [with] migrations to <text> with assets":
    Text("RUBBER_ENV=") + Function(lib.format.lowercase_text) +
    Text(" cap deploy:migrations"),
    "cap deploy [with] migrations to <text> with assets with filter":
    Text("RUBBER_ENV=") + Function(lib.format.lowercase_text) +
    Text(" cap deploy:migrations FILTER="),
    "cap deploy [with] migrations to <text> with assets with filter roles":
    Text("RUBBER_ENV=") + Function(lib.format.lowercase_text) +
    Text(" cap deploy:migrations FILTER_ROLES="),
    "cap deploy to <text>":
    Text("SKIP_ASSETS=true RUBBER_ENV=") +
    Function(lib.format.lowercase_text) + Text(" cap deploy"),
    "cap deploy to <text> with filter":
コード例 #27
0
def output_pipe_into(name):
    execute_with_dictation(name, lambda n: Text("|> %s()" % format_name(n)),
                           lambda n: Text("|> "))
コード例 #28
0
DYN_MODULE_NAME = "bash"
INCOMPATIBLE_MODULES = []


def directory_up(n):
    repeat = ['..' for i in range(n)]  # @UnusedVariable
    txt = "cd %s\n" % ("/".join(repeat))
    Text(txt).execute()


rules = MappingRule(
    mapping={
        # Commands and keywords:
        "apt cache search":
        Text("apt-cache search "),
        # "apt cache search <text>": SCText("apt-cache search %(text)s"),
        # "apt cache show": Text("apt-cache show "),
        # "apt cache show <text>": SCText("apt-get show %(text)s"),
        # "apt get install": Text("apt-get install "),
        # "apt get install <text>": SCText("apt-get install %(text)s"),
        # "apt get update": Text("apt-get update") + Key("enter"),
        "sudo apt get install":
        Text("sudo apt-get install "),
        # "sudo apt get install <text>": SCText("sudo apt-get install %(text)s"),
        "sudo apt get update":
        Text("sudo apt-get update") + Key("enter"),
        "sudo apt get upgrade":
        Text("sudo apt-get upgrade") + Key("enter"),
        # "background": Text("bg "),
        # "(cat|C A T)": Text("cat "),
コード例 #29
0
def output_interactive_command(interactive_command=None):
    interactive_command_output = interactive_command if interactive_command is not None else ""

    Text("iex %s" % interactive_command_output).execute()
コード例 #30
0
ファイル: ide.py プロジェクト: akanix42/my-caster-commands
def findText(text):
    Key('c-f/25').execute()
    Text(text).execute()