chapters
Chapter Navigation Tag
The community/tags/chapters directory defines a standardized interface for navigating chapters in reading applications (such as e-book readers, document viewers, or daisy-book players). By defining a common tag and set of actions, it allows different application-specific contexts to implement their own chapter navigation mechanics while sharing a unified voice vocabulary.
How It Works
This module relies on Talon's tag-and-action system to decouple voice commands from application-specific implementations:
- chapters.py: Defines the
user.chapterstag and registers a set of action declarations under the@mod.action_classdecorator.chapter_current() -> int: An abstract action meant to return the current chapter number.chapter_jump(number: int): An abstract action meant to navigate to a specific chapter.chapter_final(): An abstract action meant to navigate to the last chapter.chapter_next()andchapter_previous(): Provided with default implementations that calculate the target chapter relative tochapter_current()and callchapter_jump().
- chapters.talon: Activates when the
user.chapterstag is enabled in the active context. It maps intuitive voice commands directly to the actions declared in the Python file.
Voice Commands
When the chapter tag is active, the following commands become available:
chapter next: Navigates to the next chapter.chapter last: Navigates to the previous chapter.go chapter <number>: Jumps directly to a specified chapter number.go chapter final: Jumps to the very last chapter.
To support these commands for a specific application, a developer only needs to activate the user.chapters tag in that application's context file and implement the actual keyboard shortcuts or API calls for chapter_current(), chapter_jump(), and chapter_final().