tin  2.6.1
About: TIN is a threaded NNTP and spool based UseNet newsreader.
  Fossies Dox: tin-2.6.1.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

tcurses.h
Go to the documentation of this file.
1/*
2 * Project : tin - a Usenet reader
3 * Module : tcurses.h
4 * Author : Thomas Dickey
5 * Created : 1997-03-02
6 * Updated : 2021-12-14
7 * Notes : curses #include files, #defines & struct's
8 *
9 * Copyright (c) 1997-2022 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# undef bool
48# define bool XCursesBool
49# include <xcurses.h>
50# undef bool
51# define getattrs(w) (w)->_attrs
52# else
53# if defined(HAVE_NCURSESW_NCURSES_H)
54# ifndef _XOPEN_SOURCE_EXTENDED
55# define _XOPEN_SOURCE_EXTENDED 1
56# endif /* _XOPEN_SOURCE_EXTENDED */
57# include <ncursesw/ncurses.h>
58 /* we need a recent ncursesw for wide-char */
59# if (NCURSES_VERSION_MAJOR == 5) && (NCURSES_VERSION_MINOR >= 3) || (NCURSES_VERSION_MAJOR >= 6)
60# define HAVE_NCURSESW 1
61# endif /* NCURSES_VERSION_MAJOR == 5 && NCURSES_VERSION_MINOR >=3 || NCURSES_VERSION_MAJOR >= 6 */
62# else
63# if defined(HAVE_NCURSES_H)
64# include <ncurses.h>
65# else
66# if defined(HAVE_NCURSES_NCURSES_H)
67# include <ncurses/ncurses.h>
68# else
69# undef TRUE
70# undef FALSE
71# include <curses.h>
72# ifndef FALSE
73# define FALSE 0
74# endif /* !FALSE */
75# ifndef TRUE
76# define TRUE (!FALSE)
77# endif /* !TRUE */
78# endif /* HAVE_NCURSES_NCURSES_H */
79# endif /* HAVE_NCURSES_H */
80# endif /* HAVE_NCURSESW_NCURSES_H */
81# if defined(NCURSES_WIDECHAR) && defined(HAVE_GET_WCH) && defined(HAVE_WGET_WCH)
82# define HAVE_NCURSESW 1
83# endif /* NCURSES_WIDECHAR && HAVE_GET_WCH && HAVE_WGET_WCH */
84# endif /* HAVE_NCURSES_H */
85# endif /* USE_CURSES || NEED_CURSES_H */
86
87# ifdef USE_CURSES
88
89# ifdef USE_TRACE
90# ifdef HAVE_NOMACROS_H
91# include <nomacros.h>
92# endif /* HAVE_NOMACROS_H */
93# endif /* USE_TRACE */
94
95# define cCRLF "\n"
96# define my_flush() my_fflush(stdout)
97# define ClearScreen() my_erase()
98# define CleartoEOLN() clrtoeol()
99# define CleartoEOS() clrtobot()
100# define ScrollScreen(lines_to_scroll) scrl(lines_to_scroll)
101# define SetScrollRegion(top,bottom) setscrreg(top, bottom)
102# define WriteLine(row,buffer) write_line(row, buffer)
103
104# define HpGlitch(func) /*nothing*/
105
106extern int cmdReadCh(void);
107extern int cmd_get_arrow_key(int prech);
108extern char *screen_contents(int row, int col, char *buffer);
109extern void MoveCursor(int row, int col);
110extern void my_erase(void);
111extern void my_fflush(FILE *stream);
112extern void my_fputc(int ch, FILE *stream);
113extern void my_fputs(const char *str, FILE *stream);
114# if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE)
115 extern void my_fputwc(wint_t wc, FILE *fp);
116 extern void my_fputws(const wchar_t *wstr, FILE *fp);
117 extern wint_t cmdReadWch(void);
118 extern wint_t ReadWch(void);
119# endif /* MULTIBYTE_ABLE && !NO_LOCALE */
120extern void my_fprintf(FILE *stream, const char *fmt, ...)
121# if defined(__GNUC__) && !defined(printf)
122 __attribute__((format(printf,2,3)))
123# endif /* __GNUC__ && !printf */
124 ;
125extern void my_printf(const char *fmt, ...)
126# if defined(__GNUC__) && !defined(printf)
127 __attribute__((format(printf,1,2)))
128# endif /* __GNUC__ && !printf */
129 ;
130extern void my_retouch(void);
131# ifdef HAVE_COLOR
132 extern void refresh_color(void);
133 extern void reset_color(void);
134# endif /* HAVE_COLOR */
135extern void write_line(int row, char *buffer);
136
137# else /* !USE_CURSES */
138
139# ifdef NEED_TERM_H
140# include <curses.h>
141# ifdef HAVE_NCURSESW_TERM_H
142# include <ncursesw/term.h>
143# else
144# ifdef HAVE_NCURSES_TERM_H
145# include <ncurses/term.h>
146# else
147# include <term.h>
148# endif /* HAVE_NCURSES_TERM_H */
149# endif /* HAVE_NCURSESW_TERM_H */
150# else
151# ifdef HAVE_TERMCAP_H
152# include <termcap.h>
153# endif /* HAVE_TERMCAP_H */
154# endif /* NEED_TERM_H */
155
156# define cCRLF "\r\n"
157
158# define my_fputc(ch, stream) fputc(ch, stream)
159# define my_fputs(str, stream) fputs(str, stream)
160# if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE)
161# define my_fputwc(wc, stream) { \
162 if (fwide(stream, 0) <= 0) \
163 fprintf(stream, "%lc", wc); \
164 else \
165 fputwc((wchar_t) (wc), stream); \
166 }
167# define my_fputws(wstr, stream) { \
168 if (fwide(stream, 0) <= 0) \
169 fprintf(stream, "%ls", wstr); \
170 else \
171 fputws(wstr, stream); \
172 }
173# endif /* MULTIBYTE_ABLE && !NO_LOCALE */
174
175# define my_printf printf
176# define my_fprintf fprintf
177# define my_flush() fflush(stdout)
178# define my_fflush(stream) fflush(stream)
179# define my_retouch() ClearScreen()
180# define WriteLine(row,buffer) MoveCursor(row, 0); my_fputs(buffer, stdout);
181
182# define HpGlitch(func) if (_hp_glitch) func
183
184# endif /* USE_CURSES/!USE_CURSES */
185
186extern void my_dummy(void);
187
188#endif /* !TCURSES_H */
void MoveCursor(int row, int col)
Definition: curses.c:441
#define my_fprintf
Definition: tcurses.h:176
#define my_fflush(stream)
Definition: tcurses.h:178
#define my_fputs(str, stream)
Definition: tcurses.h:159
#define my_retouch()
Definition: tcurses.h:179
#define my_printf
Definition: tcurses.h:175
#define my_fputc(ch, stream)
Definition: tcurses.h:158
void my_dummy(void)