Software /
code /
prosody
Comparison
util/human/io.lua @ 13038:83b93ad08b23
util.human.io: Pass expected width to mapper function
In order to allow it to adjust its output to available space, apply its
own ellipsis method or other compacting method.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 07 Apr 2023 13:00:00 +0200 |
parent | 13031:1023c3faffac |
child | 13039:9ddb344b9fab |
comparison
equal
deleted
inserted
replaced
13037:635ed9a362ee | 13038:83b93ad08b23 |
---|---|
160 local output = {}; | 160 local output = {}; |
161 for i, column in ipairs(col_specs) do | 161 for i, column in ipairs(col_specs) do |
162 local width = widths[i]; | 162 local width = widths[i]; |
163 local v = row[not titles and column.key or i]; | 163 local v = row[not titles and column.key or i]; |
164 if not titles and column.mapper then | 164 if not titles and column.mapper then |
165 v = column.mapper(v, row); | 165 v = column.mapper(v, row, width); |
166 end | 166 end |
167 if v == nil then | 167 if v == nil then |
168 v = column.default or ""; | 168 v = column.default or ""; |
169 else | 169 else |
170 v = tostring(v); | 170 v = tostring(v); |