示例#1
0
def jump(m, k=None):
    jump_number = text_to_number(m._words[1:])
    if jump_number == 0:
        jump_number = 1
    press("cmd-esc")

    Str(str(jump_number))(None)
    Str(k)(None)
 def blade_for_each_function(m):
     Str('@foreach ($ as $)')(None)
     press('return')
     press('return')
     Str('@endforeach')(None)
     press('shift-tab')
     press('up')
     press('up')
     press('left')
 def blade_section_function(m):
     Str('@section(\'\')')(None)
     press('return')
     press('return')
     Str('@endsection')(None)
     press('shift-tab')
     press('up')
     press('up')
     press('left')
 def blade_if_function(m):
     Str('@if ()')(None)
     press('return')
     press('return')
     Str('@endif')(None)
     press('shift-tab')
     press('up')
     press('up')
     press('left')
 def blade_for_function(m):
     Str('@for ($i = 0; $i < ; $i++)')(None)
     press('return')
     press('return')
     Str('@endfor')(None)
     press('shift-tab')
     press('up')
     press('up')
     for x in range(12):
         press('right')
示例#6
0
def change_dir(m):
    print("{}".format(" ".join([str(w) for w in m._words])))
    name = None
    if len(m._words) > 1:
        name = str(m._words[1])
    if name in subdirs:
        Str("cd {}; ls\n".format(subdirs[name]))(None)
        update_ctx(newdir=subdirs[name])
    else:
        Str("cd ")(None)
示例#7
0
def dash(m):
    words = parse_words(m)
    press(' ')
    if len(words) == 1 and len(words[0]) == 1:
        press('-')
        Str(words[0])(None)
    else:
        press('-')
        press('-')
        Str('-'.join(words))(None)
示例#8
0
def dash(m):
    words = parse_words(m)
    press(" ")
    if len(words) == 1 and len(words[0]) == 1:
        press("-")
        Str(words[0])(None)
    else:
        press("-")
        press("-")
        Str("-".join(words))(None)
示例#9
0
def dash(m):
    words = parse_words(m)
    press(" ")
    if len(words) == 1 and len(words[0]) == 1:
        press("-")
        Str(words[0])(None)
    else:
        if words == ["michelle"]:
            words = ["shell"]
        press("-")
        press("-")
        Str("-".join(words))(None)
 def blade_if_else_function(m):
     Str('@if ()')(None)
     press('return')
     press('return')
     press('shift-tab')
     blade_else()(None)
     press('return')
     Str('@endif')(None)
     press('shift-tab')
     for x in range(4):
         press('up')
     press('left')
示例#11
0
def repeat_k(n, k):
    for i in range(0, n):
        for key in k:
            if key == 'down' or key == 'up' or key == 'enter' or key == "ctrl-alt-j" or key == "ctrl-alt-k" or key == "ctrl-p" or key == "ctrl-n":
                press(key)
            else:
                Str(str(key))(None)  # Key(key)
示例#12
0
def jump_to_line(m):
    line_number = parse_words_as_integer(m._words[1:])

    if line_number == None:
        return

    # Zeroth line should go to first line
    if line_number == 0:
        line_number = 1

    # TODO: Directly interface with VSCode to accomplish the following

    # Open the jump to line input
    press('ctrl-g')

    # TODO: If requesting line that is beyond the end of the focused document, jump to last line instead

    # Enter whole line number data as if from keyboard
    Str(str(line_number))(None)

    # Confirm the navigation
    press('enter')

    # Position cursor at the beginning of meaningful text on the current line (Mac OS X)
    press('cmd-right')
    press('cmd-left')
示例#13
0
def go_to_line(m):
    line = utils.extract_num_from_m(m, default=None)
    print(line)

    press("cmd-l")
    Str(str(line))(None)
    press("enter")
示例#14
0
def FormatText(m):
    fmt = []
    for w in m._words:
        if isinstance(w, Word):
            fmt.append(w.word)
    words = [str(s).lower() for s in m.dgndictation[0]._words]

    space_at_end = False

    tmp = []
    spaces = True
    for i, word in enumerate(words):
        word = parse_word(word)
        for name in reversed(fmt):
            if name == 'vak':
                space_at_end = True
            smash, func = formatters[name]
            word = func(i, word, i == len(words)-1)
            spaces = spaces and not smash
        tmp.append(word)
    words = tmp

    sep = ' '
    if not spaces:
        sep = ''
    string = sep.join(words)
    string += ' ' if space_at_end else ''
    Str(string)(None)
示例#15
0
def PostFormatText(m):
    prev_clip = clip.get()
    press("ctrl-c")
    fmt = []
    for w in m._words[1:]:
        if w in formatters:
            fmt.append(w)
        else:
            break
    words = clip.get().split()
    tmp = []
    spaces = True
    for i, w in enumerate(words):
        for name in reversed(fmt):
            smash, func = formatters[name]
            w = func(i, w, i == len(words) - 1)
            spaces = spaces and not smash
        tmp.append(w)
    words = tmp

    sep = " "
    if not spaces:
        sep = ""
    clip.set(prev_clip)
    Str(sep.join(words))(None)
示例#16
0
def FormatText(m):
    fmt = []
    for w in m._words:
        if isinstance(w, Word) and w != "over":
            fmt.append(w.word)
    words = parse_words(m)
    if not words:
        with clip.capture() as s:
            press("cmd-c")
        words = s.get().split(" ")
        if not words:
            return

    tmp = []
    spaces = True
    for i, word in enumerate(words):
        word = parse_word(word).lower()
        for name in reversed(fmt):
            smash, func = formatters[name]
            word = func(i, word, i == len(words) - 1)
            spaces = spaces and not smash
        tmp.append(word)
    words = tmp

    sep = " "
    if not spaces:
        sep = ""
    Str(sep.join(words))(None)
示例#17
0
def text(m):
    try:
        tmp = [str(s).lower() for s in m.dgndictation[0]._words]
        words = [parse_word(word) for word in tmp]
        Str(' '.join(words))(None)
    except AttributeError:
        return
 def foundation_breakpoint_function(m):
     Str('@include breakpoint() {')(None)
     press('enter')
     press('cmd-right')
     press('up')
     for x in range(3):
         press('left')
示例#19
0
 def channelSwitcher(m):
     delay = 0.3
     press('cmd-k')
     sleep(delay)
     Str(name)(None)
     sleep(delay)
     press('enter')
示例#20
0
def jump_to_bol(m):
    line = text_to_number(m)
    press('ctrl-g')
    time.sleep(0.35)  # DON'T MESS WITH THE LAG
    Str(str(line))(None)
    time.sleep(0.25)
    press('enter')
示例#21
0
def format_text(m):
    fmt = []
    # noinspection PyProtectedMember
    for w in m._words:
        if isinstance(w, Word):
            # noinspection PyUnresolvedReferences
            fmt.append(w.word)
    # noinspection PyProtectedMember
    words = [str(s).lower() for s in m.dgndictation[0]._words]

    tmp = []
    spaces = True
    for i, word in enumerate(words):
        word = parse_word(word)
        for name in reversed(fmt):
            smash, func = formatters[name]
            word = func(i, word, i == len(words) - 1)
            spaces = spaces and not smash
        tmp.append(word)
    words = tmp

    sep = " "
    if not spaces:
        sep = ""
    Str(sep.join(words))(None)
示例#22
0
def keeper(j):
    if j["cmd"] == "p.end" and j["grammar"] == "talon":
        phrase = j["phrase"]
        if phrase and phrase[0] == "keeper":
            # Str(' '.join(map(parse_word, phrase[1:])))(None)
            Str(" ".join(phrase[1:]))(None)
            j["cmd"] = "p.skip"
示例#23
0
def keeper(j):
    if j['cmd'] == 'p.end' and j['grammar'] == 'talon':
        phrase = j['phrase']
        if phrase and phrase[0] == 'keeper':
            # Str(' '.join(map(parse_word, phrase[1:])))(None)
            Str(' '.join(phrase[1:]))(None)
            return False
示例#24
0
def FormatText(m):
    fmt = []

    for w in m._words:
        if isinstance(w, Word) and w != "over":
            fmt.append(w.word)
    words = parse_words(m)
    if not words:
        try:
            with clip.capture() as s:
                press("cmd-c")
            words = s.get().split(" ")
        except clip.NoChange:
            words = [""]

    tmp = []

    smash = False
    for i, w in enumerate(words):
        word = parse_word(w).lower()
        for name in reversed(fmt):
            smash, func = formatters[name]
            word = func(i, word, i == len(words) - 1)
        tmp.append(word)

    sep = "" if smash else " "
    Str(sep.join(tmp))(None)
    # if no words, move cursor inside surrounders
    if not words[0]:
        for i in range(len(tmp[0]) // 2):
            press("left")
示例#25
0
def FormatText(m):
    fmt = []
    for w in m._words:
        if isinstance(w, Word):
            fmt.append(w.word)
    try:
        words = parse_words(m)
    except AttributeError:
        with clip.capture() as s:
            press('cmd-c')
        words = s.get().split(' ')
        if not words:
            return

    tmp = []
    spaces = True
    for i, word in enumerate(words):
        word = parse_word(word)
        for name in reversed(fmt):
            smash, func = formatters[name]
            word = func(i, word, i == len(words)-1)
            spaces = spaces and not smash
        tmp.append(word)
    words = tmp

    sep = ' '
    if not spaces:
        sep = ''
    Str(sep.join(words))(None)
示例#26
0
def markdown_complete(m):
    jump_to_bol(m)
    press("right")
    press("right")
    press("right")
    press("delete")
    Str("X")(None)
示例#27
0
def FormatText(m):
    fmt = []
    if m._words[-1] == "over":
        m._words = m._words[:-1]
    for w in m._words:
        if isinstance(w, Word):
            fmt.append(w.word)
    try:
        words = parse_words(m)
    except AttributeError:
        with clip.capture() as s:
            press("cmd-c")
        words = s.get().split(" ")
        if not words:
            return

    tmp = []
    spaces = True
    for i, w in enumerate(words):
        w = parse_word(w)
        for name in reversed(fmt):
            smash, func = formatters[name]
            w = func(i, w, i == len(words) - 1)
            spaces = spaces and not smash
        tmp.append(w)
    words = tmp

    sep = " "
    if not spaces:
        sep = ""
    Str(sep.join(words))(None)
示例#28
0
def key(m):
    modifiers = basic_keys.get_modifiers(m)
    key = basic_keys.get_keys(m)[0]
    if key is None:
        print("no key", m)
        return
    Str("Key('{}')".format("-".join(modifiers + [key])))(None)
示例#29
0
def new_entry(m):
    press('cmd-down') # Go to end of first line of the file
    press('return')
    press('return')
    press('return')

    # Return to just after the date entry
    press('up')

    Str('# ')(None)
    Str(datetime.date.today().isoformat())(None) # Add the current date

    # Create spacing from any previous entries
    press('return')
    # Enter start of new list item
    Str('* ')(None)
示例#30
0
def show_panel(name):
    open_focus_devtools(None)

    # Open command menu
    press("cmd-shift-p")

    Str("Show %s" % (name))(None)
    press("enter")