"Fossies" - the Fresh Open Source Software Archive

Member "tin-2.4.1/include/tcurses.h" (12 Oct 2016, 5960 Bytes) of archive /linux/misc/tin-2.4.1.tar.gz:


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.0_vs_2.4.1.

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