Beispiel #1
0
def CursorText(s):
    left, right = s.split("{.}", 1)
    return [left + right, Key(" ".join(["left"] * len(right)))]
Beispiel #2
0

def set_dir(d):
    def wrapper(m):
        global direction
        direction = d

    return wrapper


ctx.keymap({
    # moving

    # left, right, up and down already defined
    'go word left':
    Key('alt-left'),
    'go word right':
    Key('alt-right'),
    'go left':
    Key('left'),
    'go right':
    Key('right'),
    'go up':
    Key('up'),
    'go down':
    Key('down'),
    'go line start':
    Key('cmd-left'),
    'go line end':
    Key('cmd-right'),
    'go way left':
Beispiel #3
0
# Talon voice commands for interacting with macOS Mail
# John S. Cooper  [email protected]

from talon.voice import Key, Context

ctx = Context('mail', bundle='com.apple.mail')

ctx.keymap({
    'new mail': Key('cmd-n'),
    'send mail': Key('cmd-shift-d'),
    'reply mail': Key('cmd-r'),
    'reply all': Key('cmd-shift-r'),
    'forward mail': Key('cmd-shift-f'),
    'mark (read | unread)': Key('cmd-shift-u'),

    # show favorites bar, and drag personal and work inboxes to it in first and second slots
    'show personal': Key('cmd-1'),
    'show work': Key('cmd-2'),
})
Beispiel #4
0
from talon.voice import Context, Key

context = Context("spectacle")

# Requires: https://www.spectacleapp.com/

keymap = {
    "spec center": Key("alt-cmd-c"),
    "spec full": Key("alt-cmd-f"),
    "spec left": Key("alt-cmd-left"),
    "spec right": Key("alt-cmd-right"),
    "spec top": Key("alt-cmd-up"),
    "spec bottom": Key("alt-cmd-down"),
    # "spec up left": Key("ctrl-cmd-left"),
    # "spec low left": Key("ctrl-shift-cmd-left"),
    # "spec up right": Key("ctrl-cmd-right"),
    # "spec low right": Key("ctrl-shift-cmd-right"),
    "spec next": Key("ctrl-alt-cmd-right"),
    "spec previous": Key("ctrl-alt-cmd-left"),
    # "spec next slice": Key("ctrl-alt-right"),
    # "spec (previous | last) slice": Key("ctrl-alt-left"),
    # "spec grow": Key("ctrl-alt-shift-right"),
    # "spec shrink": Key("ctrl-alt-shift-left"),
    "spec undo": Key("alt-cmd-z"),
    "spec redo": Key("alt-shift-cmd-z"),
    "diffie up": Key("alt-cmd-ctrl-up"),
    "diffie down": Key("alt-cmd-ctrl-down"),
    "diffie left": Key("alt-cmd-ctrl-shift-left"),
    "diffie right": Key("alt-cmd-ctrl-shift-right"),
    "diffie (full | fullscreen)": Key("alt-cmd-ctrl-shift-up"),
    "diffie present":
Beispiel #5
0
def context(app, win):
    if app.bundle == "com.apple.finder":
        return True
    # allow these commands to work while using open dialogue in atom. There is
    # probably a better way to do this more generally
    elif app.bundle == "com.github.atom" and win.title == "Open Folder":
        return True
    else:
        return False


ctx = Context("Finder", func=context)

ctx.keymap({
    # actions
    "select all": Key("cmd-a"),
    "copy": Key("cmd-c"),
    "duplicate": Key("cmd-d"),
    "eject": Key("cmd-e"),
    "(search | find)": Key("cmd-f"),
    "hide [finder]": Key("cmd-h"),
    "hide (others | else)": Key("cmd-alt-h"),
    "(hide | no) toolbar": Key("cmd-alt-t"),
    "info": Key("cmd-i"),
    "view [options]": Key("cmd-j"),
    "connect [to server]": Key("cmd-k"),
    "[(make | create)] (alias | shortcut)": Key("cmd-l"),
    "minimize": Key("cmd-m"),
    "new window": Key("cmd-n"),
    "new folder": Key("cmd-shift-n"),
    # NOT WORKING "new smart folder": Key("cmd-alt-n"),
Beispiel #6
0
from talon.voice import Context, Key

context = Context(
    "lastpass",
    func=lambda app, win: app.bundle in
    ["com.google.Chrome", "org.mozilla.firefox"],
)

context.keymap({
    "last pass next": Key("cmd-pageup"),
    "last pass (previous | preev)": Key("cmd-pagedown"),
    "last pass generate password": Key("cmd-shift-ctrl-alt-1"),
    "last pass recheck page": Key("cmd-shift-ctrl-alt-2"),
    "last pass site search": Key("cmd-shift-ctrl-alt-3"),
    "last pass submit": Key("cmd-shift-ctrl-alt-4"),
    "last pass open vault": Key("cmd-shift-ctrl-alt-5"),
    "last pass save data": Key("cmd-shift-ctrl-alt-6"),
    "last pass logout": Key("cmd-shift-ctrl-alt-7"),
    "last pass fill in default": Key("cmd-shift-ctrl-alt-8"),
})
Beispiel #7
0
from talon.voice import Key, Context

ctx = Context('iterm', bundle='com.googlecode.iterm2')

keymap = {
    'broadcaster': Key('cmd-alt-i'),
    'split horizontal': Key('cmd-shift-d'),
    'split vertical': Key('cmd-d'),
    'password': Key('cmd-alt-f'),
}

ctx.keymap(keymap)
from talon.voice import Context, Key

ctx = Context("jupyter")

ctx.keymap({"cell run": Key("shift-enter")})
# command pallet
# restart and run all
# other?
Beispiel #9
0

def parse_word(word):
    word = word.lstrip('\\').split('\\', 1)[0]
    return word


def search_for(m):
    press('cmd-l')
    tmp = [str(s).lower() for s in m.dgndictation[0]._words]
    words = [parse_word(word) for word in tmp]
    Str(' '.join(words))(None)


keymap = {
    'search for [<dgndictation>]': search_for,
    'make new playlist': Key('cmd-n'),
    'make new playlist folder': Key('cmd-shift-n'),
    'seek forward': Key('cmd-shift-right'),
    'seek backward': Key('cmd-shift-left'),
    '(more volume | volume up | increase volume)': Key('cmd-up'),
    '(less volume | volume down | decrease volume)': Key('cmd-down'),
    '[toggle] shuffle': Key('cmd-s'),
    '[toggle] repeat': Key('cmd-r'),
    'filter': Key('cmd-f'),
    'mute volume': Key('cmd-shift-down'),
    'max volume': Key('cmd-shift-up'),
}

ctx.keymap(keymap)
Beispiel #10
0
# from talon.voice import Context, Key # moved to top

ctx1 = Context("hiss_to_scroll")
ctx1.keymap({
    '(toggle hiss | hissy)': [toggle_enabled(), set_speed(1)],
    '(toggle hiss | hissy) on': [toggle_enabled("on"),
                                 set_speed(1)],
    '(toggle hiss | hissy) off': [toggle_enabled("off"),
                                  set_speed(1)],
    '(toggle hiss | hissy) slower':
    [toggle_enabled(), set_speed(1 / config.multiplier)],
    '(toggle hiss | hissy) faster':
    [toggle_enabled(), set_speed(config.multiplier)],
    'viper': [toggle_enabled(), set_speed(1),
              Key("cmd-tab")],
    'viper on': [toggle_enabled("on"),
                 set_speed(1),
                 Key("cmd-tab")],
    'viper off': [toggle_enabled("off"),
                  set_speed(1),
                  Key("cmd-tab")],
})

ctx2 = Context("hiss_to_scroll_settings",
               func=lambda app, window: config.enabled)
ctx2.keymap({
    'reverse': reverse,
    'slower': adjust_speed(1 / config.multiplier),
    'faster': adjust_speed(config.multiplier),
    'default': set_speed(1),
Beispiel #11
0
from talon.voice import Key, Context

ctx = Context("telegram", bundle="com.tdesktop.Telegram")

keymap = {
    "channel down": Key("alt-down"),
    "channel up": Key("alt-up"),
    "send": Key("enter"),
}

ctx.keymap(keymap)
Beispiel #12
0
    "pragma",
    "pragmas",
    "vim",
    "configs",
    "spotify",
    "upsert",
    "utils",
]

keymap = {}
keymap.update({
    "dragon words":
    "<dgnwords>",
    "dragon dictation":
    "<dgndictation>",
    "slap": [Key("cmd-right enter")],
    "cd":
    "cd ",
    "cd talon home":
    "cd {}\n".format(TALON_HOME),
    "cd talon user":
    "******".format(TALON_USER),
    "cd talon [user] emily":
    "cd {}/emily\n".format(TALON_USER),
    "cd talon plugins":
    "cd {}\n".format(TALON_PLUGINS),
    "talon logs":
    "cd {} && tail -f talon.log\n".format(TALON_HOME),
    "grep":
    "grep ",
    "elle less":
Beispiel #13
0
 "run get": "git ",
 "get (R M | remove)": "git rm ",
 "[run] get add": "git add ",
 "git add dot": "git add .",
 "get bisect": "git bisect ",
 "get branch": "git branch ",
 "get branch all": "git branch -a ",
 "run get branch": "git branch\n",
 "get checkout": "git checkout ",
 "get checkout master": "git checkout master",
 "run get checkout master": "git checkout master\n",
 "[run] get checkout new": "git checkout -b ",
 "[run] get clone": "git clone ",
 "get commit": "git commit ",
 "run get commit": "git commit\n",
 "git commit message": ['git commit -m ""', Key("left")],
 "get diff": "git diff ",
 "run get diff": "git diff\n",
 "run get diff master": "git diff master\n",
 "get fetch": "git fetch",
 "run get fetch": "git fetch\n",
 "get grep": "git grep ",
 "get in it": "git init",
 "run get in it": "git init\n",
 "get log": "git log ",
 "run get log": "git log\n",
 "get brief log": "git log --oneline --max-count=5 ",
 "get next release": "git log --oneline --no-decorate --grep 'Merge pull' ",
 "get (author | co-author)": "git log --format='%an <%ae>' -n1 --author=",
 "[run] get merge": "git merge ",
 "get move": "git mv ",
Beispiel #14
0
}

context = Context('GoogleChrome', bundle='com.google.Chrome')

context.set_list('websites', websites.keys())


def open_website(m):
    name = str(m._words[1])
    w = websites.get(name)
    code = r'''
    tell application "Google Chrome"
	if title of active tab of window 1 is "New Tab" then
            set t to active tab of window 1
	else
            set t to make new tab at end of tabs of window 1
	end if
	set URL of t to "%s"
    end tell
    ''' % w
    applescript.run(code)


keymaps = {
    'back': Key('cmd-['),
    'forward': Key('cmd-]'),
    'website {GoogleChrome.websites}': open_website,
}

context.keymap(keymaps)
Beispiel #15
0
from ..misc import basic_keys
from ..utils import parse_words, text
import string

ctx = Context("talon_editor")


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)


def format_text(fmt):
    def wrapper(m):
        Str(fmt.format(" ".join(parse_words(m))))(None)

    return wrapper


ctx.keymap({
    "key {basic_keys.modifiers}* {basic_keys.keymap}": key,
    "map <dgndictation>": ("'", text, "': ,", Key("left")),
    "map string <dgndictation>": format_text("'{0}': '{0}',"),
    "dragon dictation": "<dgndictation>",
    "stir": ["Str()(None)"] + [Key("left")] * 7,
})
from talon.voice import Context, Key
from ..utils import text

ctx = Context("search_replace")

keymap = {
    "marco [<dgndictation>] [over]": [Key("cmd-f"), text,
                                      Key("enter")],
    # "marneck": Key("cmd-g"),
    # "marpreev": Key("cmd-shift-g"),
    # "marthis": [Key("alt-right"), Key("shift-alt-left"), Key("cmd-f"), Key("enter")],
    # "(find selected text | find selection | sell find)": Key("cmd-e cmd-f enter"),
    # "set selection [text]": Key("cmd-e"),
    # "set replacement [text]": Key("cmd-shift-e"),
    # "([ (search | find) ] [and] replace (selected text | selection) | sell find ace)": Key(
    #     "cmd-e cmd-alt-f"
    # ),
    # "([ (search | find) ] [and] replace [text] | find ace)": Key("cmd-alt-f"),
}

ctx.keymap(keymap)
Beispiel #17
0
from talon import ui
from talon.voice import Key, Context

ctx = Context(
    "amethyst",
    func=lambda app, win: bool(ui.apps(bundle="com.amethyst.Amethyst")))

keymap = {
    # 'desk <dgndictation>': desk,
    "window next screen": Key("ctrl-alt-shift-l"),
    "window (previous|prev) screen": Key("ctrl-alt-shift-h"),
    "window next": Key("alt-shift-j"),
    "window previous": Key("alt-shift-k"),
    "window move desk": Key("ctrl-alt-shift-h"),
    "window full": Key("alt-shift-d"),
    "window tall": Key("alt-shift-a"),
    "window middle": Key("alt-shift-`"),
    "window move main": Key("alt-shift-enter"),
    "window grow": Key("alt-shift-l"),
    "window shrink": Key("alt-shift-h"),
}

single_digits = "0123456789"
keymap.update(
    {"desk %s" % digit: Key("ctrl-%s" % digit)
     for digit in single_digits})
keymap.update({
    "window move desk %s" % digit: Key("ctrl-alt-shift-%s" % digit)
    for digit in single_digits
})
Beispiel #18
0
    press('?')
    w = str(m.dgndictation[0]._words[0])
    w = w.lower()
    Str(w)(None)
    press('enter')


def change_tab(m):
    window = str(m._words[1])
    press(window)
    press('g')
    press('t')


ctx.keymap({
    'trough': Key('ctrl-w'),
    'win (%s)+' % (' | '.join(map(str, range(10)))): change_tab,
    'last file': [Key('escape'), Key('ctrl-^')],

    # insert mode
    # assumes you have AutoPair installed
    'insert code': ['```', Key('return')],

    # normal mode
    'vip': 'vip',
    'pain left': [Key('ctrl-w'), Key('h')],
    'pain right': [Key('ctrl-w'), Key('l')],
    'pain down': [Key('ctrl-w'), Key('j')],
    'pain up': [Key('ctrl-w'), Key('k')],
    'vertical split': [Key('escape'), ':vsplit\n'],
    'horizontal split': [Key('escape'), ':split\n'],
Beispiel #19
0
        return filename.endswith(ext)

    return language_match


ctx = Context("python", func=extension_context(".py"))
# ctx.vocab = [
#     '',
#     '',
# ]
# ctx.vocab_remove = ['']
ctx.keymap({
    "state (def | deaf | deft)": "def ",
    "state else if": "elif ",
    "state if": "if ",
    "state while": ["while ()", Key("left")],
    "state for": "for ",
    "state import": "import ",
    "state class": "class ",
    "state (past | pass)": "pass",
})

ctx = Context("golang", func=extension_context(".go"))
ctx.keymap({
    "state (funk | func | fun)": "func ",
    "state if": "if ",
    "state else if": " else if ",
    "state while": "for ",
    "state for": "for ",
    "state switch": "switch ",
    "state case": "case ",
Beispiel #20
0
    'right':  'l',
    'upple':  'y',
    'downle': 'b',
    'upper':  'u',
    'downer': 'n',

    'way up':     'K',
    'way down':   'J',
    'way left':   'H',
    'way right':  'L',
    'way upple':  'U',
    'way downle': 'B',
    'way upper':  'U',
    'way downer': 'N',

    '(escape | back)': Key('esc'),
    '(enter | shock | ok)': Key('enter'),
    'tarp': Key('tab'),
    '(question mark | question | questo)': '?',
    '(star | asterisk)': '*',
    '(dot | period)': '.',

    '(wander | explore | roam)': 'o',
    '(rest | sleep)': '5',
    'wait': '.',
    '(inventory | invent)': 'i',
    'auto': Key('tab'),
    'fight': Key(' '.join(['tab'] * 10)),
    'stand [and] fight': Key(' '.join(['shift-tab'] * 10)),
    'eat [food]': 'e',
    '(quaff | drink)': 'q',
Beispiel #21
0
 " <<= ",
 "[(op | logical | bitwise)] (right shift | shift right) equals":
 " >>= ",
 "[op] (arrow | lambo)":
 " -> ",
 "[op] fat (arrow | lambo)":
 " => ",
 # Completed matchables
 "(empty parens | call)":
 "()",
 "empty (dict | object)":
 "{}",
 "(empty array | brackers)":
 "[]",
 # Blocks
 "[brace] block": [" {}", Key("left enter enter up tab")],
 "(square | brax) | block": ["[", Key("enter")],
 "(paren | prex) block": ["(", Key("enter")],
 # Combos
 "coalshock": [":", Key("enter")],
 "comshock": [",", Key("enter")],
 "sinker": [Key("cmd-right ;")],
 "swipe":
 ", ",
 "coalgap":
 ": ",
 "[forward] slasher":
 "// ",
 # Statements
 "state (def | deaf | deft)":
 "def ",
Beispiel #22
0

def jump_tab(m):
    tab_number = utils.parse_words_as_integer(m._words[1:])
    if tab_number is not None and tab_number > 0 and tab_number < 9:
        press("cmd-%s" % tab_number)


def mendeley(m):
    navigate_to_url(f"https://www.mendeley.com/import/?url={get_url()}")


context.keymap(
    {
        "(address bar | focus address | focus url | url)": focus_address_bar,
        "copy url": Key("escape y y"),
        "go back": back,
        "go forward": forward,
        "reload": Key("cmd-r"),
        "hard reload": Key("cmd-shift-r"),
        "new tab": Key("cmd-t"),
        "close tab": Key("cmd-w"),
        "(reopen | unclose) tab": Key("cmd-shift-t"),
        "(next tab | goneck)": Key("cmd-shift-]"),
        "((last | previous | preev) tab | gopreev)": Key("cmd-shift-["),
        "tab (1 | 2 | 3 | 4 | 5 | 6 | 7 | 8)": jump_tab,
        "(end | rightmost) tab": Key("cmd-9"),
        "marco": Key("cmd-f"),
        "marneck": Key("cmd-g"),
        "(last | prevous)": Key("cmd-shift-g"),
        "toggle dev tools": Key("cmd-alt-i"),
Beispiel #23
0
    # compound
    # Move to code shortcuts?
    # "mintwice": "--",
    # "plustwice": "++",
    # "minquall": "-=",
    # "pluqual": "+=",
    # "starqual": "*=",
    "double prime": "''",
    "double tick": "``",
    "triple prime": "'''",
    "triple tick": "```",
    "[forward] dubslash": "//",
    "coal twice": "::",
    "(dot dot | dotdot)": "..",
    "(ellipsis | dot dot dot | dotdotdot)": "...",
    # unnecessary: use repetition commands?

    "coif": ['""', Key("left")],
    "posh": ["''", Key("left")],
    # "(surround tics | surround glitch)": (False, surround("`")),
    "prank": ["  ", Key("left")],
    # "surround dunder": (False, surround("__")),
    # "surround angler": (False, surround("<", ">")),
    "brisk": ["[]", Key("left")],
    "kirk": ["{}", Key("left")],
    # "surround precoif": (False, surround('("', '")')),
    "prex": ["()", Key("left")],
}

ctx.keymap(keymap)
Beispiel #24
0
ctx = Context("input")
ctx.vocab = vocab
ctx.keymap(
    {
        "over": delay(0.3),
        "literal <dgndictation>++": text,
        "say <dgndictation> [over]": text,
        # "sentence <dgndictation> [over]": sentence_text,  # Formatters.
        # "comma <dgndictation> [over]": [", ", text],
        # "period <dgndictation> [over]": [". ", text],
        # "more <dgndictation> [over]": [" ", text],
        "more <dgndictation> [over]": text_with_leading(" "),
        "word <dgnwords>": word,
        f"numeral {numerals}": type_number,
        "slap": [Key("cmd-right enter")],
        "cape": [Key("escape")],
        "pa": [Key("space")],
        "question [mark]": i("?"),
        "tilde": i("~"),
        "(bang | exclamation point)": i("!"),
        "dollar [sign]": i("$"),
        "downscore": i("_"),
        "colon": i(":"),
        "(paren | left paren)": i("("),
        "(rparen | are paren | right paren)": i(")"),
        "(brace | left brace)": i("{"),
        "(rbrace | are brace | right brace)": i("}"),
        # Square Brackets are in basic_keys.py!
        # "(square | left square)": "[",
        # "(rsquare | are square | right square)": "]",
Beispiel #25
0
from talon.voice import Context, Key

ides = ['com.jetbrains.PhpStorm', 'com.jetbrains.intellij']
ctx = Context('phpstorm', func=lambda app, win: any(
    i in app.bundle for i in ides))

keymap = {
    'comment declaration': ['/**', Key('space')],
    'comment block': ['/**', Key('enter')],
    # annotation command

    '(next tab | goneck)': Key('cmd-shift-['),
    '(last tab | gopreev)': Key('cmd-shift-]'),
    'last file': Key('ctrl-tab'),

    'jolt': Key('cmd-d'),
    'comply': Key('tab'),
    'import class': Key('alt-enter enter'),
    'quickfix': Key('alt-enter'),
    'go class': Key('cmd-o'),
    'go file': Key('cmd-shift-o'),
    '(go implement | go definition)': Key('cmd-b'),
    'preev method': Key('ctrl-up'),
    'neck method': Key('ctrl-down'),
    'refactor': Key('shift-f6'),
    'generate': Key('cmd-n'),
    'recent': Key('cmd-e'),
    'trundle': Key('cmd-/'),
    '(fix imports | remove unused imports)': Key('ctrl-alt-o'),
    'complete [statement]': Key('cmd-shift-enter'),
}
Beispiel #26
0
    (x, y) = ctrl.mouse_pos()
    ctrl.mouse(x - distance_to_navigate, y)


context.keymap({
    # Navigating text
    'line' + optional_numerals:
    jump_to_line,

    # Selecting text
    'select line' + optional_numerals + 'until' + optional_numerals:
    select_lines_function,

    # Finding text
    'find':
    Key('cmd-f'),
    'find all':
    Key('cmd-shift-f'),
    'find next <dgndictation>':
    jump_to_next_word_instance,

    # Clipboard
    'clone':
    Key('cmd-d'),
    'cut line':
    Key('end cmd-shift-left cmd-x backspace'),
    'copy line':
    Key('end cmd-shift-left cmd-c'),

    # Navigation
    'Go to line':
Beispiel #27
0
from talon.voice import Context, Key
from .utils import text

ctx = Context("slack", bundle="com.tinyspeck.slackmacgap")

keymap = {
    # Channel
    "channel":
    Key("cmd-k"),
    "channel <dgndictation>": [Key("cmd-k"), text],
    "([channel] unread last | gopreev)":
    Key("alt-shift-up"),
    "([channel] unread next | goneck)":
    Key("alt-shift-down"),
    "(slack | lack) [channel] info":
    Key("cmd-shift-i"),
    "channel up":
    Key("alt-up"),
    "channel down":
    Key("alt-down"),
    # Navigation
    "(move | next) focus":
    Key("ctrl-`"),
    "[next] (section | zone)":
    Key("f6"),
    "(previous | last) (section | zone)":
    Key("shift-f6"),
    "(slack | lack) [direct] messages":
    Key("cmd-shift-k"),
    "(slack | lack) threads":
    Key("cmd-shift-t"),
Beispiel #28
0
        press(k)


ctx = Context("basic_keys")
ctx.keymap({
    "sky {basic_keys.alphabet}+ [(lowercase | sunk)]":
    uppercase_letters,
    "{basic_keys.modifiers}* {basic_keys.alphabet}+":
    press_keys,
    "{basic_keys.modifiers}* {basic_keys.digits}+":
    press_keys,
    "{basic_keys.modifiers}* {basic_keys.keys}+":
    press_keys,
    "(go | {basic_keys.modifiers}+) {basic_keys.arrows}+":
    press_keys,
    "number {basic_keys.digits}+ [over]":
    press_keys,
    "day " + optional_numerals:
    repeat_function(1, "backspace"),
    "(scrap | delete) " + optional_numerals:
    repeat_function(1, "delete"),
    "tabback":
    Key("shift-tab"),
})
ctx.set_list("alphabet", alphabet.keys())
ctx.set_list("digits", digits.keys())
ctx.set_list("keys", keys.keys())
ctx.set_list("arrows", arrows.keys())
ctx.set_list("modifiers", modifiers.keys())
ctx.set_list("keymap", keymap.keys())
Beispiel #29
0
]
keys = alnum + [(k, k) for k in keys]
keys += [
    ('tilde', '`'),
    ('comma', ','),
    ('dot', '.'),
    ('slash', '/'),
    ('(semi | semicolon)', ';'),
    ('quote', "'"),
    ('[left] square', '['),
    ('(right | are) square', ']'),
    ('backslash', '\\'),
    ('minus', '-'),
    ('equals', '='),
] + fkeys
alpha.update({word: Key(key) for word, key in fkeys})
alpha.update({'control %s' % k: Key('ctrl-%s' % v) for k, v in keys})
alpha.update(
    {'control shift %s' % k: Key('ctrl-shift-%s' % v)
     for k, v in keys})
alpha.update({'control alt %s' % k: Key('ctrl-alt-%s' % v) for k, v in keys})
alpha.update({'command %s' % k: Key('cmd-%s' % v) for k, v in keys})
alpha.update(
    {'command shift %s' % k: Key('cmd-shift-%s' % v)
     for k, v in keys})
alpha.update(
    {'command alt shift %s' % k: Key('cmd-alt-shift-%s' % v)
     for k, v in keys})
alpha.update({'alt %s' % k: Key('alt-%s' % v) for k, v in keys})
alpha.update({'alt shift %s' % k: Key('alt-%s' % v) for k, v in keys})
Beispiel #30
0
)

JS_EXTENSIONS = (".js", ".jsx", ".ts", ".tsx")

# context = Context("javascript", func=is_filetype(JS_EXTENSIONS))
context = Context("javascript")
PREFIX = "java"


def remove_spaces_around_dashes(m):
    words = parse_words(m)
    s = " ".join(words)
    s = s.replace(" – ", "-")
    insert(s)


def CursorText(s):
    left, right = s.split("{.}", 1)
    return [left + right, Key(" ".join(["left"] * len(right)))]


context.keymap(
    {
        f"{PREFIX} const [<dgndictation>]": ["const ", text],
        f"{PREFIX} let [<dgndictation>]": ["let ", text],
        f"{PREFIX} arrow": " => ",
        f"{PREFIX} print": ["console.log()", Key("left")],
        f"{PREFIX} trip": " === ",
    }
)