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 #ifdef notdef_lyndon_posix
45 XXX No current termcap should need this. If your compile barfs,
46 email details to lyndon@orthanc.ca. This code will vanish soon ...
49 * These variables are sometimes defined in,
50 * and needed by the termcap library.
53 # ifdef MUST_DEFINE_OSPEED
62 #endif /* notdef_lyndon_posix */
64 static long speedcode;
66 static int initLI = 0;
67 static int initCO = 0;
69 static int HC = 0; /* are we on a hardcopy terminal? */
70 static int LI = 40; /* number of lines */
71 static int CO = 80; /* number of colums */
72 static char *CL = NULL; /* termcap string to clear screen */
73 static char *SE = NULL; /* termcap string to end standout mode */
74 static char *SO = NULL; /* termcap string to begin standout mode */
76 static char termcap[TXTSIZ];
85 #ifndef TGETENT_ACCEPTS_NULL
90 static int inited = 0;
95 if (!(term = getenv ("TERM")))
99 * If possible, we let tgetent allocate its own termcap buffer
101 #ifdef TGETENT_ACCEPTS_NULL
102 if (tgetent (NULL, term) != TGETENT_SUCCESS)
105 if (tgetent (termbuf, term) != TGETENT_SUCCESS)
109 speedcode = cfgetospeed(&tio);
111 HC = tgetflag ("hc");
113 if (!initCO && (CO = tgetnum ("co")) <= 0)
115 if (!initLI && (LI = tgetnum ("li")) <= 0)
119 CL = tgetstr ("cl", &cp);
120 if ((bp = tgetstr ("pc", &cp)))
122 if (tgetnum ("sg") <= 0) {
123 SE = tgetstr ("se", &cp);
124 SO = tgetstr ("so", &cp);
136 if (ioctl (fileno (stderr), TIOCGWINSZ, &win) != NOTOK
137 && (width = win.ws_col) > 0) {
141 #endif /* TIOCGWINSZ */
154 if (ioctl (fileno (stderr), TIOCGWINSZ, &win) != NOTOK
155 && (LI = win.ws_row) > 0)
158 #endif /* TIOCGWINSZ */
178 tputs (CL, LI, outc);
190 * print in standout mode
193 SOprintf (char *fmt, ...)
213 * Is this a hardcopy terminal?