3 * termsbr.c -- termcap support
5 * This code is Copyright (c) 2002, by the authors of nmh. See the
6 * COPYRIGHT file in the root directory of the nmh distribution for
7 * complete copyright information.
14 /* It might be better to tie this to the termcap_curses_order in
15 configure.ac. It would be fine to check for ncurses/termcap.h
16 first on Linux, it's a symlink to termcap.h. */
19 #elif defined (HAVE_NCURSES_TERMCAP_H)
20 # include <ncurses/termcap.h>
23 /* <sys/ioctl.h> is need anyway for ioctl()
24 #ifdef GWINSZ_IN_SYS_IOCTL
26 # include <sys/ioctl.h>
31 #ifdef WINSIZE_IN_PTEM
32 # include <sys/stream.h>
33 # include <sys/ptem.h>
39 # define TXTSIZ BUFSIZ
42 static long speedcode;
44 static int initLI = 0;
45 static int initCO = 0;
47 static int HC = 0; /* are we on a hardcopy terminal? */
48 static int LI = 40; /* number of lines */
49 static int CO = 80; /* number of colums */
50 static char *CL = NULL; /* termcap string to clear screen */
51 static char *SE = NULL; /* termcap string to end standout mode */
52 static char *SO = NULL; /* termcap string to begin standout mode */
54 static char termcap[TXTSIZ];
63 #ifndef TGETENT_ACCEPTS_NULL
68 static int inited = 0;
73 if (!(term = getenv ("TERM")))
77 * If possible, we let tgetent allocate its own termcap buffer
79 #ifdef TGETENT_ACCEPTS_NULL
80 if (tgetent (NULL, term) != TGETENT_SUCCESS)
83 if (tgetent (termbuf, term) != TGETENT_SUCCESS)
87 speedcode = cfgetospeed(&tio);
91 if (!initCO && (CO = tgetnum ("co")) <= 0)
93 if (!initLI && (LI = tgetnum ("li")) <= 0)
97 CL = tgetstr ("cl", &cp);
98 if (tgetnum ("sg") <= 0) {
99 SE = tgetstr ("se", &cp);
100 SO = tgetstr ("so", &cp);
112 if (ioctl (fileno (stderr), TIOCGWINSZ, &win) != NOTOK
113 && (width = win.ws_col) > 0) {
117 #endif /* TIOCGWINSZ */
130 if (ioctl (fileno (stderr), TIOCGWINSZ, &win) != NOTOK
131 && (LI = win.ws_row) > 0)
134 #endif /* TIOCGWINSZ */
154 tputs (CL, LI, outc);
166 * print in standout mode
169 SOprintf (char *fmt, ...)
189 * Is this a hardcopy terminal?