Truncate listing titles on the left side.

- Better to retain the file name than the directory.
This commit is contained in:
Andrew Hamilton 2019-09-01 14:01:19 +10:00
parent 9f44030bb9
commit a0892616bf

View file

@ -401,12 +401,14 @@ class Border:
if self.title is None: if self.title is None:
title_bar = self.top * content_width title_bar = self.top * content_width
else: else:
padded_title = (" " + self.title + " ")[:content_width] title = ("" + self.title[-(content_width-1):]
if len(self.title) > content_width - 2
else " " + self.title + " ")
try: try:
title_bar = padded_title.center(content_width, self.top) title_bar = title.center(content_width, self.top)
except TypeError: except TypeError:
padded_title = termstr.TermStr(padded_title) title = termstr.TermStr(title)
title_bar = padded_title.center(content_width, self.top) title_bar = title.center(content_width, self.top)
result = [self.top_left + title_bar + self.top_right] result = [self.top_left + title_bar + self.top_right]
result.extend(self.left + line + self.right for line in body_content) result.extend(self.left + line + self.right for line in body_content)
result.append(self.bottom_left + self.bottom * content_width + result.append(self.bottom_left + self.bottom * content_width +