Coding style
- Rename appearance_min to appearance.
This commit is contained in:
parent
6681101b1c
commit
695c1d7f96
7 changed files with 41 additions and 42 deletions
|
|
@ -88,8 +88,8 @@ class Row:
|
|||
return join_horizontal([column_widget.appearance_for((item_width, height))
|
||||
for column_widget, item_width in zip(self.widgets, widths)])
|
||||
|
||||
def appearance_min(self):
|
||||
appearances = [column_widget.appearance_min() for column_widget in self.widgets]
|
||||
def appearance(self):
|
||||
appearances = [column_widget.appearance() for column_widget in self.widgets]
|
||||
dimensions = [appearance_dimensions(appearance) for appearance in appearances]
|
||||
max_height = max(height for width, height in dimensions)
|
||||
return join_horizontal([appearance_resize(appearance, (width, max_height))
|
||||
|
|
@ -132,7 +132,7 @@ class Column:
|
|||
def _appearance_list(self, widgets):
|
||||
if widgets == []:
|
||||
return []
|
||||
appearances = [row_widget.appearance_min() for row_widget in widgets]
|
||||
appearances = [row_widget.appearance() for row_widget in widgets]
|
||||
dimensions = [appearance_dimensions(appearance) for appearance in appearances]
|
||||
max_width = max(width for width, height in dimensions)
|
||||
padded_appearances = [appearance_resize(appearance, (max_width, height))
|
||||
|
|
@ -146,7 +146,7 @@ class Column:
|
|||
start_y, end_y = interval
|
||||
return self._appearance_list(self.widgets[start_y:end_y])
|
||||
|
||||
def appearance_min(self):
|
||||
def appearance(self):
|
||||
return self._appearance_list(self.widgets)
|
||||
|
||||
|
||||
|
|
@ -156,7 +156,7 @@ class Filler:
|
|||
self.widget = widget
|
||||
|
||||
def appearance_for(self, dimensions):
|
||||
return appearance_resize(self.widget.appearance_min(), dimensions)
|
||||
return appearance_resize(self.widget.appearance(), dimensions)
|
||||
|
||||
|
||||
class ScrollBar:
|
||||
|
|
@ -231,7 +231,7 @@ class Portal:
|
|||
try:
|
||||
appearance = self.widget.appearance_interval((y, y+height))
|
||||
except AttributeError:
|
||||
appearance = self.widget.appearance_min()[y:y+height]
|
||||
appearance = self.widget.appearance()[y:y+height]
|
||||
self.last_dimensions = dimensions
|
||||
return appearance_resize([row[x:x+width] for row in appearance],
|
||||
dimensions, self.background_char)
|
||||
|
|
@ -270,7 +270,7 @@ class View:
|
|||
try:
|
||||
full_width, full_height = self.portal.widget.appearance_dimensions()
|
||||
except AttributeError:
|
||||
full_appearance = self.portal.widget.appearance_min()
|
||||
full_appearance = self.portal.widget.appearance()
|
||||
full_width, full_height = appearance_dimensions(full_appearance)
|
||||
if full_width == 0 or full_height == 0:
|
||||
return self.portal.appearance_for(dimensions)
|
||||
|
|
@ -311,11 +311,11 @@ class Text:
|
|||
def __init__(self, text, pad_char=" "):
|
||||
self.text = str_to_appearance(text, pad_char)
|
||||
|
||||
def appearance_min(self):
|
||||
def appearance(self):
|
||||
return self.text
|
||||
|
||||
def appearance_for(self, dimensions):
|
||||
return appearance_resize(self.appearance_min(), dimensions)
|
||||
return appearance_resize(self.appearance(), dimensions)
|
||||
|
||||
|
||||
class Table:
|
||||
|
|
@ -324,10 +324,10 @@ class Table:
|
|||
self._widgets = table
|
||||
self._pad_char = pad_char
|
||||
|
||||
def appearance_min(self):
|
||||
def appearance(self):
|
||||
if self._widgets == []:
|
||||
return []
|
||||
appearances = [[cell.appearance_min() for cell in row] for row in self._widgets]
|
||||
appearances = [[cell.appearance() for cell in row] for row in self._widgets]
|
||||
row_heights = [0] * len(self._widgets)
|
||||
column_widths = [0] * len(self._widgets[0])
|
||||
for y, row in enumerate(appearances):
|
||||
|
|
@ -376,8 +376,8 @@ class Border:
|
|||
result.append(self.bottom_left + self.bottom * content_width + self.bottom_right)
|
||||
return result
|
||||
|
||||
def appearance_min(self):
|
||||
return self._add_border(self.widget.appearance_min())
|
||||
def appearance(self):
|
||||
return self._add_border(self.widget.appearance())
|
||||
|
||||
def appearance_for(self, dimensions):
|
||||
width, height = dimensions
|
||||
|
|
@ -389,8 +389,8 @@ class Placeholder:
|
|||
def __init__(self, widget=None):
|
||||
self.widget = widget
|
||||
|
||||
def appearance_min(self):
|
||||
return self.widget.appearance_min()
|
||||
def appearance(self):
|
||||
return self.widget.appearance()
|
||||
|
||||
def appearance_for(self, dimensions):
|
||||
return self.widget.appearance_for(dimensions)
|
||||
|
|
@ -398,12 +398,12 @@ class Placeholder:
|
|||
|
||||
class Fixed:
|
||||
|
||||
def __init__(self, appearance_min):
|
||||
self.appearance_min_ = appearance_min
|
||||
self.dimensions = appearance_dimensions(appearance_min)
|
||||
def __init__(self, appearance):
|
||||
self.appearance_ = appearance
|
||||
self.dimensions = appearance_dimensions(appearance)
|
||||
|
||||
def appearance_min(self):
|
||||
return self.appearance_min_
|
||||
def appearance(self):
|
||||
return self.appearance_
|
||||
|
||||
def appearance_dimensions(self):
|
||||
return self.dimensions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue