scripts: maps: Adopted persistent padding for status strings
This automatically minimizes the status strings without flickering, all it took was a bit of ~*global state*~. --- If I'm remembering correctly, this was actually how tracebd.py used to work before dbgbmap.py was added. The idea was dropped with dbgbmap.py since dbgbmap.py relied on watch.py for real-time rendering and couldn't persist state. But now dbgbmap.py has its own -k/--keep-open flag, so that's not a problem.
This commit is contained in:
+18
-4
@@ -4588,12 +4588,26 @@ def main_(ring, disk, mroots=None, *,
|
||||
lfs.cksum,
|
||||
'' if lfs.ckgcksum() else '?'))
|
||||
else:
|
||||
title_ = ('bd %sx%s, %5s mdir, %5s btree, %5s data' % (
|
||||
# hack time~, to avoid flickering, keep track of worst padding
|
||||
# globally
|
||||
mdir_percent = '%.1f%%' % (100*mdir_count / max(len(bmap), 1))
|
||||
btree_percent = '%.1f%%' % (100*btree_count / max(len(bmap), 1))
|
||||
data_percent = '%.1f%%' % (100*data_count / max(len(bmap), 1))
|
||||
main_.mdir_padding = max(
|
||||
getattr(main_, 'mdir_padding', 0),
|
||||
len(mdir_percent))
|
||||
main_.btree_padding = max(
|
||||
getattr(main_, 'btree_padding', 0),
|
||||
len(btree_percent))
|
||||
main_.data_padding = max(
|
||||
getattr(main_, 'data_padding', 0),
|
||||
len(data_percent))
|
||||
title_ = ('bd %sx%s, %.*s mdir, %.*s btree, %.*s data' % (
|
||||
lfs.block_size if lfs.block_size is not None else '?',
|
||||
lfs.block_count if lfs.block_count is not None else '?',
|
||||
'%.1f%%' % (100*mdir_count / max(len(bmap), 1)),
|
||||
'%.1f%%' % (100*btree_count / max(len(bmap), 1)),
|
||||
'%.1f%%' % (100*data_count / max(len(bmap), 1))))
|
||||
main_.mdir_padding, mdir_percent,
|
||||
main_.btree_padding, btree_percent,
|
||||
main_.data_padding, data_percent))
|
||||
|
||||
# scale width/height if requested
|
||||
if (to_scale is not None
|
||||
|
||||
Reference in New Issue
Block a user