Allow passing a "reset" argument to resize_window

This commit is contained in:
Kovid Goyal 2022-02-11 08:16:17 +05:30
parent c4b3bbd057
commit 1c48ec7196
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 6 additions and 1 deletions

View File

@ -248,6 +248,8 @@ action, for example::
map ctrl+right resize_window wider map ctrl+right resize_window wider
map ctrl+up resize_window taller map ctrl+up resize_window taller
map ctrl+down resize_window shorter 3 map ctrl+down resize_window shorter 3
# reset all windows to default sizes
map ctrl+home resize_window reset
The ``resize_window`` action has a second, optional argument to control The ``resize_window`` action has a second, optional argument to control
the resizing increment (a positive integer that defaults to 1). the resizing increment (a positive integer that defaults to 1).

View File

@ -211,7 +211,7 @@ def resize_window(func: str, rest: str) -> FuncArgsType:
args = ['wider', 1] args = ['wider', 1]
else: else:
quality = vals[0].lower() quality = vals[0].lower()
if quality not in ('taller', 'shorter', 'wider', 'narrower'): if quality not in ('reset', 'taller', 'shorter', 'wider', 'narrower'):
log_error(f'Invalid quality specification: {quality}') log_error(f'Invalid quality specification: {quality}')
quality = 'wider' quality = 'wider'
increment = 1 increment = 1

View File

@ -316,6 +316,9 @@ class Tab: # {{{
See :ref:`window_resizing` for details. See :ref:`window_resizing` for details.
''') ''')
def resize_window(self, quality: str, increment: int) -> None: def resize_window(self, quality: str, increment: int) -> None:
if quality == 'reset':
self.reset_window_sizes()
return
if increment < 1: if increment < 1:
raise ValueError(increment) raise ValueError(increment)
is_horizontal = quality in ('wider', 'narrower') is_horizontal = quality in ('wider', 'narrower')