One machine I use has terminals that happen to be very nicely sized at
75 columns wide. Day to day, this is almost perfect, except when trying
to view a man page, because just a little too much text goes on each
line.
I think mandoc should adjust its default output width based on the
terminal size. At least in the case where the terminal is narrow. This
diff doesn't change anything if you have wider than 80 column terminals.
Index: term_ascii.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/term_ascii.c,v
retrieving revision 1.10
diff -u -p -r1.10 term_ascii.c
--- term_ascii.c 1 Jun 2013 14:27:13 -0000 1.10
+++ term_ascii.c 21 Jul 2013 14:24:58 -0000
@@ -15,8 +15,10 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/types.h>
+#include <sys/ioctl.h>
#include <assert.h>
+#include <fcntl.h>
#include <locale.h>
#include <stdint.h>
#include <stdio.h>
@@ -50,11 +52,21 @@ ascii_init(enum termenc enc, char *outop
const char *toks[4];
char *v;
struct termp *p;
+ struct winsize ws;
+ int tfd;
p = mandoc_calloc(1, sizeof(struct termp));
p->tabwidth = 5;
p->defrmargin = 78;
+ if ((tfd = open("/dev/tty", O_RDWR, 0)) != -1) {
+ if (ioctl(tfd, TIOCGWINSZ, &ws) != -1) {
+ if (ws.ws_col < 80)
+ p->defrmargin = ws.ws_col - 2;
+ }
+ close(tfd);
+ }
+
p->begin = ascii_begin;
p->end = ascii_end;