Fixed width bug with wider borders.
This commit is contained in:
parent
fdc6cc76a4
commit
033b07469e
1 changed files with 6 additions and 13 deletions
|
|
@ -64,14 +64,6 @@ contents being cropped. Each cell can only shrink
|
||||||
to a minimum width and height of 1.
|
to a minimum width and height of 1.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Contrary to prettytable, Mudtable does not allow
|
|
||||||
for importing from files.
|
|
||||||
|
|
||||||
It is intended to be used with ANSIString for supporting
|
It is intended to be used with ANSIString for supporting
|
||||||
ANSI-coloured string types.
|
ANSI-coloured string types.
|
||||||
|
|
||||||
|
|
@ -329,7 +321,8 @@ class Cell(object):
|
||||||
left = self.border_left_char * self.border_left
|
left = self.border_left_char * self.border_left
|
||||||
right = self.border_right_char * self.border_right
|
right = self.border_right_char * self.border_right
|
||||||
|
|
||||||
cwidth = self.width + self.pad_left + self.pad_right + (self.border_left-1) + (self.border_right-1)
|
cwidth = self.width + self.pad_left + self.pad_right + \
|
||||||
|
max(0,self.border_left-1) + max(0, self.border_right-1)
|
||||||
|
|
||||||
vfill = self.corner_top_left if left else ""
|
vfill = self.corner_top_left if left else ""
|
||||||
vfill += cwidth * self.border_top_char
|
vfill += cwidth * self.border_top_char
|
||||||
|
|
@ -355,7 +348,6 @@ class Cell(object):
|
||||||
Get the minimum possible width of cell, including at least one
|
Get the minimum possible width of cell, including at least one
|
||||||
character-width for data.
|
character-width for data.
|
||||||
"""
|
"""
|
||||||
print "min width:", self.pad_left, self.pad_right, self.border_left, self.border_right, 1
|
|
||||||
return self.pad_left + self.pad_right + self.border_left + self.border_right + 1
|
return self.pad_left + self.pad_right + self.border_left + self.border_right + 1
|
||||||
|
|
||||||
def get_height(self):
|
def get_height(self):
|
||||||
|
|
@ -490,7 +482,7 @@ class MudTable(object):
|
||||||
corner_char - character to use in corners when border is
|
corner_char - character to use in corners when border is
|
||||||
active.
|
active.
|
||||||
header_line_char - characters to use for underlining
|
header_line_char - characters to use for underlining
|
||||||
the header row (default is '=')
|
the header row (default is '~')
|
||||||
Requires border to be active.
|
Requires border to be active.
|
||||||
|
|
||||||
width - fixed width of table. If not set, width is
|
width - fixed width of table. If not set, width is
|
||||||
|
|
@ -534,8 +526,8 @@ class MudTable(object):
|
||||||
# header border underling etc. We only allow this if a header
|
# header border underling etc. We only allow this if a header
|
||||||
# was actually set
|
# was actually set
|
||||||
self.header = kwargs.pop("header", self.header) if self.header else False
|
self.header = kwargs.pop("header", self.header) if self.header else False
|
||||||
hchar = kwargs.pop("header_line_char", "=")
|
hchar = kwargs.pop("header_line_char", "~")
|
||||||
self.header_line_char = hchar[0] if hchar else "="
|
self.header_line_char = hchar[0] if hchar else "~"
|
||||||
|
|
||||||
border = kwargs.pop("border", None)
|
border = kwargs.pop("border", None)
|
||||||
if not border in (None, "none", "table", "tablecols",
|
if not border in (None, "none", "table", "tablecols",
|
||||||
|
|
@ -787,6 +779,7 @@ class MudTable(object):
|
||||||
# calculate actual table width/height in characters
|
# calculate actual table width/height in characters
|
||||||
self.cwidth = sum(cwidths)
|
self.cwidth = sum(cwidths)
|
||||||
self.cheight = sum(cheights)
|
self.cheight = sum(cheights)
|
||||||
|
print "actual table width, height:", self.cwidth, self.cheight, self.width, self.height
|
||||||
|
|
||||||
def _generate_lines(self):
|
def _generate_lines(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue