def wrapped_function(*args, **kwargs): old = clip.get() fn(*args, **kwargs) clip.set(old)
def raise_homophones(m, force_raise=False, is_selection=False): global pick_context global active_word_list if is_selection: word = get_selection() word = word.strip() elif hasattr(m, 'dgndictation'): # this mode is currently disabled... # experimenting with using a canonical representation and not using # dgndictation word = str(m.dgndictation[0]._words[0]) word = parse_word(word) elif len(m._words) >= 2: word = str(m._words[len(m._words) - 1]) word = parse_word(word) word = word.lower() if word not in all_homophones: app.notify('homophones.py', '"%s" not in homophones list' % word) return active_word_list = all_homophones[word] if is_selection and len(active_word_list) == 2 and quick_replace and \ not force_raise: if word == active_word_list[0].lower(): new = active_word_list[1] else: new = active_word_list[0] clip.set(new) press('cmd-v', wait=0) return valid_indices = range(len(active_word_list)) panel.show() panel.freeze() keymap = { '0': lambda x: close_homophones(), } def capitalize(x): return x[0].upper() + x[1:] def uppercase(x): return x.upper() def lowercase(x): return x.lower() keymap.update({'%s' % (i + 1): lambda m: make_selection(m, is_selection) for i in valid_indices}) keymap.update({'champ %s' % (i + 1): lambda m: make_selection(m, is_selection, capitalize) for i in valid_indices}) keymap.update({'yeller %s' % (i + 1): lambda m: make_selection(m, is_selection, uppercase) for i in valid_indices}) 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()
def copy_bundle(m): bundle = ui.active_app().bundle clip.set(bundle) app.notify('Copied app bundle', body='{}'.format(bundle))
def insert(w, is_selection): if is_selection: clip.set(w) press("cmd-v", wait=0) else: Str(w)(None)
def wrapped_function(*args, **kwargs): old = clip.get() ret = fn(*args, **kwargs) sleep(0.1) clip.set(old) return ret
def paste_text(text): with clip.revert(): clip.set(text) # sleep(0.1) press("cmd-v") sleep(0.1)
def copy_bundle(): """Copy application bundle""" bundle = ui.active_app().bundle clip.set(bundle) app.notify("Copied app bundle", body="{}".format(bundle))
def raise_homophones(m, force_raise=False, is_selection=False): global pick_context global active_word_list if is_selection: word = get_selection() word = word.strip() # elif hasattr(m, "dgndictation"): # # this mode is currently disabled... # # experimenting with using a canonical representation and not using # # dgndictation # word = str(m.dgndictation[0]._words[0]) # word = parse_word(word) elif len(m._words) >= 2: word = str(m._words[len(m._words) - 1]) word = parse_word(word) is_capitalized = word == word.capitalize() is_upper = word.isupper() word = word.lower() if word not in all_homophones: app.notify("homophones.py", '"%s" not in homophones list' % word) return active_word_list = all_homophones[word] if (is_selection and len(active_word_list) == 2 and quick_replace and not force_raise): if word == active_word_list[0].lower(): new = active_word_list[1] else: new = active_word_list[0] if is_capitalized: new = new.capitalize() elif is_upper: new = new.upper() clip.set(new) press("cmd-v", wait=0) return valid_indices = range(len(active_word_list)) webview.render(phones_template, homophones=active_word_list) webview.show() keymap = {"(cancel | 0)": lambda x: close_homophones()} def capitalize(x): return x[0].upper() + x[1:] def uppercase(x): return x.upper() def lowercase(x): return x.lower() keymap.update({ "[pick] %s" % (i + 1): lambda m: make_selection(m, is_selection) for i in valid_indices }) keymap.update({ "(ship | title) %s" % (i + 1): lambda m: make_selection(m, is_selection, capitalize) for i in valid_indices }) keymap.update({ "(yeller | upper | uppercase) %s" % (i + 1): lambda m: make_selection(m, is_selection, uppercase) for i in valid_indices }) keymap.update({ "(lower | lowercase) %s" % (i + 1): lambda m: make_selection(m, is_selection, lowercase) for i in valid_indices }) pick_context.keymap(keymap) pick_context.load()
def repo_copy_git_repo(m): # [email protected]:vitchyr/rlkit.git url = browser.get_url() git_url = f"[email protected]:{re.fullmatch('https://github.com/([^/]*/[^/]*).*', url).group(1)}.git" clip.set(git_url)
def copy_bundle(m): bundle = ui.active_app().bundle clip.set(bundle) app.notify("Copied app bundle", body="{}".format(bundle))
def make_selection(self, m): words = m._words selection = int(parse_word(words[1])) clip.set(self.data[selection - 1]) press("cmd-v", wait=2000) self.close()
from talon import clip, ui from talon.voice import Context context = Context("bundle") context.keymap( {"copy [app] bundle": lambda m: clip.set(ui.active_app().bundle)})
def emoji_helper(emoji): # TODO: preserve clipboard clip.set(emoji) press("cmd-v", wait=2000)
"clear way left": extendable("shift-home delete"), "clear way right": extendable("shift-end delete"), # searching "search [<dgndictation>]": [Key("cmd-f"), utils.text], # clipboard "cut this": Key("cmd-x"), "copy this": Key("cmd-c"), "paste [here]": Key("cmd-v"), # Copying "copy path": lambda _: clip.set(current_dir()), "copy phrase": [utils.select_last_insert, Key("cmd-c")], "copy all": [Key("cmd-a cmd-c")], "copy line": extendable("cmd-left cmd-left cmd-shift-right cmd-c cmd-right"), "copy word left": extendable("shift-alt-left cmd-c"), "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"),
def paste_text(text): clip.set(text) sleep(0.1) press('cmd-v')