From 56976a127c081a6a008c81966360003a8711a319 Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Mon, 13 Oct 2014 23:15:23 +0200 Subject: make --columns default to terminal width, as returned by ioctl() If set, the COLUMNS environment variable will take precedence over terminal width. However, please note that COLUMNS is usually *not* exported by shells to child processes, so in most cases COLUMNS will be undefined for ledger---hence the motivation for this change. Terminal width is queried using ioctl() on stdin. For the sake of portability the querying is done only on platform where ioctl() is detected as supported at compile-time. --- src/system.hh.in | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/system.hh.in') diff --git a/src/system.hh.in b/src/system.hh.in index eaee14dc..67a218da 100644 --- a/src/system.hh.in +++ b/src/system.hh.in @@ -63,6 +63,7 @@ #define HAVE_REALPATH @HAVE_REALPATH@ #define HAVE_GETPWUID @HAVE_GETPWUID@ #define HAVE_GETPWNAM @HAVE_GETPWNAM@ +#define HAVE_IOCTL @HAVE_IOCTL@ #define HAVE_ISATTY @HAVE_ISATTY@ #define HAVE_UNIX_PIPES @HAVE_UNIX_PIPES@ @@ -151,6 +152,10 @@ typedef std::ostream::pos_type ostream_pos_type; #include #endif +#if HAVE_IOCTL +#include +#endif + #if HAVE_UNIX_PIPES #include #include -- cgit v1.2.3