Allow matching on window/tab state

This commit is contained in:
Kovid Goyal
2022-04-12 20:14:01 +05:30
parent ade38870a0
commit b3fa7310cb
4 changed files with 41 additions and 13 deletions

View File

@@ -76,18 +76,21 @@ ArgsType = List[str]
MATCH_WINDOW_OPTION = '''\
--match -m
The window to match. Match specifications are of the form:
:italic:`field:regexp`. Where field can be one of: id, title, pid, cwd, cmdline, num, env and recent.
:italic:`field:regexp`. Where field can be one of: id, title, pid, cwd, cmdline, num, env, state and recent.
You can use the :italic:`ls` command to get a list of windows. Expressions can
be :ref:`combined using Boolean operators <search_syntax>`. Note that for
numeric fields such as id, pid, recent and num the expression is interpreted as a number,
not a regular expression. The field num refers to the window position in the current tab,
numeric fields such as :code:`id`, :code:`pid`, :code:`recent` and :code:`num` the expression is interpreted as a number,
not a regular expression. The field :code:`num` refers to the window position in the current tab,
starting from zero and counting clockwise (this is the same as the order in which the
windows are reported by the :italic:`ls` command). The window id of the current window
is available as the KITTY_WINDOW_ID environment variable. The field recent refers to recently
is available as the KITTY_WINDOW_ID environment variable. The field :code:`recent` refers to recently
active windows in the currently active tab, with zero being the currently active window, one being the previously active
window and so on. When using the :italic:`env` field
to match on environment variables you can specify only the environment variable name or a name
and value, for example, :italic:`env:MY_ENV_VAR=2`
and value, for example, :italic:`env:MY_ENV_VAR=2`. The field :code:`state` matches
on the state of the window. Supported states are: :code:`active`, :code:`focused` and :code:`needs_attention`.
Active windows are windows that are the active window in their parent tab. There is only one focused window
and it is the window to which keyboard events are delivered.
'''
MATCH_TAB_OPTION = '''\
--match -m
@@ -103,7 +106,10 @@ for that window is used. You can also use window_id and window_title to match
the tab that contains the window with the specified id or title. The index number
is used to match the nth tab in the currently active OS window. The recent number
matches recently active tabs in the currently active OS window, with zero being the currently
active tab, one the previously active tab and so on.
active tab, one the previously active tab and so on. The field :code:`state` matches
on the state of the tab. Supported states are: :code:`active`, :code:`focused` and :code:`needs_attention`.
Active tabs are tabs that are the active tab in their parent OS Window. There is only one focused tab
and it is the tab to which keyboard events are delivered.
'''