sort out some prototypes, put them where they belong.
[apps/madmutt.git] / lib-ui / curses.h
1 /*
2  * Copyright notice from original mutt:
3  * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
4  * Copyright (C) 2004 g10 Code GmbH
5  *
6  * This file is part of mutt-ng, see http://www.muttng.org/.
7  * It's licensed under the GNU General Public License,
8  * please see the file GPL in the top level source directory.
9  */
10 #ifndef _MUTT_CURSES_H
11 #define _MUTT_CURSES_H
12
13 #include "mutt.h"
14
15 #ifdef USE_SLANG_CURSES
16
17 #ifndef unix                    /* this symbol is not defined by the hp-ux compiler (sigh) */
18 #define unix
19 #endif /* unix */
20
21 #include "slcurses.h"
22
23 #define KEY_DC SL_KEY_DELETE
24 #define KEY_IC SL_KEY_IC
25
26 /*
27  * ncurses and SLang seem to send different characters when the Enter key is
28  * pressed, so define some macros to properly detect the Enter key.
29  */
30 #define M_ENTER_C '\r'
31 #define M_ENTER_S "\r"
32
33 #else
34
35 #ifdef HAVE_NCURSESW_NCURSES_H
36 #include <ncursesw/ncurses.h>
37 #else
38 #ifdef HAVE_NCURSES_NCURSES_H
39 #include <ncurses/ncurses.h>
40 #else
41 #ifdef HAVE_NCURSES_H
42 #include <ncurses.h>
43 #else
44 #include <curses.h>
45 #endif
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,(option(OPTMBOXPANE)?SidebarWidth:0)), 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 void mutt_need_hard_redraw (void);
99
100 /* ----------------------------------------------------------------------------
101  * Support for color
102  */
103
104 enum {
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_SIDEBAR,
122   MT_COLOR_UNDERLINE,
123   MT_COLOR_INDEX,
124   MT_COLOR_NEW,
125   MT_COLOR_FLAGGED,
126   MT_COLOR_MAX
127 };
128
129 typedef struct color_line {
130   regex_t rx;
131   char *pattern;
132   pattern_t *color_pattern;     /* compiled pattern to speed up index color
133                                    calculation */
134   short fg;
135   short bg;
136   int pair;
137   struct color_line *next;
138 } COLOR_LINE;
139
140 typedef struct {
141   const char* msg;
142   long pos;
143   long size;
144   char sizestr[SHORT_STRING];
145 } progress_t;
146
147 void mutt_progress_bar (progress_t* progress, long pos);
148 void mutt_clear_error (void);
149 void mutt_edit_file (const char *, const char *);
150 void mutt_curses_error (const char *, ...);
151 void mutt_curses_message (const char *, ...);
152 void mutt_format_string (char *, ssize_t, int, int, int, char, const char *,
153                          ssize_t, int);
154 void mutt_format_s (char *, ssize_t, const char *, const char *);
155 void mutt_format_s_tree (char *, ssize_t, const char *, const char *);
156 void mutt_free_color (int fg, int bg);
157 void mutt_paddstr (int, const char *);
158 #define mutt_perror(a) _mutt_perror (a, __FILE__, __LINE__)
159 void _mutt_perror (const char*, const char*,int);
160 void mutt_query_exit (void);
161 void mutt_query_menu (char *, ssize_t);
162 void mutt_show_error (void);
163
164 int mutt_addwch (wchar_t);
165 int mutt_alloc_color (int fg, int bg);
166 int mutt_any_key_to_continue (const char *);
167 int mutt_complete (char *, ssize_t);
168 #define mutt_enter_fname(A,B,C,D,E) _mutt_enter_fname(A,B,C,D,E,0,NULL,NULL)
169 int _mutt_enter_fname (const char *, char *, ssize_t, int *, int, int,
170                        char ***, int *);
171
172 #define mutt_get_field(A,B,C,D) _mutt_get_field(A,B,C,D,0,NULL,NULL)
173 int _mutt_get_field (const char *, char *, ssize_t, int, int, char ***, int *);
174 int mutt_get_field_unbuffered (char *, char *, ssize_t, int);
175 int mutt_index_menu (void);
176 int mutt_is_mail_list (address_t *);
177 int mutt_is_subscribed_list (address_t *);
178 int mutt_multi_choice (char *prompt, char *letters);
179 int mutt_parse_color (BUFFER *, BUFFER *, unsigned long, BUFFER *);
180 int mutt_parse_uncolor (BUFFER *, BUFFER *, unsigned long, BUFFER *);
181 int mutt_parse_mono (BUFFER *, BUFFER *, unsigned long, BUFFER *);
182 int mutt_parse_unmono (BUFFER *, BUFFER *, unsigned long, BUFFER *);
183 int mutt_query_complete (char *, ssize_t);
184 int mutt_strwidth (const char *);
185 int mutt_user_is_recipient (HEADER *);
186 int mutt_yesorno (const char *, int);
187 void mutt_set_header_color (CONTEXT *, HEADER *);
188
189 extern int *ColorQuote;
190 extern int ColorQuoteUsed;
191 extern int ColorDefs[];
192 extern COLOR_LINE *ColorHdrList;
193 extern COLOR_LINE *ColorBodyList;
194 extern COLOR_LINE *ColorIndexList;
195
196 void ci_init_color (void);
197 void ci_start_color (void);
198
199 #define mutt_make_string(A,B,C,D,E) _mutt_make_string(A,B,C,D,E,0)
200 void _mutt_make_string (char *, ssize_t, const char *, CONTEXT *,
201                         HEADER *, format_flag);
202
203
204 #define SETCOLOR(X) attrset(ColorDefs[X])
205 #define ADDCOLOR(X) attron(ColorDefs[X])
206
207 #define MAYBE_REDRAW(x) if (option (OPTNEEDREDRAW)) { unset_option (OPTNEEDREDRAW); x = REDRAW_FULL; }
208
209 #endif /* !_MUTT_CURSES_H */