Software /
code /
prosody
Comparison
util/human/io.lua @ 13068:7a75cbc4d87c
util.human.io: Fix column width miscalculation
Fixes that the more fixed width columns there are, the narrower the
resulting table becomes. A right-aligned variable-width column at the
last position should always be flush to the right side of the terminal.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 09 Apr 2023 22:31:12 +0200 |
parent | 13067:386ca97bec5b |
child | 13199:278920294dfe |
comparison
equal
deleted
inserted
replaced
13067:386ca97bec5b | 13068:7a75cbc4d87c |
---|---|
140 if not (type(width) == "string" and width:match("[p%%]$")) then | 140 if not (type(width) == "string" and width:match("[p%%]$")) then |
141 local title = col_specs[i].title; | 141 local title = col_specs[i].title; |
142 width = math.max(tonumber(width), title and (#title+1) or 0); | 142 width = math.max(tonumber(width), title and (#title+1) or 0); |
143 widths[i] = width; | 143 widths[i] = width; |
144 free_width = free_width - width; | 144 free_width = free_width - width; |
145 if i > 1 then | |
146 free_width = free_width - #separator; | |
147 end | |
148 end | 145 end |
149 end | 146 end |
150 | 147 |
151 -- Calculate width of proportional columns | 148 -- Calculate width of proportional columns |
152 local total_proportional_width = 0; | 149 local total_proportional_width = 0; |