mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-27 02:08:54 +00:00
If there is a small space for ellipsis_truncate, show '...' only
This commit is contained in:
parent
af925d2723
commit
76638d0562
1 changed files with 3 additions and 4 deletions
|
@ -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,9 +1264,6 @@ 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)
|
||||
return self.output(self.msg % tuple([pct] + info), justify=False)
|
||||
|
||||
|
|
Loading…
Reference in a new issue