コード例 #1
0
    # jsc modified with some voice-code compatibility
    "righty (click | chirff)": right_click,
    "righty press": Key("shift-f10"),
    "(click | chiff)": click,
    "(dubclick | duke)": dubclick,
    "(tripclick | triplick)": tripclick,
    "drag": mouse_drag,
    "drag release": mouse_release,
    "control click": control_click,
    "shift click": shift_click,
    # "(command click | chom lick)": command_click,
    "(control shift click | troll shift click)": control_shift_click,
    "(control shift double click | troll shift double click)": lambda m: control_shift_click(
        m, 0, 2
    ),
    "do park": [dubclick, Key("ctrl-v")],
    "do koosh": [dubclick, Key("ctrl-c")],
    # "wheel down": mouse_smooth_scroll(250),
    # "wheel up": mouse_smooth_scroll(-250),
    # "wheel down here": [mouse_center, mouse_smooth_scroll(250)],
    # "wheel up here": [mouse_center, mouse_smooth_scroll(-250)],
    "mouse center": mouse_center,
    "mouse {mouse.regions} half": mouse_place("half"),
    "mouse {mouse.regions} [full]": mouse_place("full"),
    "move {mouse.regions} (one | 1)": mouse_move_pixels("one"),
    "move {mouse.regions} ten": mouse_move_pixels("ten"),
    "move {mouse.regions} hundred": mouse_move_pixels("hundred"),
}
ctx.set_list("regions", regions.keys())
ctx.keymap(keymap)
コード例 #2
0
ファイル: homophones.py プロジェクト: pimentel/talon_user
<tr><td class="pick">🔊 yeller [number]</td><td>make a selection and uppercase it</td></tr>
<tr><td class="pick">🔊 lower [number]</td><td>make a selection and lowercase it</td></tr>
<tr><td colspan="2" class="pick cancel">🔊 cancel</td></tr>
</table>
</div>
""")


def homophones_help(m):
    webview.render(help_template)
    webview.show()

    keymap = {"(cancel | exit)": lambda x: close_homophones()}
    pick_context.keymap(keymap)
    pick_context.load()


context.keymap({
    "phones help":
    homophones_help,
    "phones {basic_keys.digits}* {homophones.canonical}":
    raise_homophones,
    "phones {basic_keys.digits}*":
    lambda m: raise_homophones(m, is_selection=True),
    "force phones {homophones.canonical}":
    lambda m: raise_homophones(m, force_raise=True),
    "force phones":
    lambda m: raise_homophones(m, force_raise=True, is_selection=True),
})
context.set_list("canonical", canonical)
コード例 #3
0
    'tilde': '~',
    '(bang | exclamation point)': '!',
    'dollar [sign]': '$',
    'downscore': '_',
    'colon': ':',
    '(paren | left paren)': '(',
    '(rparen | are paren | right paren)': ')',
    '(brace | left brace)': '{',
    '(rbrace | are brace | right brace)': '}',
    '(angle | left angle | less than)': '<',
    '(rangle | are angle | right angle | greater than)': '>',
    '(star | asterisk)': '*',
    'hash [sign]': '#',
    'percent [sign]': '%',
    'caret': '^',
    'at sign': '@',
    '(and sign | ampersand | amper)': '&',
    'pipe': '|',
    'power to sign': '^',
    '(dubquote | double quote)': '"',
    'triple quote': "'''",
    'back tick': '`',
    'elipsis': ['...'],
})
ctx.set_list('alphabet', alphabet.keys())
ctx.set_list('arrows', arrows.keys())
ctx.set_list('digits', digits.keys())
ctx.set_list('keys', keys.keys())
ctx.set_list('modifiers', modifiers.keys())
ctx.set_list('keymap', keymap.keys())
コード例 #4
0
ファイル: uppercase.py プロジェクト: tremol/talon_community
from talon.voice import Context, Key
import string
from ..utils import insert

# upper_alphabet_words = "append backer change delete ender finder gutter high insert join keyword lower middle next open paste command replace sneaker teeter undo visual wordy exit yanker zoink"
upper_alphabet_words = "ash baker chain dog egg fox gig horse ice jake king lash mule net oak page quail raft scout tide use vessel winch xray yacht zoo"

alphabet_upper = dict(zip(upper_alphabet_words.split(),
                          string.ascii_uppercase))
print(alphabet_upper)


def upper(m):
    s = m['uppercase.alphabet_upper']
    c = str(alphabet_upper[s[0]])
    insert(c)


# ctx = Context("uppercase", bundle="org.vim.MacVim")
ctx = Context("uppercase")

ctx.keymap({
    "{uppercase.alphabet_upper}": upper,
})
ctx.set_list('alphabet_upper', alphabet_upper)
コード例 #5
0
            print(keys)
            return keys
        except Exception as e:
            # print(e)
            return []

    def dump(self):
        resource.write(warps_file, json.dumps(self.data, indent=2))


mj = MouseWarp()
ctx = Context("warp")
ctx.keymap({
    "mark <dgndictation> [over]": [
        lambda m: mj.mark(utils.join_words(utils.parse_words(m))),
        lambda _: ctx.set_list("warps", mj.warps()),
    ],
    "warp {warp.warps}": [lambda m: mj.warp(m["warp.warps"][0])],
    "clear warp {warp.warps} [over]":
    [lambda m: mj.delete(m["warp.warps"][0])],
    "list warps": [
        lambda _: app.notify("Warps:", ", ".join(mj.warps())),
        lambda _: ctx.set_list("warps", mj.warps()),
    ],
    "click {warp.warps}": [
        lambda m: mj.warp(m["warp.warps"][0]),
        lambda _: ctrl.mouse_click(button=0),
    ],
})

コード例 #6
0
ファイル: editor.py プロジェクト: ym-han/talon-user
    "copy word right":
    extendable("shift-alt-right cmd-c"),
    "copy way left":
    extendable("cmd-shift-left cmd-c"),
    "copy way right":
    extendable("cmd-shift-right cmd-c"),
    "copy way up":
    extendable("cmd-shift-up cmd-c"),
    "copy way down":
    extendable("cmd-shift-down cmd-c"),
    # Cutting
    "cut phrase": [utils.select_last_insert,
                   Key("cmd-x")],
    "cut all": [Key("cmd-a cmd-x")],
    "cut line":
    extendable("cmd-left cmd-left cmd-shift-right cmd-x cmd-right"),
    "cut word left":
    extendable("shift-alt-left cmd-x"),
    "cut word right":
    extendable("shift-alt-right cmd-x"),
    "cut way left":
    extendable("cmd-shift-left cmd-x"),
    "cut way right":
    extendable("cmd-shift-right cmd-x"),
    "cut way up":
    extendable("cmd-shift-up cmd-x"),
    "cut way down":
    extendable("cmd-shift-down cmd-x"),
})
ctx.set_list("alphabet", alphabet.keys())
コード例 #7
0
ファイル: GoogleChrome.py プロジェクト: mollymking/talon_user
websites = {
    'calendar': 'https://calendar.google.com',
    'facebook': 'https://facebook.com',
    'twitter': 'https://twitter.com',
    'trello': 'https://trello.com',
    'gmail': 'https://gmail.com',
    'get hub': 'https://github.com',
    'reddit': 'https://reddit.com',
    'talon docs': 'https://github.com/dwighthouse/unofficial-talonvoice-docs',
    'talon official docs': 'https://talonvoice.com/docs/index.html',
}

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
コード例 #8
0
}

for action in ("get", "delete", "describe"):
    for object in ("nodes", "jobs", "pods", "namespaces", "services", ""):
        if object:
            object = object + " "
        command = f"{KUBERNETES_PREFIX} {action} {object}"
        typed = f"kubectl {action} {object}"
        keymap.update({command: typed})

keymap.update(
    {"(pain | bang) " + str(i): Key("alt-" + str(i))
     for i in range(10)})

ctx.keymap(keymap)
ctx.set_list("directory_shortcuts", directory_shortcuts.keys())


def shell_rerun(m):
    # switch_app(name='iTerm2')
    app = ui.apps(bundle="com.googlecode.iterm2")[0]
    ctrl.key_press("c", ctrl=True, app=app)
    time.sleep(0.05)
    ctrl.key_press("up", app=app)
    ctrl.key_press("enter", app=app)


global_ctx = Context("global_terminal")
global_ctx.keymap({"shell rerun": shell_rerun})
# module.exports = {
#   permissions: "chmod "
コード例 #9
0
    "shell make": "make\n",
    "shell jobs": "jobs\n",
}

for action in ("get", "delete", "describe"):
    for object in ("nodes", "jobs", "pods", "namespaces", "services", "events", ""):
        if object:
            object = object + " "
        command = f"{KUBERNETES_PREFIX} {action} {object}"
        typed = f"kubectl {action} {object}"
        keymap.update({command: typed})

keymap.update({"(pain | bang) " + str(i): Key("alt-" + str(i)) for i in range(10)})

ctx.keymap(keymap)
ctx.set_list("directory_shortcuts", directory_shortcuts.keys())
# ctx.set_list("servers", servers.keys())


def shell_rerun(m):
    # switch_app(name='iTerm2')
    app = ui.apps(bundle="com.googlecode.iterm2")[0]
    ctrl.key_press("c", ctrl=True, app=app)
    time.sleep(0.05)
    ctrl.key_press("up", app=app)
    ctrl.key_press("enter", app=app)


global_ctx = Context("global_terminal")
global_ctx.keymap(
    {"shell rerun": shell_rerun, "shell server {global_terminal.servers}": name_servers}
コード例 #10
0
ファイル: terminal.py プロジェクト: slin63/talon_community
def shell_rerun(m):
    # switch_app(name='iTerm2')
    app = ui.apps(bundle="com.googlecode.iterm2")[0]
    ctrl.key_press("c", ctrl=True, app=app)
    time.sleep(0.05)
    ctrl.key_press("up", app=app)
    ctrl.key_press("enter", app=app)


global_ctx = Context("global_terminal")
global_ctx.keymap({
    "SHE rerun": shell_rerun,
    "SHE server {global_terminal.servers}": name_servers
})
global_ctx.set_list("servers", servers.keys())
# module.exports = {
#   permissions: "chmod "
#   access: "chmod "
#   ownership: "chown "
#   "change own": "chown "
#   "change group": "chgrp "
#   cat: "cat "
#   chat: "cat " # dragon doesn't like the word 'cat'
#   copy: "cp "
#   "copy recursive": "cp -r "
#   move: "mv "
#   remove: "rm "
#   "remove recursive": "rm -rf "
#   "remove directory": "rmdir "
#   "make directory": "mkdir "
コード例 #11
0
    "lint (next | neck)": command("linter ui default: next in current file"),
    "lint (preev | previous)": command("linter ui default: previous in current file"),
    # atom-isort
    "sort imports": command("atom isort sort imports"),
    # atom-blacken
    "(atom | adam) black": command("atom blacken"),
    # platformio-ide-terminal
    "(platform | terminal | termy | termie) new": command("platformio new"),
    "(platform | terminal | termy | termie) (toggle | switch)": command(
        "platformio toggle"
    ),
    "(platform | terminal | termy | termie) (previous | preev)": command(
        "platformio prev"
    ),
    "(platform | terminal | termy | termie) next": command("platformio next"),
    "(platform | terminal | termy | termie) (cell | sell)": command(
        "platformio insert selected"
    ),
    "(platform | terminal | termy | termie) close": command("platformio close"),
    "(platform | terminal | termy | termie) close all": command("platformio close all"),
    # atom-script
    "(code | script) (run | sprint | go)": command("script run"),
    "script close": command("script close view"),
    "(code | script) kill": Key("ctrl-q"),
    "(rep | rap | wrap) (toggle | switch)": command("toggle soft wrap"),
    # bookmark
    "(bookmark | mark) toggle": command("bookmark toggle"),
}
ctx.set_list("snippets", snippets.keys())
ctx.keymap(keymap)
コード例 #12
0
        'play': 'play',
        'pause': 'play',
        'stop': 'stop',
        'quieter': 'volumeDown\n' * 2,
        'louder': 'volumeUp\n' * 2,
        'way quieter': 'volumeDown\n' * 6,
        'way louder': 'volumeUp\n' * 6,
        'focus': lambda: app().focus(),
    }

    def cmd(self, cmd):
        ret = applescript.run(f'tell application "VLC"\n{cmd}\nend tell')
        if ret:
            return ffi.string(ret).decode('utf8')

    def __call__(self, m):
        cmd = str(m['vlc.commands'][0])
        action = self.commands[cmd]
        if isinstance(action, str):
            self.cmd(action)
        else:
            action()


vlc = VLC()
ctx = Context('vlc')  # , bundle=BUNDLE)
ctx.keymap({
    'video {vlc.commands}': vlc,
})
ctx.set_list('commands', vlc.commands.keys())
コード例 #13
0
ファイル: picker.py プロジェクト: ym-han/talon-user
from talon.voice import Context, Key

from .. import utils


def pick(m):
    try:
        index = utils.ordinal_indexes[m["picker.ordinal"][0]]
        Key("down " * index + "enter")(m)
    except:
        pass


ctx = Context("picker")
ctx.keymap({"pick {picker.ordinal}": pick})

ctx.set_list("ordinal", utils.ordinal_indexes.keys())
コード例 #14
0
        "paste": Key("ctrl-v"),
        # "menu help": Key("cmd-shift-?"),
        "spotlight": Key(
            "win-s"
        ),  # spotlight search bar in mac corresponding to windows search bar
        "(undo | under | skunks)": Key("ctrl-z"),
        "redo": Key("ctrl-shift-z"),
        "(crap | clear | scratch )": Key("ctrl-backspace"),
        "(select | sell | cell) all": Key("ctrl-a"),
        # "more bright": Key("brightness_up"),
        # "less bright": Key("brightness_down"),
        # "volume up": Key("volume_up"),
        # "volume down": Key("volume_down"),
        # "mute": Key("mute"),
        # "play next": Key("next"),
        # "play previous": Key("previous"),
        # "(play | pause)": Key("space"),  # spotify
        "(wipe | vipe)": Key("backspace"),
        "(pad | padding ) ": ["  ", Key("left")],
        "funny": "haha",
        "arch hive": Key(key_pressify_string("arxiv")),
        # "menubar": Key("ctrl-f2"),
        # "status menu": Key("ctrl-f8"),
        # "my doc": Key("ctrl-f3"),
        "{standard.vocab}": inputs_vocab,
    }
)

ctx.set_list("vocab", vocab)
ctx.keymap(keymap)
コード例 #15
0
keymap = {
    "{mouseSnapNine.digits}+":
    narrow,
    "(oops | back)":
    mg.go_back,
    "(reset | clear | escape)":
    mg.reset,
    "done": [
        mg.stop, lambda _: ctx.unload(), lambda _: speech.set_enabled(True),
        lambda _: click()
    ],
    "exit":
    [mg.stop, lambda _: ctx.unload(), lambda _: speech.set_enabled(True)],
}

ctx.keymap(keymap)
ctx.set_list("digits", digits.keys())
group.load()
ctx.unload()

startCtx = Context("mouseSnapNineStarter")
startCtx.keymap({
    "(grid | mouse grid | mousegrid)": [
        mg.reset, mg.start, lambda _: ctx.load(),
        lambda _: speech.set_enabled(False)
    ],
    # "snap done": [mg.stop, lambda _: ctx.unload()],
})
# mg.start()
# Hot reload while grid is active is very confusing without this.
speech.set_enabled(True)
コード例 #16
0
def global_go_to_webpage(m):
    switcher.switch_app(name="Google Chrome")
    new_tab_go_to_webpage(m)


def global_chrome_close_tab(m):
    current_app = ui.active_window().app
    switcher.switch_app(name="Google Chrome")
    press("cmd-w")
    current_app.focus()
    # app = ui.apps(bundle="com.google.Chrome")[0]
    # ctrl.key_press("w", cmd=True, app=app)


global_ctx = Context("global_browser")
global_ctx.set_list("webpages", webpages.keys())
global_ctx.set_list("searches", searches.keys())
global_ctx.keymap({
    "chrome new tab":
    global_chrome_new_tab,
    "chrome new [tab] {global_browser.webpages}":
    global_go_to_webpage,
    "chrome close tab":
    global_chrome_close_tab,
    "chrome search [<dgndictation>]": [global_chrome_new_tab, utils.text, " "],
    "chrome lucky [<dgndictation>]": [
        global_chrome_new_tab,
        "lucky ",
        utils.text,
        " ",
    ],
コード例 #17
0
def ordinal(n):
    """
    Convert an integer into its ordinal representation::
        ordinal(0)   => '0th'
        ordinal(3)   => '3rd'
        ordinal(122) => '122nd'
        ordinal(213) => '213th'
    """
    n = int(n)
    suffix = ["th", "st", "nd", "rd", "th"][min(n % 10, 4)]
    if 11 <= (n % 100) <= 13:
        suffix = "th"
    return str(n) + suffix


for n in range(2, 11):
    ordinals[ordinal(n)] = n - 1

ctx.set_list("ordinals", ordinals.keys())


def repeat(m):
    o = m["repeater.ordinals"][0]
    repeater = Rep(int(ordinals[o]))
    repeater.ctx = talon
    return repeater(None)


ctx.keymap({"{repeater.ordinals}": repeat})
コード例 #18
0
ファイル: switcher.py プロジェクト: ym-han/talon-configs
    new = {}
    for base in "/Applications", "/Applications/Utilities":
        for name in os.listdir(base):
            path = os.path.join(base, name)
            name = name.rsplit(".", 1)[0]
            new[name] = path
            words = name.split(" ")
            for word in words:
                if word and word not in new:
                    if len(name) > 6 and len(word) < 3:
                        continue
                    new[word] = path
    launch = new
    ctx.set_list("launch", launch.keys())


def ui_event(event, arg):
    if event in ("app_activate", "app_launch", "app_close", "win_open",
                 "win_close"):
        # print(event, arg)
        if event in ("win_open", "win_closed"):
            if arg.app.name == "Amethyst":
                return
        update_lists()


# ui.register("", ui_event)
# update_lists()
ctx.set_list("running", hardcoded_application_names)
コード例 #19
0
        push_loc,
        idea_psi("select"),
        utils.delay(0.2),
        idea("action Refactorings.QuickListPopupAction"),
    ],
    "rename [{jetbrains.ordinal}] {jetbrains.path}": [
        push_loc,
        idea_psi("select"),
        utils.delay(0.2),
        idea("action RenameElement"),
    ],
    "select [{jetbrains.ordinal}] {jetbrains.path}": [
        push_loc, idea_psi("select")
    ],
    "clear [{jetbrains.ordinal}] {jetbrains.path}": [
        push_loc,
        idea_psi("select"),
        idea("action EditorDelete"),
    ],
    "add {jetbrains.path} [<dgndictation>] [over]": [
        push_loc, idea_psi_and_snippet()
    ],
}

ctx.keymap(keymap)
ctx.set_list("alphabet", alphabet.keys())
ctx.set_list("ordinal", utils.ordinal_indexes.keys())
ctx.set_list("path", PSI_PATHS.keys())

# group.load()
コード例 #20
0
ファイル: atom.py プロジェクト: thatcherervin/talon_community
    "switch [header] source":
    command("switch header source"),
    # treeview
    "(tree [view] rename | rename file)":
    command("tree view rename"),
    # linter
    "lint (next | neck)":
    command("linter ui default: next in current file"),
    "lint (prev | previous)":
    command("linter ui default: previous in current file"),
    # atom-isort
    "sort imports":
    command("atom isort sort imports"),
    # editor
    "move line up":
    command("editor: move line up"),
    "move line down":
    command("editor: move line down"),
    "move [current line] [to] line" + numerals:
    move_to_line,
}
ctx.set_list("snippets", set(snippets.keys()) - set(snippet_formatters.keys()))
ctx.set_list("snippets_with_formatter", snippet_formatters.keys())
ctx.keymap(keymap)
"""
ideal AST navigation and manipulation

syntax_node_type := (function | method | class | if | statement | call | for | loop | with | number | ...)
(go (start | end) | select | copy | cut | delete) [(inside | all)] [(next | prev)] {syntax_node_type}
"""
コード例 #21
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())
コード例 #22
0
ファイル: latex.py プロジェクト: tremol/talon_community
        "painter text blue": ["\\textcolor{blue}{}", Key('left')],
        "painter text green": ["\\textcolor{green}{}", Key('left')],

        # new environments
        "new {latex.environments}": new_environment,
        "new <word> environment": new_custom_environment,

        # greek letters
        "(greek | greco) {basic_keys.alphabet}": greek,
        "upper (greek | greco) {basic_keys.alphabet}": upper_greek,
        "{basic_keys.digits} pie": number_pi,
        # TODO: define a function that references the names of the Greek letters directly

        # label and reference commands
        "label {latex.label_reference_commands}": label_command,
        "reference {latex.label_reference_commands}": reference_command,
        "label equation": ["\\label{eq:}", Key('left')],
        "reference equation": ["\\eqref{eq:}", Key('left')],
        "clever reference on": lambda m: clever_reference_on(),
        "clever reference off": lambda m: clever_reference_off(),
        "citation": ["\\cite{}", Key("left")],

    }
)
ctx.set_list('greek_alphabet', greek_letter_mappings.values())
ctx.set_list('environments', environments)
ctx.set_list('delimiters', delimiters)
ctx.set_list('zero_parameter_commands', zero_parameter_commands)
ctx.set_list('single_parameter_commands', single_parameter_commands)
ctx.set_list('label_reference_commands', label_reference_commands)
コード例 #23
0
ファイル: spaces.py プロジェクト: tremol/talon_community
def move_win_left_space(m):
    with drag_window():
        press("ctrl-cmd-alt-left")


def move_win_right_space(m):
    with drag_window():
        press("ctrl-cmd-alt-right")


def window_move_space(m):
    desktop_number = NAMED_DESKTOPS[m["spaces.named_desktops"][0]]
    with drag_window():
        press(f"ctrl-{desktop_number}")


def desk(m):
    desktop_number = NAMED_DESKTOPS[m["spaces.named_desktops"][0]]
    press(f"ctrl-{desktop_number}")
    # cron.after('300ms', last_phrase.history.refresh)


keymap = {
    "window move (space | desk) {spaces.named_desktops}": window_move_space,
    "desk {spaces.named_desktops}": desk,
}

ctx = Context("spaces")
ctx.keymap(keymap)
ctx.set_list("named_desktops", NAMED_DESKTOPS.keys())
コード例 #24
0
ctx.keymap({
    "dot pie": ".py",
    "dot pipe": ".py",
    "star (arguments | args)": "*args",
    "star star K wargs": "**kwargs",
    "raise value error": ["raise ValueError()",
                          Key("left")],
    "raise not implemented error": "raise NotImplementedError()",
    "raise {global_python.exception}": raise_exception,

    # for when using jupyter, not in a .py file
    "toggle jupey": toggle_enabled(),
    "toggle jupey on": toggle_enabled("on"),
    "toggle jupey off": toggle_enabled("off"),
})
ctx.set_list("exception", exceptions.keys())


def enable_python(appl, window):
    return is_filetype(FILETYPES)(appl, window) or config.enabled


# TODO: fix these so they're still useful but don't conflict with vim so much
ctx2 = Context("python", func=enable_python)
ctx2.keymap({
    # Statements
    "state (def | deaf | deft)":
    "def ",
    "state if":
    "if ",
    "state elif":
コード例 #25
0
        }
    )
    keymap.update(
        {
            "lower %s" % (i + 1): lambda m: make_selection(m, is_selection, lowercase)
            for i in valid_indices
        }
    )
    pick_context.keymap(keymap)
    pick_context.load()


# keymap = {
#     # Usage:
#     # 'homophones word' to look up those homophones.
#     # when the list pops up, say appropriate number or zero
#     # (leave and do nothing).
#     # can also call 'homophones' without any arguments.
#     # it will look at the selected text and look that up.
#     # 'phones [<dgndictation>]': raise_homophones,
#     # 'force phones [<dgndictation>]': lambda m: raise_homophones(m, True),
# }

context.keymap({
    'phones {homophones.canonical}': raise_homophones,
    'phones': lambda m: raise_homophones(m, is_selection=True),
    'force phones {homophones.canonical}': lambda m: raise_homophones(m, force_raise=True),
    'force phones': lambda m: raise_homophones(m, force_raise=True, is_selection=True),
})
context.set_list('canonical', canonical)
コード例 #26
0
    for n in range(10, 20, 1):
        numeral_map[str(n)] = n
if INCLUDE_TENS_IN_NUMERALS:
    for n in range(20, 101, 10):
        numeral_map[str(n)] = n
for n in range(100, 1001, 100):
    numeral_map[str(n)] = n
for n in range(1000, 10001, 1000):
    numeral_map[str(n)] = n
numeral_map["oh"] = 0  # synonym for zero
numeral_map["and"] = None  # drop me

numeral_list = sorted(numeral_map.keys())

ctx = Context("n")
ctx.set_list("all", numeral_list)
numerals = " {n.all}+"
optional_numerals = " {n.all}*"


def text_to_number(words):
    tmp = [str(s).lower() for s in words]
    words = [parse_word(word) for word in tmp]

    result = 0
    factor = 1
    for word in reversed(words):
        if word not in numeral_list:
            raise Exception("not a number: {}".format(words))

        number = numeral_map[word]
コード例 #27
0
# https://github.com/JonathanNickerson/talon_voice_user_scripts

import time

import talon.clip as clip
from talon.voice import Key, press, Str, Context
from ..utils import (
    parse_words,
    join_words,
    is_not_vim,
    numeral_list,
    extract_num_from_m,
)

ctx = Context("generic_editor", func=is_not_vim)
ctx.set_list("n", numeral_list)


def find_next(m):
    press("cmd-f")
    Str(str(m.dgndictation[0]._words[0]))(None)
    press("escape")


def find_previous(m):
    press("left")
    press("cmd-f")
    Str(str(m.dgndictation[0]._words[0]))(None)
    press("cmd-shift-g")
    press("escape")
コード例 #28
0
    # create the commands to navigate through pages
    for idx, items in enumerate(pages):
        keymap.update({
            "page " + str(idx + 1):
            create_render_page(
                templates["commands"],
                context_name=context.name,
                mapping=items,
                current_page=idx + 1,
                total_pages=len(pages),
            )
        })

    render_webview(
        templates["commands"],
        keymap,
        context_name=context.name,
        mapping=(pages[target_page - 1] if pages else []),
        current_page=target_page,
        total_pages=len(pages),
    )


keymap = {
    "help alphabet": render_alphabet_help,
    "help [commands] {help.contexts}": render_commands_help,
    "help context": render_contexts_help,
}
ctx.set_list("contexts", contexts().keys())
ctx.keymap(keymap)
コード例 #29
0
def uppercase_letters(m):
    insert("".join(get_keys(m)).upper())


def press_keys(m):
    mods = get_modifiers(m)
    keys = get_keys(m)
    if mods:
        press("-".join(mods + [keys[0]]))
        keys = keys[1:]
    for k in keys:
        press(k)


ctx = Context("basic")
ctx.keymap(
    {
        "(uppercase | ship) {basic.alphabet}+ [(lowercase | sunk)]": uppercase_letters,
        "{basic.modifiers}* {basic.alphabet}+": press_keys,
        "{basic.modifiers}* {basic.digits}+": press_keys,
        "{basic.modifiers}* {basic.keys}+": press_keys,
        "(go | {basic.modifiers}+) {basic.arrows}+": press_keys,
    }
)
ctx.set_list("alphabet", alphabet.keys())
ctx.set_list("arrows", arrows.keys())
ctx.set_list("digits", digits.keys())
ctx.set_list("keys", keys.keys())
ctx.set_list("modifiers", modifiers.keys())
コード例 #30
0
context = Context("registers")

regs = {str(i): i for i in range(10)}

global regs_list
regs_list = [str(i) for i in range(10)]


def send_clip_to_register(m):
    press("ctrl-c")
    cur_reg = int(m._words[-1])
    regs_list[cur_reg] = clip.get()
    # print(regs_list)


def paste_from_register(m):
    cur_reg = int(m._words[-1])
    reg_contents = regs_list[cur_reg]
    print(reg_contents)
    Str(reg_contents)(None)


keymap = {
    "(copy | send) (register | reggie) {registers.regs}": send_clip_to_register,
    "(paste  | stick) (register | reggie) {registers.regs}": paste_from_register,
}

context.set_list("regs", regs.keys())
context.keymap(keymap)