mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-28 03:01:57 +02:00
add new-tab-neighbor option to detach_window
This commit is contained in:
committed by
Kovid Goyal
parent
1a9a7a59ac
commit
4575608a97
@@ -2677,6 +2677,8 @@ class Boss:
|
|||||||
tm = self.os_window_map[target_os_window_id]
|
tm = self.os_window_map[target_os_window_id]
|
||||||
if target_tab_id == 'new':
|
if target_tab_id == 'new':
|
||||||
target_tab = tm.new_tab(empty_tab=True)
|
target_tab = tm.new_tab(empty_tab=True)
|
||||||
|
elif target_tab_id == 'new_as_neighbor':
|
||||||
|
target_tab = tm.new_tab(empty_tab=True, as_neighbor=True)
|
||||||
else:
|
else:
|
||||||
target_tab = tm.tab_at_location(target_tab_id) or tm.new_tab(empty_tab=True)
|
target_tab = tm.tab_at_location(target_tab_id) or tm.new_tab(empty_tab=True)
|
||||||
else:
|
else:
|
||||||
@@ -2767,8 +2769,13 @@ class Boss:
|
|||||||
def detach_window(self, *args: str) -> None:
|
def detach_window(self, *args: str) -> None:
|
||||||
if not args or args[0] == 'new':
|
if not args or args[0] == 'new':
|
||||||
return self._move_window_to(target_os_window_id='new')
|
return self._move_window_to(target_os_window_id='new')
|
||||||
if args[0] in ('new-tab', 'tab-prev', 'tab-left', 'tab-right'):
|
if args[0] in ('new-tab', 'tab-prev', 'tab-left', 'tab-right', 'new-tab-neighbor'):
|
||||||
where = 'new' if args[0] == 'new-tab' else args[0][4:]
|
if args[0] == 'new-tab':
|
||||||
|
where = 'new'
|
||||||
|
elif args[0] == 'new-tab-neighbor':
|
||||||
|
where = 'new_as_neighbor'
|
||||||
|
else:
|
||||||
|
where = args[0][4:]
|
||||||
return self._move_window_to(target_tab_id=where)
|
return self._move_window_to(target_tab_id=where)
|
||||||
ct = self.active_tab
|
ct = self.active_tab
|
||||||
items: List[Tuple[Union[str, int], str]] = [(t.id, t.effective_title) for t in self.all_tabs if t is not ct]
|
items: List[Tuple[Union[str, int], str]] = [(t.id, t.effective_title) for t in self.all_tabs if t is not ct]
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ def goto_tab_parse(func: str, rest: str) -> FuncArgsType:
|
|||||||
|
|
||||||
@func_with_args('detach_window')
|
@func_with_args('detach_window')
|
||||||
def detach_window_parse(func: str, rest: str) -> FuncArgsType:
|
def detach_window_parse(func: str, rest: str) -> FuncArgsType:
|
||||||
if rest not in ('new', 'new-tab', 'ask', 'tab-prev', 'tab-left', 'tab-right'):
|
if rest not in ('new', 'new-tab', 'new-tab-neighbor', 'ask', 'tab-prev', 'tab-left', 'tab-right'):
|
||||||
log_error(f'Ignoring invalid detach_window argument: {rest}')
|
log_error(f'Ignoring invalid detach_window argument: {rest}')
|
||||||
rest = 'new'
|
rest = 'new'
|
||||||
return func, (rest,)
|
return func, (rest,)
|
||||||
|
|||||||
Reference in New Issue
Block a user