Further fixes to format_grid

This commit is contained in:
Griatch 2020-04-11 11:37:30 +02:00
parent c9cab183f5
commit a863ff77db

View file

@ -1746,18 +1746,13 @@ def format_grid(elements, width=78, sep=" "):
wl = wls[ie]
lrow = len(row)
debug = row.replace(" ", ".")
# from evennia import set_trace;set_trace()
if ie >= nelements - 1:
# last element in list - make sure to add it
if lrow + wl > width:
# last slot extends outside grid, move to next line
row += " " * (width - lrow)
rows.append(row)
row = crop(element, width)
else:
row += crop(element, width)
row += " " * max(0, (width - len(row)))
if lrow + wl > width:
# last slot extends outside grid, move to next line
row += " " * (width - lrow)
rows.append(row)
row = crop(element, width)
ic = 0
elif ic >= aver_per_row - 1:
# last slot on the line
if ic == 0:
@ -1796,6 +1791,10 @@ def format_grid(elements, width=78, sep=" "):
row += element + " " * max(0, averlen - wl)
ic += 1
if ie >= nelements - 1:
# last element, make sure to store
rows.append(row)
return "\n".join(rows)