Skip to content

edit

The community/core/edit directory contains files that define core editing functionality for Talon. It provides actions for navigating, selecting, and manipulating text, as well as some higher-level editing commands. The files are designed to work together to provide a consistent and powerful editing experience across different operating systems.

The core functionality is split across multiple files:

  • edit_linux.py, edit_mac.py, and edit_win.py: These files define the basic edit actions for Linux, macOS, and Windows, respectively. They use the Context class from Talon to define actions that are specific to each operating system. These files are all structured similarly and define actions such as copy, cut, delete, navigation, and selection using native OS keyboard shortcuts. For example, edit_linux.py defines copy as ctrl-c, while edit_mac.py defines copy as cmd-c.

  • edit.py: This file provides more advanced actions that are not specific to any operating system. It defines things like selected_text to retrieve the currently selected text using the clipboard, line_insert_down, selection_clone, and line_clone, as well as more robust select_word functionality. It also contains actions such as paste which preserves the clipboard, delete_right which deletes a single character to the right of the cursor, and words_left and words_right which move the cursor by a given number of words. Finally, it also defines cut_word_left, cut_word_right, copy_word_left, copy_word_right, select_line_start, select_line_end, and line_middle to manipulate text at the word and line level.

  • edit_command.py: This file defines the edit_command action which is used to perform more complex editing commands that are composed of an action and a modifier (e.g. "select line", "copy word"). It maps combinations of actions and modifiers to Talon actions, including compound actions such as "go before line", "go after line", "delete word", and "cut to clipboard line".

  • edit_command_modifiers.py: This file defines the EditModifier class and a capture that is used to parse the modifier part of the edit command. It also provides callbacks for each type of modifier such as document, paragraph, word, and line for use in the edit_command action. The modifiers are defined in edit_command_modifiers.talon-list.

  • edit_command_actions.py: This file defines the EditAction dataclasses (EditSimpleAction, EditInsertAction, EditWrapAction, and EditFormatAction) and a capture that is used to parse the action part of the edit command. It also provides callbacks for each type of action such as select, goBefore, copyToClipboard, and delete for use in the edit_command action. The simple actions are defined in edit_command_actions.talon-list.

  • edit_navigation_steps.py: This file provides support for relative navigation. The navigation_step capture parses a spoken form of navigation (e.g. "go 2 words left") into a NavigationStep dataclass, which is then used by perform_navigation_steps to execute the navigation.

  • edit_paragraph.py: This file provides actions for navigating and selecting paragraphs. It includes actions like paragraph_start, paragraph_end, select_paragraph, delete_paragraph, cut_paragraph, copy_paragraph, and paste_paragraph. It also implements the helper functions is_line_empty, extend_paragraph_start_with_success, and extend_paragraph_end_with_success that are used to manipulate paragraphs.

  • delimiter_pair.py: This file defines actions for inserting and wrapping text with delimiter pairs. It introduces the delimiter_pair capture which parses a delimiter pair and the delimiter_pair_insert and delimiter_pair_wrap_selection actions that use the capture. The delimiter pairs are defined in delimiter_pair.talon-list.

  • insert_between.py: This file defines a helper action insert_between that can be used to insert text with the cursor in between.

  • edit.talon: This file contains the Talon code that binds spoken commands to the actions defined in the other files. It implements commands such as "select line", "clear all", "zoom in", "find it", "go left", "select left", "indent", "clear right", "copy that", "cut that", "paste that", "clone that", "new line above", "padding", and "undo that". It also includes a rule that maps <user.edit_action> <user.edit_modifier> to user.edit_command.

In summary, these files work together to provide a comprehensive and extensible editing framework. The OS-specific files define the basic actions, while the other files provide more advanced features and abstractions for use in edit.talon.

The lists used are: * edit_command_modifiers.talon-list defines the list of modifiers used by edit_command.py. * edit_command_actions.talon-list defines the list of actions used by edit_command.py. * delimiter_pair.talon-list defines the list of delimiter pairs used by delimiter_pair.py.