Software /
code /
prosody
Comparison
util/human/io.lua @ 10908:18dc4639442e
util.human.io: Replace overflow with ellipsis
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 04 Jun 2020 18:32:33 +0200 |
parent | 10907:6af28c756752 |
child | 10909:3af3354366eb |
comparison
equal
deleted
inserted
replaced
10907:6af28c756752 | 10908:18dc4639442e |
---|---|
126 titles, row = true, array.pluck(col_specs, "title", ""); | 126 titles, row = true, array.pluck(col_specs, "title", ""); |
127 end | 127 end |
128 local output = {}; | 128 local output = {}; |
129 for i, column in ipairs(col_specs) do | 129 for i, column in ipairs(col_specs) do |
130 local width = widths[i]; | 130 local width = widths[i]; |
131 local v = tostring(row[not titles and column.key or i] or ""):sub(1, width); | 131 local v = tostring(row[not titles and column.key or i] or ""); |
132 if #v < width then | 132 if #v < width then |
133 if column.align == "right" then | 133 if column.align == "right" then |
134 v = padleft(v, width-1).." "; | 134 v = padleft(v, width-1).." "; |
135 else | 135 else |
136 v = padright(v, width); | 136 v = padright(v, width); |
137 end | 137 end |
138 elseif #v > width then | |
139 v = v:sub(1, width-1) .. "\u{2026}"; | |
138 end | 140 end |
139 table.insert(output, v); | 141 table.insert(output, v); |
140 end | 142 end |
141 return table.concat(output, separator); | 143 return table.concat(output, separator); |
142 end; | 144 end; |