Shortcut to move window to top

This commit is contained in:
Kovid Goyal 2016-12-08 12:34:40 +05:30
parent 32d73cfaf0
commit 9d75d91f47
3 changed files with 7 additions and 2 deletions

View File

@ -157,6 +157,7 @@ windows are:
|Previous window | {sc_previous_window}
|Move window forward | {sc_move_window_forward}
|Move window backward | {sc_move_window_backward}
|Move window to top | {sc_move_window_to_top}
|Focus specific window (windows are counted clockwise from the top left corner) | {sc_first_window}, {sc_second_window} ... {sc_tenth_window}
|===

View File

@ -1,4 +1,4 @@
# vim:fileencoding=utf-8:ft=config
# vim:fileencoding=utf-8:ft=conf
# Font family
font_family monospace
@ -145,6 +145,7 @@ map ctrl+shift+] next_window
map ctrl+shift+[ previous_window
map ctrl+shift+f move_window_forward
map ctrl+shift+b move_window_backward
map ctrl+shift+` move_window_to_top
map ctrl+shift+1 first_window
map ctrl+shift+2 second_window
map ctrl+shift+3 third_window

View File

@ -144,13 +144,16 @@ class Tab:
self._next_window(-1)
def move_window(self, delta=1):
if len(self.windows) > 1:
if len(self.windows) > 1 and abs(delta) > 0:
idx = self.active_window_idx
nidx = (idx + len(self.windows) + delta) % len(self.windows)
self.windows[nidx], self.windows[idx] = self.windows[idx], self.windows[nidx]
self.active_window_idx = nidx
self.relayout()
def move_window_to_top(self):
self.move_window(-self.active_window_idx)
def move_window_forward(self):
self.move_window()