9df89bedc86a505d22d24ef5b8460a315c9bc333
[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(W, x) wmove(W, x,0), wclrtoeol(W)
23 #define BEEP() do { if (mod_core.beep) beep(); } while (0)
24
25 #define BKGDSET(W, x)   wbkgdset(W, ColorDefs[x] | ' ')
26 #define SETCOLOR(W, X)  wattrset(W, ColorDefs[X])
27 #define ADDCOLOR(W, X)  wattron(W, ColorDefs[X])
28
29 void mutt_curs_set (int);
30
31 #define ctrl(c) ((c)-'@')
32
33 #ifdef KEY_ENTER
34 #define CI_is_return(c) ((c) == '\r' || (c) == '\n' || (c) == KEY_ENTER)
35 #else
36 #define CI_is_return(c) ((c) == '\r' || (c) == '\n')
37 #endif
38
39 event_t mutt_getch (void);
40 #define waddwch(win, w)  waddnwstr(win, &(w), 1)
41
42 void curses_initialize(void);
43 void curses_install(void);
44
45 void mutt_flushinp (void);
46 void mutt_ungetch (int, int);
47
48 /* ----------------------------------------------------------------------------
49  * Support for color
50  */
51
52 enum {
53   MT_COLOR_HDEFAULT = 0,
54   MT_COLOR_QUOTED,
55   MT_COLOR_SIGNATURE,
56   MT_COLOR_INDICATOR,
57   MT_COLOR_STATUS,
58   MT_COLOR_TREE,
59   MT_COLOR_NORMAL,
60   MT_COLOR_ERROR,
61   MT_COLOR_TILDE,
62   MT_COLOR_MARKERS,
63   MT_COLOR_BODY,
64   MT_COLOR_HEADER,
65   MT_COLOR_MESSAGE,
66   MT_COLOR_ATTACHMENT,
67   MT_COLOR_SEARCH,
68   MT_COLOR_BOLD,
69   MT_COLOR_SIDEBAR,
70   MT_COLOR_UNDERLINE,
71   MT_COLOR_INDEX,
72   MT_COLOR_NEW,
73   MT_COLOR_FLAGGED,
74   MT_COLOR_MAX
75 };
76
77 typedef struct color_line {
78   regex_t rx;
79   char *pattern;
80   pattern_t *color_pattern;     /* compiled pattern to speed up index color
81                                    calculation */
82   short fg;
83   short bg;
84   int pair;
85   struct color_line *next;
86 } COLOR_LINE;
87
88 typedef struct {
89   const char* msg;
90   long pos;
91   long size;
92   char sizestr[STRING];
93 } progress_t;
94
95 void mutt_progress_bar (progress_t* progress, long pos);
96 void mutt_clear_error (void);
97 void mutt_edit_file (const char *);
98 void mutt_curses_error (const char *, ...)
99     __attribute__((format(printf, 1, 2)));
100 void mutt_curses_message (const char *, ...)
101     __attribute__((format(printf, 1, 2)));
102 void mutt_format_string (char *, ssize_t, int, int, int, char, const char *,
103                          ssize_t, int);
104 void mutt_format_s (char *, ssize_t, const char *, const char *);
105 void mutt_format_s_tree (char *, ssize_t, const char *, const char *);
106 void mutt_free_color (int fg, int bg);
107 void mutt_paddstr(WINDOW *, int, const char *);
108 #define mutt_perror(s)  \
109   mutt_error("%s: %m (errno = %d) from %s:%i", s, errno, __FILE__, __LINE__)
110 void mutt_query_exit (void);
111 void mutt_query_menu (char *, ssize_t);
112 void mutt_show_error (void);
113 ssize_t mutt_pretty_size(char *s, ssize_t len, ssize_t n);
114
115 int mutt_any_key_to_continue (const char *);
116 int mutt_complete (char *, ssize_t);
117 #define mutt_enter_fname(A,B,C,D,E) _mutt_enter_fname(A,B,C,D,E,0,NULL,NULL)
118 int _mutt_enter_fname (const char *, char *, ssize_t, int *, int, int,
119                        char ***, int *);
120
121 #define mutt_get_field(A,B,C,D) _mutt_get_field(A,B,C,D,0,NULL,NULL)
122 int _mutt_get_field (const char *, char *, ssize_t, int, int, char ***, int *);
123 int mutt_get_field_unbuffered (char *, char *, ssize_t, int);
124 int mutt_index_menu (void);
125 int mutt_is_mail_list (address_t *);
126 int mutt_is_subscribed_list (address_t *);
127 int mutt_multi_choice (const char *prompt, const char *letters);
128 int mutt_parse_color (BUFFER *, BUFFER *, unsigned long, BUFFER *);
129 int mutt_parse_uncolor (BUFFER *, BUFFER *, unsigned long, BUFFER *);
130 int mutt_query_complete (char *, ssize_t);
131 int mutt_user_is_recipient (HEADER *);
132 int mutt_yesorno (const char *, int);
133 void mutt_set_header_color (CONTEXT *, HEADER *);
134
135 extern int *ColorQuote;
136 extern int ColorQuoteUsed;
137 extern int ColorDefs[];
138 extern COLOR_LINE *ColorHdrList;
139 extern COLOR_LINE *ColorBodyList;
140 extern COLOR_LINE *ColorIndexList;
141
142 void ci_start_color (void);
143
144 #define mutt_make_string(A,B,C,D,E) _mutt_make_string(A,B,C,D,E,0)
145 void _mutt_make_string (char *, ssize_t, const char *, CONTEXT *,
146                         HEADER *, format_flag);
147
148 #define MAYBE_REDRAW(x) if (option (OPTNEEDREDRAW)) { unset_option (OPTNEEDREDRAW); x = REDRAW_FULL; }
149
150 #endif /* !_MUTT_CURSES_H */