[PATCH 02/12] setup_pager(): save terminal width before redirecting stdout
After redirecting, we may no longer read terminal width.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
pager.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/pager.c b/pager.c
index fc6c3e0..ad447cf 100644
--- a/pager.c
+++ b/pager.c
@@ -81,6 +81,15 @@ void setup_pager(void)
spawned_pager = 1; /* means we are emitting to terminal */
+#ifdef TIOCGWINSZ
+ {
+ struct winsize ws;
+ if (!ioctl(1, TIOCGWINSZ, &ws)) {
+ if (ws.ws_col)
+ max_columns = ws.ws_col;
+ }
+ }
+#endif
/* spawn the pager */
pager_argv[0] = pager;
pager_process.use_shell = 1;
--
1.7.0.1.370.gd3c5