Get real persnickety about nice option/blackbox alignment.

This commit is contained in:
Solderpunk 2023-11-17 20:08:48 +01:00
parent a9b34278a8
commit 607223c25a
1 changed files with 5 additions and 3 deletions

View File

@ -992,15 +992,16 @@ Slow internet connection? Use 'set timeout' to be more patient.""")
# Compute some constants for pretty alignment
ljust = max((len(k) for k in self.options.keys()))
rjust = max((len(str(v)) for v in self.options.values()))
gap = 48 - (ljust + rjust)
if not line.strip():
# Show all current settings
for option in sorted(self.options.keys()):
print("%s %s" % (option.ljust(ljust+4), str(self.options[option]).rjust(rjust)))
print(option.ljust(ljust+gap) + str(self.options[option]).rjust(rjust))
elif len(line.split()) == 1:
# Show current value of one specific setting
option = line.strip()
if option in self.options:
print("%s %s" % (option.ljust(ljust+4), str(self.options[option]).rjust(rjust)))
print(option.ljust(ljust+gap) + str(self.options[option]).rjust(rjust))
else:
print("Unrecognised option %s" % option)
else:
@ -1447,8 +1448,9 @@ current gemini browsing session."""
# Print
ljust = max((len(k) for k,v in lines))
rjust = max((len(str(v)) for k,v in lines))
gap = 48 - (ljust + rjust)
for key, value in lines:
print(key.ljust(ljust+4) + str(value).rjust(rjust))
print(key.ljust(ljust+gap) + str(value).rjust(rjust))
### The end!
def do_quit(self, *args):