Skip to content

text_navigation

The community/plugin/text_navigation directory contains files that enable advanced text navigation using Talon. It allows users to move, select, copy, cut, or delete text based on various criteria, including specific characters, phrases, or predefined units like words or parenthesized expressions.

The core logic resides in text_navigation.py. It defines the navigation action, which takes a direction, a target (specified by a regex), an action (like "GO", "SELECT", "COPY", etc), and a position relative to the target (before or after). This action is then used to perform the requested text operation. The file also provides helper functions for finding text in different directions, handling different actions and selections, and moving the cursor. There are also a number of lists defined here which are referenced in the talon files.

The text_navigation.talon file defines the grammar that allows users to invoke the text navigation commands. The main command navigate takes a variety of options: an arrow key direction (left, right, up, down), a navigation action (move, extend, select, cut, copy, clear), a navigation target name, a before/after specifier, an ordinal number, and a navigation target itself. The file also contains some convenience commands for selecting words, small words, or big words.

The before_or_after.talon-list defines the vocabulary for specifying the position of the cursor relative to the target text, such as "before" or "after". The navigation_action.talon-list defines the vocabulary for the different navigation actions, such as "move", "extend", "select", "clear", "cut", and "copy". These lists are then used in the text_navigation.talon grammar.

Together, these files enable complex text navigation with voice commands. For example, a user could say "navigate left copy third word" to copy the third word to the left of the cursor, or "navigate up clear phrase I think" to delete the next occurrence of "I think" on the preceding lines.