util.human.io: Prefer using the $COLUMNS environment variable if set (by readline)

Feels like it should be faster.
pull/27/head
Kim Alvefur 3 years ago
parent d73eaf9e5e
commit 9760019a25
  1. 2
      util/human/io.lua
  2. 2
      util/prosodyctl/shell.lua

@ -109,6 +109,8 @@ if utf8.len and utf8.offset then
end
local function term_width(default)
local env_cols = os.getenv "COLUMNS";
if env_cols then return env_cols; end
local stty = io.popen("stty -a");
if not stty then return default; end
local result = stty:read("*a");

@ -30,7 +30,7 @@ local function read_line(prompt_string)
end
local function send_line(client, line)
client.send(st.stanza("repl-input", { width = os.getenv "COLUMNS" or term_width() }):text(line));
client.send(st.stanza("repl-input", { width = term_width() }):text(line));
end
local function repl(client)

Loading…
Cancel
Save