1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-26 09:47:58 +00:00

If there is a small space for ellipsis_truncate, show '...' only

This commit is contained in:
Abogical 2016-11-14 14:56:34 +02:00
parent af925d2723
commit 76638d0562

View file

@ -1200,6 +1200,8 @@ def ellipsis_truncate(msg, space):
from .platform import swidth
ellipsis_width = swidth('...')
msg_width = swidth(msg)
if space < 8:
return '...' + ' ' * (space - ellipsis_width)
if space < ellipsis_width + msg_width:
return '%s...%s' % (swidth_slice(msg, space // 2 - ellipsis_width),
swidth_slice(msg, -space // 2))
@ -1262,10 +1264,7 @@ def show(self, current=None, increase=1, info=None):
terminal_space = get_terminal_size(fallback=(-1, -1))[0]
if terminal_space != -1:
space = terminal_space - len(self.msg % tuple([pct] + info[:-1] + ['']))
if space < 8:
info[-1] = ' ' * space
else:
info[-1] = ellipsis_truncate(info[-1], space)
info[-1] = ellipsis_truncate(info[-1], space)
return self.output(self.msg % tuple([pct] + info), justify=False)
return self.output(self.msg % pct)