tmp
[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 /* flags for mutt_get_field() */
78 #define  M_ALIAS       (1<<0)  /* do alias "completion" by calling up the alias-menu */
79 #define  M_FILE        (1<<1)  /* do file completion */
80 #define  M_EFILE       (1<<2)  /* do file completion, plus incoming folders */
81 #define  M_CMD         (1<<3)  /* do completion on previous word */
82 #define  M_PASS        (1<<4)  /* password mode (no echo) */
83 #define  M_CLEAR       (1<<5)  /* clear input if printable character is pressed */
84 #define  M_COMMAND     (1<<6)  /* do command completion */
85 #define  M_PATTERN     (1<<7)  /* pattern mode - only used for history classes */
86 #define  M_LASTFOLDER  (1<<8)  /* last-folder mode - hack hack hack */
87
88 typedef struct color_line {
89   regex_t rx;
90   char *pattern;
91   pattern_t *color_pattern;     /* compiled pattern to speed up index color
92                                    calculation */
93   short fg;
94   short bg;
95   int pair;
96   struct color_line *next;
97 } COLOR_LINE;
98
99 typedef struct {
100   const char* msg;
101   long pos;
102   long size;
103   char sizestr[STRING];
104 } progress_t;
105
106 void mutt_progress_bar (progress_t* progress, long pos);
107 void mutt_clear_error (void);
108 void mutt_edit_file (const char *);
109 void mutt_curses_error (const char *, ...)
110     __attribute__((format(printf, 1, 2)));
111 void mutt_curses_message (const char *, ...)
112     __attribute__((format(printf, 1, 2)));
113 void mutt_format_string (char *, ssize_t, int, int, int, char, const char *,
114                          ssize_t, int);
115 void mutt_format_s (char *, ssize_t, const char *, const char *);
116 void mutt_format_s_tree (char *, ssize_t, const char *, const char *);
117 void mutt_free_color (int fg, int bg);
118 void mutt_paddstr(WINDOW *, int, const char *);
119 #define mutt_perror(s)  \
120   mutt_error("%s: %m (errno = %d) from %s:%i", s, errno, __FILE__, __LINE__)
121 void mutt_query_exit (void);
122 void mutt_query_menu (char *, ssize_t);
123 void mutt_show_error (void);
124 ssize_t mutt_pretty_size(char *s, ssize_t len, ssize_t n);
125
126 int mutt_any_key_to_continue (const char *);
127 int mutt_complete (char *, ssize_t);
128 #define mutt_enter_fname(A,B,C,D,E) _mutt_enter_fname(A,B,C,D,E,0,NULL,NULL)
129 int _mutt_enter_fname (const char *, char *, ssize_t, int *, int, int,
130                        char ***, int *);
131
132 #define mutt_get_field(A,B,C,D) _mutt_get_field(A,B,C,D,0,NULL,NULL)
133 int _mutt_get_field (const char *, char *, ssize_t, int, int, char ***, int *);
134 int mutt_get_field_unbuffered (char *, char *, ssize_t, int);
135 int mutt_index_menu (void);
136 int mutt_is_mail_list (address_t *);
137 int mutt_is_subscribed_list (address_t *);
138 int mutt_multi_choice (const char *prompt, const char *letters);
139 int mutt_parse_color (BUFFER *, BUFFER *, unsigned long, BUFFER *);
140 int mutt_parse_uncolor (BUFFER *, BUFFER *, unsigned long, BUFFER *);
141 int mutt_query_complete (char *, ssize_t);
142 int mutt_user_is_recipient (HEADER *);
143 int mutt_yesorno (const char *, int);
144 void mutt_set_header_color (CONTEXT *, HEADER *);
145
146 extern int *ColorQuote;
147 extern int ColorQuoteUsed;
148 extern int ColorDefs[];
149 extern COLOR_LINE *ColorHdrList;
150 extern COLOR_LINE *ColorBodyList;
151 extern COLOR_LINE *ColorIndexList;
152
153 void ci_start_color (void);
154
155 #define mutt_make_string(A,B,C,D,E) _mutt_make_string(A,B,C,D,E,0)
156 void _mutt_make_string (char *, ssize_t, const char *, CONTEXT *,
157                         HEADER *, format_flag);
158
159 #define MAYBE_REDRAW(x) if (option (OPTNEEDREDRAW)) { unset_option (OPTNEEDREDRAW); x = REDRAW_FULL; }
160
161 #endif /* !_MUTT_CURSES_H */