How to use the iterm2.window.Window function in iterm2

To help you get started, we’ve selected a few iterm2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gnachman / iTerm2 / api / library / python / iterm2 / iterm2 / window.py View on Github external
if tab.HasField("tmux_window_id"):
                tmux_window_id = tab.tmux_window_id
            else:
                tmux_window_id = None
            tabs.append(
                iterm2.tab.Tab(
                    connection,
                    tab.tab_id,
                    root,
                    tmux_window_id,
                    tab.tmux_connection_id))

        if not tabs:
            return None

        return iterm2.window.Window(
            connection,
            window.window_id,
            tabs,
            window.frame,
            window.number)
github gnachman / iTerm2 / api / library / python / iterm2 / iterm2 / app.py View on Github external
connection: iterm2.connection.Connection) -> 'App':
        """Don't use this directly. Use :func:`async_get_app()`.

        Use this to construct a new hierarchy instead of __init__.
        This exists only because __init__ can't be async.
        """
        response = await iterm2.rpc.async_list_sessions(connection)
        list_sessions_response = response.list_sessions_response
        windows = App._windows_from_list_sessions_response(
            connection, list_sessions_response)
        buried_sessions = App._buried_sessions_from_list_sessions_response(
            connection, list_sessions_response)
        app = App(connection, windows, buried_sessions)
        iterm2.session.Session.delegate = app
        iterm2.tab.Tab.delegate = app
        iterm2.window.Window.delegate = app
        iterm2.tmux.DELEGATE = app

        # pylint: disable=protected-access
        await app._async_listen()
        # pylint: enable=protected-access
        await app.async_refresh_focus()
        await app.async_refresh_broadcast_domains()
        return app
github gnachman / iTerm2 / api / library / python / iterm2 / iterm2 / app.py View on Github external
else:
        await App.instance.async_refresh()
    return App.instance


# See note in tmux.async_get_tmux_connections()
iterm2.tmux.DELEGATE_FACTORY = async_get_app  # type: ignore
iterm2.window.DELEGATE_FACTORY = async_get_app  # type: ignore


# pylint: disable=too-many-public-methods
class App(
        iterm2.session.Session.Delegate,
        iterm2.tab.Tab.Delegate,
        iterm2.tmux.Delegate,
        iterm2.window.Window.Delegate):
    """Represents the application.

    Stores and provides access to app-global state. Holds a collection of
    terminal windows and provides utilities for them.

    This object keeps itself up to date by getting notifications when sessions,
    tabs, or windows change.
    """
    instance: typing.Union[None, 'App'] = None

    @staticmethod
    async def async_construct(
            connection: iterm2.connection.Connection) -> 'App':
        """Don't use this directly. Use :func:`async_get_app()`.

        Use this to construct a new hierarchy instead of __init__.
github gnachman / iTerm2 / api / library / python / iterm2 / iterm2 / app.py View on Github external
async def tmux_delegate_async_get_window_for_tab_id(
            self, tab_id: str) -> typing.Optional[iterm2.window.Window]:
        await self.async_refresh()
        return self.get_window_for_tab(tab_id)
github gnachman / iTerm2 / api / library / python / iterm2 / iterm2 / hierarchy.py View on Github external
def _windows_from_list_sessions_response(connection, response):
    windows = []
    for w in response.windows:
      tabs = []
      for t in w.tabs:
        root = iterm2.session.Splitter.from_node(t.root, connection)
        tabs.append(iterm2.tab.Tab(connection, t.tab_id, root))
      windows.append(iterm2.window.Window(connection, w.window_id, tabs, w.frame))
    return windows
github gnachman / iTerm2 / api / library / python / iterm2 / iterm2 / app.py View on Github external
                map(lambda window: iterm2.window.Window.create_from_proto(
                    connection, window),
                    response.windows)))
github gnachman / iTerm2 / api / library / python / iterm2 / iterm2 / tmux.py View on Github external
async def tmux_delegate_async_get_window_for_tab_id(
            self, tab_id: str) -> typing.Optional[iterm2.window.Window]:
        """Refreshes and gets the window for the specified tab."""