2 * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
3 * Copyright (C) 2004 g10 Code GmbH
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 2 of the License, or
8 * (at your option) any later version.
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.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef _MUTT_CURSES_H_
21 #define _MUTT_CURSES_H_ 1
23 #ifdef USE_SLANG_CURSES
25 #ifndef unix /* this symbol is not defined by the hp-ux compiler (sigh) */
29 #include <slang.h> /* in addition to slcurses.h, we need slang.h for the version
30 number to test for 2.x having UTF-8 support in main.c */
33 #define KEY_DC SL_KEY_DELETE
34 #define KEY_IC SL_KEY_IC
37 * ncurses and SLang seem to send different characters when the Enter key is
38 * pressed, so define some macros to properly detect the Enter key.
40 #define M_ENTER_C '\r'
41 #define M_ENTER_S "\r"
43 #else /* USE_SLANG_CURSES */
45 #if HAVE_NCURSESW_NCURSES_H
46 # include <ncursesw/ncurses.h>
47 #elif HAVE_NCURSES_NCURSES_H
48 # include <ncurses/ncurses.h>
55 #define M_ENTER_C '\n'
56 #define M_ENTER_S "\n"
58 #endif /* USE_SLANG_CURSES */
60 /* AIX defines ``lines'' in <term.h>, but it's used as a var name in
61 * various places in Mutt
67 #define CLEARLINE(x) move(x,0), clrtoeol()
68 #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x)
69 #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0)
71 #if ! (defined(USE_SLANG_CURSES) || defined(HAVE_CURS_SET))
75 #if !defined(USE_SLANG_CURSES) && defined(HAVE_BKGDSET)
76 #define BKGDSET(x) bkgdset (ColorDefs[x] | ' ')
81 #if (defined(USE_SLANG_CURSES) || defined(HAVE_CURS_SET))
82 void mutt_curs_set (int);
84 #define mutt_curs_set(x)
86 #define PAGELEN (LINES-3)
88 #define ctrl(c) ((c)-'@')
91 #define CI_is_return(c) ((c) == '\r' || (c) == '\n' || (c) == KEY_ENTER)
93 #define CI_is_return(c) ((c) == '\r' || (c) == '\n')
96 event_t mutt_getch (void);
98 void mutt_endwin (const char *);
99 void mutt_flushinp (void);
100 void mutt_refresh (void);
101 void mutt_resize_screen (void);
102 void mutt_ungetch (int, int);
103 void mutt_need_hard_redraw (void);
105 /* ----------------------------------------------------------------------------
111 MT_COLOR_HDEFAULT = 0,
132 typedef struct color_line
136 pattern_t *color_pattern; /* compiled pattern to speed up index color
141 struct color_line *next;
144 #define M_PROGRESS_SIZE (1<<0) /* traffic-based progress */
145 #define M_PROGRESS_MSG (1<<1) /* message-based progress */
150 unsigned short flags;
154 unsigned int timestamp;
155 char sizestr[SHORT_STRING];
158 void mutt_progress_init (progress_t* progress, const char *msg,
159 unsigned short flags, unsigned short inc,
161 /* If percent is positive, it is displayed as percentage, otherwise
162 * percentage is calculated from progress->size and pos if progress
163 * was initialized with positive size, otherwise no percentage is shown */
164 void mutt_progress_update (progress_t* progress, long pos, int percent);
166 static inline int mutt_term_width(short wrap)
169 return COLS > -wrap ? COLS + wrap : COLS;
171 return wrap < COLS ? wrap : COLS;
176 extern int *ColorQuote;
177 extern int ColorQuoteUsed;
178 extern int ColorDefs[];
179 extern COLOR_LINE *ColorHdrList;
180 extern COLOR_LINE *ColorBodyList;
181 extern COLOR_LINE *ColorIndexList;
183 void ci_init_color (void);
184 void ci_start_color (void);
186 #define SETCOLOR(X) attrset(ColorDefs[X])
187 #define ADDCOLOR(X) attron(ColorDefs[X])
189 #define MAYBE_REDRAW(x) if (option (OPTNEEDREDRAW)) { unset_option (OPTNEEDREDRAW); x = REDRAW_FULL; }
191 /* ----------------------------------------------------------------------------
192 * These are here to avoid compiler warnings with -Wall under SunOS 4.1.x
195 #if !defined(STDC_HEADERS) && !defined(NCURSES_VERSION) && !defined(USE_SLANG_CURSES)
199 extern int isendwin();
200 extern int w32addch();
202 extern int wclrtobot();
203 extern int mvprintw();
204 extern int getcurx();
205 extern int getcury();
208 extern int wrefresh();
211 extern int waddstr();
212 extern int wclrtoeol();
215 #endif /* _MUTT_CURSES_H_ */