Add a new mappable action nth_os_window to focus OS window

This commit is contained in:
pagedown 2021-12-04 20:45:01 +08:00
parent 0456399ce5
commit 1f3d86a434
No known key found for this signature in database
GPG Key ID: E921CF18AC8FF6EB
3 changed files with 11 additions and 1 deletions

View File

@ -148,6 +148,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- macOS: Fix keyboard input not working after toggling traditional fullscreen - macOS: Fix keyboard input not working after toggling traditional fullscreen
till the window is clicked in 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] 0.23.1 [2021-08-17]
---------------------- ----------------------

View File

@ -1183,6 +1183,13 @@ class Boss:
text = '\n'.join(parse_uri_list(text)) text = '\n'.join(parse_uri_list(text))
w.paste(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') @ac('win', 'Close the currently active OS Window')
def close_os_window(self) -> None: def close_os_window(self) -> None:
tm = self.active_tab_manager tm = self.active_tab_manager

View File

@ -250,7 +250,7 @@ def remote_control(func: str, rest: str) -> FuncArgsType:
return func, args 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: def single_integer_arg(func: str, rest: str) -> FuncArgsType:
try: try:
num = int(rest) num = int(rest)