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 theContext
class 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.py
definescopy
asctrl-c
, whileedit_mac.py
definescopy
ascmd-c
. -
edit.py
: This file provides more advanced actions that are not specific to any operating system. It defines things likeselected_text
to retrieve the currently selected text using the clipboard,line_insert_down
,selection_clone
, andline_clone
, as well as more robustselect_word
functionality. It also contains actions such aspaste
which preserves the clipboard,delete_right
which deletes a single character to the right of the cursor, andwords_left
andwords_right
which 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_middle
to manipulate text at the word and line level. -
edit_command.py
: This file defines theedit_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 theEditModifier
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 asdocument
,paragraph
,word
, andline
for use in theedit_command
action. The modifiers are defined inedit_command_modifiers.talon-list
. -
edit_command_actions.py
: This file defines theEditAction
dataclasses (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
, anddelete
for use in theedit_command
action. The simple actions are defined inedit_command_actions.talon-list
. -
edit_navigation_steps.py
: This file provides support for relative navigation. Thenavigation_step
capture parses a spoken form of navigation (e.g. "go 2 words left") into aNavigationStep
dataclass, which is then used byperform_navigation_steps
to 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_success
that are used to manipulate paragraphs. -
delimiter_pair.py
: This file defines actions for inserting and wrapping text with delimiter pairs. It introduces thedelimiter_pair
capture which parses a delimiter pair and thedelimiter_pair_insert
anddelimiter_pair_wrap_selection
actions that use the capture. The delimiter pairs are defined indelimiter_pair.talon-list
. -
insert_between.py
: This file defines a helper actioninsert_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>
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
.