Add resize_window configuration action

This patch adds the `resize_window` configuration action, which has the
following arguments:

1. Quality of resize amongst `wider`, `narrower`, `taller`, and
   `shorter` (mandatory).
2. Increment in number of cells (optional, default: 1).

This makes it possible to configure keys as such:

    map ctrl+shift+left resize_window narrower
    map ctrl+shift+right resize_window wider
    map ctrl+shift+up resize_window taller
    map ctrl+shift+down resize_window shorter

and have a behaviour which is somewhat close to Terminator's.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
This commit is contained in:
Philippe Proulx
2018-12-17 09:21:38 -05:00
parent b4a93c67c9
commit d22686da10
3 changed files with 55 additions and 0 deletions

View File

@@ -199,6 +199,24 @@ class Tab: # {{{
return
return 'Could not resize'
def resize_window(self, quality, increment):
if increment < 1:
raise ValueError(increment)
if quality == 'taller':
is_horizontal = False
elif quality == 'shorter':
is_horizontal = False
increment *= -1
elif quality == 'wider':
is_horizontal = True
elif quality == 'narrower':
is_horizontal = True
increment *= -1
else:
raise ValueError(quality)
self.resize_window_by(self.windows[self.active_window_idx].id,
increment, is_horizontal)
def reset_window_sizes(self):
if self.current_layout.remove_all_biases():
self.relayout()