Skip to content

Commit

Permalink
[man-] replace len() by dispwidth() in parse_options
Browse files Browse the repository at this point in the history
  • Loading branch information
midichef committed Jan 6, 2025
1 parent 5ae669b commit cb2bad3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions visidata/man/parse_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import sys
import visidata
dispwidth = visidata.dispwidth


fncli, fnopts = sys.argv[1:]
Expand Down Expand Up @@ -31,7 +32,7 @@
optkeys = visidata.options.keys()
optvalues = [visidata.options._opts._get(optname) for optname in optkeys]

widestoptwidth, widestopt = sorted((len(opt.name)+len(str(opt.value)), opt.name) for opt in optvalues)[-1]
widestoptwidth, widestopt = sorted((dispwidth(opt.name)+dispwidth(str(opt.value)), opt.name) for opt in optvalues)[-1]
print('widest option+default is "%s", width %d' % (widestopt, widestoptwidth))
widestoptwidth = 35
menuOut.write('.Bl -tag -width %s -compact\n' % ('X'*(widestoptwidth+3)))
Expand All @@ -51,7 +52,7 @@
else:
cli_optname=opt.name.replace('_', '-')
cli_type=type(opt.value).__name__
optlen = len(cli_optname)+len(cli_type)+1
optlen = dispwidth(cli_optname)+dispwidth(cli_type)+1
if cli_type != 'bool' or visidata.options.getdefault(opt.name):
cliOut.write(options_cli_skel.format(cli_optname=cli_optname,
optname = opt.name,
Expand Down

0 comments on commit cb2bad3

Please sign in to comment.