Software /
code /
prosody
Comparison
util/human/io.lua @ 13049:115ce3ab5b8b
util.human.io: table: don't read $COLUMNS directly, just use term_width()
...which now reads $COLUMNS for us and does the right thing.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 07 Apr 2023 12:51:26 +0100 |
parent | 13048:946442df65d3 |
child | 13051:164c2787901a |
comparison
equal
deleted
inserted
replaced
13048:946442df65d3 | 13049:115ce3ab5b8b |
---|---|
126 if width == 1 then return "…"; end | 126 if width == 1 then return "…"; end |
127 return utf8_cut(s, width - 1) .. "…"; | 127 return utf8_cut(s, width - 1) .. "…"; |
128 end | 128 end |
129 | 129 |
130 local function new_table(col_specs, max_width) | 130 local function new_table(col_specs, max_width) |
131 max_width = max_width or term_width(os.getenv("COLUMNS") or 80); | 131 max_width = max_width or term_width(80); |
132 local separator = " | "; | 132 local separator = " | "; |
133 | 133 |
134 local widths = {}; | 134 local widths = {}; |
135 local total_width = max_width - #separator * (#col_specs-1); | 135 local total_width = max_width - #separator * (#col_specs-1); |
136 local free_width = total_width; | 136 local free_width = total_width; |