mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-23 08:47:47 +02:00
Remote control: When matching windows allow using negative id numbers to match recently created windows
Fixes #5753
This commit is contained in:
@@ -67,6 +67,8 @@ Detailed list of changes
|
|||||||
|
|
||||||
- Wayland: Fix signal handling not working with some GPU drivers (:iss:`4636`)
|
- Wayland: Fix signal handling not working with some GPU drivers (:iss:`4636`)
|
||||||
|
|
||||||
|
- Remote control: When matching windows allow using negative id numbers to match recently created windows (:iss:`5753`)
|
||||||
|
|
||||||
0.26.5 [2022-11-07]
|
0.26.5 [2022-11-07]
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|||||||
@@ -379,8 +379,16 @@ class Boss:
|
|||||||
tm = self.os_window_map.get(last_focused_os_window_id())
|
tm = self.os_window_map.get(last_focused_os_window_id())
|
||||||
if tm is not None:
|
if tm is not None:
|
||||||
tab = tm.active_tab
|
tab = tm.active_tab
|
||||||
|
window_id_limit = max(self.window_id_map, default=-1) + 1
|
||||||
|
|
||||||
def get_matches(location: str, query: str, candidates: Set[int]) -> Set[int]:
|
def get_matches(location: str, query: str, candidates: Set[int]) -> Set[int]:
|
||||||
|
if location == 'id' and query.startswith('-'):
|
||||||
|
try:
|
||||||
|
q = int(query)
|
||||||
|
except Exception:
|
||||||
|
return set()
|
||||||
|
if q < 0:
|
||||||
|
query = str(window_id_limit + q)
|
||||||
return {wid for wid in candidates if self.window_id_map[wid].matches_query(location, query, tab)}
|
return {wid for wid in candidates if self.window_id_map[wid].matches_query(location, query, tab)}
|
||||||
|
|
||||||
for wid in search(match, (
|
for wid in search(match, (
|
||||||
@@ -403,8 +411,18 @@ class Boss:
|
|||||||
if current_focused_os_window_id() <= 0:
|
if current_focused_os_window_id() <= 0:
|
||||||
tm = self.os_window_map.get(last_focused_os_window_id()) or tm
|
tm = self.os_window_map.get(last_focused_os_window_id()) or tm
|
||||||
tim = {t.id: t for t in self.all_tabs}
|
tim = {t.id: t for t in self.all_tabs}
|
||||||
|
tab_id_limit = max(tim, default=-1) + 1
|
||||||
|
window_id_limit = max(self.window_id_map, default=-1) + 1
|
||||||
|
|
||||||
def get_matches(location: str, query: str, candidates: Set[int]) -> Set[int]:
|
def get_matches(location: str, query: str, candidates: Set[int]) -> Set[int]:
|
||||||
|
if location in ('id', 'window_id') and query.startswith('-'):
|
||||||
|
try:
|
||||||
|
q = int(query)
|
||||||
|
except Exception:
|
||||||
|
return set()
|
||||||
|
if q < 0:
|
||||||
|
limit = tab_id_limit if location == 'id' else window_id_limit
|
||||||
|
query = str(limit + q)
|
||||||
return {wid for wid in candidates if tim[wid].matches_query(location, query, tm)}
|
return {wid for wid in candidates if tim[wid].matches_query(location, query, tm)}
|
||||||
|
|
||||||
found = False
|
found = False
|
||||||
|
|||||||
@@ -103,7 +103,8 @@ Where :italic:`field` can be one of: :code:`id`, :code:`title`, :code:`pid`, :co
|
|||||||
The special value :code:`all` matches all windows.
|
The special value :code:`all` matches all windows.
|
||||||
|
|
||||||
For numeric fields: :code:`id`, :code:`pid`, :code:`num` and :code:`recent`, the expression is interpreted as
|
For numeric fields: :code:`id`, :code:`pid`, :code:`num` and :code:`recent`, the expression is interpreted as
|
||||||
a number, not a regular expression.
|
a number, not a regular expression. Negative values for :code:`id` match from the highest id number down, in particular,
|
||||||
|
-1 is the most recently created window.
|
||||||
|
|
||||||
The field :code:`num` refers to the window position in the current tab, starting from zero and counting clockwise (this
|
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 :ref:`kitty @ ls <at-ls>` command).
|
is the same as the order in which the windows are reported by the :ref:`kitty @ ls <at-ls>` command).
|
||||||
@@ -134,7 +135,8 @@ Where :italic:`field` can be one of: :code:`id`, :code:`index`, :code:`title`, :
|
|||||||
The special value :code:`all` matches all tabs.
|
The special value :code:`all` matches all tabs.
|
||||||
|
|
||||||
For numeric fields: :code:`id`, :code:`index`, :code:`window_id`, :code:`pid` and :code:`recent`, the
|
For numeric fields: :code:`id`, :code:`index`, :code:`window_id`, :code:`pid` and :code:`recent`, the
|
||||||
expression is interpreted as a number, not a regular expression.
|
expression is interpreted as a number, not a regular expression. Negative values for :code:`id`/:code:`window_id` match
|
||||||
|
from the highest id number down, in particular, -1 is the most recently created tab/window.
|
||||||
|
|
||||||
When using :code:`title` or :code:`id`, first a matching tab is looked for, and if not found a matching window is looked
|
When using :code:`title` or :code:`id`, first a matching tab is looked for, and if not found a matching window is looked
|
||||||
for, and the tab for that window is used.
|
for, and the tab for that window is used.
|
||||||
|
|||||||
Reference in New Issue
Block a user