Example #1
0
def _instance(text2="", text=""):
    Key('at').execute()
    snake_case_text(text)
    Key('space, equal, space').execute()
    if (text2):
        snake_case_text(text2)
        Key('o').execute()
Example #2
0
class ExModeCommands(MappingRule):
    mapping = {
        "read": Text("r "),
        "(write|save) file": Text("w "),
        "quit": Text("q "),
        "turbo quit": Text("q! "),
        "write and quit": Text("wq "),
        "edit": Text("e "),
        "tab edit": Text("tabe "),
        "set number": Text("set number "),
        "set relative number": Text("set relativenumber "),
        "set ignore case": Text("set ignorecase "),
        "set no ignore case": Text("set noignorecase "),
        "set file format UNIX": Text("set fileformat=unix "),
        "set file format DOS": Text("set fileformat=dos "),
        "set file type Python": Text("set filetype=python"),
        "set file type tex": Text("set filetype=tex"),
        "P. W. D.": Text("pwd "),
        "help": Text("help"),
        "substitute": Text("s/"),
        "up": Key("up"),
        "down": Key("down"),
        "[<n>] left": Key("left:%(n)d"),
        "[<n>] right": Key("right:%(n)d"),
    }
    extras = [
        Dictation("text"),
        IntegerRef("n", 1, 50),
    ]
    defaults = {
        "n": 1,
    }
Example #3
0
def git(git_command, name=""):
    t = "git "
    if git_command is "clone":
        t += "clone [email protected]:"
    elif git_command is "add":
        t += "add ."
    elif git_command is "delete":
        t += "push origin --delete {} && git branch -d {}".format(name, name)
    elif git_command is "all":
        t += 'add . && git commit -m "" && git push'
    elif git_command is "commit":
        t += 'commit -m ""'
        Key("left").execute()
    elif git_command is "pull":
        t += "pull "
    elif git_command is "push":
        t += "push "
    elif git_command is "checkout":
        t += "checkout "
    elif git_command is "init":
        t += "init "
    elif git_command is "status":
        t += "status "
    else:
        t += git_command + " "
    Text(t).execute()

    if git_command is "all":
        Key("c-left:3,right:3").execute()
Example #4
0
class Shortcuts(MergeRule):
    mapping = {
        "<single_shortcut>": Function(single_press),
        "<repeat_shortcut> [<n500>]": Function(repeat_press),
        "work <n12>": Function(workspace_switcher),
        "switch [<n100>]": Key('alt:down,tab:%(n100)s,alt:up'),
        "swap [<n100>]": Key('alt:down,backtick:%(n100)s,alt:up'),
        "swipe [<n100>]": Key('alt:down,ctrl:down,tab:%(n100)s,ctrl:down,alt:up'),
        "window move <n12>": Function(workspace_mover),
        "window <window_direction>": Function(resize_window),
        "launcher": Key("win:down,ctrl:down,l,ctrl:up,win:up"),
        # "swap <n100>": Key('alt:down/25,tab/25:%(n100)s,alt:up')
    }

    extras = [
        IntegerRef("n100", 1, 100),
        IntegerRef("n500", 1, 500),
        IntegerRef("n12", 1, 13),
        Choice("single_shortcut", single_shortcut),
        Choice("repeat_shortcut", repeat_shortcut),
        Choice("window_direction", {
            "left": "left",
            "right": "right",
            "maximize": "maximize",
            "minimize": "minimize",
            })
    ]

    defaults = {
        "n100": 1,
        "n500": 1,
    }
Example #5
0
class Bash(MergeRule):

    mapping = {
        "pseudo-": Text("sudo "),
        "change": Text("cd "),
        "list": Key("l,s,enter"),
        "sublime": Text("subl "),
        "home": Text("~/"),
        "pie": Text("py"),
        "copy": Key("cs-c"),
        "copy <t>": Function(copy),
        "paste": Key("cs-v"),
        "paste <t>": Function(paste),
        "make directory": Text("mkdir "),
        ".Thought": Text(".."),
        "parent": Text("../"),
        "remote <ssh_server>": Text('ssh %(ssh_server)s'),
        "dropbox": Text("cd ~/Dropbox/"),
        "reset": Key("c-c,c-c,up,enter")
    }

    extras = [
        Choice('ssh_server', {}),
        Dictation("t"),
    ]

    defaults = {
        "t": 'default',
    }
Example #6
0
class InsertModeEntry(MappingRule):
    mapping = {
        'inns': Key('i'),
        'syn': Key('a'),
        'phyllo': Key('o'),
        'phylum': Key('O'),
    }
Example #7
0
 def workspace_direction(direction1, direction2=None):
     try:
         Key("ctrl:down, alt:down, %s/5" % direction1).execute()
         if direction2:
             Key("%s/5" % direction2).execute()
     finally:  # Make sure to release the modifier keys.
         Key("alt:up, ctrl:up").execute()
def template_preamble():
    Key("langle, percent").execute()
    Key("enter").execute()
    Text("  @path = \"\"", static=True).execute()
    Key("enter").execute()
    Key("backspace, backspace, percent, rangle").execute()
    Key("enter, enter").execute()
Example #9
0
class Keyboard(MergeRule):

    mapping = {
        "<single_key>": Function(single_press),
        "[<modify_letter>] <alphabet_key>": Function(alphabet_press),
        "<repeat_key> [<n500>]": Function(repeat_press),
        '<modifier_key> <any_key> [<n100>]': Function(any_press),
        "develop testing": Key('colon'),
        "super [<any_key>]": Function(super_press),
        "hold <modifier_full_name>": Key("%(modifier_full_name)s:down"),
        "release": Key("ctrl:up,alt:up,shift:up,win:up")
    }

    extras = [
        IntegerRef("n100", 1, 100),
        IntegerRef("n500", 1, 500),
        Choice("single_key", single_key),
        Choice("repeat_key", repeat_key),
        Choice("any_key", any_key),
        Choice("modifier_key", modifier_key),
        Choice("alphabet_key", alphabet_key),
        Choice("modify_letter", {"cap": "cap"}),
        Choice("modifier_full_name", modifier_full_name)
    ]

    defaults = {
        "n100": 1,
        "n500": 1,
    }
Example #10
0
def _call_implicit(text=""):
    snake_case_text(text) 
    Key("lparen, rparen").execute()
    _esc()
    if (text == ""):
        Key('h, i').execute()
    else:
        Key('i').execute()
Example #11
0
 def _execute(self, data=None):
     output = control.nexus().temp
     Text(output).execute()
     if output:
         Key(self.action_if_text).execute()
     else:
         Key(self.action_if_no_text).execute()
     return True
def cancelMouseGrid():
    #print "Calling showMouseGrid(cancel) on the server to hide the MouseGrid"
    # Run our aenea plugin script that shows the mouse grid fullscreen in Linux.
    #aenea.communications.server.showMouseGrid("cancel")

    print "Sending Escape to cancel the mouse grid"
    action = Key("escape")
    action.execute()
Example #13
0
def resize_window(window_direction):
    if window_direction is "left":
        Key("cw-left").execute()
    elif window_direction is "right":
        Key("cw-right").execute()
    elif window_direction is "maximize":
        Key("cw-up").execute()
    elif window_direction is "minimize":
        Key("cw-down").execute()
Example #14
0
class PrimitiveCommand(MappingRule):
    mapping = {
        'vim scratch': Key('X'),
        'vim chuck': Key('x'),
        'vim undo': Key('u'),
        'plap': Key('P'),
        'plop': Key('p'),
        'ditto': Text('.'),
        'ripple': 'macro',
        }
Example #15
0
 def _process_recognition(self, node, extras):
     ExModeGrammar.disable()
     exModeBootstrap.enable()
     #normalModeGrammar.enable()
     if extras["command"] == "cancel":
         #print "ex mode command canceled"
         Key("escape").execute()
     else:
         #print "ex mode command accepted"
         Key("enter").execute()
Example #16
0
def _method(text=""):
    Key('d, e, f, space').execute()
    snake_case_text(text)
    Key('lparen, rparen, enter').execute()
    Key('e, n, d').execute()
    _esc()
    if (text == ""):
	Key('k, s-4, h, a').execute()
    else: 
	Key('k, f, lparen, a').execute()
Example #17
0
def execute_insertion_buffer(insertion_buffer):
    if not insertion_buffer:
        return

    if insertion_buffer[0][0] is not None:
        insertion_buffer[0][0].execute()
    else:
        Key('a').execute()

    for insertion in insertion_buffer:
        insertion[1].execute()

    Key('escape:2').execute()
Example #18
0
def _func(text=""):
    Text('function ').execute()
    camel_case_text(text) 
    Text('() {').execute()
    Key('enter').execute()
    Key('rbrace').execute()

    _esc()

    if (text == ""):
	Key('k, s-4, h, h, h, i').execute()
    else: 
	Key('k, o').execute()
Example #19
0
def paste(t,n):
    if n != 0:
        t=n
    if t=="default":
        Key("cs-v").execute()
    else:
        global CLIPBOARD
        key = str(t)
        if key in CLIPBOARD.dictionary:
            previous = aenea.communications.server.paste(CLIPBOARD.dictionary[key])
            Key("cs-v").execute()
            # restore previous clipboard value
            aenea.communications.server.paste(previous)
        else:
            print("No key '%s' in clipboard dictionary" % key)
Example #20
0
def any_press(any_key, n100=1, modifier_key=None):
    if modifier_key is None:
        k = any_key
    else:
        k = modifier_key + "-" + any_key
    for x in range(n100):
        Key(k).execute()
Example #21
0
 def value(self, node):
     cmd = Key('w-m')
     if node.has_child_with_name('ssh'):
         cmd += node.get_child_by_name('ssh').value()
     elif node.has_child_with_name('command'):
         cmd += node.get_child_by_name('command').value()
     return cmd
Example #22
0
def tags(element):
    elementString = str(element)
    if element in voidElements:
        Text("<%s />" % str(element)).execute()
    else:
        Text("<%s></%s>" % (elementString, elementString)).execute()
        Key("left:%s" % (len(elementString) + 3)).execute()
Example #23
0
def expand_count(n):
    """Formats n words to the left of the cursor by adding whitespace in
    certain positions.
    Note that word count differs between editors and programming languages.
    The examples are all from Eclipse/Python.

    Example, with to compact code:
    "result=(width1+width2)/2 'expand 9' " => "result = (width1 + width2) / 2"

    """
    saveText = _get_clipboard_text()
    cutText = _select_and_cut_text(n)
    if cutText:
        endSpace = cutText.endswith(' ')
        cutText = _expand_after_special_chars(cutText)
        reg = re.compile(
            r'([a-zA-Z0-9_\"\'\)][=\+\-\*/\%]|[=\+\-\*/\%][a-zA-Z0-9_\"\'\(])')
        hit = reg.search(cutText)
        count = 0
        while hit and count < 10:
            cutText = cutText[:hit.start() + 1] + ' ' + \
                cutText[hit.end() - 1:]
            hit = reg.search(cutText)
            count += 1
        newText = cutText
        if endSpace:
            newText = newText + ' '
        newText = newText.replace("%", "%%")  # Escape any format chars.
        Text(newText).execute()
    else:  # Failed to get text from clipboard.
        Key('c-v').execute()  # Restore cut out text.
    _set_clipboard_text(saveText)
Example #24
0
def squash_count(n):
    """Formats n words to the left of the cursor with whitespace removed.
    Excepting spaces immediately after comma, colon and percent chars.

    Note: Word count differs between editors and programming languages.
    The examples are all from Eclipse/Python.

    Example:
    "'my new variable' *pause* 'squash 3'" => "mynewvariable".
    "'my<tab>new variable' *pause* 'squash 3'" => "mynewvariable".
    "( foo = bar, fee = fye )", 'squash 9'" => "(foo=bar, fee=fye)"

    """
    saveText = _get_clipboard_text()
    cutText = _select_and_cut_text(n)
    if cutText:
        endSpace = cutText.endswith(' ')
        text = _cleanup_text(cutText)
        newText = ''.join(text.split(' '))
        if endSpace:
            newText = newText + ' '
        newText = _expand_after_special_chars(newText)
        newText = newText.replace("%", "%%")  # Escape any format chars.
        Text(newText).execute()
    else:  # Failed to get text from clipboard.
        Key('c-v').execute()  # Restore cut out text.
    _set_clipboard_text(saveText)
Example #25
0
def paste_command():
    # Add Command Prompt, putty, ...?
    context = AppContext(executable="console")
    window = Window.get_foreground()
    if context.matches(window.executable, window.title, window.handle):
        return
    release.execute()
    Key("c-v/3").execute()
Example #26
0
class Command(MappingRule):
    mapping = {'switch win [<n>]': Key(LEADER + ', ' + '%(n)s')}
    extras = [
        Integer("n", 0, 10),
    ]
    defaults = {
        "n": 1,
    }
Example #27
0
def reload_natlink():
    """Reloads Natlink and custom Python modules."""
    win = Window.get_foreground()
    FocusWindow(executable="natspeak",
                title="Messages from Python Macros").execute()
    Pause("10").execute()
    Key("a-f, r").execute()
    Pause("10").execute()
    win.set_foreground()
Example #28
0
def _select_and_cut_text(wordCount):
    """Selects wordCount number of words to the left of the cursor and cuts
    them out of the text. Returns the text from the system clip board.

    """
    clipboard = Clipboard()
    clipboard.set_system_text('')
    Key('cs-left/3:%s/10, c-x/10' % wordCount).execute()
    return clipboard.get_system_text()
Example #29
0
class PrimitiveMotion(MappingRule):
    mapping = {
        'up': Text('k'),
        'down': Text('j'),
        'left': Text('h'),
        'right': Text('l'),
        'lope': Text('b'),
        'yope': Text('w'),
        'elope': Text('ge'),
        'iyope': Text('e'),
        'lopert': Text('B'),
        'yopert': Text('W'),
        'elopert': Text('gE'),
        'eyopert': Text('E'),
        'apla': Text('{'),
        'anla': Text('}'),
        'sapla': Text('('),
        'sanla': Text(')'),
        'care': Text('^'),
        'hard care': Text('0'),
        'doll': Text('$'),
        'screecare': Text('g^'),
        'screedoll': Text('g$'),
        'scree up': Text('gk'),
        'scree down': Text('gj'),
        'go': Text('G'),
        'page high': Text('H'),
        'page low': Text('L'),

        # CamelCaseMotion plugin
        'calalope': Text(',b'),
        'calayope': Text(',w'),
        'end calayope': Text(',e'),
        'inner calalope': Text('i,b'),
        'inner calayope': Text('i,w'),
        'inner end calayope': Text('i,e'),

        # EasyMotion
        'easy lope': Key('%s:2, b' % LEADER),
        'easy yope': Key('%s:2, w' % LEADER),
        'easy elope': Key('%s:2, g, e' % LEADER),
        'easy iyope': Key('%s:2, e' % LEADER),
        'easy lopert': Key('%s:2, B' % LEADER),
        'easy yopert': Key('%s:2, W' % LEADER),
        'easy elopert': Key('%s:2, g, E' % LEADER),
        'easy eyopert': Key('%s:2, E' % LEADER),
    }

    for (spoken_object, command_object) in (('(lope | yope)', 'w'),
                                            ('(lopert | yopert)', 'W')):
        for (spoken_modifier, command_modifier) in (('inner', 'i'), ('outer',
                                                                     'a')):
            map_action = Text(command_modifier + command_object)
            mapping['%s %s' % (spoken_modifier, spoken_object)] = map_action
Example #30
0
class PrimitiveCommand(MappingRule):
    mapping = {
        'flax': Key('X'),
        'nix': Key('x'),
        'undo': Key('u'),
        'pesto': Key('P'),
        'post': Key('p'),
        'ditto': Text('.'),
        'ripple': 'macro',
        "visual": Key("v"),
        "visual line": Key("s-v"),
        "visual block": Key("c-v"),
        'dell': Key('d'),
        'yank': Key('y'),
        "dello": Text("daw"),
        "cello": Text("caw")
        #"indent left": Key("<"),
        #"indent right": Key(">")
    }