Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 216 lines (182 sloc) 5.584 kb
14c2920 Imported Upstream version 1.5.18
Antonio Radici authored
1 /*
2 * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
3 * Copyright (C) 2004 g10 Code GmbH
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20 #ifndef _MUTT_CURSES_H_
21 #define _MUTT_CURSES_H_ 1
22
23 #ifdef USE_SLANG_CURSES
24
25 #ifndef unix /* this symbol is not defined by the hp-ux compiler (sigh) */
26 #define unix
27 #endif /* unix */
28
29 #include <slang.h> /* in addition to slcurses.h, we need slang.h for the version
30 number to test for 2.x having UTF-8 support in main.c */
31 #include <slcurses.h>
32
33 #define KEY_DC SL_KEY_DELETE
34 #define KEY_IC SL_KEY_IC
35
36 /*
37 * ncurses and SLang seem to send different characters when the Enter key is
38 * pressed, so define some macros to properly detect the Enter key.
39 */
40 #define M_ENTER_C '\r'
41 #define M_ENTER_S "\r"
42
43 #else /* USE_SLANG_CURSES */
44
45 #if HAVE_NCURSESW_NCURSES_H
46 # include <ncursesw/ncurses.h>
47 #elif HAVE_NCURSES_NCURSES_H
48 # include <ncurses/ncurses.h>
49 #elif HAVE_NCURSES_H
50 # include <ncurses.h>
51 #else
52 # include <curses.h>
53 #endif
54
55 #define M_ENTER_C '\n'
56 #define M_ENTER_S "\n"
57
58 #endif /* USE_SLANG_CURSES */
59
60 /* AIX defines ``lines'' in <term.h>, but it's used as a var name in
61 * various places in Mutt
62 */
63 #ifdef lines
64 #undef lines
65 #endif /* lines */
66
67 #define CLEARLINE(x) move(x,0), clrtoeol()
68 #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x)
69 #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0)
70
71 #if ! (defined(USE_SLANG_CURSES) || defined(HAVE_CURS_SET))
72 #define curs_set(x)
73 #endif
74
75 #if !defined(USE_SLANG_CURSES) && defined(HAVE_BKGDSET)
76 #define BKGDSET(x) bkgdset (ColorDefs[x] | ' ')
77 #else
78 #define BKGDSET(x)
79 #endif
80
81 #if (defined(USE_SLANG_CURSES) || defined(HAVE_CURS_SET))
82 void mutt_curs_set (int);
83 #else
84 #define mutt_curs_set(x)
85 #endif
86 #define PAGELEN (LINES-3)
87
88 #define ctrl(c) ((c)-'@')
89
90 #ifdef KEY_ENTER
91 #define CI_is_return(c) ((c) == '\r' || (c) == '\n' || (c) == KEY_ENTER)
92 #else
93 #define CI_is_return(c) ((c) == '\r' || (c) == '\n')
94 #endif
95
96 event_t mutt_getch (void);
97
98 void mutt_endwin (const char *);
99 void mutt_flushinp (void);
100 void mutt_refresh (void);
101 void mutt_resize_screen (void);
102 void mutt_ungetch (int, int);
103 void mutt_need_hard_redraw (void);
104
105 /* ----------------------------------------------------------------------------
106 * Support for color
107 */
108
109 enum
110 {
111 MT_COLOR_HDEFAULT = 0,
112 MT_COLOR_QUOTED,
113 MT_COLOR_SIGNATURE,
114 MT_COLOR_INDICATOR,
115 MT_COLOR_STATUS,
116 MT_COLOR_TREE,
117 MT_COLOR_NORMAL,
118 MT_COLOR_ERROR,
119 MT_COLOR_TILDE,
120 MT_COLOR_MARKERS,
121 MT_COLOR_BODY,
122 MT_COLOR_HEADER,
123 MT_COLOR_MESSAGE,
124 MT_COLOR_ATTACHMENT,
125 MT_COLOR_SEARCH,
126 MT_COLOR_BOLD,
127 MT_COLOR_UNDERLINE,
128 MT_COLOR_INDEX,
129 MT_COLOR_MAX
130 };
131
132 typedef struct color_line
133 {
134 regex_t rx;
135 char *pattern;
136 pattern_t *color_pattern; /* compiled pattern to speed up index color
137 calculation */
138 short fg;
139 short bg;
140 int pair;
141 struct color_line *next;
142 } COLOR_LINE;
143
144 #define M_PROGRESS_SIZE (1<<0) /* traffic-based progress */
145 #define M_PROGRESS_MSG (1<<1) /* message-based progress */
146
147 typedef struct
148 {
149 unsigned short inc;
150 unsigned short flags;
151 const char* msg;
152 long pos;
153 long size;
154 unsigned int timestamp;
155 char sizestr[SHORT_STRING];
156 } progress_t;
157
158 void mutt_progress_init (progress_t* progress, const char *msg,
159 unsigned short flags, unsigned short inc,
160 long size);
161 /* If percent is positive, it is displayed as percentage, otherwise
162 * percentage is calculated from progress->size and pos if progress
163 * was initialized with positive size, otherwise no percentage is shown */
164 void mutt_progress_update (progress_t* progress, long pos, int percent);
165
166 static inline int mutt_term_width(short wrap)
167 {
168 if (wrap < 0)
169 return COLS > -wrap ? COLS + wrap : COLS;
170 else if (wrap)
171 return wrap < COLS ? wrap : COLS;
172 else
173 return COLS;
174 }
175
176 extern int *ColorQuote;
177 extern int ColorQuoteUsed;
178 extern int ColorDefs[];
179 extern COLOR_LINE *ColorHdrList;
180 extern COLOR_LINE *ColorBodyList;
181 extern COLOR_LINE *ColorIndexList;
182
183 void ci_init_color (void);
184 void ci_start_color (void);
185
186 #define SETCOLOR(X) attrset(ColorDefs[X])
187 #define ADDCOLOR(X) attron(ColorDefs[X])
188
189 #define MAYBE_REDRAW(x) if (option (OPTNEEDREDRAW)) { unset_option (OPTNEEDREDRAW); x = REDRAW_FULL; }
190
191 /* ----------------------------------------------------------------------------
192 * These are here to avoid compiler warnings with -Wall under SunOS 4.1.x
193 */
194
195 #if !defined(STDC_HEADERS) && !defined(NCURSES_VERSION) && !defined(USE_SLANG_CURSES)
196 extern int endwin();
197 extern int printw();
198 extern int beep();
199 extern int isendwin();
200 extern int w32addch();
201 extern int keypad();
202 extern int wclrtobot();
203 extern int mvprintw();
204 extern int getcurx();
205 extern int getcury();
206 extern int noecho();
207 extern int wdelch();
208 extern int wrefresh();
209 extern int wmove();
210 extern int wclear();
211 extern int waddstr();
212 extern int wclrtoeol();
213 #endif
214
215 #endif /* _MUTT_CURSES_H_ */
Something went wrong with that request. Please try again.