Imported Upstream version 0.19.7
[platform/upstream/gettext.git] / gettext-tools / gnulib-lib / terminfo.h
1 /* Information about terminal capabilities.
2    Copyright (C) 2006, 2015 Free Software Foundation, Inc.
3    Written by Bruno Haible <bruno@clisp.org>, 2006.
4
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.
9
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.
14
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/>.  */
17
18 #ifndef _TERMINFO_H
19 #define _TERMINFO_H
20
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.  */
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 #if HAVE_TERMINFO
29
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);
34
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);
38
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);
42
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);
46
47 #elif HAVE_TERMCAP
48
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);
52
53 /* Retrieves the value of a numerical capability.
54    Returns -1 if it is not available.  */
55 extern int tgetnum (const char *id);
56
57 /* Retrieves the value of a boolean capability.
58    Returns 1 if it available, 0 otherwise.  */
59 extern int tgetflag (const char *id);
60
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);
65
66 #endif
67
68 #if HAVE_TPARAM
69
70 /* API provided by GNU termcap in <termcap.h>.  */
71
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, ...);
76
77 #else
78
79 /* API provided by
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.  */
84
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, ...);
88
89 #endif
90
91 #if HAVE_TERMINFO || HAVE_TERMCAP
92
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);
97
98 #endif
99
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
103    padding commands.  */
104 extern void tputs (const char *cp, int affcnt, int (*outcharfun) (int));
105
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
108    of colors.  */
109
110 #ifdef __cplusplus
111 }
112 #endif
113
114 #endif /* _TERMINFO_H */