Skip to content

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, particularly window_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], and snap 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>+, and snap <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 predefined RelativeScreenPos 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, and windows_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 define app actions which are then used within the window_management.talon file.

    • They define app actions like tab_close, tab_next, window_close, window_hide, window_open and platform specific actions like window_hide_others and preferences.
    • They also implement user actions such as switcher_focus_last with platform-specific keybindings.
  • tabs.py: This file defines generic tab actions that can be used across different applications. It includes actions such as tab_jump, tab_final, tab_close_wrapper, and tab_duplicate. The tab_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 in tabs.py and the app actions defined in the platform-specific windows_and_tabs files.

  • windows_and_tabs.py: This file provides some cross-platform window cycling actions. The window_next and window_previous actions cycle through all valid windows of the active application. It defines a helper function is_window_valid to determine which windows to include in the cycling and a helper function cycle_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.