Commit | Line | Data |
---|---|---|
14f22a3a FF |
1 | diff -u -r ../mdocml-1.14.1/term_ascii.c ./term_ascii.c |
2 | --- ../mdocml-1.14.1/term_ascii.c 2017-02-21 00:25:20.000000000 +0000 | |
3 | +++ ./term_ascii.c 2017-03-02 14:04:37.164590198 +0000 | |
4 | @@ -18,8 +18,10 @@ | |
80c266a7 FF |
5 | #include "config.h" |
6 | ||
7 | #include <sys/types.h> | |
8 | +#include <sys/ioctl.h> | |
9 | ||
10 | #include <assert.h> | |
14f22a3a | 11 | +#include <fcntl.h> |
80c266a7 | 12 | #if HAVE_WCHAR |
14f22a3a FF |
13 | #include <locale.h> |
14 | #endif | |
15 | @@ -64,12 +66,22 @@ | |
80c266a7 FF |
16 | char *v; |
17 | #endif | |
18 | struct termp *p; | |
19 | + struct winsize ws; | |
20 | + int tfd; | |
21 | ||
22 | p = mandoc_calloc(1, sizeof(struct termp)); | |
23 | ||
24 | p->line = 1; | |
25 | p->tabwidth = 5; | |
26 | p->defrmargin = p->lastrmargin = 78; | |
27 | + if ((tfd = open("/dev/tty", O_RDWR, 0)) != -1) { | |
28 | + if (ioctl(tfd, TIOCGWINSZ, &ws) != -1) { | |
29 | + if (ws.ws_col < 80) | |
30 | + p->defrmargin = p->lastrmargin = ws.ws_col - 2; | |
31 | + } | |
32 | + close(tfd); | |
33 | + } | |
34 | + | |
35 | p->fontq = mandoc_reallocarray(NULL, | |
36 | (p->fontsz = 8), sizeof(enum termfont)); | |
37 | p->fontq[0] = p->fontl = TERMFONT_NONE; |