talon_draft_window
The talon_draft_window
directory contains the code for a Talon plugin that provides a dedicated window for editing text, using a system of word labels to enable voice-driven manipulation.
The core logic resides in these files:
draft_talon_helpers.py
: This file sets up the Talon module, contexts, settings, and actions that manage the draft window. It initializes theDraftManager
which is responsible for the UI. It also handles settings for the window's theme, text size, and label styling. It defines actions for showing, hiding, selecting text, positioning the caret, and resizing the draft window. It also includes a workaround for the experimental textarea's undo functionality. Finally it defines capture groups for anchors (<user.draft_anchor>
) and positions (<user.draft_window_position>
).draft_ui.py
: This file contains theDraftManager
class, which manages the text area using Talon's experimental textarea API, and the logic to generate word labels. It implementscalculate_text_anchors
which assigns a letter to each word in the draft window. This class also sets the style of the text area, and handles moving and resizing of the window.
These files provide the user-facing interface and customization options:
draft_window_open.talon
: This file defines Talon commands that are active when the draft window is open (but not necessarily focused). It includes commands to hide the window and to submit the text in the window back to the editor.draft_window.talon
: This file contains Talon commands that are active when the draft window is focused. It defines commands for replacing words, positioning the cursor, selecting words, deleting words and applying formatters using the anchor labels. It also enables smart dictation mode.settings.talon.example
: Provides example settings that the user can copy into their own Talon files to customize the appearance of the draft window.
These files support the plugin's functionality:
__init__.py
: An empty file that allows pytest to run the tests.test_draft_ui.py
: Contains unit tests for thecalculate_text_anchors
function indraft_ui.py
.LICENSE
: Contains the MIT license for this project.
Finally, draft_global.talon
defines commands to show the draft window globally in command mode. It includes commands to open the window in different positions and sizes, and also to copy the current selection into the draft window.
In summary, draft_talon_helpers.py
and draft_ui.py
implement the core functionality of the plugin. The .talon
files provide the voice commands to make use of the functionality, while test_draft_ui.py
and LICENSE
provide support and licensing. README.md
provides documentation about how to use the plugin.