From 1f3d86a434fe678ea37eaf3af3b9b48e27d6846f Mon Sep 17 00:00:00 2001 From: pagedown Date: Sat, 4 Dec 2021 20:45:01 +0800 Subject: [PATCH] Add a new mappable action nth_os_window to focus OS window --- docs/changelog.rst | 3 +++ kitty/boss.py | 7 +++++++ kitty/options/utils.py | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 322b5ec33..2deed70d3 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -148,6 +148,9 @@ To update |kitty|, :doc:`follow the instructions `. - macOS: Fix keyboard input not working after toggling traditional fullscreen till the window is clicked in +- A new mappable action ``nth_os_window`` to to focus the specified nth OS + window. (:pull:`4316`) + 0.23.1 [2021-08-17] ---------------------- diff --git a/kitty/boss.py b/kitty/boss.py index 8ac74e0e4..5367d56e8 100755 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -1183,6 +1183,13 @@ class Boss: text = '\n'.join(parse_uri_list(text)) w.paste(text) + @ac('win', 'Focus the nth OS window') + def nth_os_window(self, num: int = 1) -> None: + if self.os_window_map and num > 0: + ids = list(self.os_window_map.keys()) + os_window_id = ids[min(num, len(ids)) - 1] + focus_os_window(os_window_id, True) + @ac('win', 'Close the currently active OS Window') def close_os_window(self) -> None: tm = self.active_tab_manager diff --git a/kitty/options/utils.py b/kitty/options/utils.py index 8a2bfce23..8736d81f6 100644 --- a/kitty/options/utils.py +++ b/kitty/options/utils.py @@ -250,7 +250,7 @@ def remote_control(func: str, rest: str) -> FuncArgsType: return func, args -@func_with_args('nth_window', 'scroll_to_prompt', 'visual_window_select_action_trigger') +@func_with_args('nth_os_window', 'nth_window', 'scroll_to_prompt', 'visual_window_select_action_trigger') def single_integer_arg(func: str, rest: str) -> FuncArgsType: try: num = int(rest)