Skip to content

text

The community/core/text directory contains files that define how Talon handles text input and formatting. It includes lists of words and phrases, as well as Python code to manipulate text. Here's a breakdown of the key files and how they work together:

  • currency.talon-list: This file defines a list of currency symbols and their spoken forms, such as "dollar" and "$". This allows users to speak currency amounts and have them correctly inserted.

  • prose_modifiers.talon-list: This file lists modifiers that can be used within prose, such as "cap", "no cap", and "no space". These modifiers are used to change the formatting of text, for example to capitalize the next word, prevent capitalization, or remove spaces. These modifiers are referenced in text_and_dictation.py.

  • prose_snippets.talon-list: This file contains common text snippets like "spacebar", "new line", and "open quote". These snippets provide convenient ways to insert common text elements by voice.

  • phrase_ender.talon-list: This file defines a list of commands that can be used to end a phrase, such as "over". This is used in text.talon to provide both anchored and unanchored phrase commands.

  • text.talon: This is the main Talon script for text manipulation. It defines commands for inserting text, formatting prose, and working with the phrase history. It uses the lists defined in other files to provide functionality. Key features include:

    • Inserting text with optional phrase enders.
    • Formatting prose using user.prose_formatter.
    • Inserting formatted code using user.format_code.
    • Reformatting selections using user.formatters.
    • Formatting individual words using user.word_formatter.
    • Managing a phrase history with commands such as "recent list", "recent repeat", and "recent copy."
    • Selecting, deleting and reformatting the last phrase using "select that", "nope that", and "nope that was".
    • Abbreviating words using "abbreviate" and user.abbreviation.
  • text_and_dictation.py: This Python file contains the core logic for text formatting and dictation. It defines captures for words, phrases, and prose, and handles auto-spacing and capitalization. It also provides the DictationFormat class, which is used to format text based on the surrounding context and applied modifiers. The dictation_insert action is used to insert formatted text, and dictation_peek peeks at surrounding text. The DictationFormat class is used by the various prose captures to provide auto spacing and capitalization. It is also used by the dictation_insert action for the same purpose. This file also defines the lists user.hours_twelve, user.hours, and user.minutes.

  • phrase_history.py: This Python file manages a history of recently spoken phrases. It provides actions for getting, clearing, and selecting the last phrase, as well as adding a new phrase to the history. It also provides a GUI for viewing the phrase history. The phrase history is used by commands such as "recent repeat", "recent copy", "select that" and "nope that".

In summary, these files work together to provide a comprehensive system for text input and manipulation in Talon. The .talon-list files define lists of words and phrases, the text.talon file defines commands, and the Python files contain the core logic for formatting and managing the phrase history. The text_and_dictation.py file is central, providing the DictationFormat class and the dictation_insert action, as well as many of the text captures used in text.talon.