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(x) move(x,0), clrtoeol()
62 #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x)
63 #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0)
64
65 #if ! (defined(USE_SLANG_CURSES) || defined(HAVE_CURS_SET))
66 #define curs_set(x)
67 #endif
68
69 #if !defined(USE_SLANG_CURSES) && defined(HAVE_BKGDSET)
70 #define BKGDSET(x) bkgdset (ColorDefs[x] | ' ')
71 #else
72 #define BKGDSET(x)
73 #endif
74
75 #if (defined(USE_SLANG_CURSES) || defined(HAVE_CURS_SET))
76 void mutt_curs_set (int);
77 #else
78 #define mutt_curs_set(x)
79 #endif
80 #define PAGELEN (LINES-3)
81
82 #define ctrl(c) ((c)-'@')
83
84 #ifdef KEY_ENTER
85 #define CI_is_return(c) ((c) == '\r' || (c) == '\n' || (c) == KEY_ENTER)
86 #else
87 #define CI_is_return(c) ((c) == '\r' || (c) == '\n')
88 #endif
89
90 event_t mutt_getch (void);
91
92 void mutt_endwin (const char *);
93 void mutt_flushinp (void);
94 void mutt_refresh (void);
95 void mutt_resize_screen (void);
96 void mutt_ungetch (int, int);
97
98 /* ----------------------------------------------------------------------------
99  * Support for color
100  */
101
102 enum
103 {
104   MT_COLOR_HDEFAULT = 0,
105   MT_COLOR_QUOTED,
106   MT_COLOR_SIGNATURE,
107   MT_COLOR_INDICATOR,
108   MT_COLOR_STATUS,
109   MT_COLOR_TREE,
110   MT_COLOR_NORMAL,
111   MT_COLOR_ERROR,
112   MT_COLOR_TILDE,
113   MT_COLOR_MARKERS,
114   MT_COLOR_BODY,
115   MT_COLOR_HEADER,
116   MT_COLOR_MESSAGE,
117   MT_COLOR_ATTACHMENT,
118   MT_COLOR_SEARCH,
119   MT_COLOR_BOLD,
120   MT_COLOR_UNDERLINE,
121   MT_COLOR_INDEX,
122   MT_COLOR_MAX
123 };
124
125 typedef struct color_line
126 {
127   regex_t rx;
128   char *pattern;
129   pattern_t *color_pattern; /* compiled pattern to speed up index color
130                                calculation */
131   short fg;
132   short bg;
133   int pair;
134   struct color_line *next;
135 } COLOR_LINE;
136
137 extern int *ColorQuote;
138 extern int ColorQuoteUsed;
139 extern int ColorDefs[];
140 extern COLOR_LINE *ColorHdrList;
141 extern COLOR_LINE *ColorBodyList;
142 extern COLOR_LINE *ColorIndexList;
143
144 void ci_init_color (void);
145 void ci_start_color (void);
146
147 #define SETCOLOR(X) attrset(ColorDefs[X])
148 #define ADDCOLOR(X) attron(ColorDefs[X])
149
150 #define MAYBE_REDRAW(x) if (option (OPTNEEDREDRAW)) { unset_option (OPTNEEDREDRAW); x = REDRAW_FULL; }
151
152 /* ----------------------------------------------------------------------------
153  * These are here to avoid compiler warnings with -Wall under SunOS 4.1.x
154  */
155
156 #if !defined(STDC_HEADERS) && !defined(NCURSES_VERSION) && !defined(USE_SLANG_CURSES)
157 extern int endwin();
158 extern int printw();
159 extern int beep();
160 extern int isendwin();
161 extern int w32addch();
162 extern int keypad();
163 extern int wclrtobot();
164 extern int mvprintw();
165 extern int getcurx();
166 extern int getcury();
167 extern int noecho();
168 extern int wdelch();
169 extern int wrefresh();
170 extern int wmove();
171 extern int wclear();
172 extern int waddstr();
173 extern int wclrtoeol();
174 #endif