Add a new action :ref:detach_window that can be used to move the current window into a different tab
Fixes #1310
This commit is contained in:
parent
18619b14ac
commit
35ab7eb472
@ -7,6 +7,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
|
|||||||
0.15.0 [future]
|
0.15.0 [future]
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
|
- Add a new action :ref:`detach_window` that can be used to move the current
|
||||||
|
window into a different tab (:iss:`1310`)
|
||||||
|
|
||||||
- Add a new style ``powerline`` for tab bar rendering, see :opt:`tab_bar_style` (:pull:`2021`)
|
- Add a new style ``powerline`` for tab bar rendering, see :opt:`tab_bar_style` (:pull:`2021`)
|
||||||
|
|
||||||
- Allow changing colors by mapping a keyboard shortcut to read a kitty config
|
- Allow changing colors by mapping a keyboard shortcut to read a kitty config
|
||||||
|
|||||||
@ -173,6 +173,15 @@ You can also define a shortcut to switch to the previously active window::
|
|||||||
``nth_window`` will focus the nth window for positive numbers and the
|
``nth_window`` will focus the nth window for positive numbers and the
|
||||||
previously active windows for negative numbers.
|
previously active windows for negative numbers.
|
||||||
|
|
||||||
|
.. _detach_window:
|
||||||
|
|
||||||
|
Finally you can define shortcuts to detach the current window and
|
||||||
|
move it to another tab or another OS window::
|
||||||
|
|
||||||
|
map ctrl+f2 detach_window # moves the window into a new OS window
|
||||||
|
map ctrl+f3 detach_window new-tab # moves the window into a new Tab
|
||||||
|
map ctrl+f4 detach_window ask # asks which tab to move the window into
|
||||||
|
|
||||||
|
|
||||||
Other keyboard shortcuts
|
Other keyboard shortcuts
|
||||||
----------------------------------
|
----------------------------------
|
||||||
|
|||||||
@ -675,7 +675,7 @@ class Boss:
|
|||||||
output += str(s.linebuf.line(i))
|
output += str(s.linebuf.line(i))
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def _run_kitten(self, kitten, args=(), input_data=None, window=None):
|
def _run_kitten(self, kitten, args=(), input_data=None, window=None, custom_callback=None):
|
||||||
orig_args, args = list(args), list(args)
|
orig_args, args = list(args), list(args)
|
||||||
from kittens.runner import create_kitten_handler
|
from kittens.runner import create_kitten_handler
|
||||||
end_kitten = create_kitten_handler(kitten, orig_args)
|
end_kitten = create_kitten_handler(kitten, orig_args)
|
||||||
@ -724,7 +724,7 @@ class Boss:
|
|||||||
),
|
),
|
||||||
copy_colors_from=w
|
copy_colors_from=w
|
||||||
)
|
)
|
||||||
overlay_window.action_on_close = partial(self.on_kitten_finish, w.id, end_kitten)
|
overlay_window.action_on_close = partial(self.on_kitten_finish, w.id, custom_callback or end_kitten)
|
||||||
return overlay_window
|
return overlay_window
|
||||||
|
|
||||||
def kitten(self, kitten, *args):
|
def kitten(self, kitten, *args):
|
||||||
@ -1142,6 +1142,28 @@ class Boss:
|
|||||||
target_tab.make_active()
|
target_tab.make_active()
|
||||||
|
|
||||||
def detach_window(self, *args):
|
def detach_window(self, *args):
|
||||||
if not args:
|
if not args or args[0] == 'new':
|
||||||
|
return self._move_window_to(target_os_window_id='new')
|
||||||
|
if args[0] == 'new-tab':
|
||||||
return self._move_window_to(target_tab_id='new')
|
return self._move_window_to(target_tab_id='new')
|
||||||
# TODO: Implementthis
|
lines = [
|
||||||
|
'Choose a tab to move the window to',
|
||||||
|
''
|
||||||
|
]
|
||||||
|
tab_id_map = {}
|
||||||
|
for i, tab in enumerate(self.all_tabs):
|
||||||
|
tab_id_map[i + 1] = tab.id
|
||||||
|
lines.append('{} {}'.format(i + 1, tab.title))
|
||||||
|
|
||||||
|
def done(data, target_window_id, self):
|
||||||
|
target_window = None
|
||||||
|
for w in self.all_windows:
|
||||||
|
if w.id == target_window_id:
|
||||||
|
target_window = w
|
||||||
|
break
|
||||||
|
tab_id = tab_id_map[int(data['match'][0].partition(' ')[0])]
|
||||||
|
self._move_window_to(window=target_window, target_tab_id=tab_id)
|
||||||
|
|
||||||
|
self._run_kitten(
|
||||||
|
'hints', args=('--type=regex', r'--regex=(?m)^\d+ .+$',),
|
||||||
|
input_data='\r\n'.join(lines).encode('utf-8'), custom_callback=done)
|
||||||
|
|||||||
@ -94,7 +94,9 @@ def goto_tab_parse(func, rest):
|
|||||||
|
|
||||||
@func_with_args('detach_window')
|
@func_with_args('detach_window')
|
||||||
def detach_window_parse(func, rest):
|
def detach_window_parse(func, rest):
|
||||||
return func, to_cmdline(rest)
|
if rest not in ('new', 'new-tab', 'ask'):
|
||||||
|
rest = 'new'
|
||||||
|
return func, (rest,)
|
||||||
|
|
||||||
|
|
||||||
@func_with_args('set_background_opacity', 'goto_layout', 'kitty_shell')
|
@func_with_args('set_background_opacity', 'goto_layout', 'kitty_shell')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user