Fix truncation of border titles.
- Ellipses weren't always standing in for truncations.
This commit is contained in:
parent
a0892616bf
commit
71f8461bc3
2 changed files with 10 additions and 6 deletions
|
|
@ -401,14 +401,14 @@ class Border:
|
|||
if self.title is None:
|
||||
title_bar = self.top * content_width
|
||||
else:
|
||||
title = ("…" + self.title[-(content_width-1):]
|
||||
if len(self.title) > content_width - 2
|
||||
else " " + self.title + " ")
|
||||
padded_title = " " + ("…" + self.title[-(content_width-3):]
|
||||
if len(self.title) > content_width - 2
|
||||
else self.title) + " "
|
||||
try:
|
||||
title_bar = title.center(content_width, self.top)
|
||||
title_bar = padded_title.center(content_width, self.top)
|
||||
except TypeError:
|
||||
title = termstr.TermStr(title)
|
||||
title_bar = title.center(content_width, self.top)
|
||||
padded_title = termstr.TermStr(padded_title)
|
||||
title_bar = padded_title.center(content_width, self.top)
|
||||
result = [self.top_left + title_bar + self.top_right]
|
||||
result.extend(self.left + line + self.right for line in body_content)
|
||||
result.append(self.bottom_left + self.bottom * content_width +
|
||||
|
|
|
|||
|
|
@ -64,6 +64,10 @@ class WidgetTests(unittest.TestCase):
|
|||
"┌─ AB ─┐\n"
|
||||
"│abcdef│\n"
|
||||
"└──────┘")
|
||||
self.assert_string(fill3.Border(text, title="ABC").appearance((6, 3)),
|
||||
"┌ …C ┐\n"
|
||||
"│abcd│\n"
|
||||
"└────┘")
|
||||
|
||||
def test_placeholder_widget(self):
|
||||
placeholder = fill3.Placeholder(self.TEXT_A)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue