exp2l: Work around a NetBSD 10.0/i386 bug.
[gnulib.git] / lib / terminfo.h
blob1c5f111debb06754d2360f1fc8c5086cd9dccd27
1 /* Information about terminal capabilities.
2 Copyright (C) 2006-2024 Free Software Foundation, Inc.
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation, either version 3 of the
7 License, or (at your option) any later version.
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Bruno Haible <bruno@clisp.org>, 2006. */
19 #ifndef _TERMINFO_H
20 #define _TERMINFO_H
22 /* This file uses HAVE_TERMINFO, HAVE_TERMCAP, HAVE_TPARAM. */
23 #if !_GL_CONFIG_H_INCLUDED
24 #error "Please include config.h first."
25 #endif
27 /* Including <curses.h> or <term.h> is dangerous, because it also declares
28 a lot of junk, such as variables PC, UP, and other. */
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
34 #if HAVE_TERMINFO
36 /* Gets the capability information for terminal type TYPE and prepares FD.
37 Returns 0 if successful, -1 upon error. If ERRP is non-NULL, also returns
38 an error indicator in *ERRP; otherwise an error is signalled. */
39 extern int setupterm (const char *type, int fd, int *errp);
41 /* Retrieves the value of a numerical capability.
42 Returns -1 if it is not available, -2 if ID is invalid. */
43 extern int tigetnum (const char *id);
45 /* Retrieves the value of a boolean capability.
46 Returns 1 if it available, 0 if not available, -1 if ID is invalid. */
47 extern int tigetflag (const char *id);
49 /* Retrieves the value of a string capability.
50 Returns NULL if it is not available, (char *)(-1) if ID is invalid. */
51 extern const char * tigetstr (const char *id);
53 #elif HAVE_TERMCAP
55 /* Gets the capability information for terminal type TYPE.
56 BP must point to a buffer, at least 2048 bytes large.
57 Returns 1 if successful, 0 if TYPE is unknown, -1 on other error. */
58 extern int tgetent (char *bp, const char *type);
60 /* Retrieves the value of a numerical capability.
61 Returns -1 if it is not available. */
62 extern int tgetnum (const char *id);
64 /* Retrieves the value of a boolean capability.
65 Returns 1 if it available, 0 otherwise. */
66 extern int tgetflag (const char *id);
68 /* Retrieves the value of a string capability.
69 Returns NULL if it is not available.
70 Also, if AREA != NULL, stores it at *AREA and advances *AREA. */
71 extern const char * tgetstr (const char *id, char **area);
73 #endif
75 #if HAVE_TPARAM
77 /* API provided by GNU termcap in <termcap.h>. */
79 /* Instantiates a string capability with format strings.
80 BUF must be a buffer having room for BUFSIZE bytes.
81 The return value is either equal to BUF or freshly malloc()ed. */
82 extern char * tparam (const char *str, void *buf, int bufsize, ...);
84 #else
86 /* API provided by
87 - GNU ncurses in <term.h>, <curses.h>, <ncurses.h>,
88 - OSF/1 curses in <term.h>, <curses.h>,
89 - Solaris, AIX, HP-UX, IRIX curses in <term.h>,
90 - gnulib's replacement. */
92 /* Instantiates a string capability with format strings.
93 The return value is statically allocated and must not be freed. */
94 extern char * tparm (const char *str, ...);
96 #endif
98 #if HAVE_TERMINFO || HAVE_TERMCAP
100 /* Retrieves a string that causes cursor positioning to (column, row).
101 This function is necessary because the string returned by tgetstr ("cm")
102 is in a special format. */
103 extern const char * tgoto (const char *cm, int column, int row);
105 #endif
107 /* Retrieves the value of a string capability.
108 OUTCHARFUN is called in turn for each 'char' of the result.
109 This function is necessary because string capabilities can contain
110 padding commands. */
111 extern void tputs (const char *cp, int affcnt, int (*outcharfun) (int));
113 /* The ncurses functions for color handling (see ncurses/base/lib_color.c)
114 are overkill: Most terminal emulators support only a fixed, small number
115 of colors. */
117 #ifdef __cplusplus
119 #endif
121 #endif /* _TERMINFO_H */