Don't crash when the vigil window is made very small.

This is a workaround, not being able to get very small appearances is still
there. For now the main appearance won't shrink below a width of 10
or a height of 20, but thats okay since the interface is already impractical
at that point. The minimum appearance is then cropped to fit the window.
This commit is contained in:
Andrew Hamilton 2016-01-26 09:54:24 +00:00
parent 4f802b2a11
commit 5d1c124d8e
2 changed files with 10 additions and 5 deletions

4
BUGS
View file

@ -5,7 +5,6 @@ Current
e.g. vigil.py pylint, BUGS metadata, BUGS _pygments e.g. vigil.py pylint, BUGS metadata, BUGS _pygments
- Scrolling in the help screen doesn't work with the arrow keys. - Scrolling in the help screen doesn't work with the arrow keys.
- Within the sandbox sudo is not working for tools. - Within the sandbox sudo is not working for tools.
- There is an exception if vigil's window is made too small.
Current (tool related) Current (tool related)
@ -207,6 +206,9 @@ Fixed
<- 'Watching' is never off now <- 'Watching' is never off now
- When the filesystem changes a lot vigil is syncing the summary repeatedly - When the filesystem changes a lot vigil is syncing the summary repeatedly
for each part in a queue of changes. Needs to empty the queue then sync. for each part in a queue of changes. Needs to empty the queue then sync.
- There is an exception if vigil's window is made too small.
<- When the window is narrower than 10 or shorter than 20 the contents
start to crop instead of shrink.
On hold, run-tool related On hold, run-tool related

9
vigil
View file

@ -761,7 +761,7 @@ class Screen:
return [bar[:progress_bar_size].underline() + bar[progress_bar_size:]] return [bar[:progress_bar_size].underline() + bar[progress_bar_size:]]
def appearance(self, dimensions): def appearance(self, dimensions):
width, height = dimensions width, height = max(dimensions[0], 10), max(dimensions[1], 20)
if self._is_help_visible: if self._is_help_visible:
return self._help_widget.appearance(dimensions) return self._help_widget.appearance(dimensions)
widget = self._summary.get_selection() widget = self._summary.get_selection()
@ -778,9 +778,12 @@ class Screen:
status_bar_appearance = self._get_status_bar_appearance( status_bar_appearance = self._get_status_bar_appearance(
width, self._summary.is_directory_sort, self._is_paused, width, self._summary.is_directory_sort, self._is_paused,
progress_bar_size) progress_bar_size)
return (self._layouts[self._is_log_visible][self._is_listing_portrait] result = (self._layouts[self._is_log_visible]
.appearance((width, height-len(status_bar_appearance))) + [self._is_listing_portrait] .appearance(
(width, height-len(status_bar_appearance))) +
status_bar_appearance) status_bar_appearance)
return (result if (width, height) == dimensions
else fill3.appearance_resize(result, dimensions))
_KEY_DATA = [ _KEY_DATA = [
({"t"}, toggle_window_orientation), ({"l"}, toggle_log), ({"t"}, toggle_window_orientation), ({"l"}, toggle_log),