Andreas Krennmair:
[apps/madmutt.git] / mutt_curses.h
1 /*
2  * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
3  * 
4  *     This program is free software; you can redistribute it and/or modify
5  *     it under the terms of the GNU General Public License as published by
6  *     the Free Software Foundation; either version 2 of the License, or
7  *     (at your option) any later version.
8  * 
9  *     This program 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 General Public License for more details.
13  * 
14  *     You should have received a copy of the GNU General Public License
15  *     along with this program; if not, write to the Free Software
16  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
17  */ 
18
19 #ifdef USE_SLANG_CURSES
20
21 #ifndef unix /* this symbol is not defined by the hp-ux compiler (sigh) */
22 #define unix
23 #endif /* unix */
24
25 #include "slcurses.h"
26
27 #define KEY_DC SL_KEY_DELETE
28 #define KEY_IC SL_KEY_IC
29
30 /*
31  * ncurses and SLang seem to send different characters when the Enter key is
32  * pressed, so define some macros to properly detect the Enter key.
33  */
34 #define M_ENTER_C '\r'
35 #define M_ENTER_S "\r"
36
37 #else
38
39 #ifdef HAVE_NCURSESW_NCURSES_H
40 #include <ncursesw/ncurses.h>
41 #else
42 #ifdef HAVE_NCURSES_H
43 #include <ncurses.h>
44 #else
45 #include <curses.h>
46 #endif
47 #endif
48
49 #define M_ENTER_C '\n'
50 #define M_ENTER_S "\n"
51
52 #endif /* USE_SLANG_CURSES */
53
54 /* AIX defines ``lines'' in <term.h>, but it's used as a var name in
55  * various places in Mutt
56  */
57 #ifdef lines
58 #undef lines
59 #endif /* lines */
60
61 #define CLEARLINE_WIN(x) move(x,SidebarWidth), clrtoeol()
62 #define CLEARLINE(x) move(x,0), clrtoeol()
63 #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x)
64 #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0)
65
66 #if ! (defined(USE_SLANG_CURSES) || defined(HAVE_CURS_SET))
67 #define curs_set(x)
68 #endif
69
70 #if !defined(USE_SLANG_CURSES) && defined(HAVE_BKGDSET)
71 #define BKGDSET(x) bkgdset (ColorDefs[x] | ' ')
72 #else
73 #define BKGDSET(x)
74 #endif
75
76 #if (defined(USE_SLANG_CURSES) || defined(HAVE_CURS_SET))
77 void mutt_curs_set (int);
78 #else
79 #define mutt_curs_set(x)
80 #endif
81 #define PAGELEN (LINES-3)
82
83 #define ctrl(c) ((c)-'@')
84
85 #ifdef KEY_ENTER
86 #define CI_is_return(c) ((c) == '\r' || (c) == '\n' || (c) == KEY_ENTER)
87 #else
88 #define CI_is_return(c) ((c) == '\r' || (c) == '\n')
89 #endif
90
91 event_t mutt_getch (void);
92
93 void mutt_endwin (const char *);
94 void mutt_flushinp (void);
95 void mutt_refresh (void);
96 void mutt_resize_screen (void);
97 void mutt_ungetch (int, int);
98
99 /* ----------------------------------------------------------------------------
100  * Support for color
101  */
102
103 enum
104 {
105   MT_COLOR_HDEFAULT = 0,
106   MT_COLOR_QUOTED,
107   MT_COLOR_SIGNATURE,
108   MT_COLOR_INDICATOR,
109   MT_COLOR_STATUS,
110   MT_COLOR_TREE,
111   MT_COLOR_NORMAL,
112   MT_COLOR_ERROR,
113   MT_COLOR_TILDE,
114   MT_COLOR_MARKERS,
115   MT_COLOR_BODY,
116   MT_COLOR_HEADER,
117   MT_COLOR_MESSAGE,
118   MT_COLOR_ATTACHMENT,
119   MT_COLOR_SEARCH,
120   MT_COLOR_BOLD,
121   MT_COLOR_UNDERLINE,
122   MT_COLOR_INDEX,
123   MT_COLOR_NEW,
124   MT_COLOR_MAX
125 };
126
127 typedef struct color_line
128 {
129   regex_t rx;
130   char *pattern;
131   pattern_t *color_pattern; /* compiled pattern to speed up index color
132                                calculation */
133   short fg;
134   short bg;
135   int pair;
136   struct color_line *next;
137 } COLOR_LINE;
138
139 extern int *ColorQuote;
140 extern int ColorQuoteUsed;
141 extern int ColorDefs[];
142 extern COLOR_LINE *ColorHdrList;
143 extern COLOR_LINE *ColorBodyList;
144 extern COLOR_LINE *ColorIndexList;
145
146 void ci_init_color (void);
147 void ci_start_color (void);
148
149 #define SETCOLOR(X) attrset(ColorDefs[X])
150 #define ADDCOLOR(X) attron(ColorDefs[X])
151
152 #define MAYBE_REDRAW(x) if (option (OPTNEEDREDRAW)) { unset_option (OPTNEEDREDRAW); x = REDRAW_FULL; }
153
154 /* ----------------------------------------------------------------------------
155  * These are here to avoid compiler warnings with -Wall under SunOS 4.1.x
156  */
157
158 #if !defined(STDC_HEADERS) && !defined(NCURSES_VERSION) && !defined(USE_SLANG_CURSES)
159 extern int endwin();
160 extern int printw();
161 extern int beep();
162 extern int isendwin();
163 extern int w32addch();
164 extern int keypad();
165 extern int wclrtobot();
166 extern int mvprintw();
167 extern int getcurx();
168 extern int getcury();
169 extern int noecho();
170 extern int wdelch();
171 extern int wrefresh();
172 extern int wmove();
173 extern int wclear();
174 extern int waddstr();
175 extern int wclrtoeol();
176 #endif