summaryrefslogtreecommitdiff
path: root/src/select.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/select.cc')
-rw-r--r--src/select.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/select.cc b/src/select.cc
index 45ae34be..a9e943ab 100644
--- a/src/select.cc
+++ b/src/select.cc
@@ -145,10 +145,17 @@ value_t select_command(call_scope_t& args)
string thus_far = "";
std::size_t cols = 0;
+#if HAVE_IOCTL
+ struct winsize ws;
+#endif
if (report.HANDLED(columns_))
cols = lexical_cast<std::size_t>(report.HANDLER(columns_).value);
else if (const char * columns_env = std::getenv("COLUMNS"))
cols = lexical_cast<std::size_t>(columns_env);
+#if HAVE_IOCTL
+ else if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) != -1)
+ cols = ws.ws_col;
+#endif
else
cols = 80;