e8c6055054a8d2c0cb4ed21c2ecfae4af0d44e9b
[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 /* AIX defines ``lines'' in <term.h>, but it's used as a var name in
16  * various places in Mutt
17  */
18 #ifdef lines
19 #undef lines
20 #endif /* lines */
21
22 #define CLEARLINE_WIN(x) wmove(stdscr, x,(option(OPTMBOXPANE)?SidebarWidth:0)), wclrtoeol(stdscr)
23 #define CLEARLINE(x) wmove(stdscr, x,0), wclrtoeol(stdscr)
24 #define CENTERLINE(x,y) wmove(stdscr, y, (COLS-strlen(x))/2), waddstr(stdscr, x)
25 #define BEEP() do { if (mod_core.beep) beep(); } while (0)
26
27 #define BKGDSET(x)  wbkgdset(stdscr, ColorDefs[x] | ' ')
28
29 void mutt_curs_set (int);
30 #define PAGELEN (LINES-3)
31
32 #define ctrl(c) ((c)-'@')
33
34 #ifdef KEY_ENTER
35 #define CI_is_return(c) ((c) == '\r' || (c) == '\n' || (c) == KEY_ENTER)
36 #else
37 #define CI_is_return(c) ((c) == '\r' || (c) == '\n')
38 #endif
39
40 event_t mutt_getch (void);
41
42 void curses_initialize(void);
43 void curses_install(void);
44
45 void mutt_endwin (const char *);
46 void mutt_flushinp (void);
47 void mutt_refresh (void);
48 void mutt_resize_screen (void);
49 void mutt_ungetch (int, int);
50 void mutt_need_hard_redraw (void);
51
52 /* ----------------------------------------------------------------------------
53  * Support for color
54  */
55
56 enum {
57   MT_COLOR_HDEFAULT = 0,
58   MT_COLOR_QUOTED,
59   MT_COLOR_SIGNATURE,
60   MT_COLOR_INDICATOR,
61   MT_COLOR_STATUS,
62   MT_COLOR_TREE,
63   MT_COLOR_NORMAL,
64   MT_COLOR_ERROR,
65   MT_COLOR_TILDE,
66   MT_COLOR_MARKERS,
67   MT_COLOR_BODY,
68   MT_COLOR_HEADER,
69   MT_COLOR_MESSAGE,
70   MT_COLOR_ATTACHMENT,
71   MT_COLOR_SEARCH,
72   MT_COLOR_BOLD,
73   MT_COLOR_SIDEBAR,
74   MT_COLOR_UNDERLINE,
75   MT_COLOR_INDEX,
76   MT_COLOR_NEW,
77   MT_COLOR_FLAGGED,
78   MT_COLOR_MAX
79 };
80
81 typedef struct color_line {
82   regex_t rx;
83   char *pattern;
84   pattern_t *color_pattern;     /* compiled pattern to speed up index color
85                                    calculation */
86   short fg;
87   short bg;
88   int pair;
89   struct color_line *next;
90 } COLOR_LINE;
91
92 typedef struct {
93   const char* msg;
94   long pos;
95   long size;
96   char sizestr[STRING];
97 } progress_t;
98
99 void mutt_progress_bar (progress_t* progress, long pos);
100 void mutt_clear_error (void);
101 void mutt_edit_file (const char *);
102 void mutt_curses_error (const char *, ...)
103     __attribute__((format(printf, 1, 2)));
104 void mutt_curses_message (const char *, ...)
105     __attribute__((format(printf, 1, 2)));
106 void mutt_format_string (char *, ssize_t, int, int, int, char, const char *,
107                          ssize_t, int);
108 void mutt_format_s (char *, ssize_t, const char *, const char *);
109 void mutt_format_s_tree (char *, ssize_t, const char *, const char *);
110 void mutt_free_color (int fg, int bg);
111 void mutt_paddstr (int, const char *);
112 #define mutt_perror(a) _mutt_perror (a, __FILE__, __LINE__)
113 void _mutt_perror (const char*, const char*,int);
114 void mutt_query_exit (void);
115 void mutt_query_menu (char *, ssize_t);
116 void mutt_show_error (void);
117 ssize_t mutt_pretty_size(char *s, ssize_t len, ssize_t n);
118
119 int mutt_addwch (wchar_t);
120 int mutt_alloc_color (int fg, int bg);
121 int mutt_any_key_to_continue (const char *);
122 void mutt_what_key (void);
123 int mutt_complete (char *, ssize_t);
124 #define mutt_enter_fname(A,B,C,D,E) _mutt_enter_fname(A,B,C,D,E,0,NULL,NULL)
125 int _mutt_enter_fname (const char *, char *, ssize_t, int *, int, int,
126                        char ***, int *);
127
128 #define mutt_get_field(A,B,C,D) _mutt_get_field(A,B,C,D,0,NULL,NULL)
129 int _mutt_get_field (const char *, char *, ssize_t, int, int, char ***, int *);
130 int mutt_get_field_unbuffered (char *, char *, ssize_t, int);
131 int mutt_index_menu (void);
132 int mutt_is_mail_list (address_t *);
133 int mutt_is_subscribed_list (address_t *);
134 int mutt_multi_choice (const char *prompt, const char *letters);
135 int mutt_parse_color (BUFFER *, BUFFER *, unsigned long, BUFFER *);
136 int mutt_parse_uncolor (BUFFER *, BUFFER *, unsigned long, BUFFER *);
137 int mutt_parse_mono (BUFFER *, BUFFER *, unsigned long, BUFFER *);
138 int mutt_parse_unmono (BUFFER *, BUFFER *, unsigned long, BUFFER *);
139 int mutt_query_complete (char *, ssize_t);
140 int mutt_user_is_recipient (HEADER *);
141 int mutt_yesorno (const char *, int);
142 void mutt_set_header_color (CONTEXT *, HEADER *);
143
144 extern int *ColorQuote;
145 extern int ColorQuoteUsed;
146 extern int ColorDefs[];
147 extern COLOR_LINE *ColorHdrList;
148 extern COLOR_LINE *ColorBodyList;
149 extern COLOR_LINE *ColorIndexList;
150
151 void ci_start_color (void);
152
153 #define mutt_make_string(A,B,C,D,E) _mutt_make_string(A,B,C,D,E,0)
154 void _mutt_make_string (char *, ssize_t, const char *, CONTEXT *,
155                         HEADER *, format_flag);
156
157
158 #define SETCOLOR(X) wattrset(stdscr, ColorDefs[X])
159 #define ADDCOLOR(X) wattron(stdscr, ColorDefs[X])
160
161 #define MAYBE_REDRAW(x) if (option (OPTNEEDREDRAW)) { unset_option (OPTNEEDREDRAW); x = REDRAW_FULL; }
162
163 #define SW              (option(OPTMBOXPANE)?SidebarWidth:0)
164
165 #endif /* !_MUTT_CURSES_H */