(root)/
gettext-0.22.4/
libtextstyle/
lib/
terminfo.h
       1  /* Information about terminal capabilities.
       2     Copyright (C) 2006-2023 Free Software Foundation, Inc.
       3  
       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.
       8  
       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.
      13  
      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/>.  */
      16  
      17  /* Written by Bruno Haible <bruno@clisp.org>, 2006.  */
      18  
      19  #ifndef _TERMINFO_H
      20  #define _TERMINFO_H
      21  
      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
      26  
      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.  */
      29  
      30  #ifdef __cplusplus
      31  extern "C" {
      32  #endif
      33  
      34  #if HAVE_TERMINFO
      35  
      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);
      40  
      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);
      44  
      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);
      48  
      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);
      52  
      53  #elif HAVE_TERMCAP
      54  
      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);
      59  
      60  /* Retrieves the value of a numerical capability.
      61     Returns -1 if it is not available.  */
      62  extern int tgetnum (const char *id);
      63  
      64  /* Retrieves the value of a boolean capability.
      65     Returns 1 if it available, 0 otherwise.  */
      66  extern int tgetflag (const char *id);
      67  
      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);
      72  
      73  #endif
      74  
      75  #if HAVE_TPARAM
      76  
      77  /* API provided by GNU termcap in <termcap.h>.  */
      78  
      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, ...);
      83  
      84  #else
      85  
      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.  */
      91  
      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, ...);
      95  
      96  #endif
      97  
      98  #if HAVE_TERMINFO || HAVE_TERMCAP
      99  
     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);
     104  
     105  #endif
     106  
     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));
     112  
     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.  */
     116  
     117  #ifdef __cplusplus
     118  }
     119  #endif
     120  
     121  #endif /* _TERMINFO_H */