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, andedit_win.py: These files define the basic edit actions for Linux, macOS, and Windows, respectively. They use theContextclass from Talon to define actions that are specific to each operating system. These files are all structured similarly and define actions such ascopy,cut,delete, navigation, and selection using native OS keyboard shortcuts. For example,edit_linux.pydefinescopyasctrl-c, whileedit_mac.pydefinescopyascmd-c. -
edit.py: This file provides more advanced actions that are not specific to any operating system. It defines things likeselected_textto retrieve the currently selected text using the clipboard,line_insert_down,selection_clone, andline_clone, as well as more robustselect_wordfunctionality. It also contains actions such aspastewhich preserves the clipboard,delete_rightwhich deletes a single character to the right of the cursor, andwords_leftandwords_rightwhich move the cursor by a given number of words. Finally, it also definescut_word_left,cut_word_right,copy_word_left,copy_word_right,select_line_start,select_line_end, andline_middleto manipulate text at the word and line level. -
edit_command.py: This file defines theedit_commandaction 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 theEditModifierclass 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 asdocument,paragraph,word, andlinefor use in theedit_commandaction. The modifiers are defined inedit_command_modifiers.talon-list. -
edit_command_actions.py: This file defines theEditActiondataclasses (EditSimpleAction,EditInsertAction,EditWrapAction, andEditFormatAction) 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 asselect,goBefore,copyToClipboard, anddeletefor use in theedit_commandaction. The simple actions are defined inedit_command_actions.talon-list. -
edit_navigation_steps.py: This file provides support for relative navigation. Thenavigation_stepcapture parses a spoken form of navigation (e.g. "go 2 words left") into aNavigationStepdataclass, which is then used byperform_navigation_stepsto execute the navigation. -
edit_paragraph.py: This file provides actions for navigating and selecting paragraphs. It includes actions likeparagraph_start,paragraph_end,select_paragraph,delete_paragraph,cut_paragraph,copy_paragraph, andpaste_paragraph. It also implements the helper functionsis_line_empty,extend_paragraph_start_with_success, andextend_paragraph_end_with_successthat are used to manipulate paragraphs. -
delimiter_pair.py: This file defines actions for inserting and wrapping text with delimiter pairs. It introduces thedelimiter_paircapture which parses a delimiter pair and thedelimiter_pair_insertanddelimiter_pair_wrap_selectionactions that use the capture. The delimiter pairs are defined indelimiter_pair.talon-list. -
insert_between.py: This file defines a helper actioninsert_betweenthat 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>touser.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.