Coding style
- Rename appearance to appearance_for.
This commit is contained in:
parent
62ebbd562b
commit
6681101b1c
4 changed files with 65 additions and 64 deletions
|
|
@ -432,14 +432,14 @@ class Summary:
|
|||
+ appearance[highlighted_y][-1])
|
||||
return appearance
|
||||
|
||||
def appearance(self, dimensions):
|
||||
def appearance_for(self, dimensions):
|
||||
width, height = dimensions
|
||||
if len(self._entries) == 0:
|
||||
return [" " * width for row in range(height)]
|
||||
cursor_x, cursor_y = self.cursor_position()
|
||||
width, height = width - 1, height - 1 # Minus one for the scrollbars
|
||||
self._set_scroll_position(cursor_x, cursor_y, height)
|
||||
return self._highlight_cursor_row(self._view_widget.appearance(dimensions), cursor_y)
|
||||
return self._highlight_cursor_row(self._view_widget.appearance_for(dimensions), cursor_y)
|
||||
|
||||
def scroll(self, dx, dy):
|
||||
scroll_x, scroll_y = self._view_widget.position
|
||||
|
|
@ -579,7 +579,7 @@ class Log:
|
|||
def log_command(self, message, timestamp=None):
|
||||
self.log_message(message, char_style=Log._GREEN_STYLE)
|
||||
|
||||
def appearance(self, dimensions):
|
||||
def appearance_for(self, dimensions):
|
||||
if self._appearance is None or fill3.appearance_dimensions(self._appearance) != dimensions:
|
||||
width, height = dimensions
|
||||
del self.lines[:-height]
|
||||
|
|
@ -632,8 +632,8 @@ class Help:
|
|||
action()
|
||||
fill3.APPEARANCE_CHANGED_EVENT.set()
|
||||
|
||||
def appearance(self, dimensions):
|
||||
return self.widget.appearance(dimensions)
|
||||
def appearance_for(self, dimensions):
|
||||
return self.widget.appearance_for(dimensions)
|
||||
|
||||
|
||||
class Listing:
|
||||
|
|
@ -642,9 +642,9 @@ class Listing:
|
|||
self.view = view
|
||||
self.last_dimensions = None
|
||||
|
||||
def appearance(self, dimensions):
|
||||
def appearance_for(self, dimensions):
|
||||
self.last_dimensions = dimensions
|
||||
return self.view.appearance(dimensions)
|
||||
return self.view.appearance_for(dimensions)
|
||||
|
||||
|
||||
class Screen:
|
||||
|
|
@ -946,7 +946,7 @@ class Screen:
|
|||
max(0, width * incomplete / self._summary.result_total))
|
||||
return self._get_status_bar_appearance(width, progress_bar_size)
|
||||
|
||||
def appearance(self, dimensions):
|
||||
def appearance_for(self, dimensions):
|
||||
if len(self._summary._entries) > 0:
|
||||
self._fix_listing()
|
||||
if self._is_help_visible:
|
||||
|
|
@ -956,7 +956,7 @@ class Screen:
|
|||
else:
|
||||
body = self._layouts[self._is_log_visible][self._is_listing_portrait]
|
||||
width, height = max(dimensions[0], 10), max(dimensions[1], 20)
|
||||
result = body.appearance((width, height-1)) + self._get_status_bar(width)
|
||||
result = body.appearance_for((width, height-1)) + self._get_status_bar(width)
|
||||
return (result if (width, height) == dimensions
|
||||
else fill3.appearance_resize(result, dimensions))
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ _DIMENSIONS = (100, 60)
|
|||
|
||||
|
||||
def _widget_to_string(widget, dimensions=_DIMENSIONS):
|
||||
appearance = widget.appearance_min() if dimensions is None else widget.appearance(dimensions)
|
||||
appearance = (widget.appearance_min() if dimensions is None
|
||||
else widget.appearance_for(dimensions))
|
||||
return str(fill3.join("\n", appearance))
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue