1 /* Information about terminal capabilities.
2 Copyright (C) 2006, 2015 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2006.
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 /* Including <curses.h> or <term.h> is dangerous, because it also declares
22 a lot of junk, such as variables PC, UP, and other. */
30 /* Gets the capability information for terminal type TYPE and prepares FD.
31 Returns 0 if successful, -1 upon error. If ERRP is non-NULL, also returns
32 an error indicator in *ERRP; otherwise an error is signalled. */
33 extern int setupterm (const char *type, int fd, int *errp);
35 /* Retrieves the value of a numerical capability.
36 Returns -1 if it is not available, -2 if ID is invalid. */
37 extern int tigetnum (const char *id);
39 /* Retrieves the value of a boolean capability.
40 Returns 1 if it available, 0 if not available, -1 if ID is invalid. */
41 extern int tigetflag (const char *id);
43 /* Retrieves the value of a string capability.
44 Returns NULL if it is not available, (char *)(-1) if ID is invalid. */
45 extern const char * tigetstr (const char *id);
49 /* Gets the capability information for terminal type TYPE.
50 Returns 1 if successful, 0 if TYPE is unknown, -1 on other error. */
51 extern int tgetent (char *bp, const char *type);
53 /* Retrieves the value of a numerical capability.
54 Returns -1 if it is not available. */
55 extern int tgetnum (const char *id);
57 /* Retrieves the value of a boolean capability.
58 Returns 1 if it available, 0 otherwise. */
59 extern int tgetflag (const char *id);
61 /* Retrieves the value of a string capability.
62 Returns NULL if it is not available.
63 Also, if AREA != NULL, stores it at *AREA and advances *AREA. */
64 extern const char * tgetstr (const char *id, char **area);
70 /* API provided by GNU termcap in <termcap.h>. */
72 /* Instantiates a string capability with format strings.
73 BUF must be a buffer having room for BUFSIZE bytes.
74 The return value is either equal to BUF or freshly malloc()ed. */
75 extern char * tparam (const char *str, void *buf, int bufsize, ...);
80 - GNU ncurses in <term.h>, <curses.h>, <ncurses.h>,
81 - OSF/1 curses in <term.h>, <curses.h>,
82 - Solaris, AIX, HP-UX, IRIX curses in <term.h>,
83 - gnulib's replacement. */
85 /* Instantiates a string capability with format strings.
86 The return value is statically allocated and must not be freed. */
87 extern char * tparm (const char *str, ...);
91 #if HAVE_TERMINFO || HAVE_TERMCAP
93 /* Retrieves a string that causes cursor positioning to (column, row).
94 This function is necessary because the string returned by tgetstr ("cm")
95 is in a special format. */
96 extern const char * tgoto (const char *cm, int column, int row);
100 /* Retrieves the value of a string capability.
101 OUTCHARFUN is called in turn for each 'char' of the result.
102 This function is necessary because string capabilities can contain
104 extern void tputs (const char *cp, int affcnt, int (*outcharfun) (int));
106 /* The ncurses functions for color handling (see ncurses/base/lib_color.c)
107 are overkill: Most terminal emulators support only a fixed, small number
114 #endif /* _TERMINFO_H */