NeoMutt  2018-07-16 +2388-bcedc8
Teaching an old dog new tricks
DOXYGEN
menu.c File Reference

GUI present the user with a selectable list. More...

#include "config.h"
#include <regex.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <wchar.h>
#include "mutt/mutt.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "mutt.h"
#include "color.h"
#include "commands.h"
#include "context.h"
#include "curs_lib.h"
#include "globals.h"
#include "keymap.h"
#include "mutt_curses.h"
#include "mutt_logging.h"
#include "mutt_menu.h"
#include "mutt_window.h"
#include "muttlib.h"
#include "opcodes.h"
#include "options.h"
#include "pattern.h"
#include "protos.h"
#include "sidebar.h"
+ Include dependency graph for menu.c:

Go to the source code of this file.

Macros

#define DIRECTION   ((neg * 2) + 1)
 
#define MUTT_SEARCH_UP   1
 
#define MUTT_SEARCH_DOWN   2
 

Functions

static int get_color (int index, unsigned char *s)
 Choose a colour for a line of the index. More...
 
static void print_enriched_string (int index, int attr, unsigned char *s, bool do_color)
 Display a string with embedded colours and graphics. More...
 
static void menu_make_entry (char *buf, size_t buflen, struct Menu *menu, int i)
 Create string to display in a Menu (the index) More...
 
static void menu_pad_string (struct Menu *menu, char *buf, size_t buflen)
 Pad a string with spaces for display in the Menu. More...
 
void menu_redraw_full (struct Menu *menu)
 Force the redraw of the Menu. More...
 
void menu_redraw_status (struct Menu *menu)
 Force the redraw of the status bar. More...
 
void menu_redraw_sidebar (struct Menu *menu)
 Force the redraw of the sidebar. More...
 
void menu_redraw_index (struct Menu *menu)
 Force the redraw of the index. More...
 
void menu_redraw_motion (struct Menu *menu)
 Force the redraw of the list part of the menu. More...
 
void menu_redraw_current (struct Menu *menu)
 Redraw the current menu. More...
 
static void menu_redraw_prompt (struct Menu *menu)
 Force the redraw of the message window. More...
 
void menu_check_recenter (struct Menu *menu)
 Recentre the menu on screen. More...
 
static void menu_jump (struct Menu *menu)
 Jump to another item in the menu. More...
 
void menu_next_line (struct Menu *menu)
 Move the view down one line, keeping the selection the same. More...
 
void menu_prev_line (struct Menu *menu)
 Move the view up one line, keeping the selection the same. More...
 
static void menu_length_jump (struct Menu *menu, int jumplen)
 Calculate the destination of a jump. More...
 
void menu_next_page (struct Menu *menu)
 Move the focus to the next page in the menu. More...
 
void menu_prev_page (struct Menu *menu)
 Move the focus to the previous page in the menu. More...
 
void menu_half_down (struct Menu *menu)
 Move the focus down half a page in the menu. More...
 
void menu_half_up (struct Menu *menu)
 Move the focus up half a page in the menu. More...
 
void menu_top_page (struct Menu *menu)
 Move the focus to the top of the page. More...
 
void menu_bottom_page (struct Menu *menu)
 Move the focus to the bottom of the page. More...
 
void menu_middle_page (struct Menu *menu)
 Move the focus to the centre of the page. More...
 
void menu_first_entry (struct Menu *menu)
 Move the focus to the first entry in the menu. More...
 
void menu_last_entry (struct Menu *menu)
 Move the focus to the last entry in the menu. More...
 
void menu_current_top (struct Menu *menu)
 Move the current selection to the top of the window. More...
 
void menu_current_middle (struct Menu *menu)
 Move the current selection to the centre of the window. More...
 
void menu_current_bottom (struct Menu *menu)
 Move the current selection to the bottom of the window. More...
 
static void menu_next_entry (struct Menu *menu)
 Move the focus to the next item in the menu. More...
 
static void menu_prev_entry (struct Menu *menu)
 Move the focus to the previous item in the menu. More...
 
static int default_color (int line)
 Get the default colour for a line of the menu - Implements Menu::menu_color() More...
 
static int generic_search (struct Menu *menu, regex_t *rx, int line)
 Search a menu for a item matching a regex - Implements Menu::menu_search() More...
 
void mutt_menu_init (void)
 Initialise all the Menus. More...
 
struct Menumutt_menu_new (enum MenuType type)
 Create a new Menu. More...
 
void mutt_menu_free (struct Menu **ptr)
 Destroy a menu. More...
 
void mutt_menu_add_dialog_row (struct Menu *menu, const char *row)
 Add a row to a Menu. More...
 
static struct Menuget_current_menu (void)
 Get the current Menu. More...
 
void mutt_menu_push_current (struct Menu *menu)
 Add a new Menu to the stack. More...
 
void mutt_menu_pop_current (struct Menu *menu)
 Remove a Menu from the stack. More...
 
void mutt_menu_set_current_redraw (MuttRedrawFlags redraw)
 Set redraw flags on the current menu. More...
 
void mutt_menu_set_current_redraw_full (void)
 Flag the current menu to be fully redrawn. More...
 
void mutt_menu_set_redraw (int menu_type, MuttRedrawFlags redraw)
 Set redraw flags on a menu. More...
 
void mutt_menu_set_redraw_full (int menu_type)
 Flag a menu to be fully redrawn. More...
 
void mutt_menu_current_redraw (void)
 Redraw the current menu. More...
 
static int menu_search (struct Menu *menu, int op)
 Search a menu. More...
 
static int menu_dialog_translate_op (int i)
 Convert menubar movement to scrolling. More...
 
static int menu_dialog_dokey (struct Menu *menu, int *ip)
 Check if there are any menu key events to process. More...
 
int menu_redraw (struct Menu *menu)
 Redraw the parts of the screen that have been flagged to be redrawn. More...
 
int mutt_menu_loop (struct Menu *menu)
 Menu event loop. More...
 
int mutt_menu_observer (struct NotifyCallback *nc)
 Listen for config changes affecting the menu - Implements observer_t() More...
 

Variables

short C_MenuContext
 Config: Number of lines of overlap when changing pages in the index. More...
 
bool C_MenuMoveOff
 Config: Allow the last menu item to move off the bottom of the screen. More...
 
bool C_MenuScroll
 Config: Scroll the menu/index by one line, rather than a page. More...
 
char * SearchBuffers [MENU_MAX]
 
static size_t MenuStackCount = 0
 
static size_t MenuStackLen = 0
 
static struct Menu ** MenuStack = NULL
 

Detailed Description

GUI present the user with a selectable list.

Authors
  • Michael R. Elkins

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file menu.c.

Macro Definition Documentation

#define DIRECTION   ((neg * 2) + 1)

Definition at line 71 of file menu.c.

#define MUTT_SEARCH_UP   1

Definition at line 73 of file menu.c.

#define MUTT_SEARCH_DOWN   2

Definition at line 74 of file menu.c.

Function Documentation

static int get_color ( int  index,
unsigned char *  s 
)
static

Choose a colour for a line of the index.

Parameters
indexIndex number
sString of embedded colour codes
Return values
numColour pair in an integer

Text is coloured by inserting special characters into the string, e.g. MT_COLOR_INDEX_AUTHOR

Definition at line 85 of file menu.c.

86 {
87  struct ColorLineHead *color = NULL;
88  struct ColorLine *np = NULL;
89  struct Email *e = Context->mailbox->emails[Context->mailbox->v2r[index]];
90  int type = *s;
91 
92  switch (type)
93  {
95  color = &ColorIndexAuthorList;
96  break;
98  color = &ColorIndexFlagsList;
99  break;
101  color = &ColorIndexSubjectList;
102  break;
103  case MT_COLOR_INDEX_TAG:
104  STAILQ_FOREACH(np, &ColorIndexTagList, entries)
105  {
106  if (strncmp((const char *) (s + 1), np->pattern, strlen(np->pattern)) == 0)
107  return np->pair;
108  const char *transform = mutt_hash_find(TagTransforms, np->pattern);
109  if (transform &&
110  (strncmp((const char *) (s + 1), transform, strlen(transform)) == 0))
111  {
112  return np->pair;
113  }
114  }
115  return 0;
116  default:
117  return ColorDefs[type];
118  }
119 
120  STAILQ_FOREACH(np, color, entries)
121  {
124  return np->pair;
125  }
126 
127  return 0;
128 }
struct Email ** emails
Array of Emails.
Definition: mailbox.h:110
Index: subject field (takes a pattern)
Definition: mutt_curses.h:160
The "current" mailbox.
Definition: context.h:36
The envelope/body of an email.
Definition: email.h:39
struct Hash * TagTransforms
Lookup table of alternative tag names.
Definition: tags.c:38
struct ColorLineHead ColorIndexFlagsList
List of colours applied to the flags in the index.
Definition: color.c:60
void * mutt_hash_find(const struct Hash *table, const char *strkey)
Find the HashElem data in a Hash table element using a key.
Definition: hash.c:379
char * pattern
Definition: mutt_curses.h:184
struct Mailbox * mailbox
Definition: context.h:50
struct ColorLineHead ColorIndexAuthorList
List of colours applied to the author in the index.
Definition: color.c:59
int mutt_pattern_exec(struct Pattern *pat, PatternExecFlags flags, struct Mailbox *m, struct Email *e, struct PatternCache *cache)
Match a pattern against an email header.
Definition: pattern.c:2002
Index: tag field (g, takes a pattern)
Definition: mutt_curses.h:159
Index: flags field (takes a pattern)
Definition: mutt_curses.h:158
#define SLIST_FIRST(head)
Definition: queue.h:229
Index: author field (takes a pattern)
Definition: mutt_curses.h:157
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
int ColorDefs[MT_COLOR_MAX]
Array of all fixed colours, see enum ColorId.
Definition: color.c:55
#define MUTT_MATCH_FULL_ADDRESS
Match the full address.
Definition: pattern.h:75
int * v2r
Mapping from virtual to real msgno.
Definition: mailbox.h:112
struct ColorLineHead ColorIndexSubjectList
List of colours applied to the subject in the index.
Definition: color.c:62
struct ColorLineHead ColorIndexTagList
List of colours applied to tags in the index.
Definition: color.c:63
int index
The absolute (unsorted) message number.
Definition: email.h:87
A regular expression and a color to highlight a line.
Definition: mutt_curses.h:180
struct PatternHead * color_pattern
compiled pattern to speed up index color calculation
Definition: mutt_curses.h:185

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void print_enriched_string ( int  index,
int  attr,
unsigned char *  s,
bool  do_color 
)
static

Display a string with embedded colours and graphics.

Parameters
indexIndex number
attrDefault colour for the line
sString of embedded colour codes
do_colorIf true, apply colour

Definition at line 137 of file menu.c.

138 {
139  wchar_t wc;
140  size_t k;
141  size_t n = mutt_str_strlen((char *) s);
142  mbstate_t mbstate;
143 
144  if (!stdscr)
145  return;
146 
147  memset(&mbstate, 0, sizeof(mbstate));
148  while (*s)
149  {
150  if (*s < MUTT_TREE_MAX)
151  {
152  if (do_color)
153 #if defined(HAVE_COLOR) && defined(HAVE_USE_DEFAULT_COLORS)
154  /* Combining tree fg color and another bg color requires
155  * having use_default_colors, because the other bg color
156  * may be undefined. */
158 #else
160 #endif
161 
162  while (*s && (*s < MUTT_TREE_MAX))
163  {
164  switch (*s)
165  {
166  case MUTT_TREE_LLCORNER:
167  if (C_AsciiChars)
168  addch('`');
169 #ifdef WACS_LLCORNER
170  else
171  add_wch(WACS_LLCORNER);
172 #else
173  else if (CharsetIsUtf8)
174  addstr("\342\224\224"); /* WACS_LLCORNER */
175  else
176  addch(ACS_LLCORNER);
177 #endif
178  break;
179  case MUTT_TREE_ULCORNER:
180  if (C_AsciiChars)
181  addch(',');
182 #ifdef WACS_ULCORNER
183  else
184  add_wch(WACS_ULCORNER);
185 #else
186  else if (CharsetIsUtf8)
187  addstr("\342\224\214"); /* WACS_ULCORNER */
188  else
189  addch(ACS_ULCORNER);
190 #endif
191  break;
192  case MUTT_TREE_LTEE:
193  if (C_AsciiChars)
194  addch('|');
195 #ifdef WACS_LTEE
196  else
197  add_wch(WACS_LTEE);
198 #else
199  else if (CharsetIsUtf8)
200  addstr("\342\224\234"); /* WACS_LTEE */
201  else
202  addch(ACS_LTEE);
203 #endif
204  break;
205  case MUTT_TREE_HLINE:
206  if (C_AsciiChars)
207  addch('-');
208 #ifdef WACS_HLINE
209  else
210  add_wch(WACS_HLINE);
211 #else
212  else if (CharsetIsUtf8)
213  addstr("\342\224\200"); /* WACS_HLINE */
214  else
215  addch(ACS_HLINE);
216 #endif
217  break;
218  case MUTT_TREE_VLINE:
219  if (C_AsciiChars)
220  addch('|');
221 #ifdef WACS_VLINE
222  else
223  add_wch(WACS_VLINE);
224 #else
225  else if (CharsetIsUtf8)
226  addstr("\342\224\202"); /* WACS_VLINE */
227  else
228  addch(ACS_VLINE);
229 #endif
230  break;
231  case MUTT_TREE_TTEE:
232  if (C_AsciiChars)
233  addch('-');
234 #ifdef WACS_TTEE
235  else
236  add_wch(WACS_TTEE);
237 #else
238  else if (CharsetIsUtf8)
239  addstr("\342\224\254"); /* WACS_TTEE */
240  else
241  addch(ACS_TTEE);
242 #endif
243  break;
244  case MUTT_TREE_BTEE:
245  if (C_AsciiChars)
246  addch('-');
247 #ifdef WACS_BTEE
248  else
249  add_wch(WACS_BTEE);
250 #else
251  else if (CharsetIsUtf8)
252  addstr("\342\224\264"); /* WACS_BTEE */
253  else
254  addch(ACS_BTEE);
255 #endif
256  break;
257  case MUTT_TREE_SPACE:
258  addch(' ');
259  break;
260  case MUTT_TREE_RARROW:
261  addch('>');
262  break;
263  case MUTT_TREE_STAR:
264  addch('*'); /* fake thread indicator */
265  break;
266  case MUTT_TREE_HIDDEN:
267  addch('&');
268  break;
269  case MUTT_TREE_EQUALS:
270  addch('=');
271  break;
272  case MUTT_TREE_MISSING:
273  addch('?');
274  break;
275  }
276  s++;
277  n--;
278  }
279  if (do_color)
280  ATTR_SET(attr);
281  }
282  else if (*s == MUTT_SPECIAL_INDEX)
283  {
284  s++;
285  if (do_color)
286  {
287  if (*s == MT_COLOR_INDEX)
288  {
289  attrset(attr);
290  }
291  else
292  {
293  if (get_color(index, s) == 0)
294  {
295  attron(attr);
296  }
297  else
298  {
299  attron(get_color(index, s));
300  }
301  }
302  }
303  s++;
304  n -= 2;
305  }
306  else if ((k = mbrtowc(&wc, (char *) s, n, &mbstate)) > 0)
307  {
308  addnstr((char *) s, k);
309  s += k;
310  n -= k;
311  }
312  else
313  break;
314  }
315 }
Lower left corner.
Definition: mutt_menu.h:61
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:666
Right arrow.
Definition: mutt_menu.h:67
Bottom T-piece.
Definition: mutt_menu.h:72
int mutt_combine_color(uint32_t fg_attr, uint32_t bg_attr)
Blank space.
Definition: mutt_menu.h:66
Vertical line.
Definition: mutt_menu.h:65
Top T-piece.
Definition: mutt_menu.h:71
Index: default colour (takes a pattern)
Definition: mutt_curses.h:156
Star character (for threads)
Definition: mutt_menu.h:68
Equals (for threads)
Definition: mutt_menu.h:70
Ampersand character (for threads)
Definition: mutt_menu.h:69
Question mark.
Definition: mutt_menu.h:73
#define ATTR_SET
Definition: mutt_curses.h:232
WHERE bool C_AsciiChars
Config: Use plain ASCII characters, when drawing email threads.
Definition: globals.h:205
Index: tree-drawing characters.
Definition: mutt_curses.h:130
int ColorDefs[MT_COLOR_MAX]
Array of all fixed colours, see enum ColorId.
Definition: color.c:55
#define SET_COLOR(X)
Definition: mutt_curses.h:224
Colour indicator.
Definition: mutt_menu.h:76
bool CharsetIsUtf8
Is the user&#39;s current character set utf-8?
Definition: charset.c:64
int index
The absolute (unsorted) message number.
Definition: email.h:87
Left T-piece.
Definition: mutt_menu.h:63
Upper left corner.
Definition: mutt_menu.h:62
Horizontal line.
Definition: mutt_menu.h:64

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void menu_make_entry ( char *  buf,
size_t  buflen,
struct Menu menu,
int  i 
)
static

Create string to display in a Menu (the index)

Parameters
bufBuffer for the result
buflenLength of the buffer
menuCurrent Menu
iSelected item

Definition at line 324 of file menu.c.

325 {
326  if (menu->dialog)
327  {
328  mutt_str_strfcpy(buf, NONULL(menu->dialog[i]), buflen);
329  menu->current = -1; /* hide menubar */
330  }
331  else
332  menu->menu_make_entry(buf, buflen, menu, i);
333 }
#define NONULL(x)
Definition: string2.h:37
char ** dialog
dialog lines themselves
Definition: mutt_menu.h:104
void(* menu_make_entry)(char *buf, size_t buflen, struct Menu *menu, int line)
Format a item for a menu.
Definition: mutt_menu.h:122
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:750
int current
current entry
Definition: mutt_menu.h:87

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void menu_pad_string ( struct Menu menu,
char *  buf,
size_t  buflen 
)
static

Pad a string with spaces for display in the Menu.

Parameters
menuCurrent Menu
bufBuffer containing the string
buflenLength of the buffer
Note
The string is padded in-place.

Definition at line 343 of file menu.c.

344 {
345  char *scratch = mutt_str_strdup(buf);
346  int shift = C_ArrowCursor ? 3 : 0;
347  int cols = menu->indexwin->cols - shift;
348 
349  mutt_simple_format(buf, buflen, cols, cols, JUSTIFY_LEFT, ' ', scratch,
350  mutt_str_strlen(scratch), true);
351  buf[buflen - 1] = '\0';
352  FREE(&scratch);
353 }
Left justify the text.
Definition: curs_lib.h:46
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:666
struct MuttWindow * indexwin
Definition: mutt_menu.h:95
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
#define FREE(x)
Definition: memory.h:40
void mutt_simple_format(char *buf, size_t buflen, int min_width, int max_width, enum FormatJustify justify, char pad_char, const char *s, size_t n, bool arboreal)
Format a string, like snprintf()
Definition: curs_lib.c:996
WHERE bool C_ArrowCursor
Config: Use an arrow &#39;->&#39; instead of highlighting in the index.
Definition: globals.h:204

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void menu_redraw_full ( struct Menu menu)

Force the redraw of the Menu.

Parameters
menuCurrent Menu

Definition at line 359 of file menu.c.

360 {
361  NORMAL_COLOR;
362  /* clear() doesn't optimize screen redraws */
363  move(0, 0);
364  clrtobot();
365 
366  if (C_Help)
367  {
369  mutt_window_move(menu->helpwin, 0, 0);
370  mutt_paddstr(menu->helpwin->cols, menu->help);
371  NORMAL_COLOR;
372  }
373  menu->offset = 0;
374  menu->pagelen = menu->indexwin->rows;
375 
376  mutt_show_error();
377 
379 #ifdef USE_SIDEBAR
380  menu->redraw |= REDRAW_SIDEBAR;
381 #endif
382 }
#define NORMAL_COLOR
Definition: mutt_curses.h:239
WHERE bool C_Help
Config: Display a help line with common key bindings.
Definition: globals.h:231
#define REDRAW_SIDEBAR
Redraw the sidebar.
Definition: mutt_menu.h:51
void mutt_paddstr(int n, const char *s)
Display a string on screen, padded if necessary.
Definition: curs_lib.c:1169
struct MuttWindow * helpwin
Definition: mutt_menu.h:97
#define REDRAW_STATUS
Redraw the status bar.
Definition: mutt_menu.h:46
struct MuttWindow * indexwin
Definition: mutt_menu.h:95
int pagelen
number of entries per screen
Definition: mutt_menu.h:92
#define SET_COLOR(X)
Definition: mutt_curses.h:224
int mutt_window_move(struct MuttWindow *win, int row, int col)
Move the cursor in a Window.
Definition: mutt_window.c:188
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
int offset
row offset within the window to start the index
Definition: mutt_menu.h:91
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:42
Status bar.
Definition: mutt_curses.h:129
void mutt_show_error(void)
Show the user an error message.
Definition: curs_lib.c:485
char * help
quickref for the current menu
Definition: mutt_menu.h:85

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void menu_redraw_status ( struct Menu menu)

Force the redraw of the status bar.

Parameters
menuCurrent Menu

Definition at line 388 of file menu.c.

389 {
390  char buf[256];
391 
392  snprintf(buf, sizeof(buf), "-- NeoMutt: %s", menu->title);
394  mutt_window_move(menu->statuswin, 0, 0);
395  mutt_paddstr(menu->statuswin->cols, buf);
396  NORMAL_COLOR;
397  menu->redraw &= ~REDRAW_STATUS;
398 }
#define NORMAL_COLOR
Definition: mutt_curses.h:239
void mutt_paddstr(int n, const char *s)
Display a string on screen, padded if necessary.
Definition: curs_lib.c:1169
struct MuttWindow * statuswin
Definition: mutt_menu.h:96
#define REDRAW_STATUS
Redraw the status bar.
Definition: mutt_menu.h:46
#define SET_COLOR(X)
Definition: mutt_curses.h:224
int mutt_window_move(struct MuttWindow *win, int row, int col)
Move the cursor in a Window.
Definition: mutt_window.c:188
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
char * title
the title of this menu
Definition: mutt_menu.h:84
Status bar.
Definition: mutt_curses.h:129

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void menu_redraw_sidebar ( struct Menu menu)

Force the redraw of the sidebar.

Parameters
menuCurrent Menu

Definition at line 405 of file menu.c.

406 {
407  menu->redraw &= ~REDRAW_SIDEBAR;
408  mutt_sb_draw();
409 }
#define REDRAW_SIDEBAR
Redraw the sidebar.
Definition: mutt_menu.h:51
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void menu_redraw_index ( struct Menu menu)

Force the redraw of the index.

Parameters
menuCurrent Menu

Definition at line 416 of file menu.c.

417 {
418  char buf[1024];
419  bool do_color;
420  int attr;
421 
422  for (int i = menu->top; i < menu->top + menu->pagelen; i++)
423  {
424  if (i < menu->max)
425  {
426  attr = menu->menu_color(i);
427 
428  menu_make_entry(buf, sizeof(buf), menu, i);
429  menu_pad_string(menu, buf, sizeof(buf));
430 
431  ATTR_SET(attr);
432  mutt_window_move(menu->indexwin, i - menu->top + menu->offset, 0);
433  do_color = true;
434 
435  if (i == menu->current)
436  {
438  if (C_ArrowCursor)
439  {
440  addstr("->");
441  ATTR_SET(attr);
442  addch(' ');
443  }
444  else
445  do_color = false;
446  }
447  else if (C_ArrowCursor)
448  addstr(" ");
449 
450  print_enriched_string(i, attr, (unsigned char *) buf, do_color);
451  }
452  else
453  {
454  NORMAL_COLOR;
455  mutt_window_clearline(menu->indexwin, i - menu->top + menu->offset);
456  }
457  }
458  NORMAL_COLOR;
459  menu->redraw = 0;
460 }
#define NORMAL_COLOR
Definition: mutt_curses.h:239
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:95
#define ATTR_SET
Definition: mutt_curses.h:232
struct MuttWindow * indexwin
Definition: mutt_menu.h:95
int top
entry that is the top of the current page
Definition: mutt_menu.h:110
int pagelen
number of entries per screen
Definition: mutt_menu.h:92
#define SET_COLOR(X)
Definition: mutt_curses.h:224
int mutt_window_move(struct MuttWindow *win, int row, int col)
Move the cursor in a Window.
Definition: mutt_window.c:188
int(* menu_color)(int line)
Calculate the colour for a line of the menu.
Definition: mutt_menu.h:146
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
int offset
row offset within the window to start the index
Definition: mutt_menu.h:91
Selected item in list.
Definition: mutt_curses.h:128
int current
current entry
Definition: mutt_menu.h:87
WHERE bool C_ArrowCursor
Config: Use an arrow &#39;->&#39; instead of highlighting in the index.
Definition: globals.h:204

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void menu_redraw_motion ( struct Menu menu)

Force the redraw of the list part of the menu.

Parameters
menuCurrent Menu

Definition at line 466 of file menu.c.

467 {
468  char buf[1024];
469 
470  if (menu->dialog)
471  {
472  menu->redraw &= ~REDRAW_MOTION;
473  return;
474  }
475 
476  /* Note: menu->color() for the index can end up retrieving a message
477  * over imap (if matching against ~h for instance). This can
478  * generate status messages. So we want to call it *before* we
479  * position the cursor for drawing. */
480  const int old_color = menu->menu_color(menu->oldcurrent);
481  mutt_window_move(menu->indexwin, menu->oldcurrent + menu->offset - menu->top, 0);
482  ATTR_SET(old_color);
483 
484  if (C_ArrowCursor)
485  {
486  /* clear the pointer */
487  addstr(" ");
488 
489  if (menu->redraw & REDRAW_MOTION_RESYNC)
490  {
491  menu_make_entry(buf, sizeof(buf), menu, menu->oldcurrent);
492  menu_pad_string(menu, buf, sizeof(buf));
493  mutt_window_move(menu->indexwin, menu->oldcurrent + menu->offset - menu->top, 3);
494  print_enriched_string(menu->oldcurrent, old_color, (unsigned char *) buf, 1);
495  }
496 
497  /* now draw it in the new location */
499  mutt_window_mvaddstr(menu->indexwin, menu->current + menu->offset - menu->top, 0, "->");
500  }
501  else
502  {
503  /* erase the current indicator */
504  menu_make_entry(buf, sizeof(buf), menu, menu->oldcurrent);
505  menu_pad_string(menu, buf, sizeof(buf));
506  print_enriched_string(menu->oldcurrent, old_color, (unsigned char *) buf, 1);
507 
508  /* now draw the new one to reflect the change */
509  const int cur_color = menu->menu_color(menu->current);
510  menu_make_entry(buf, sizeof(buf), menu, menu->current);
511  menu_pad_string(menu, buf, sizeof(buf));
513  mutt_window_move(menu->indexwin, menu->current + menu->offset - menu->top, 0);
514  print_enriched_string(menu->current, cur_color, (unsigned char *) buf, 0);
515  }
516  menu->redraw &= REDRAW_STATUS;
517  NORMAL_COLOR;
518 }
int oldcurrent
for driver use only
Definition: mutt_menu.h:111
#define NORMAL_COLOR
Definition: mutt_curses.h:239
char ** dialog
dialog lines themselves
Definition: mutt_menu.h:104
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:43
#define REDRAW_MOTION_RESYNC
Redraw any changing the menu selection.
Definition: mutt_menu.h:44
#define REDRAW_STATUS
Redraw the status bar.
Definition: mutt_menu.h:46
#define ATTR_SET
Definition: mutt_curses.h:232
struct MuttWindow * indexwin
Definition: mutt_menu.h:95
int top
entry that is the top of the current page
Definition: mutt_menu.h:110
#define SET_COLOR(X)
Definition: mutt_curses.h:224
int mutt_window_mvaddstr(struct MuttWindow *win, int row, int col, const char *str)
Move the cursor and write a fixed string to a Window.
Definition: mutt_window.c:202
int mutt_window_move(struct MuttWindow *win, int row, int col)
Move the cursor in a Window.
Definition: mutt_window.c:188
int(* menu_color)(int line)
Calculate the colour for a line of the menu.
Definition: mutt_menu.h:146
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
int offset
row offset within the window to start the index
Definition: mutt_menu.h:91
Selected item in list.
Definition: mutt_curses.h:128
int current
current entry
Definition: mutt_menu.h:87
WHERE bool C_ArrowCursor
Config: Use an arrow &#39;->&#39; instead of highlighting in the index.
Definition: globals.h:204

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void menu_redraw_current ( struct Menu menu)

Redraw the current menu.

Parameters
menuCurrent Menu

Definition at line 524 of file menu.c.

525 {
526  char buf[1024];
527  int attr = menu->menu_color(menu->current);
528 
529  mutt_window_move(menu->indexwin, menu->current + menu->offset - menu->top, 0);
530  menu_make_entry(buf, sizeof(buf), menu, menu->current);
531  menu_pad_string(menu, buf, sizeof(buf));
532 
534  if (C_ArrowCursor)
535  {
536  addstr("->");
537  ATTR_SET(attr);
538  addch(' ');
539  menu_pad_string(menu, buf, sizeof(buf));
540  print_enriched_string(menu->current, attr, (unsigned char *) buf, 1);
541  }
542  else
543  print_enriched_string(menu->current, attr, (unsigned char *) buf, 0);
544  menu->redraw &= REDRAW_STATUS;
545  NORMAL_COLOR;
546 }
#define NORMAL_COLOR
Definition: mutt_curses.h:239
#define REDRAW_STATUS
Redraw the status bar.
Definition: mutt_menu.h:46
#define ATTR_SET
Definition: mutt_curses.h:232
struct MuttWindow * indexwin
Definition: mutt_menu.h:95
int top
entry that is the top of the current page
Definition: mutt_menu.h:110
#define SET_COLOR(X)
Definition: mutt_curses.h:224
int mutt_window_move(struct MuttWindow *win, int row, int col)
Move the cursor in a Window.
Definition: mutt_window.c:188
int(* menu_color)(int line)
Calculate the colour for a line of the menu.
Definition: mutt_menu.h:146
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
int offset
row offset within the window to start the index
Definition: mutt_menu.h:91
Selected item in list.
Definition: mutt_curses.h:128
int current
current entry
Definition: mutt_menu.h:87
WHERE bool C_ArrowCursor
Config: Use an arrow &#39;->&#39; instead of highlighting in the index.
Definition: globals.h:204

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void menu_redraw_prompt ( struct Menu menu)
static

Force the redraw of the message window.

Parameters
menuCurrent Menu

Definition at line 552 of file menu.c.

553 {
554  if (!menu || !menu->dialog)
555  return;
556 
557  if (OptMsgErr)
558  {
559  mutt_sleep(1);
560  OptMsgErr = false;
561  }
562 
563  if (ErrorBufMessage)
565 
566  mutt_window_mvaddstr(menu->messagewin, 0, 0, menu->prompt);
568 }
char * prompt
prompt for user, similar to mutt_multi_choice
Definition: mutt_menu.h:106
void mutt_window_clrtoeol(struct MuttWindow *win)
Clear to the end of the line.
Definition: mutt_window.c:107
char ** dialog
dialog lines themselves
Definition: mutt_menu.h:104
void mutt_sleep(short s)
Sleep for a while.
Definition: muttlib.c:1502
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:143
WHERE bool ErrorBufMessage
true if the last message was an error
Definition: globals.h:43
int mutt_window_mvaddstr(struct MuttWindow *win, int row, int col, const char *str)
Move the cursor and write a fixed string to a Window.
Definition: mutt_window.c:202
struct MuttWindow * messagewin
Definition: mutt_menu.h:98
WHERE bool OptMsgErr
(pseudo) used by mutt_error/mutt_message
Definition: options.h:39

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void menu_check_recenter ( struct Menu menu)

Recentre the menu on screen.

Parameters
menuCurrent Menu

Definition at line 574 of file menu.c.

575 {
576  int c = MIN(C_MenuContext, menu->pagelen / 2);
577  int old_top = menu->top;
578 
579  if (!C_MenuMoveOff && (menu->max <= menu->pagelen)) /* less entries than lines */
580  {
581  if (menu->top != 0)
582  {
583  menu->top = 0;
584  menu->redraw |= REDRAW_INDEX;
585  }
586  }
587  else
588  {
589  if (C_MenuScroll || (menu->pagelen <= 0) || (c < C_MenuContext))
590  {
591  if (menu->current < menu->top + c)
592  menu->top = menu->current - c;
593  else if (menu->current >= menu->top + menu->pagelen - c)
594  menu->top = menu->current - menu->pagelen + c + 1;
595  }
596  else
597  {
598  if (menu->current < menu->top + c)
599  {
600  menu->top -= (menu->pagelen - c) * ((menu->top + menu->pagelen - 1 - menu->current) /
601  (menu->pagelen - c)) -
602  c;
603  }
604  else if ((menu->current >= menu->top + menu->pagelen - c))
605  {
606  menu->top +=
607  (menu->pagelen - c) * ((menu->current - menu->top) / (menu->pagelen - c)) - c;
608  }
609  }
610  }
611 
612  if (!C_MenuMoveOff) /* make entries stick to bottom */
613  menu->top = MIN(menu->top, menu->max - menu->pagelen);
614  menu->top = MAX(menu->top, 0);
615 
616  if (menu->top != old_top)
617  menu->redraw |= REDRAW_INDEX;
618 }
#define MIN(a, b)
Definition: memory.h:31
#define MAX(a, b)
Definition: memory.h:30
int top
entry that is the top of the current page
Definition: mutt_menu.h:110
int pagelen
number of entries per screen
Definition: mutt_menu.h:92
int max
the number of entries in the menu
Definition: mutt_menu.h:88
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:42
int current
current entry
Definition: mutt_menu.h:87

+ Here is the caller graph for this function:

static void menu_jump ( struct Menu menu)
static

Jump to another item in the menu.

Parameters
menuCurrent Menu

Ask the user for a message number to jump to.

Definition at line 626 of file menu.c.

627 {
628  int n;
629 
630  if (menu->max)
631  {
633  char buf[128];
634  buf[0] = '\0';
635  if ((mutt_get_field(_("Jump to: "), buf, sizeof(buf), 0) == 0) && buf[0])
636  {
637  if ((mutt_str_atoi(buf, &n) == 0) && (n > 0) && (n < menu->max + 1))
638  {
639  n--; /* msg numbers are 0-based */
640  menu->current = n;
641  menu->redraw = REDRAW_MOTION;
642  }
643  else
644  mutt_error(_("Invalid index number"));
645  }
646  }
647  else
648  mutt_error(_("No entries"));
649 }
int mutt_str_atoi(const char *str, int *dst)
Convert ASCII string to an integer.
Definition: string.c:262
void mutt_unget_event(int ch, int op)
Return a keystroke to the input buffer.
Definition: curs_lib.c:715
#define _(a)
Definition: message.h:28
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:86
int LastKey
contains the last key the user pressed
Definition: keymap.c:145
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:43
int max
the number of entries in the menu
Definition: mutt_menu.h:88
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
#define mutt_error(...)
Definition: logging.h:84
int current
current entry
Definition: mutt_menu.h:87

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void menu_next_line ( struct Menu menu)

Move the view down one line, keeping the selection the same.

Parameters
menuCurrent Menu

Definition at line 655 of file menu.c.

656 {
657  if (menu->max)
658  {
659  int c = MIN(C_MenuContext, menu->pagelen / 2);
660 
661  if ((menu->top + 1 < menu->max - c) &&
662  (C_MenuMoveOff ||
663  ((menu->max > menu->pagelen) && (menu->top < menu->max - menu->pagelen))))
664  {
665  menu->top++;
666  if ((menu->current < menu->top + c) && (menu->current < menu->max - 1))
667  menu->current++;
668  menu->redraw = REDRAW_INDEX;
669  }
670  else
671  mutt_message(_("You can't scroll down farther"));
672  }
673  else
674  mutt_error(_("No entries"));
675 }
#define MIN(a, b)
Definition: memory.h:31
#define mutt_message(...)
Definition: logging.h:83
#define _(a)
Definition: message.h:28
int top
entry that is the top of the current page
Definition: mutt_menu.h:110
int pagelen
number of entries per screen
Definition: mutt_menu.h:92
int max
the number of entries in the menu
Definition: mutt_menu.h:88
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:42
#define mutt_error(...)
Definition: logging.h:84
int current
current entry
Definition: mutt_menu.h:87

+ Here is the caller graph for this function:

void menu_prev_line ( struct Menu menu)

Move the view up one line, keeping the selection the same.

Parameters
menuCurrent Menu

Definition at line 681 of file menu.c.

682 {
683  if (menu->top > 0)
684  {
685  int c = MIN(C_MenuContext, menu->pagelen / 2);
686 
687  menu->top--;
688  if ((menu->current >= menu->top + menu->pagelen - c) && (menu->current > 1))
689  menu->current--;
690  menu->redraw = REDRAW_INDEX;
691  }
692  else
693  mutt_message(_("You can't scroll up farther"));
694 }
#define MIN(a, b)
Definition: memory.h:31
#define mutt_message(...)
Definition: logging.h:83
#define _(a)
Definition: message.h:28
int top
entry that is the top of the current page
Definition: mutt_menu.h:110
int pagelen
number of entries per screen
Definition: mutt_menu.h:92
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:42
int current
current entry
Definition: mutt_menu.h:87

+ Here is the caller graph for this function:

static void menu_length_jump ( struct Menu menu,
int  jumplen 
)
static

Calculate the destination of a jump.

Parameters
menuCurrent Menu
jumplenNumber of lines to jump
  • pageup: jumplen == -pagelen
  • pagedown: jumplen == pagelen
  • halfup: jumplen == -pagelen/2
  • halfdown: jumplen == pagelen/2

Definition at line 706 of file menu.c.

707 {
708  const int neg = (jumplen >= 0) ? 0 : -1;
709  const int c = MIN(C_MenuContext, menu->pagelen / 2);
710 
711  if (menu->max)
712  {
713  /* possible to scroll? */
714  int tmp;
715  if (DIRECTION * menu->top <
716  (tmp = (neg ? 0 : (menu->max /* -1 */) - (menu->pagelen /* -1 */))))
717  {
718  menu->top += jumplen;
719 
720  /* jumped too long? */
721  if ((neg || !C_MenuMoveOff) && (DIRECTION * menu->top > tmp))
722  menu->top = tmp;
723 
724  /* need to move the cursor? */
725  if ((DIRECTION *
726  (tmp = (menu->current - (menu->top + (neg ? (menu->pagelen - 1) - c : c))))) < 0)
727  {
728  menu->current -= tmp;
729  }
730 
731  menu->redraw = REDRAW_INDEX;
732  }
733  else if ((menu->current != (neg ? 0 : menu->max - 1)) && !menu->dialog)
734  {
735  menu->current += jumplen;
736  menu->redraw = REDRAW_MOTION;
737  }
738  else
739  {
740  mutt_message(neg ? _("You are on the first page") : _("You are on the last page"));
741  }
742 
743  menu->current = MIN(menu->current, menu->max - 1);
744  menu->current = MAX(menu->current, 0);
745  }
746  else
747  mutt_error(_("No entries"));
748 }
#define MIN(a, b)
Definition: memory.h:31
#define mutt_message(...)
Definition: logging.h:83
char ** dialog
dialog lines themselves
Definition: mutt_menu.h:104
#define _(a)
Definition: message.h:28
#define MAX(a, b)
Definition: memory.h:30
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:43
int top
entry that is the top of the current page
Definition: mutt_menu.h:110
int pagelen
number of entries per screen
Definition: mutt_menu.h:92
int max
the number of entries in the menu
Definition: mutt_menu.h:88
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:42
#define mutt_error(...)
Definition: logging.h:84
int current
current entry
Definition: mutt_menu.h:87

+ Here is the caller graph for this function:

void menu_next_page ( struct Menu menu)

Move the focus to the next page in the menu.

Parameters
menuCurrent Menu

Definition at line 754 of file menu.c.

755 {
756  menu_length_jump(menu, MAX(menu->pagelen /* - MenuOverlap */, 0));
757 }
#define MAX(a, b)
Definition: memory.h:30
int pagelen
number of entries per screen
Definition: mutt_menu.h:92

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void menu_prev_page ( struct Menu menu)

Move the focus to the previous page in the menu.

Parameters
menuCurrent Menu

Definition at line 763 of file menu.c.

764 {
765  menu_length_jump(menu, 0 - MAX(menu->pagelen /* - MenuOverlap */, 0));
766 }
#define MAX(a, b)
Definition: memory.h:30
int pagelen
number of entries per screen
Definition: mutt_menu.h:92

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void menu_half_down ( struct Menu menu)

Move the focus down half a page in the menu.

Parameters
menuCurrent Menu

Definition at line 772 of file menu.c.

773 {
774  menu_length_jump(menu, menu->pagelen / 2);
775 }
int pagelen
number of entries per screen
Definition: mutt_menu.h:92

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void menu_half_up ( struct Menu menu)

Move the focus up half a page in the menu.

Parameters
menuCurrent Menu

Definition at line 781 of file menu.c.

782 {
783  menu_length_jump(menu, 0 - menu->pagelen / 2);
784 }
int pagelen
number of entries per screen
Definition: mutt_menu.h:92

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void menu_top_page ( struct Menu menu)

Move the focus to the top of the page.

Parameters
menuCurrent Menu

Definition at line 790 of file menu.c.

791 {
792  if (menu->current == menu->top)
793  return;
794 
795  menu->current = menu->top;
796  menu->redraw = REDRAW_MOTION;
797 }
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:43
int top
entry that is the top of the current page
Definition: mutt_menu.h:110
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
int current
current entry
Definition: mutt_menu.h:87

+ Here is the caller graph for this function:

void menu_bottom_page ( struct Menu menu)

Move the focus to the bottom of the page.

Parameters
menuCurrent Menu

Definition at line 803 of file menu.c.

804 {
805  if (menu->max)
806  {
807  menu->current = menu->top + menu->pagelen - 1;
808  if (menu->current > menu->max - 1)
809  menu->current = menu->max - 1;
810  menu->redraw = REDRAW_MOTION;
811  }
812  else
813  mutt_error(_("No entries"));
814 }
#define _(a)
Definition: message.h:28
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:43
int top
entry that is the top of the current page
Definition: mutt_menu.h:110
int pagelen
number of entries per screen
Definition: mutt_menu.h:92
int max
the number of entries in the menu
Definition: mutt_menu.h:88
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
#define mutt_error(...)
Definition: logging.h:84
int current
current entry
Definition: mutt_menu.h:87

+ Here is the caller graph for this function:

void menu_middle_page ( struct Menu menu)

Move the focus to the centre of the page.

Parameters
menuCurrent Menu

Definition at line 820 of file menu.c.

821 {
822  if (menu->max)
823  {
824  int i = menu->top + menu->pagelen;
825  if (i > menu->max - 1)
826  i = menu->max - 1;
827  menu->current = menu->top + (i - menu->top) / 2;
828  menu->redraw = REDRAW_MOTION;
829  }
830  else
831  mutt_error(_("No entries"));
832 }
#define _(a)
Definition: message.h:28
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:43
int top
entry that is the top of the current page
Definition: mutt_menu.h:110
int pagelen
number of entries per screen
Definition: mutt_menu.h:92
int max
the number of entries in the menu
Definition: mutt_menu.h:88
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
#define mutt_error(...)
Definition: logging.h:84
int current
current entry
Definition: mutt_menu.h:87

+ Here is the caller graph for this function:

void menu_first_entry ( struct Menu menu)

Move the focus to the first entry in the menu.

Parameters
menuCurrent Menu

Definition at line 838 of file menu.c.

839 {
840  if (menu->max)
841  {
842  menu->current = 0;
843  menu->redraw = REDRAW_MOTION;
844  }
845  else
846  mutt_error(_("No entries"));
847 }
#define _(a)
Definition: message.h:28
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:43
int max
the number of entries in the menu
Definition: mutt_menu.h:88
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
#define mutt_error(...)
Definition: logging.h:84
int current
current entry
Definition: mutt_menu.h:87

+ Here is the caller graph for this function:

void menu_last_entry ( struct Menu menu)

Move the focus to the last entry in the menu.

Parameters
menuCurrent Menu

Definition at line 853 of file menu.c.

854 {
855  if (menu->max)
856  {
857  menu->current = menu->max - 1;
858  menu->redraw = REDRAW_MOTION;
859  }
860  else
861  mutt_error(_("No entries"));
862 }
#define _(a)
Definition: message.h:28
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:43
int max
the number of entries in the menu
Definition: mutt_menu.h:88
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
#define mutt_error(...)
Definition: logging.h:84
int current
current entry
Definition: mutt_menu.h:87

+ Here is the caller graph for this function:

void menu_current_top ( struct Menu menu)

Move the current selection to the top of the window.

Parameters
menuCurrent Menu

Definition at line 868 of file menu.c.

869 {
870  if (menu->max)
871  {
872  menu->top = menu->current;
873  menu->redraw = REDRAW_INDEX;
874  }
875  else
876  mutt_error(_("No entries"));
877 }
#define _(a)
Definition: message.h:28
int top
entry that is the top of the current page
Definition: mutt_menu.h:110
int max
the number of entries in the menu
Definition: mutt_menu.h:88
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:42
#define mutt_error(...)
Definition: logging.h:84
int current
current entry
Definition: mutt_menu.h:87

+ Here is the caller graph for this function:

void menu_current_middle ( struct Menu menu)

Move the current selection to the centre of the window.

Parameters
menuCurrent Menu

Definition at line 883 of file menu.c.

884 {
885  if (menu->max)
886  {
887  menu->top = menu->current - menu->pagelen / 2;
888  if (menu->top < 0)
889  menu->top = 0;
890  menu->redraw = REDRAW_INDEX;
891  }
892  else
893  mutt_error(_("No entries"));
894 }
#define _(a)
Definition: message.h:28
int top
entry that is the top of the current page
Definition: mutt_menu.h:110
int pagelen
number of entries per screen
Definition: mutt_menu.h:92
int max
the number of entries in the menu
Definition: mutt_menu.h:88
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:42
#define mutt_error(...)
Definition: logging.h:84
int current
current entry
Definition: mutt_menu.h:87

+ Here is the caller graph for this function:

void menu_current_bottom ( struct Menu menu)

Move the current selection to the bottom of the window.

Parameters
menuCurrent Menu

Definition at line 900 of file menu.c.

901 {
902  if (menu->max)
903  {
904  menu->top = menu->current - menu->pagelen + 1;
905  if (menu->top < 0)
906  menu->top = 0;
907  menu->redraw = REDRAW_INDEX;
908  }
909  else
910  mutt_error(_("No entries"));
911 }
#define _(a)
Definition: message.h:28
int top
entry that is the top of the current page
Definition: mutt_menu.h:110
int pagelen
number of entries per screen
Definition: mutt_menu.h:92
int max
the number of entries in the menu
Definition: mutt_menu.h:88
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:42
#define mutt_error(...)
Definition: logging.h:84
int current
current entry
Definition: mutt_menu.h:87

+ Here is the caller graph for this function:

static void menu_next_entry ( struct Menu menu)
static

Move the focus to the next item in the menu.

Parameters
menuCurrent Menu

Definition at line 917 of file menu.c.

918 {
919  if (menu->current < menu->max - 1)
920  {
921  menu->current++;
922  menu->redraw = REDRAW_MOTION;
923  }
924  else
925  mutt_message(_("You are on the last entry"));
926 }
#define mutt_message(...)
Definition: logging.h:83
#define _(a)
Definition: message.h:28
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:43
int max
the number of entries in the menu
Definition: mutt_menu.h:88
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
int current
current entry
Definition: mutt_menu.h:87

+ Here is the caller graph for this function:

static void menu_prev_entry ( struct Menu menu)
static

Move the focus to the previous item in the menu.

Parameters
menuCurrent Menu

Definition at line 932 of file menu.c.

933 {
934  if (menu->current)
935  {
936  menu->current--;
937  menu->redraw = REDRAW_MOTION;
938  }
939  else
940  mutt_message(_("You are on the first entry"));
941 }
#define mutt_message(...)
Definition: logging.h:83
#define _(a)
Definition: message.h:28
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:43
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
int current
current entry
Definition: mutt_menu.h:87

+ Here is the caller graph for this function:

static int default_color ( int  line)
static

Get the default colour for a line of the menu - Implements Menu::menu_color()

Definition at line 946 of file menu.c.

947 {
948  return ColorDefs[MT_COLOR_NORMAL];
949 }
Plain text.
Definition: mutt_curses.h:131
int ColorDefs[MT_COLOR_MAX]
Array of all fixed colours, see enum ColorId.
Definition: color.c:55

+ Here is the caller graph for this function:

static int generic_search ( struct Menu menu,
regex_t *  rx,
int  line 
)
static

Search a menu for a item matching a regex - Implements Menu::menu_search()

Definition at line 954 of file menu.c.

955 {
956  char buf[1024];
957 
958  menu_make_entry(buf, sizeof(buf), menu, line);
959  return regexec(rx, buf, 0, NULL, 0);
960 }
const char * line
Definition: common.c:36

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mutt_menu_init ( void  )

Initialise all the Menus.

Definition at line 965 of file menu.c.

966 {
967  for (int i = 0; i < MENU_MAX; i++)
968  SearchBuffers[i] = NULL;
969 }

+ Here is the caller graph for this function:

struct Menu* mutt_menu_new ( enum MenuType  type)

Create a new Menu.

Parameters
typeMenu type, e.g. MENU_PAGER
Return values
ptrNew Menu

Definition at line 976 of file menu.c.

977 {
978  struct Menu *menu = mutt_mem_calloc(1, sizeof(struct Menu));
979 
980  if (type >= MENU_MAX)
981  type = MENU_GENERIC;
982 
983  menu->menu = type;
984  menu->current = 0;
985  menu->top = 0;
986  menu->offset = 0;
987  menu->redraw = REDRAW_FULL;
988  menu->pagelen = MuttIndexWindow->rows;
989  menu->indexwin = MuttIndexWindow;
990  menu->statuswin = MuttStatusWindow;
991  menu->helpwin = MuttHelpWindow;
993  menu->menu_color = default_color;
994  menu->menu_search = generic_search;
995 
996  return menu;
997 }
#define REDRAW_FULL
Redraw everything.
Definition: mutt_menu.h:47
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
struct MuttWindow * MuttStatusWindow
Status Window.
Definition: mutt_window.c:41
GUI selectable list of items.
Definition: mutt_menu.h:82
struct MuttWindow * MuttHelpWindow
Help Window.
Definition: mutt_window.c:39
int menu
menu definition for keymap entries.
Definition: mutt_menu.h:90
struct MuttWindow * helpwin
Definition: mutt_menu.h:97
struct MuttWindow * statuswin
Definition: mutt_menu.h:96
struct MuttWindow * MuttIndexWindow
Index Window.
Definition: mutt_window.c:40
struct MuttWindow * indexwin
Definition: mutt_menu.h:95
int top
entry that is the top of the current page
Definition: mutt_menu.h:110
int pagelen
number of entries per screen
Definition: mutt_menu.h:92
int(* menu_color)(int line)
Calculate the colour for a line of the menu.
Definition: mutt_menu.h:146
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
int(* menu_search)(struct Menu *menu, regex_t *rx, int line)
Search a menu for a item matching a regex.
Definition: mutt_menu.h:131
int offset
row offset within the window to start the index
Definition: mutt_menu.h:91
struct MuttWindow * messagewin
Definition: mutt_menu.h:98
struct MuttWindow * MuttMessageWindow
Message Window.
Definition: mutt_window.c:42
int current
current entry
Definition: mutt_menu.h:87
Generic selection list.
Definition: keymap.h:76

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mutt_menu_free ( struct Menu **  ptr)

Destroy a menu.

Parameters
[out]ptrMenu to destroy

Definition at line 1003 of file menu.c.

1004 {
1005  if (!ptr || !*ptr)
1006  return;
1007 
1008  struct Menu *m = *ptr;
1009  if (m->dialog)
1010  {
1011  for (int i = 0; i < m->max; i++)
1012  FREE(&m->dialog[i]);
1013 
1014  FREE(&m->dialog);
1015  }
1016 
1017  FREE(ptr);
1018 }
GUI selectable list of items.
Definition: mutt_menu.h:82
char ** dialog
dialog lines themselves
Definition: mutt_menu.h:104
int max
the number of entries in the menu
Definition: mutt_menu.h:88
#define FREE(x)
Definition: memory.h:40

+ Here is the caller graph for this function:

void mutt_menu_add_dialog_row ( struct Menu menu,
const char *  row 
)

Add a row to a Menu.

Parameters
menuMenu to add to
rowRow of text to add

Definition at line 1025 of file menu.c.

1026 {
1027  if (menu->dsize <= menu->max)
1028  {
1029  menu->dsize += 10;
1030  mutt_mem_realloc(&menu->dialog, menu->dsize * sizeof(char *));
1031  }
1032  menu->dialog[menu->max++] = mutt_str_strdup(row);
1033 }
char ** dialog
dialog lines themselves
Definition: mutt_menu.h:104
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Definition: memory.c:114
int max
the number of entries in the menu
Definition: mutt_menu.h:88
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
int dsize
number of allocated dialog lines
Definition: mutt_menu.h:105

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static struct Menu* get_current_menu ( void  )
static

Get the current Menu.

Return values
ptrCurrent Menu

Definition at line 1039 of file menu.c.

1040 {
1041  return MenuStackCount ? MenuStack[MenuStackCount - 1] : NULL;
1042 }

+ Here is the caller graph for this function:

void mutt_menu_push_current ( struct Menu menu)

Add a new Menu to the stack.

Parameters
menuMenu to add

The menus are stored in a LIFO. The top-most is shown to the user.

Definition at line 1050 of file menu.c.

1051 {
1053  {
1054  MenuStackLen += 5;
1055  mutt_mem_realloc(&MenuStack, MenuStackLen * sizeof(struct Menu *));
1056  }
1057 
1059  CurrentMenu = menu->menu;
1060 }
GUI selectable list of items.
Definition: mutt_menu.h:82
int menu
menu definition for keymap entries.
Definition: mutt_menu.h:90
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Definition: memory.c:114
WHERE int CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: globals.h:86

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mutt_menu_pop_current ( struct Menu menu)

Remove a Menu from the stack.

Parameters
menuCurrent Menu

The menus are stored in a LIFO. The top-most is shown to the user.

Definition at line 1068 of file menu.c.

1069 {
1070  struct Menu *prev_menu = NULL;
1071 
1072  if (!MenuStackCount || (MenuStack[MenuStackCount - 1] != menu))
1073  {
1074  mutt_debug(LL_DEBUG1, "called with inactive menu\n");
1075  return;
1076  }
1077 
1078  MenuStackCount--;
1079  prev_menu = get_current_menu();
1080  if (prev_menu)
1081  {
1082  CurrentMenu = prev_menu->menu;
1083  prev_menu->redraw = REDRAW_FULL;
1084  }
1085  else
1086  {
1088  move(0, 0);
1089  clrtobot();
1090  }
1091 }
#define REDRAW_FULL
Redraw everything.
Definition: mutt_menu.h:47
GUI selectable list of items.
Definition: mutt_menu.h:82
Index panel (list of emails)
Definition: keymap.h:77
int menu
menu definition for keymap entries.
Definition: mutt_menu.h:90
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
Log at debug level 1.
Definition: logging.h:56
WHERE int CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: globals.h:86
#define mutt_debug(LEVEL,...)
Definition: logging.h:81

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mutt_menu_set_current_redraw ( MuttRedrawFlags  redraw)

Set redraw flags on the current menu.

Parameters
redrawFlags to set, see MuttRedrawFlags

Definition at line 1097 of file menu.c.

1098 {
1099  struct Menu *current_menu = get_current_menu();
1100  if (current_menu)
1101  current_menu->redraw |= redraw;
1102 }
GUI selectable list of items.
Definition: mutt_menu.h:82
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mutt_menu_set_current_redraw_full ( void  )

Flag the current menu to be fully redrawn.

Definition at line 1107 of file menu.c.

1108 {
1109  struct Menu *current_menu = get_current_menu();
1110  if (current_menu)
1111  current_menu->redraw = REDRAW_FULL;
1112 }
#define REDRAW_FULL
Redraw everything.
Definition: mutt_menu.h:47
GUI selectable list of items.
Definition: mutt_menu.h:82
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mutt_menu_set_redraw ( int  menu_type,
MuttRedrawFlags  redraw 
)

Set redraw flags on a menu.

Parameters
menu_typeMenu type, e.g. MENU_ALIAS
redrawFlags, e.g. REDRAW_INDEX

This is ignored if it's not the current menu.

Definition at line 1121 of file menu.c.

1122 {
1123  if (CurrentMenu == menu_type)
1125 }
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
WHERE int CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: globals.h:86

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mutt_menu_set_redraw_full ( int  menu_type)

Flag a menu to be fully redrawn.

Parameters
menu_typeMenu type, e.g. MENU_ALIAS

This is ignored if it's not the current menu.

Definition at line 1133 of file menu.c.

1134 {
1135  if (CurrentMenu == menu_type)
1137 }
WHERE int CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: globals.h:86

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mutt_menu_current_redraw ( void  )

Redraw the current menu.

Definition at line 1142 of file menu.c.

1143 {
1144  struct Menu *current_menu = get_current_menu();
1145  if (current_menu)
1146  {
1147  if (menu_redraw(current_menu) == OP_REDRAW)
1148  {
1149  /* On a REDRAW_FULL with a non-customized redraw, menu_redraw()
1150  * will return OP_REDRAW to give the calling menu-loop a chance to
1151  * customize output. */
1152  menu_redraw(current_menu);
1153  }
1154  }
1155 }
GUI selectable list of items.
Definition: mutt_menu.h:82

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int menu_search ( struct Menu menu,
int  op 
)
static

Search a menu.

Parameters
menuMenu to search
opSearch operation, e.g. OP_SEARCH_NEXT
Return values
>=0Index of matching item
-1Search failed, or was cancelled

Definition at line 1164 of file menu.c.

1165 {
1166  int rc = 0, wrap = 0;
1167  int search_dir;
1168  regex_t re;
1169  char buf[128];
1170  char *search_buf =
1171  ((menu->menu >= 0) && (menu->menu < MENU_MAX)) ? SearchBuffers[menu->menu] : NULL;
1172 
1173  if (!(search_buf && *search_buf) || ((op != OP_SEARCH_NEXT) && (op != OP_SEARCH_OPPOSITE)))
1174  {
1175  mutt_str_strfcpy(buf, search_buf && (search_buf[0] != '\0') ? search_buf : "",
1176  sizeof(buf));
1177  if ((mutt_get_field(((op == OP_SEARCH) || (op == OP_SEARCH_NEXT)) ?
1178  _("Search for: ") :
1179  _("Reverse search for: "),
1180  buf, sizeof(buf), MUTT_CLEAR) != 0) ||
1181  !buf[0])
1182  {
1183  return -1;
1184  }
1185  if ((menu->menu >= 0) && (menu->menu < MENU_MAX))
1186  {
1187  mutt_str_replace(&SearchBuffers[menu->menu], buf);
1188  search_buf = SearchBuffers[menu->menu];
1189  }
1190  menu->search_dir =
1191  ((op == OP_SEARCH) || (op == OP_SEARCH_NEXT)) ? MUTT_SEARCH_DOWN : MUTT_SEARCH_UP;
1192  }
1193 
1194  search_dir = (menu->search_dir == MUTT_SEARCH_UP) ? -1 : 1;
1195  if (op == OP_SEARCH_OPPOSITE)
1196  search_dir = -search_dir;
1197 
1198  if (search_buf)
1199  {
1200  int flags = mutt_mb_is_lower(search_buf) ? REG_ICASE : 0;
1201  rc = REG_COMP(&re, search_buf, REG_NOSUB | flags);
1202  }
1203 
1204  if (rc != 0)
1205  {
1206  regerror(rc, &re, buf, sizeof(buf));
1207  mutt_error("%s", buf);
1208  return -1;
1209  }
1210 
1211  rc = menu->current + search_dir;
1212 search_next:
1213  if (wrap)
1214  mutt_message(_("Search wrapped to top"));
1215  while ((rc >= 0) && (rc < menu->max))
1216  {
1217  if (menu->menu_search(menu, &re, rc) == 0)
1218  {
1219  regfree(&re);
1220  return rc;
1221  }
1222 
1223  rc += search_dir;
1224  }
1225 
1226  if (C_WrapSearch && (wrap++ == 0))
1227  {
1228  rc = (search_dir == 1) ? 0 : menu->max - 1;
1229  goto search_next;
1230  }
1231  regfree(&re);
1232  mutt_error(_("Not found"));
1233  return -1;
1234 }
#define MUTT_CLEAR
Clear input if printable character is pressed.
Definition: mutt.h:69
#define mutt_message(...)
Definition: logging.h:83
#define _(a)
Definition: message.h:28
WHERE bool C_WrapSearch
Config: Wrap around when the search hits the end.
Definition: globals.h:276
int menu
menu definition for keymap entries.
Definition: mutt_menu.h:90
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:86
#define REG_COMP(preg, regex, cflags)
Compile a regular expression.
Definition: regex3.h:52
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:750
int search_dir
direction of search
Definition: mutt_menu.h:112
void mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:453
int max
the number of entries in the menu
Definition: mutt_menu.h:88
int(* menu_search)(struct Menu *menu, regex_t *rx, int line)
Search a menu for a item matching a regex.
Definition: mutt_menu.h:131
#define mutt_error(...)
Definition: logging.h:84
int current
current entry
Definition: mutt_menu.h:87
bool mutt_mb_is_lower(const char *s)
Does a multi-byte string contain only lowercase characters?
Definition: mbyte.c:358

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int menu_dialog_translate_op ( int  i)
static

Convert menubar movement to scrolling.

Parameters
iAction requested, e.g. OP_NEXT_ENTRY
Return values
numAction to perform, e.g. OP_NEXT_LINE

Definition at line 1241 of file menu.c.

1242 {
1243  switch (i)
1244  {
1245  case OP_NEXT_ENTRY:
1246  return OP_NEXT_LINE;
1247  case OP_PREV_ENTRY:
1248  return OP_PREV_LINE;
1249  case OP_CURRENT_TOP:
1250  case OP_FIRST_ENTRY:
1251  return OP_TOP_PAGE;
1252  case OP_CURRENT_BOTTOM:
1253  case OP_LAST_ENTRY:
1254  return OP_BOTTOM_PAGE;
1255  case OP_CURRENT_MIDDLE:
1256  return OP_MIDDLE_PAGE;
1257  }
1258 
1259  return i;
1260 }

+ Here is the caller graph for this function:

static int menu_dialog_dokey ( struct Menu menu,
int *  ip 
)
static

Check if there are any menu key events to process.

Parameters
menuCurrent Menu
ipKeyEvent ID
Return values
0An event occurred for the menu, or a timeout
-1There was an event, but not for menu

Definition at line 1269 of file menu.c.

1270 {
1271  struct KeyEvent ch;
1272  char *p = NULL;
1273 
1274  do
1275  {
1276  ch = mutt_getch();
1277  } while (ch.ch == -2);
1278 
1279  if (ch.ch < 0)
1280  {
1281  *ip = -1;
1282  return 0;
1283  }
1284 
1285  if (ch.ch && (p = strchr(menu->keys, ch.ch)))
1286  {
1287  *ip = OP_MAX + (p - menu->keys + 1);
1288  return 0;
1289  }
1290  else
1291  {
1292  if (ch.op == OP_NULL)
1293  mutt_unget_event(ch.ch, 0);
1294  else
1295  mutt_unget_event(0, ch.op);
1296  return -1;
1297  }
1298 }
void mutt_unget_event(int ch, int op)
Return a keystroke to the input buffer.
Definition: curs_lib.c:715
int ch
raw key pressed
Definition: mutt_curses.h:110
An event such as a keypress.
Definition: mutt_curses.h:108
struct KeyEvent mutt_getch(void)
Read a character from the input buffer.
Definition: curs_lib.c:175
char * keys
keys used in the prompt
Definition: mutt_menu.h:107

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int menu_redraw ( struct Menu menu)

Redraw the parts of the screen that have been flagged to be redrawn.

Parameters
menuMenu to redraw
Return values
OP_NULLMenu was redrawn
OP_REDRAWFull redraw required

Definition at line 1306 of file menu.c.

1307 {
1308  if (menu->menu_custom_redraw)
1309  {
1310  menu->menu_custom_redraw(menu);
1311  return OP_NULL;
1312  }
1313 
1314  /* See if all or part of the screen needs to be updated. */
1315  if (menu->redraw & REDRAW_FULL)
1316  {
1317  menu_redraw_full(menu);
1318  /* allow the caller to do any local configuration */
1319  return OP_REDRAW;
1320  }
1321 
1322  if (!menu->dialog)
1323  menu_check_recenter(menu);
1324 
1325  if (menu->redraw & REDRAW_STATUS)
1326  menu_redraw_status(menu);
1327 #ifdef USE_SIDEBAR
1328  if (menu->redraw & REDRAW_SIDEBAR)
1329  menu_redraw_sidebar(menu);
1330 #endif
1331  if (menu->redraw & REDRAW_INDEX)
1332  menu_redraw_index(menu);
1333  else if (menu->redraw & (REDRAW_MOTION | REDRAW_MOTION_RESYNC))
1334  menu_redraw_motion(menu);
1335  else if (menu->redraw == REDRAW_CURRENT)
1336  menu_redraw_current(menu);
1337 
1338  if (menu->dialog)
1339  menu_redraw_prompt(menu);
1340 
1341  return OP_NULL;
1342 }
#define REDRAW_FULL
Redraw everything.
Definition: mutt_menu.h:47
char ** dialog
dialog lines themselves
Definition: mutt_menu.h:104
#define REDRAW_SIDEBAR
Redraw the sidebar.
Definition: mutt_menu.h:51
void(* menu_custom_redraw)(struct Menu *menu)
Redraw the menu.
Definition: mutt_menu.h:151
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:43
#define REDRAW_MOTION_RESYNC
Redraw any changing the menu selection.
Definition: mutt_menu.h:44
#define REDRAW_STATUS
Redraw the status bar.
Definition: mutt_menu.h:46
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:42
#define REDRAW_CURRENT
Redraw the current line of the menu.
Definition: mutt_menu.h:45

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int mutt_menu_loop ( struct Menu menu)

Menu event loop.

Parameters
menuCurrent Menu
Return values
numAn event id that the menu can't process

Definition at line 1349 of file menu.c.

1350 {
1351  static int last_position = -1;
1352  int i = OP_NULL;
1353 
1354  if (menu->max && menu->is_mailbox_list)
1355  {
1356  if (last_position > (menu->max - 1))
1357  last_position = -1;
1358  else if (last_position >= 0)
1359  menu->current = last_position;
1360  }
1361 
1362  while (true)
1363  {
1364  if (OptMenuCaller)
1365  {
1366  OptMenuCaller = false;
1367  return OP_NULL;
1368  }
1369 
1370  /* Clear the tag prefix unless we just started it. Don't clear
1371  * the prefix on a timeout (i==-2), but do clear on an abort (i==-1) */
1372  if (menu->tagprefix && (i != OP_TAG_PREFIX) && (i != OP_TAG_PREFIX_COND) && (i != -2))
1373  menu->tagprefix = false;
1374 
1375  mutt_curs_set(0);
1376 
1377  if (menu_redraw(menu) == OP_REDRAW)
1378  return OP_REDRAW;
1379 
1380  /* give visual indication that the next command is a tag- command */
1381  if (menu->tagprefix)
1382  {
1383  mutt_window_mvaddstr(menu->messagewin, 0, 0, "tag-");
1385  }
1386 
1387  menu->oldcurrent = menu->current;
1388 
1389  /* move the cursor out of the way */
1390  if (C_ArrowCursor)
1391  mutt_window_move(menu->indexwin, menu->current - menu->top + menu->offset, 2);
1392  else if (C_BrailleFriendly)
1393  mutt_window_move(menu->indexwin, menu->current - menu->top + menu->offset, 0);
1394  else
1395  {
1396  mutt_window_move(menu->indexwin, menu->current - menu->top + menu->offset,
1397  menu->indexwin->cols - 1);
1398  }
1399 
1400  mutt_refresh();
1401 
1402  /* try to catch dialog keys before ops */
1403  if (menu->dialog && (menu_dialog_dokey(menu, &i) == 0))
1404  return i;
1405 
1406  i = km_dokey(menu->menu);
1407  if ((i == OP_TAG_PREFIX) || (i == OP_TAG_PREFIX_COND))
1408  {
1409  if (menu->tagprefix)
1410  {
1411  menu->tagprefix = false;
1413  continue;
1414  }
1415 
1416  if (menu->tagged)
1417  {
1418  menu->tagprefix = true;
1419  continue;
1420  }
1421  else if (i == OP_TAG_PREFIX)
1422  {
1423  mutt_error(_("No tagged entries"));
1424  i = -1;
1425  }
1426  else /* None tagged, OP_TAG_PREFIX_COND */
1427  {
1429  mutt_message(_("Nothing to do"));
1430  i = -1;
1431  }
1432  }
1433  else if (menu->tagged && C_AutoTag)
1434  menu->tagprefix = true;
1435 
1436  mutt_curs_set(1);
1437 
1438  if (SigWinch)
1439  {
1441  SigWinch = 0;
1442  clearok(stdscr, true); /* force complete redraw */
1443  }
1444 
1445  if (i < 0)
1446  {
1447  if (menu->tagprefix)
1449  continue;
1450  }
1451 
1452  if (!menu->dialog)
1453  mutt_clear_error();
1454 
1455  /* Convert menubar movement to scrolling */
1456  if (menu->dialog)
1457  i = menu_dialog_translate_op(i);
1458 
1459  switch (i)
1460  {
1461  case OP_NEXT_ENTRY:
1462  menu_next_entry(menu);
1463  break;
1464  case OP_PREV_ENTRY:
1465  menu_prev_entry(menu);
1466  break;
1467  case OP_HALF_DOWN:
1468  menu_half_down(menu);
1469  break;
1470  case OP_HALF_UP:
1471  menu_half_up(menu);
1472  break;
1473  case OP_NEXT_PAGE:
1474  menu_next_page(menu);
1475  break;
1476  case OP_PREV_PAGE:
1477  menu_prev_page(menu);
1478  break;
1479  case OP_NEXT_LINE:
1480  menu_next_line(menu);
1481  break;
1482  case OP_PREV_LINE:
1483  menu_prev_line(menu);
1484  break;
1485  case OP_FIRST_ENTRY:
1486  menu_first_entry(menu);
1487  break;
1488  case OP_LAST_ENTRY:
1489  menu_last_entry(menu);
1490  break;
1491  case OP_TOP_PAGE:
1492  menu_top_page(menu);
1493  break;
1494  case OP_MIDDLE_PAGE:
1495  menu_middle_page(menu);
1496  break;
1497  case OP_BOTTOM_PAGE:
1498  menu_bottom_page(menu);
1499  break;
1500  case OP_CURRENT_TOP:
1501  menu_current_top(menu);
1502  break;
1503  case OP_CURRENT_MIDDLE:
1504  menu_current_middle(menu);
1505  break;
1506  case OP_CURRENT_BOTTOM:
1507  menu_current_bottom(menu);
1508  break;
1509  case OP_SEARCH:
1510  case OP_SEARCH_REVERSE:
1511  case OP_SEARCH_NEXT:
1512  case OP_SEARCH_OPPOSITE:
1513  if (menu->menu_search && !menu->dialog) /* Searching dialogs won't work */
1514  {
1515  menu->oldcurrent = menu->current;
1516  menu->current = menu_search(menu, i);
1517  if (menu->current != -1)
1518  menu->redraw = REDRAW_MOTION;
1519  else
1520  menu->current = menu->oldcurrent;
1521  }
1522  else
1523  mutt_error(_("Search is not implemented for this menu"));
1524  break;
1525 
1526  case OP_JUMP:
1527  if (menu->dialog)
1528  mutt_error(_("Jumping is not implemented for dialogs"));
1529  else
1530  menu_jump(menu);
1531  break;
1532 
1533  case OP_ENTER_COMMAND:
1535  break;
1536 
1537  case OP_TAG:
1538  if (menu->menu_tag && !menu->dialog)
1539  {
1540  if (menu->tagprefix && !C_AutoTag)
1541  {
1542  for (i = 0; i < menu->max; i++)
1543  menu->tagged += menu->menu_tag(menu, i, 0);
1544  menu->redraw |= REDRAW_INDEX;
1545  }
1546  else if (menu->max)
1547  {
1548  int j = menu->menu_tag(menu, menu->current, -1);
1549  menu->tagged += j;
1550  if (j && C_Resolve && (menu->current < menu->max - 1))
1551  {
1552  menu->current++;
1553  menu->redraw |= REDRAW_MOTION_RESYNC;
1554  }
1555  else
1556  menu->redraw |= REDRAW_CURRENT;
1557  }
1558  else
1559  mutt_error(_("No entries"));
1560  }
1561  else
1562  mutt_error(_("Tagging is not supported"));
1563  break;
1564 
1565  case OP_SHELL_ESCAPE:
1567  break;
1568 
1569  case OP_WHAT_KEY:
1570  mutt_what_key();
1571  break;
1572 
1573  case OP_CHECK_STATS:
1574  mutt_check_stats();
1575  break;
1576 
1577  case OP_REDRAW:
1578  clearok(stdscr, true);
1579  menu->redraw = REDRAW_FULL;
1580  break;
1581 
1582  case OP_HELP:
1583  mutt_help(menu->menu);
1584  menu->redraw = REDRAW_FULL;
1585  break;
1586 
1587  case OP_NULL:
1588  km_error_key(menu->menu);
1589  break;
1590 
1591  case OP_END_COND:
1592  break;
1593 
1594  default:
1595  if (menu->is_mailbox_list)
1596  last_position = menu->current;
1597  return i;
1598  }
1599  }
1600  /* not reached */
1601 }
#define REDRAW_FULL
Redraw everything.
Definition: mutt_menu.h:47
int km_dokey(int menu)
Determine what a keypress should do.
Definition: keymap.c:570
#define mutt_message(...)
Definition: logging.h:83
int oldcurrent
for driver use only
Definition: mutt_menu.h:111
WHERE bool OptMenuCaller
(pseudo) tell menu to give caller a take
Definition: options.h:38
void mutt_window_clrtoeol(struct MuttWindow *win)
Clear to the end of the line.
Definition: mutt_window.c:107
void mutt_resize_screen(void)
Update NeoMutt&#39;s opinion about the window size (CURSES)
Definition: resize.c:98
void mutt_check_stats(void)
Forcibly update mailbox stats.
Definition: commands.c:1356
char ** dialog
dialog lines themselves
Definition: mutt_menu.h:104
void mutt_enter_command(void)
enter a neomutt command
Definition: commands.c:837
#define _(a)
Definition: message.h:28
WHERE bool C_BrailleFriendly
Config: Move the cursor to the beginning of the line.
Definition: globals.h:216
int menu
menu definition for keymap entries.
Definition: mutt_menu.h:90
void km_error_key(int menu)
Handle an unbound key sequence.
Definition: keymap.c:1050
void mutt_flush_macro_to_endcond(void)
Drop a macro from the input buffer.
Definition: curs_lib.c:771
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:95
void mutt_what_key(void)
Ask the user to press a key.
Definition: keymap.c:1572
void mutt_shell_escape(void)
invoke a command in a subshell
Definition: commands.c:809
WHERE SIG_ATOMIC_VOLATILE_T SigWinch
true after SIGWINCH is received
Definition: globals.h:84
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:143
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:43
#define REDRAW_MOTION_RESYNC
Redraw any changing the menu selection.
Definition: mutt_menu.h:44
void mutt_refresh(void)
Force a refresh of the screen.
Definition: curs_lib.c:94
struct MuttWindow * indexwin
Definition: mutt_menu.h:95
int top
entry that is the top of the current page
Definition: mutt_menu.h:110
bool tagprefix
Definition: mutt_menu.h:93
WHERE bool C_Resolve
Config: Move to the next email whenever a command modifies an email.
Definition: globals.h:257
bool is_mailbox_list
Definition: mutt_menu.h:94
int mutt_window_mvaddstr(struct MuttWindow *win, int row, int col, const char *str)
Move the cursor and write a fixed string to a Window.
Definition: mutt_window.c:202
int tagged
number of tagged entries
Definition: mutt_menu.h:113
int mutt_window_move(struct MuttWindow *win, int row, int col)
Move the cursor in a Window.
Definition: mutt_window.c:188
void mutt_help(int menu)
Display the help menu.
Definition: help.c:438
int max
the number of entries in the menu
Definition: mutt_menu.h:88
int(* menu_tag)(struct Menu *menu, int sel, int act)
Tag some menu items.
Definition: mutt_menu.h:139
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
int(* menu_search)(struct Menu *menu, regex_t *rx, int line)
Search a menu for a item matching a regex.
Definition: mutt_menu.h:131
int offset
row offset within the window to start the index
Definition: mutt_menu.h:91
#define mutt_curs_set(x)
Definition: mutt_curses.h:94
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:42
#define mutt_error(...)
Definition: logging.h:84
struct MuttWindow * messagewin
Definition: mutt_menu.h:98
WHERE bool C_AutoTag
Config: Automatically apply actions to all tagged messages.
Definition: globals.h:213
int current
current entry
Definition: mutt_menu.h:87
#define REDRAW_CURRENT
Redraw the current line of the menu.
Definition: mutt_menu.h:45
WHERE bool C_ArrowCursor
Config: Use an arrow &#39;->&#39; instead of highlighting in the index.
Definition: globals.h:204

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int mutt_menu_observer ( struct NotifyCallback nc)

Listen for config changes affecting the menu - Implements observer_t()

Definition at line 1606 of file menu.c.

1607 {
1608  if (!nc)
1609  return -1;
1610 
1611  struct EventConfig *ec = (struct EventConfig *) nc->event;
1612 
1613  const struct ConfigDef *cdef = ec->he->data;
1614  ConfigRedrawFlags flags = cdef->type & R_REDRAW_MASK;
1615 
1616  if (flags == R_REDRAW_NO_FLAGS)
1617  return 0;
1618 
1619  if (flags & R_INDEX)
1621  if (flags & R_PAGER)
1623  if (flags & R_PAGER_FLOW)
1624  {
1627  }
1628 
1629  if (flags & R_RESORT_SUB)
1630  OptSortSubthreads = true;
1631  if (flags & R_RESORT)
1632  OptNeedResort = true;
1633  if (flags & R_RESORT_INIT)
1634  OptResortInit = true;
1635  if (flags & R_TREE)
1636  OptRedrawTree = true;
1637 
1638  if (flags & R_REFLOW)
1640 #ifdef USE_SIDEBAR
1641  if (flags & R_SIDEBAR)
1643 #endif
1644  if (flags & R_MENU)
1646 
1647  return 0;
1648 }
#define R_PAGER
Redraw the pager menu.
Definition: types.h:64
#define R_PAGER_FLOW
Reflow line_info and redraw the pager menu.
Definition: types.h:65
#define REDRAW_FLOW
Used by pager to reflow text.
Definition: mutt_menu.h:49
WHERE bool OptNeedResort
(pseudo) used to force a re-sort
Definition: options.h:41
A config-change event.
Definition: set.h:199
intptr_t event
Send: event data.
Definition: observer.h:46
Index panel (list of emails)
Definition: keymap.h:77
Config item definition.
Definition: set.h:153
#define R_RESORT
Resort the mailbox.
Definition: types.h:66
#define REDRAW_SIDEBAR
Redraw the sidebar.
Definition: mutt_menu.h:51
#define R_TREE
Redraw the thread tree.
Definition: types.h:69
Pager pager (email viewer)
Definition: keymap.h:78
#define R_REDRAW_NO_FLAGS
No refresh/resort flags.
Definition: types.h:62
struct HashElem * he
Config item that changed.
Definition: set.h:202
void mutt_window_reflow(void)
Resize the Windows to fit the screen.
Definition: mutt_window.c:234
#define R_MENU
Redraw all menus.
Definition: types.h:72
#define R_RESORT_SUB
Resort subthreads.
Definition: types.h:67
#define R_REFLOW
Reflow window layout and full redraw.
Definition: types.h:70
uint32_t ConfigRedrawFlags
Flags for redraw/resort, e.g. R_INDEX.
Definition: types.h:61
WHERE bool OptRedrawTree
(pseudo) redraw the thread tree
Definition: options.h:48
WHERE bool OptResortInit
(pseudo) used to force the next resort to be from scratch
Definition: options.h:49
void * data
Definition: hash.h:46
#define R_RESORT_INIT
Resort from scratch.
Definition: types.h:68
WHERE bool OptSortSubthreads
(pseudo) used when $sort_aux changes
Definition: options.h:52
#define R_SIDEBAR
Redraw the sidebar.
Definition: types.h:71
#define R_REDRAW_MASK
Mask for the Redraw Flags.
Definition: types.h:74
#define R_INDEX
Redraw the index menu (MENU_MAIN)
Definition: types.h:63

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

short C_MenuContext

Config: Number of lines of overlap when changing pages in the index.

Definition at line 60 of file menu.c.

bool C_MenuMoveOff

Config: Allow the last menu item to move off the bottom of the screen.

Definition at line 61 of file menu.c.

bool C_MenuScroll

Config: Scroll the menu/index by one line, rather than a page.

Definition at line 62 of file menu.c.

char* SearchBuffers[MENU_MAX]

Definition at line 64 of file menu.c.

size_t MenuStackCount = 0
static

Definition at line 67 of file menu.c.

size_t MenuStackLen = 0
static

Definition at line 68 of file menu.c.

struct Menu** MenuStack = NULL
static

Definition at line 69 of file menu.c.