summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2018-10-10 09:14:03 +0300
committerRichard Lowe <richlowe@richlowe.net>2018-10-24 16:47:49 +0000
commite24b44e5c3120c9b5c8e9b7440bc10c8b7413bfb (patch)
tree202874563f8b922cada2fa1f7df8a7a989d1e093 /usr/src
parent388010da9085a461c9700f1e3664b8f2ce14cd55 (diff)
downloadillumos-joyent-e24b44e5c3120c9b5c8e9b7440bc10c8b7413bfb.tar.gz
9879 more should have better screen size detection
Reviewed by: Andy Fiddaman <omnios@citrus-it.net> Reviewed by: Alexander Pyhalov <apyhalov@gmail.com> Reviewed by: Yuri Pankov <yuripv@yuripv.net> Approved by: Richard Lowe <richlowe@richlowe.net>
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/more/more.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/usr/src/cmd/more/more.c b/usr/src/cmd/more/more.c
index 4ed3046629..14742fc6b2 100644
--- a/usr/src/cmd/more/more.c
+++ b/usr/src/cmd/more/more.c
@@ -1520,15 +1520,40 @@ initterm(void)
dumb++; ul_opt = 0;
}
else {
+ int row, col;
+ struct winsize w;
+ char *s;
+
reset_shell_mode();
- if (((Lpp = lines) < 0) || hard_copy) {
+ row = col = -1;
+ if (ioctl(fileno(stdout), TIOCGWINSZ, &w) == 0) {
+ if (w.ws_row > 0)
+ row = w.ws_row;
+ if (w.ws_col > 0)
+ col = w.ws_col;
+ }
+ if (row < 0) {
+ if ((s = getenv("LINES")) != NULL)
+ row = atoi(s);
+ }
+ if (col < 0) {
+ if ((s = getenv("COLUMNS")) != NULL)
+ col = atoi(s);
+ }
+
+ if (row > 0)
+ Lpp = row;
+ else if (((Lpp = lines) < 0) || hard_copy) {
hard++; /* Hard copy terminal */
Lpp = 24;
}
+ if (col > 0)
+ Mcol = col;
+ else if ((Mcol = columns) < 0)
+ Mcol = 80;
+
if (tailequ(fnames[0], "page") || !hard && (scroll_forward == NULL))
noscroll++;
- if ((Mcol = columns) < 0)
- Mcol = 80;
Wrap = tigetflag("am");
/*
* Set up for underlining: some terminals don't need it;