def replay_save_last(): """Save the last recording to a preconfigured directory""" global rr file_name = rr.recordings_list[-1] shutil.copy(file_name, saved_recording_directory) pathlib.Path(file_name) clip.set_text(file_name.name)
def talon_add_context_clipboard(): """Adds os-specific context info to the clipboard""" friendly_name = actions.app.name() executable = actions.app.executable().split(os.path.sep)[-1] if app.platform == "mac": result = 'mod.apps.{} = """\nos: {}\nand app.bundle: {}\n"""'.format( create_name(friendly_name), app.platform, actions.app.bundle() ) elif app.platform != "windows" or friendly_name == executable: result = 'mod.apps.{} = """\nos: {}\nand app.name: {}\n"""'.format( create_name(friendly_name), app.platform, friendly_name ) # on windows, it's best to include both the friendly name and executable name in case the muicache breaks.... else: result = 'mod.apps.{} = """\nos: {}\nand app.name: {}\nos: {}\nand app.name: {}\n"""'.format( create_name(friendly_name), app.platform, friendly_name, app.platform, executable, ) clip.set_text(result)
def replay_copy_name(choice: int): """Copy the file name of the selected replay file""" global rr file_name = rr.recordings_list[choice - 1] pathlib.Path(file_name) clip.set_text(file_name.name)
def replay_save_last(): """Save the last recording to a preconfigured directory""" global rr file_name = rr.save_recording_by_index(0) if not file_name: return # XXX - make this optional clip.set_text(file_name)
def selected_text() -> str: clip.set_text("") with clip.capture() as s: actions.edit.copy() try: return s.get() except clip.NoChange: return ""
def paste(text: str): """Pastes text and preserves clipboard""" with clip.revert(): clip.set_text(text) actions.edit.paste() # sleep here so that clip.revert doesn't revert the clipboard too soon actions.sleep("100ms")
def replay_save(choice: int): """Save the selected recording to a preconfigured directory""" global rr file_name = rr.save_recording(choice) if not file_name: return # XXX - whether or not to pace should be part of a setting clip.set_text(file_name) actions.edit.paste()
def replay_save(choice: int): """Save the selected recording to a preconfigured directory""" global rr file_name = rr.save_recording_by_index(choice) if not file_name: return if settings.get("user.replay_paste_name_on_save") != 0: clip.set_text(file_name) actions.user.insert_cursor_paste('"[|]":', "")
def replay_save_last_played(): """Insert some info from the last self.count recordings""" global rr file_name = rr.save_last_played() if not file_name: return if settings.get("user.replay_paste_name_on_save") != 0: clip.set_text(file_name) actions.user.insert_cursor_paste('"[|]":', "")
def vscode_ignore_clipboard(command: str): """Execute command via command palette. Does NOT preserve the clipboard for commands like copyFilePath""" clip.set_text(f"{command}") if not is_mac: actions.key("ctrl-shift-p") else: actions.key("cmd-shift-p") actions.edit.paste() actions.key("enter")
def replay_save(choice: int): """Save the selected recording to a preconfigured directory""" global rr file_name = rr.recordings_list[choice - 1] print(f"{file_name}") shutil.copy(file_name, saved_recording_directory) pathlib.Path(file_name) rr.last_saved_recording = file_name clip.set_text(file_name.name)
def vscode(command: str): """Execute command via command palette. Preserves the clipboard.""" # Clip is noticeably faster than insert original_clipboard = clip.text() clip.set_text(f"{command}") if not is_mac: actions.key("ctrl-shift-p") else: actions.key("cmd-shift-p") actions.edit.paste() actions.key("enter") actions.sleep("200ms") clip.set_text(original_clipboard)
def paste(text: str): """Pastes text and preserves clipboard""" # with clip.revert(): # clip.set_text(text) # actions.edit.paste() # # sleep here so that clip.revert doesn't revert the clipboard too soon # actions.sleep("100ms") old = subprocess.check_output(['xsel', '-o', '-b']) clip.set_text(text) actions.edit.paste() actions.sleep("200ms") clip.set_text(old.decode("utf-8"))
def raise_homophones(word, forced=False, selection=False): global quick_replace global active_word_list global show_help global force_raise global is_selection force_raise = forced is_selection = selection if is_selection: word = word.strip() 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_text(new) actions.user.replace_selection() return actions.mode.enable("user.homophones") show_help = False gui.show()
def talon_add_context_clipboard(): """Adds os-specific context info to the clipboard for the focused app for .talon files""" friendly_name = actions.app.name() # print(actions.app.executable()) executable = actions.app.executable().split(os.path.sep)[-1] if app.platform == "mac": result = "os: {}\nand app.bundle: {}\n".format( app.platform, actions.app.bundle() ) elif app.platform == "windows": result = "os: windows\nand app.name: {}\nos: windows\nand app.exe: {}\n".format( friendly_name, executable ) else: result = "os: {}\nand app.name: {}\n".format(app.platform, friendly_name) clip.set_text(result)
def talon_add_context_clipboard_python(): """Adds os-specific context info to the clipboard for the focused app for .py files. Assumes you've a Module named mod declared.""" friendly_name = actions.app.name() # print(actions.app.executable()) executable = actions.app.executable().split(os.path.sep)[-1] app_name = create_name(friendly_name.replace(".exe", "")) if app.platform == "mac": result = 'mod.apps.{} = """\nos: {}\nand app.bundle: {}\n"""'.format( app_name, app.platform, actions.app.bundle()) elif app.platform == "windows": result = 'mod.apps.{} = """\nos: windows\nand app.name: {}\nos: windows\nand app.exe: {}\n"""'.format( app_name, friendly_name, executable) else: result = 'mod.apps.{} = """\nos: {}\nand app.name: {}\n"""'.format( app_name, app.platform, friendly_name) clip.set_text(result)
def paste_match_style(): clip.set_text(clip.get()) time.sleep(0.1) actions.paste()
def talon_copy_list(name: str): """Dumps the contents of list to the console""" print("**** Copied list {} **** ".format(name)) clip.set_text(pp.pformat(registry.lists[name])) print("***********************")
def mouse_capture_coordinates(): """copy the current coordinate tuple to the clipboard""" print(ctrl.mouse_pos()) x, y = ctrl.mouse_pos() clip.set_text(f"{x},{y}")
def copy_contents(self): clip.set_text(remove_tokens_from_rich_text(self.panel_content.content[0])) actions.user.hud_add_log("event", "Copied contents to clipboard!")
def __exit__(self, *_): time.sleep(0.1) clip.set_text(self.old_clipboard)
def _print_and_copy_lines(lines: List): string = "\n".join(map(str, lines)) print(string) clip.set_text(string) print("String copied to clipboard.")
def copy_mouse_position(): """Copy the current mouse position coordinates""" position = ctrl.mouse_pos() clip.set_text((repr(position)))
def clip_set_safe(new_value, timeout=2): """Set clipboard to `new_value`""" if clip.get() == new_value: return with WaitForClipChange(timeout): clip.set_text(new_value)