Focus¶
- class FocusMonitor(connection: Connection)¶
An asyncio context manager for monitoring keyboard focus changes.
- Parameters:
connection – A connection to iTerm2.
See also
Example “Persistent MRU Tabs”
- async async_get_next_update() FocusUpdate¶
When focus changes, returns an update.
- Returns:
A
FocusUpdateobject.
Example:
async with iterm2.FocusMonitor(connection) as monitor: while True: update = await monitor.async_get_next_update() if update.selected_tab_changed: print("The active tab is now {}". format(update.selected_tab_changed.tab_id))
- class FocusUpdate(application_active: FocusUpdateApplicationActive | None = None, window_changed: FocusUpdateWindowChanged | None = None, selected_tab_changed: FocusUpdateSelectedTabChanged | None = None, active_session_changed: FocusUpdateActiveSessionChanged | None = None)¶
Describes a change to keyboard focus.
Up to one of application_active, window_changed, selected_tab_changed, or active_session_changed will not be None.
- property active_session_changed: None | FocusUpdateActiveSessionChanged¶
- Returns:
None if no change to active session, otherwise
FocusUpdateActiveSessionChanged.
- property application_active: None | FocusUpdateApplicationActive¶
- Returns:
None if no change to whether the app is active, otherwise
FocusUpdateApplicationActive
- property selected_tab_changed: None | FocusUpdateSelectedTabChanged¶
- Returns:
None if no change to selected tab, otherwise
FocusUpdateSelectedTabChanged.
- property window_changed: None | FocusUpdateWindowChanged¶
- Returns:
None if no change to the current window, otherwise
FocusUpdateWindowChanged.
- class FocusUpdateActiveSessionChanged(session_id: str)¶
Describes a change to the active session within a tab.
- class FocusUpdateWindowChanged(window_id: str, event: Reason)¶
Describes a change in which window is focused.
- class FocusUpdateWindowChanged.Reason(value)¶
Gives the reason for the change
- TERMINAL_WINDOW_BECAME_KEY = 0¶
A terminal window received keyboard focus.
- TERMINAL_WINDOW_IS_CURRENT = 1¶
A terminal window is current but some non-terminal window (such as Preferences) has keyboard focus.
- TERMINAL_WINDOW_RESIGNED_KEY = 2¶
A terminal window no longer has keyboard focus.
- class FocusUpdateApplicationActive(active)¶
Describes a change in whether the application is active.
