How to use the iterm2.api_pb2.VariableScope.Value 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 / variables.py View on Github external
import asyncio
import enum
import json
import typing

import iterm2.connection
import iterm2.notifications


class VariableScopes(enum.Enum):
    """Describes the scope in which a variable can be evaluated."""
    SESSION = iterm2.api_pb2.VariableScope.Value("SESSION")  #: Session scope
    TAB = iterm2.api_pb2.VariableScope.Value("TAB")  #: Tab scope
    WINDOW = iterm2.api_pb2.VariableScope.Value("WINDOW")  #: Window scope
    APP = iterm2.api_pb2.VariableScope.Value("APP")  #: Whole-app scope


class VariableMonitor:
    """
    Watches for changes to a variable.

    `VariableMonitor` is a context manager that helps observe changes in iTerm2
    Variables.

   :param connection: The connection to iTerm2.
   :param scope: The scope in which the variable should be evaluated.
   :param name: The variable name.
   :param identifier: A tab, window, or session identifier. Must correspond to
       the passed-in scope. If the scope is `APP` this should be None. If the
       scope is `SESSION` or `WINDOW` the identifier may be "all" or "active".
github gnachman / iTerm2 / api / library / python / iterm2 / iterm2 / notifications.py View on Github external
def _get_all_sessions_handler_keys_from_notification(notification):
    """Returns keys into _get_handlers() for a notification for the caller may
    have registered for all sessions/windows."""
    if notification.HasField('variable_changed_notification'):
        return [(iterm2.api_pb2.VariableScope.Value("SESSION"),
                 "all",
                 notification.variable_changed_notification.name,
                 iterm2.api_pb2.NOTIFY_ON_VARIABLE_CHANGE),

                (iterm2.api_pb2.VariableScope.Value("WINDOW"),
                 "all",
                 notification.variable_changed_notification.name,
                 iterm2.api_pb2.NOTIFY_ON_VARIABLE_CHANGE)]
    # Convert a session-specific key into an all-sessions key.
    standard_key, _ = _get_handler_key_from_notification(notification)
    return [(None, standard_key[1])]
github gnachman / iTerm2 / api / library / python / iterm2 / iterm2 / notifications.py View on Github external
def _get_all_sessions_handler_keys_from_notification(notification):
    """Returns keys into _get_handlers() for a notification for the caller may
    have registered for all sessions/windows."""
    if notification.HasField('variable_changed_notification'):
        return [(iterm2.api_pb2.VariableScope.Value("SESSION"),
                 "all",
                 notification.variable_changed_notification.name,
                 iterm2.api_pb2.NOTIFY_ON_VARIABLE_CHANGE),

                (iterm2.api_pb2.VariableScope.Value("WINDOW"),
                 "all",
                 notification.variable_changed_notification.name,
                 iterm2.api_pb2.NOTIFY_ON_VARIABLE_CHANGE)]
    # Convert a session-specific key into an all-sessions key.
    standard_key, _ = _get_handler_key_from_notification(notification)
    return [(None, standard_key[1])]
github gnachman / iTerm2 / api / library / python / iterm2 / iterm2 / variables.py View on Github external
with various objects such as sessions, tabs, and windows.
"""

import asyncio
import enum
import json
import typing

import iterm2.connection
import iterm2.notifications


class VariableScopes(enum.Enum):
    """Describes the scope in which a variable can be evaluated."""
    SESSION = iterm2.api_pb2.VariableScope.Value("SESSION")  #: Session scope
    TAB = iterm2.api_pb2.VariableScope.Value("TAB")  #: Tab scope
    WINDOW = iterm2.api_pb2.VariableScope.Value("WINDOW")  #: Window scope
    APP = iterm2.api_pb2.VariableScope.Value("APP")  #: Whole-app scope


class VariableMonitor:
    """
    Watches for changes to a variable.

    `VariableMonitor` is a context manager that helps observe changes in iTerm2
    Variables.

   :param connection: The connection to iTerm2.
   :param scope: The scope in which the variable should be evaluated.
   :param name: The variable name.
   :param identifier: A tab, window, or session identifier. Must correspond to
       the passed-in scope. If the scope is `APP` this should be None. If the
github gnachman / iTerm2 / api / library / python / iterm2 / iterm2 / variables.py View on Github external
Provides support for iTerm2 variables, which hold information associated
with various objects such as sessions, tabs, and windows.
"""

import asyncio
import enum
import json
import typing

import iterm2.connection
import iterm2.notifications


class VariableScopes(enum.Enum):
    """Describes the scope in which a variable can be evaluated."""
    SESSION = iterm2.api_pb2.VariableScope.Value("SESSION")  #: Session scope
    TAB = iterm2.api_pb2.VariableScope.Value("TAB")  #: Tab scope
    WINDOW = iterm2.api_pb2.VariableScope.Value("WINDOW")  #: Window scope
    APP = iterm2.api_pb2.VariableScope.Value("APP")  #: Whole-app scope


class VariableMonitor:
    """
    Watches for changes to a variable.

    `VariableMonitor` is a context manager that helps observe changes in iTerm2
    Variables.

   :param connection: The connection to iTerm2.
   :param scope: The scope in which the variable should be evaluated.
   :param name: The variable name.
   :param identifier: A tab, window, or session identifier. Must correspond to