windows_and_tabs
The community/core/windows_and_tabs
directory contains files for managing windows and tabs across different operating systems using Talon. It includes functionality for moving, resizing, and switching between windows and tabs, as well as snapping windows to specific screen positions.
Here's a breakdown of the key files and how they work together:
-
window_management.talon
: This file defines the core voice commands for window management. It uses actions defined in other files, particularlywindow_snap.py
, to implement features like:- Opening, closing, hiding, and focusing windows.
- Moving windows between screens.
- Snapping windows to predefined positions on the screen using the commands
snap <user.window_snap_position>
,snap next [screen]
,snap last [screen]
, andsnap screen <number>
. - Snapping applications to specific positions or screens using the commands
snap <user.running_applications> <user.window_snap_position>
,snap <user.window_split_position> <user.running_applications> <user.running_applications>+
, andsnap <user.running_applications> [screen] <number>
.
-
window_snap.py
: This file contains the logic for snapping windows to various positions and moving windows between screens. It defines:RelativeScreenPos
: A class representing a window position as a fraction of the screen._snap_positions
: A dictionary of predefinedRelativeScreenPos
objects with names such as "left", "right", "top left", and "full"._split_positions
: A dictionary of predefined layouts for splitting the screen between multiple applications.- Actions for snapping the active window or a specific application to a predefined position, moving a window to the next or previous screen, and moving a window to a specific screen.
- An action for snapping multiple applications to the screen using a predefined layout.
- A setting
user.window_snap_screen
that defines how windows are positioned and sized when moving between different physical screens.
-
windows_and_tabs_win.py
,windows_and_tabs_mac.py
, andwindows_and_tabs_linux.py
: These files provide platform-specific implementations for common window and tab actions, such as closing, opening, and switching between windows and tabs. These files defineapp
actions which are then used within thewindow_management.talon
file.- They define
app
actions liketab_close
,tab_next
,window_close
,window_hide
,window_open
and platform specific actions likewindow_hide_others
andpreferences
. - They also implement
user
actions such asswitcher_focus_last
with platform-specific keybindings.
- They define
-
tabs.py
: This file defines generic tab actions that can be used across different applications. It includes actions such astab_jump
,tab_final
,tab_close_wrapper
, andtab_duplicate
. Thetab_close_wrapper
action is designed to allow apps to implement their own delays before closing a tab, to handle repetitions better. -
tabs.talon
: This file defines voice commands for tab management, utilizing the actions defined intabs.py
and theapp
actions defined in the platform-specificwindows_and_tabs
files. -
windows_and_tabs.py
: This file provides some cross-platform window cycling actions. Thewindow_next
andwindow_previous
actions cycle through all valid windows of the active application. It defines a helper functionis_window_valid
to determine which windows to include in the cycling and a helper functioncycle_windows
which provides the window cycling logic.
In summary, these files work together to provide a comprehensive set of voice commands for managing windows and tabs across different operating systems. The window_management.talon
file is the primary entry point, using actions defined in window_snap.py
, the platform-specific windows_and_tabs_*.py
files, and tabs.py
to implement window and tab management features. The windows_and_tabs.py
file provides some cross-platform window cycling actions to complement platform-specific actions.