mirror of
https://github.com/evennia/evennia.git
synced 2026-03-21 15:26:30 +01:00
Started making a crop addition to evtable
This commit is contained in:
parent
460392f495
commit
4aa1bfc52d
1 changed files with 14 additions and 1 deletions
|
|
@ -283,6 +283,11 @@ class Cell(object):
|
|||
border_top - top border width
|
||||
border_bottom - bottom border width
|
||||
|
||||
crop_string - string to use when cropping sideways,
|
||||
default is '[...]'
|
||||
crop - crop content of cell rather than expand vertically,
|
||||
default=False
|
||||
|
||||
border_char - this will use a single border char for all borders.
|
||||
overruled by individual settings below
|
||||
border_left_char - char used for left border
|
||||
|
|
@ -328,6 +333,8 @@ class Cell(object):
|
|||
vfill_char = kwargs.get("vfill_char", fill_char)
|
||||
self.vfill_char = vfill_char[0] if vfill_char else " "
|
||||
|
||||
self.crop_string = kwargs.get("crop_string", "[...]")
|
||||
|
||||
# borders and corners
|
||||
borderwidth = kwargs.get("border_width", 0)
|
||||
self.border_left = kwargs.get("border_left", borderwidth)
|
||||
|
|
@ -375,6 +382,13 @@ class Cell(object):
|
|||
# prepare data
|
||||
self.formatted = self._reformat()
|
||||
|
||||
def _crop(self, text, width):
|
||||
"Apply cropping of text"
|
||||
if len(text) > width:
|
||||
crop_string = self.crop_string
|
||||
return text[:width-len(crop_string)] + crop_string
|
||||
return text
|
||||
|
||||
def _reformat(self):
|
||||
"Apply formatting"
|
||||
return self._border(self._pad(self._valign(self._align(self._fit_width(self.data)))))
|
||||
|
|
@ -822,7 +836,6 @@ class EvTable(object):
|
|||
|
||||
bwidth = self.border_width
|
||||
headchar = self.header_line_char
|
||||
cchar = self.corner_char
|
||||
|
||||
# use the helper functions to define various
|
||||
# table "styles"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue