"Fossies" - the Fresh Open Source Software Archive

Member "tin-2.6.0/include/tcurses.h" (13 Jul 2021, 6145 Bytes) of package /linux/misc/tin-2.6.0.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "tcurses.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.4.5_vs_2.6.0.

    1 /*
    2  *  Project   : tin - a Usenet reader
    3  *  Module    : tcurses.h
    4  *  Author    : Thomas Dickey
    5  *  Created   : 1997-03-02
    6  *  Updated   : 2021-07-12
    7  *  Notes     : curses #include files, #defines & struct's
    8  *
    9  * Copyright (c) 1997-2021 Thomas Dickey <dickey@invisible-island.net>
   10  * All rights reserved.
   11  *
   12  * Redistribution and use in source and binary forms, with or without
   13  * modification, are permitted provided that the following conditions
   14  * are met:
   15  *
   16  * 1. Redistributions of source code must retain the above copyright notice,
   17  *    this list of conditions and the following disclaimer.
   18  *
   19  * 2. Redistributions in binary form must reproduce the above copyright
   20  *    notice, this list of conditions and the following disclaimer in the
   21  *    documentation and/or other materials provided with the distribution.
   22  *
   23  * 3. Neither the name of the copyright holder nor the names of its
   24  *    contributors may be used to endorse or promote products derived from
   25  *    this software without specific prior written permission.
   26  *
   27  * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   28  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   29  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   30  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
   31  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   37  * POSSIBILITY OF SUCH DAMAGE.
   38  */
   39 
   40 
   41 #ifndef TCURSES_H
   42 #   define TCURSES_H 1
   43 
   44 
   45 #   if defined(USE_CURSES) || defined(NEED_CURSES_H)
   46 #       ifdef HAVE_XCURSES
   47 #           include <xcurses.h>
   48 #           define getattrs(w) (w)->_attrs
   49 #       else
   50 #           if defined(HAVE_NCURSESW_NCURSES_H)
   51 #               ifndef _XOPEN_SOURCE_EXTENDED
   52 #                   define _XOPEN_SOURCE_EXTENDED 1
   53 #               endif /* _XOPEN_SOURCE_EXTENDED */
   54 #               include <ncursesw/ncurses.h>
   55                 /* we need a recent ncursesw for wide-char */
   56 #               if (NCURSES_VERSION_MAJOR == 5) && (NCURSES_VERSION_MINOR >= 3) || (NCURSES_VERSION_MAJOR >= 6)
   57 #                   define HAVE_NCURSESW 1
   58 #               endif /* NCURSES_VERSION_MAJOR == 5 && NCURSES_VERSION_MINOR >=3 || NCURSES_VERSION_MAJOR >= 6 */
   59 #           else
   60 #               if defined(HAVE_NCURSES_H)
   61 #                   include <ncurses.h>
   62 #               else
   63 #                   if defined(HAVE_NCURSES_NCURSES_H)
   64 #                       include <ncurses/ncurses.h>
   65 #                   else
   66 #                       undef TRUE
   67 #                       undef FALSE
   68 #                       include <curses.h>
   69 #                       ifndef FALSE
   70 #                           define FALSE    0
   71 #                       endif /* !FALSE */
   72 #                       ifndef TRUE
   73 #                           define TRUE (!FALSE)
   74 #                       endif /* !TRUE */
   75 #                   endif /* HAVE_NCURSES_NCURSES_H */
   76 #               endif /* HAVE_NCURSES_H */
   77 #           endif /* HAVE_NCURSESW_NCURSES_H */
   78 #           if defined(NCURSES_WIDECHAR)
   79 #               define HAVE_NCURSESW 1
   80 #           endif
   81 #       endif /* HAVE_NCURSES_H */
   82 #   endif /* USE_CURSES || NEED_CURSES_H */
   83 
   84 #   ifdef USE_CURSES
   85 
   86 #       ifdef USE_TRACE
   87 #           ifdef HAVE_NOMACROS_H
   88 #               include <nomacros.h>
   89 #           endif /* HAVE_NOMACROS_H */
   90 #       endif /* USE_TRACE */
   91 
   92 #       define cCRLF                "\n"
   93 #       define my_flush()           my_fflush(stdout)
   94 #       define ClearScreen()            my_erase()
   95 #       define CleartoEOLN()            clrtoeol()
   96 #       define CleartoEOS()         clrtobot()
   97 #       define ScrollScreen(lines_to_scroll)    scrl(lines_to_scroll)
   98 #       define SetScrollRegion(top,bottom)  setscrreg(top, bottom)
   99 #       define WriteLine(row,buffer)        write_line(row, buffer)
  100 
  101 #       define HpGlitch(func)           /*nothing*/
  102 
  103 extern int cmdReadCh(void);
  104 extern int cmd_get_arrow_key(int prech);
  105 extern char *screen_contents(int row, int col, char *buffer);
  106 extern void MoveCursor(int row, int col);
  107 extern void my_erase(void);
  108 extern void my_fflush(FILE *stream);
  109 extern void my_fputc(int ch, FILE *stream);
  110 extern void my_fputs(const char *str, FILE *stream);
  111 #       if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE)
  112     extern void my_fputwc(wint_t wc, FILE *fp);
  113     extern void my_fputws(const wchar_t *wstr, FILE *fp);
  114     extern wint_t cmdReadWch(void);
  115     extern wint_t ReadWch(void);
  116 #       endif /* MULTIBYTE_ABLE && !NO_LOCALE */
  117 extern void my_fprintf(FILE *stream, const char *fmt, ...)
  118 #       if defined(__GNUC__) && !defined(printf)
  119     __attribute__((format(printf,2,3)))
  120 #       endif /* __GNUC__ && !printf */
  121     ;
  122 extern void my_printf(const char *fmt, ...)
  123 #       if defined(__GNUC__) && !defined(printf)
  124     __attribute__((format(printf,1,2)))
  125 #       endif /* __GNUC__ && !printf */
  126     ;
  127 extern void my_retouch(void);
  128 #       ifdef HAVE_COLOR
  129     extern void refresh_color(void);
  130     extern void reset_color(void);
  131 #       endif /* HAVE_COLOR */
  132 extern void write_line(int row, char *buffer);
  133 
  134 #   else    /* !USE_CURSES */
  135 
  136 #       ifdef NEED_TERM_H
  137 #           include <curses.h>
  138 #           ifdef HAVE_NCURSESW_TERM_H
  139 #               include <ncursesw/term.h>
  140 #           else
  141 #               ifdef HAVE_NCURSES_TERM_H
  142 #                   include <ncurses/term.h>
  143 #               else
  144 #                   include <term.h>
  145 #               endif /* HAVE_NCURSES_TERM_H */
  146 #           endif /* HAVE_NCURSESW_TERM_H */
  147 #       else
  148 #           ifdef HAVE_TERMCAP_H
  149 #               include <termcap.h>
  150 #           endif /* HAVE_TERMCAP_H */
  151 #       endif /* NEED_TERM_H */
  152 
  153 #       define cCRLF                "\r\n"
  154 
  155 #       define my_fputc(ch, stream)     fputc(ch, stream)
  156 #       define my_fputs(str, stream)        fputs(str, stream)
  157 #       if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE)
  158 #           define my_fputwc(wc, stream)    { \
  159                 if (fwide(stream, 0) <= 0) \
  160                     fprintf(stream, "%lc", wc); \
  161                 else \
  162                     fputwc((wchar_t) (wc), stream); \
  163             }
  164 #           define my_fputws(wstr, stream)  { \
  165                 if (fwide(stream, 0) <= 0) \
  166                     fprintf(stream, "%ls", wstr); \
  167                 else \
  168                     fputws(wstr, stream); \
  169             }
  170 #       endif /* MULTIBYTE_ABLE && !NO_LOCALE */
  171 
  172 #       define my_printf            printf
  173 #       define my_fprintf           fprintf
  174 #       define my_flush()           fflush(stdout)
  175 #       define my_fflush(stream)        fflush(stream)
  176 #       define my_retouch()         ClearScreen()
  177 #       define WriteLine(row,buffer)        MoveCursor(row, 0); my_fputs(buffer, stdout);
  178 
  179 #       define HpGlitch(func)           if (_hp_glitch) func
  180 
  181 #   endif /* USE_CURSES/!USE_CURSES */
  182 
  183 extern void my_dummy(void);
  184 
  185 #endif /* !TCURSES_H */