A new swap_with_window mappable action

Allows visual selection of a window to swap with the current window
This commit is contained in:
Kovid Goyal 2021-10-17 12:47:13 +05:30
parent 0de319fc73
commit a4a7d49bed
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
5 changed files with 13 additions and 2 deletions

View File

@ -58,6 +58,7 @@ Move window forward :sc:`move_window_forward`
Move window backward :sc:`move_window_backward`
Move window to top :sc:`move_window_to_top`
Visually focus window :sc:`focus_visible_window`
Visually swap window :sc:`swap_with_window`
Focus specific window :sc:`first_window`, :sc:`second_window` ... :sc:`tenth_window`
(also :kbd:`⌘+1`, :kbd:`⌘+2` ... :kbd:`⌘+9` on macOS)
(clockwise from the top-left)

View File

@ -32,7 +32,7 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
the request by default instead of denying by default. See
:opt:`clipboard_control` for details (:iss:`4022`)
- A new mappable action ``select_window_in_tab`` to select a window in the current tab to switch to, by window title
- A new mappable action ``swap_with_window`` to swap the current window with another window in the tab, visually
- A new option :opt:`bell_path` to specify the path to a sound file
to use as the bell sound

View File

@ -3152,6 +3152,7 @@ map('Tenth window',
)
map('Visually select focus window', 'focus_visible_window kitty_mod+f7 focus_visible_window')
map('Visually swap window with another', 'swap_with_window kitty_mod+f8 swap_with_window')
egr() # }}}

View File

@ -769,6 +769,8 @@ defaults.map = [
KeyDefinition(False, KeyAction('tenth_window'), 1024, False, 48, ()),
# focus_visible_window
KeyDefinition(False, KeyAction('focus_visible_window'), 1024, False, 57370, ()),
# swap_with_window
KeyDefinition(False, KeyAction('swap_with_window'), 1024, False, 57371, ()),
# next_tab
KeyDefinition(False, KeyAction('next_tab'), 1024, False, 57351, ()),
# next_tab

View File

@ -572,7 +572,8 @@ class Tab: # {{{
if group is not None:
w = self.active_window
if w is not None and w.id != window_id:
self.current_layout.move_window_to_group(self.windows, group.id)
if self.current_layout.move_window_to_group(self.windows, group.id):
self.relayout()
@ac('win', '''
Focus a visible window by pressing the number of the window. Window numbers are displayed
@ -584,6 +585,12 @@ class Tab: # {{{
get_boss().visual_window_select_action(self, callback, 'Choose window to switch to')
@ac('win', 'Swap the current window with another window in the current tab, selected visually')
def swap_with_window(self) -> None:
def callback(tab: Tab, window: Window) -> None:
tab.swap_active_window_with(window.id)
get_boss().visual_window_select_action(self, callback, 'Choose window to swap with')
@ac('win', 'Move active window to the top (make it the first window)')
def move_window_to_top(self) -> None:
n = self.windows.active_group_idx