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