NeoMutt  2018-07-16 +1360-3df4a2
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 "email/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 "mailbox.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_destroy (struct Menu **p)
 Destroy 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...
 
bool mutt_menu_listener (const struct ConfigSet *cs, struct HashElem *he, const char *name, enum ConfigEvent ev)
 Listen for config changes affecting the menu - Implements cs_listener() 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 70 of file menu.c.

#define MUTT_SEARCH_UP   1

Definition at line 72 of file menu.c.

#define MUTT_SEARCH_DOWN   2

Definition at line 73 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 84 of file menu.c.

85 {
86  struct ColorLineHead *color = NULL;
87  struct ColorLine *np = NULL;
88  struct Email *e = Context->mailbox->emails[Context->mailbox->v2r[index]];
89  int type = *s;
90 
91  switch (type)
92  {
94  color = &ColorIndexAuthorList;
95  break;
97  color = &ColorIndexFlagsList;
98  break;
100  color = &ColorIndexSubjectList;
101  break;
102  case MT_COLOR_INDEX_TAG:
103  STAILQ_FOREACH(np, &ColorIndexTagList, entries)
104  {
105  if (strncmp((const char *) (s + 1), np->pattern, strlen(np->pattern)) == 0)
106  return np->pair;
107  const char *transform = mutt_hash_find(TagTransforms, np->pattern);
108  if (transform &&
109  (strncmp((const char *) (s + 1), transform, strlen(transform)) == 0))
110  {
111  return np->pair;
112  }
113  }
114  return 0;
115  default:
116  return ColorDefs[type];
117  }
118 
119  STAILQ_FOREACH(np, color, entries)
120  {
122  Context->mailbox, e, NULL))
123  return np->pair;
124  }
125 
126  return 0;
127 }
struct Email ** emails
Definition: mailbox.h:100
Index: subject field (takes a pattern)
Definition: mutt_curses.h:159
The "current" mailbox.
Definition: context.h:37
The envelope/body of an email.
Definition: email.h:37
struct Hash * TagTransforms
Lookup table of alternative tag names.
Definition: tags.c:39
struct ColorLineHead ColorIndexFlagsList
List of colours applied to the flags in the index.
Definition: color.c:57
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:373
char * pattern
Definition: mutt_curses.h:182
Match the full address.
Definition: pattern.h:72
struct Mailbox * mailbox
Definition: context.h:51
struct Pattern * color_pattern
compiled pattern to speed up index color calculation
Definition: mutt_curses.h:183
struct ColorLineHead ColorIndexAuthorList
List of colours applied to the author in the index.
Definition: color.c:56
Index: tag field (g, takes a pattern)
Definition: mutt_curses.h:158
Index: flags field (takes a pattern)
Definition: mutt_curses.h:157
Index: author field (takes a pattern)
Definition: mutt_curses.h:156
#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:52
int * v2r
mapping from virtual to real msgno
Definition: mailbox.h:102
struct ColorLineHead ColorIndexSubjectList
List of colours applied to the subject in the index.
Definition: color.c:59
struct ColorLineHead ColorIndexTagList
List of colours applied to tags in the index.
Definition: color.c:60
int index
the absolute (unsorted) message number
Definition: email.h:88
int mutt_pattern_exec(struct Pattern *pat, enum PatternExecFlag flags, struct Mailbox *m, struct Email *e, struct PatternCache *cache)
Match a pattern against an email header.
Definition: pattern.c:1931
A regular expression and a color to highlight a line.
Definition: mutt_curses.h:178

+ 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 136 of file menu.c.

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

324 {
325  if (menu->dialog)
326  {
327  mutt_str_strfcpy(buf, menu->dialog[i], buflen);
328  menu->current = -1; /* hide menubar */
329  }
330  else
331  menu->menu_make_entry(buf, buflen, menu, i);
332 }
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:121
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:741
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 342 of file menu.c.

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

+ 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 358 of file menu.c.

359 {
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:237
WHERE bool C_Help
Config: Display a help line with common key bindings.
Definition: globals.h:226
#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:1083
struct MuttWindow * helpwin
Definition: mutt_menu.h:97
void mutt_window_reflow(void)
Resize the Windows to fit the screen.
Definition: mutt_window.c:222
#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
int mutt_window_move(struct MuttWindow *win, int row, int col)
Move the cursor in a Window.
Definition: mutt_window.c:162
#define SETCOLOR(X)
Definition: mutt_curses.h:222
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:128
void mutt_show_error(void)
Show the user an error message.
Definition: curs_lib.c:483
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:237
void mutt_paddstr(int n, const char *s)
Display a string on screen, padded if necessary.
Definition: curs_lib.c:1083
struct MuttWindow * statuswin
Definition: mutt_menu.h:96
#define REDRAW_STATUS
Redraw the status bar.
Definition: mutt_menu.h:46
int mutt_window_move(struct MuttWindow *win, int row, int col)
Move the cursor in a Window.
Definition: mutt_window.c:162
#define SETCOLOR(X)
Definition: mutt_curses.h:222
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:128

+ 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  ATTRSET(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  ATTRSET(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:237
#define ATTRSET
Definition: mutt_curses.h:230
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:69
struct MuttWindow * indexwin
Definition: mutt_menu.h:95
int top
entry that is the top of the current page
Definition: mutt_menu.h:109
int pagelen
number of entries per screen
Definition: mutt_menu.h:92
int mutt_window_move(struct MuttWindow *win, int row, int col)
Move the cursor in a Window.
Definition: mutt_window.c:162
int(* menu_color)(int line)
Calculate the colour for a line of the menu.
Definition: mutt_menu.h:145
#define SETCOLOR(X)
Definition: mutt_curses.h:222
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:127
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:202

+ 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  ATTRSET(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:110
#define NORMAL_COLOR
Definition: mutt_curses.h:237
char ** dialog
dialog lines themselves
Definition: mutt_menu.h:104
#define ATTRSET
Definition: mutt_curses.h:230
#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
struct MuttWindow * indexwin
Definition: mutt_menu.h:95
int top
entry that is the top of the current page
Definition: mutt_menu.h:109
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:190
int mutt_window_move(struct MuttWindow *win, int row, int col)
Move the cursor in a Window.
Definition: mutt_window.c:162
int(* menu_color)(int line)
Calculate the colour for a line of the menu.
Definition: mutt_menu.h:145
#define SETCOLOR(X)
Definition: mutt_curses.h:222
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:127
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:202

+ 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  ATTRSET(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:237
#define ATTRSET
Definition: mutt_curses.h:230
#define REDRAW_STATUS
Redraw the status bar.
Definition: mutt_menu.h:46
struct MuttWindow * indexwin
Definition: mutt_menu.h:95
int top
entry that is the top of the current page
Definition: mutt_menu.h:109
int mutt_window_move(struct MuttWindow *win, int row, int col)
Move the cursor in a Window.
Definition: mutt_window.c:162
int(* menu_color)(int line)
Calculate the colour for a line of the menu.
Definition: mutt_menu.h:145
#define SETCOLOR(X)
Definition: mutt_curses.h:222
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:127
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:202

+ 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:105
void mutt_window_clrtoeol(struct MuttWindow *win)
Clear to the end of the line.
Definition: mutt_window.c:81
char ** dialog
dialog lines themselves
Definition: mutt_menu.h:104
void mutt_sleep(short s)
Sleep for a while.
Definition: muttlib.c:1471
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:141
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:190
struct MuttWindow * messagewin
Definition: mutt_menu.h:98
WHERE bool OptMsgErr
(pseudo) used by mutt_error/mutt_message
Definition: options.h:38

+ 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:109
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:261
void mutt_unget_event(int ch, int op)
Return a keystroke to the input buffer.
Definition: curs_lib.c:668
#define _(a)
Definition: message.h:28
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:77
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:88
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_error(_("You cannot scroll down farther"));
672  }
673  else
674  mutt_error(_("No entries"));
675 }
#define MIN(a, b)
Definition: memory.h:31
#define _(a)
Definition: message.h:28
int top
entry that is the top of the current page
Definition: mutt_menu.h:109
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:88
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_error(_("You cannot scroll up farther"));
694 }
#define MIN(a, b)
Definition: memory.h:31
#define _(a)
Definition: message.h:28
int top
entry that is the top of the current page
Definition: mutt_menu.h:109
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
#define mutt_error(...)
Definition: logging.h:88
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_error(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
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:109
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:88
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:109
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:109
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:88
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:109
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:88
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:88
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:88
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:109
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:88
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:109
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:88
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:109
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:88
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_error(_("You are on the last entry"));
926 }
#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:88
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_error(_("You are on the first entry"));
941 }
#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
#define mutt_error(...)
Definition: logging.h:88
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:130
int ColorDefs[MT_COLOR_MAX]
Array of all fixed colours, see enum ColorId.
Definition: color.c:52

+ 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:35

+ 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:51
struct MuttWindow * MuttStatusWindow
Status Window.
Definition: mutt_window.c:40
GUI selectable list of items.
Definition: mutt_menu.h:82
struct MuttWindow * MuttHelpWindow
Help Window.
Definition: mutt_window.c:38
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:39
struct MuttWindow * indexwin
Definition: mutt_menu.h:95
int top
entry that is the top of the current page
Definition: mutt_menu.h:109
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:145
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:130
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:41
int current
current entry
Definition: mutt_menu.h:87
Generic selection list.
Definition: keymap.h:73

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mutt_menu_destroy ( struct Menu **  p)

Destroy a menu.

Parameters
[out]pMenu to destroy

Definition at line 1003 of file menu.c.

1004 {
1005  if ((*p)->dialog)
1006  {
1007  for (int i = 0; i < (*p)->max; i++)
1008  FREE(&(*p)->dialog[i]);
1009 
1010  FREE(&(*p)->dialog);
1011  }
1012 
1013  FREE(p);
1014 }
#define FREE(x)
Definition: memory.h:40

+ 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 1020 of file menu.c.

1021 {
1022  return MenuStackCount ? MenuStack[MenuStackCount - 1] : NULL;
1023 }

+ 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 1031 of file menu.c.

1032 {
1034  {
1035  MenuStackLen += 5;
1036  mutt_mem_realloc(&MenuStack, MenuStackLen * sizeof(struct Menu *));
1037  }
1038 
1040  CurrentMenu = menu->menu;
1041 }
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:124
WHERE int CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: globals.h:94

+ 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 1049 of file menu.c.

1050 {
1051  struct Menu *prev_menu = NULL;
1052 
1053  if (!MenuStackCount || (MenuStack[MenuStackCount - 1] != menu))
1054  {
1055  mutt_debug(LL_DEBUG1, "called with inactive menu\n");
1056  return;
1057  }
1058 
1059  MenuStackCount--;
1060  prev_menu = get_current_menu();
1061  if (prev_menu)
1062  {
1063  CurrentMenu = prev_menu->menu;
1064  prev_menu->redraw = REDRAW_FULL;
1065  }
1066  else
1067  {
1069  }
1070 }
#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:74
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:94
#define mutt_debug(LEVEL,...)
Definition: logging.h:85

+ 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 1076 of file menu.c.

1077 {
1078  struct Menu *current_menu = get_current_menu();
1079  if (current_menu)
1080  current_menu->redraw |= redraw;
1081 }
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 1086 of file menu.c.

1087 {
1088  struct Menu *current_menu = get_current_menu();
1089  if (current_menu)
1090  current_menu->redraw = REDRAW_FULL;
1091 }
#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 1100 of file menu.c.

1101 {
1102  if (CurrentMenu == menu_type)
1104 }
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
WHERE int CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: globals.h:94

+ 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 1112 of file menu.c.

1113 {
1114  if (CurrentMenu == menu_type)
1116 }
WHERE int CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: globals.h:94

+ 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 1121 of file menu.c.

1122 {
1123  struct Menu *current_menu = get_current_menu();
1124  if (current_menu)
1125  {
1126  if (menu_redraw(current_menu) == OP_REDRAW)
1127  {
1128  /* On a REDRAW_FULL with a non-customized redraw, menu_redraw()
1129  * will return OP_REDRAW to give the calling menu-loop a chance to
1130  * customize output. */
1131  menu_redraw(current_menu);
1132  }
1133  }
1134 }
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 1143 of file menu.c.

1144 {
1145  int rc = 0, wrap = 0;
1146  int search_dir;
1147  regex_t re;
1148  char buf[128];
1149  char *search_buf =
1150  menu->menu >= 0 && menu->menu < MENU_MAX ? SearchBuffers[menu->menu] : NULL;
1151 
1152  if (!(search_buf && *search_buf) || ((op != OP_SEARCH_NEXT) && (op != OP_SEARCH_OPPOSITE)))
1153  {
1154  mutt_str_strfcpy(buf, search_buf && *search_buf ? search_buf : "", sizeof(buf));
1155  if ((mutt_get_field(((op == OP_SEARCH) || (op == OP_SEARCH_NEXT)) ?
1156  _("Search for: ") :
1157  _("Reverse search for: "),
1158  buf, sizeof(buf), MUTT_CLEAR) != 0) ||
1159  !buf[0])
1160  {
1161  return -1;
1162  }
1163  if ((menu->menu >= 0) && (menu->menu < MENU_MAX))
1164  {
1165  mutt_str_replace(&SearchBuffers[menu->menu], buf);
1166  search_buf = SearchBuffers[menu->menu];
1167  }
1168  menu->search_dir =
1169  (op == OP_SEARCH || op == OP_SEARCH_NEXT) ? MUTT_SEARCH_DOWN : MUTT_SEARCH_UP;
1170  }
1171 
1172  search_dir = (menu->search_dir == MUTT_SEARCH_UP) ? -1 : 1;
1173  if (op == OP_SEARCH_OPPOSITE)
1174  search_dir = -search_dir;
1175 
1176  if (search_buf)
1177  {
1178  int flags = mutt_mb_is_lower(search_buf) ? REG_ICASE : 0;
1179  rc = REGCOMP(&re, search_buf, REG_NOSUB | flags);
1180  }
1181 
1182  if (rc != 0)
1183  {
1184  regerror(rc, &re, buf, sizeof(buf));
1185  mutt_error("%s", buf);
1186  return -1;
1187  }
1188 
1189  rc = menu->current + search_dir;
1190 search_next:
1191  if (wrap)
1192  mutt_message(_("Search wrapped to top"));
1193  while (rc >= 0 && rc < menu->max)
1194  {
1195  if (menu->menu_search(menu, &re, rc) == 0)
1196  {
1197  regfree(&re);
1198  return rc;
1199  }
1200 
1201  rc += search_dir;
1202  }
1203 
1204  if (C_WrapSearch && (wrap++ == 0))
1205  {
1206  rc = search_dir == 1 ? 0 : menu->max - 1;
1207  goto search_next;
1208  }
1209  regfree(&re);
1210  mutt_error(_("Not found"));
1211  return -1;
1212 }
#define MUTT_CLEAR
Clear input if printable character is pressed.
Definition: mutt.h:66
#define mutt_message(...)
Definition: logging.h:87
#define _(a)
Definition: message.h:28
WHERE bool C_WrapSearch
Config: Wrap around when the search hits the end.
Definition: globals.h:267
int menu
menu definition for keymap entries.
Definition: mutt_menu.h:90
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:77
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:741
int search_dir
direction of search
Definition: mutt_menu.h:111
void mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:459
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:130
#define mutt_error(...)
Definition: logging.h:88
#define REGCOMP(preg, regex, cflags)
Compile a regular expression.
Definition: regex3.h:52
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:346

+ 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 1219 of file menu.c.

1220 {
1221  switch (i)
1222  {
1223  case OP_NEXT_ENTRY:
1224  return OP_NEXT_LINE;
1225  case OP_PREV_ENTRY:
1226  return OP_PREV_LINE;
1227  case OP_CURRENT_TOP:
1228  case OP_FIRST_ENTRY:
1229  return OP_TOP_PAGE;
1230  case OP_CURRENT_BOTTOM:
1231  case OP_LAST_ENTRY:
1232  return OP_BOTTOM_PAGE;
1233  case OP_CURRENT_MIDDLE:
1234  return OP_MIDDLE_PAGE;
1235  }
1236 
1237  return i;
1238 }

+ 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
ipEvent ID
Return values
0An event occurred for the menu, or a timeout
-1There was an event, but not for menu

Definition at line 1247 of file menu.c.

1248 {
1249  struct Event ch;
1250  char *p = NULL;
1251 
1252  do
1253  {
1254  ch = mutt_getch();
1255  } while (ch.ch == -2);
1256 
1257  if (ch.ch < 0)
1258  {
1259  *ip = -1;
1260  return 0;
1261  }
1262 
1263  if (ch.ch && (p = strchr(menu->keys, ch.ch)))
1264  {
1265  *ip = OP_MAX + (p - menu->keys + 1);
1266  return 0;
1267  }
1268  else
1269  {
1270  mutt_unget_event(ch.op ? 0 : ch.ch, ch.op ? ch.op : 0);
1271  return -1;
1272  }
1273 }
void mutt_unget_event(int ch, int op)
Return a keystroke to the input buffer.
Definition: curs_lib.c:668
An event such as a keypress.
Definition: mutt_curses.h:107
struct Event mutt_getch(void)
Read a character from the input buffer.
Definition: curs_lib.c:180
char * keys
keys used in the prompt
Definition: mutt_menu.h:106
int ch
raw key pressed
Definition: mutt_curses.h:109

+ 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 1281 of file menu.c.

1282 {
1283  if (menu->menu_custom_redraw)
1284  {
1285  menu->menu_custom_redraw(menu);
1286  return OP_NULL;
1287  }
1288 
1289  /* See if all or part of the screen needs to be updated. */
1290  if (menu->redraw & REDRAW_FULL)
1291  {
1292  menu_redraw_full(menu);
1293  /* allow the caller to do any local configuration */
1294  return OP_REDRAW;
1295  }
1296 
1297  if (!menu->dialog)
1298  menu_check_recenter(menu);
1299 
1300  if (menu->redraw & REDRAW_STATUS)
1301  menu_redraw_status(menu);
1302 #ifdef USE_SIDEBAR
1303  if (menu->redraw & REDRAW_SIDEBAR)
1304  menu_redraw_sidebar(menu);
1305 #endif
1306  if (menu->redraw & REDRAW_INDEX)
1307  menu_redraw_index(menu);
1308  else if (menu->redraw & (REDRAW_MOTION | REDRAW_MOTION_RESYNC))
1309  menu_redraw_motion(menu);
1310  else if (menu->redraw == REDRAW_CURRENT)
1311  menu_redraw_current(menu);
1312 
1313  if (menu->dialog)
1314  menu_redraw_prompt(menu);
1315 
1316  return OP_NULL;
1317 }
#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:150
#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 1324 of file menu.c.

1325 {
1326  static int last_position = -1;
1327  int i = OP_NULL;
1328 
1329  if (menu->max && menu->is_mailbox_list)
1330  {
1331  if (last_position > (menu->max - 1))
1332  last_position = -1;
1333  else if (last_position >= 0)
1334  menu->current = last_position;
1335  }
1336 
1337  while (true)
1338  {
1339  if (OptMenuCaller)
1340  {
1341  OptMenuCaller = false;
1342  return OP_NULL;
1343  }
1344 
1345  /* Clear the tag prefix unless we just started it. Don't clear
1346  * the prefix on a timeout (i==-2), but do clear on an abort (i==-1) */
1347  if (menu->tagprefix && (i != OP_TAG_PREFIX) && (i != OP_TAG_PREFIX_COND) && (i != -2))
1348  menu->tagprefix = false;
1349 
1350  mutt_curs_set(0);
1351 
1352  if (menu_redraw(menu) == OP_REDRAW)
1353  return OP_REDRAW;
1354 
1355  /* give visual indication that the next command is a tag- command */
1356  if (menu->tagprefix)
1357  {
1358  mutt_window_mvaddstr(menu->messagewin, 0, 0, "tag-");
1360  }
1361 
1362  menu->oldcurrent = menu->current;
1363 
1364  /* move the cursor out of the way */
1365  if (C_ArrowCursor)
1366  mutt_window_move(menu->indexwin, menu->current - menu->top + menu->offset, 2);
1367  else if (C_BrailleFriendly)
1368  mutt_window_move(menu->indexwin, menu->current - menu->top + menu->offset, 0);
1369  else
1370  {
1371  mutt_window_move(menu->indexwin, menu->current - menu->top + menu->offset,
1372  menu->indexwin->cols - 1);
1373  }
1374 
1375  mutt_refresh();
1376 
1377  /* try to catch dialog keys before ops */
1378  if (menu->dialog && (menu_dialog_dokey(menu, &i) == 0))
1379  return i;
1380 
1381  i = km_dokey(menu->menu);
1382  if ((i == OP_TAG_PREFIX) || (i == OP_TAG_PREFIX_COND))
1383  {
1384  if (menu->tagprefix)
1385  {
1386  menu->tagprefix = false;
1388  continue;
1389  }
1390 
1391  if (menu->tagged)
1392  {
1393  menu->tagprefix = true;
1394  continue;
1395  }
1396  else if (i == OP_TAG_PREFIX)
1397  {
1398  mutt_error(_("No tagged entries"));
1399  i = -1;
1400  }
1401  else /* None tagged, OP_TAG_PREFIX_COND */
1402  {
1404  mutt_message(_("Nothing to do"));
1405  i = -1;
1406  }
1407  }
1408  else if (menu->tagged && C_AutoTag)
1409  menu->tagprefix = true;
1410 
1411  mutt_curs_set(1);
1412 
1413  if (SigWinch)
1414  {
1416  SigWinch = 0;
1417  clearok(stdscr, true); /* force complete redraw */
1418  }
1419 
1420  if (i < 0)
1421  {
1422  if (menu->tagprefix)
1424  continue;
1425  }
1426 
1427  if (!menu->dialog)
1428  mutt_clear_error();
1429 
1430  /* Convert menubar movement to scrolling */
1431  if (menu->dialog)
1432  i = menu_dialog_translate_op(i);
1433 
1434  switch (i)
1435  {
1436  case OP_NEXT_ENTRY:
1437  menu_next_entry(menu);
1438  break;
1439  case OP_PREV_ENTRY:
1440  menu_prev_entry(menu);
1441  break;
1442  case OP_HALF_DOWN:
1443  menu_half_down(menu);
1444  break;
1445  case OP_HALF_UP:
1446  menu_half_up(menu);
1447  break;
1448  case OP_NEXT_PAGE:
1449  menu_next_page(menu);
1450  break;
1451  case OP_PREV_PAGE:
1452  menu_prev_page(menu);
1453  break;
1454  case OP_NEXT_LINE:
1455  menu_next_line(menu);
1456  break;
1457  case OP_PREV_LINE:
1458  menu_prev_line(menu);
1459  break;
1460  case OP_FIRST_ENTRY:
1461  menu_first_entry(menu);
1462  break;
1463  case OP_LAST_ENTRY:
1464  menu_last_entry(menu);
1465  break;
1466  case OP_TOP_PAGE:
1467  menu_top_page(menu);
1468  break;
1469  case OP_MIDDLE_PAGE:
1470  menu_middle_page(menu);
1471  break;
1472  case OP_BOTTOM_PAGE:
1473  menu_bottom_page(menu);
1474  break;
1475  case OP_CURRENT_TOP:
1476  menu_current_top(menu);
1477  break;
1478  case OP_CURRENT_MIDDLE:
1479  menu_current_middle(menu);
1480  break;
1481  case OP_CURRENT_BOTTOM:
1482  menu_current_bottom(menu);
1483  break;
1484  case OP_SEARCH:
1485  case OP_SEARCH_REVERSE:
1486  case OP_SEARCH_NEXT:
1487  case OP_SEARCH_OPPOSITE:
1488  if (menu->menu_search && !menu->dialog) /* Searching dialogs won't work */
1489  {
1490  menu->oldcurrent = menu->current;
1491  menu->current = menu_search(menu, i);
1492  if (menu->current != -1)
1493  menu->redraw = REDRAW_MOTION;
1494  else
1495  menu->current = menu->oldcurrent;
1496  }
1497  else
1498  mutt_error(_("Search is not implemented for this menu"));
1499  break;
1500 
1501  case OP_JUMP:
1502  if (menu->dialog)
1503  mutt_error(_("Jumping is not implemented for dialogs"));
1504  else
1505  menu_jump(menu);
1506  break;
1507 
1508  case OP_ENTER_COMMAND:
1510  break;
1511 
1512  case OP_TAG:
1513  if (menu->menu_tag && !menu->dialog)
1514  {
1515  if (menu->tagprefix && !C_AutoTag)
1516  {
1517  for (i = 0; i < menu->max; i++)
1518  menu->tagged += menu->menu_tag(menu, i, 0);
1519  menu->redraw |= REDRAW_INDEX;
1520  }
1521  else if (menu->max)
1522  {
1523  int j = menu->menu_tag(menu, menu->current, -1);
1524  menu->tagged += j;
1525  if (j && C_Resolve && (menu->current < menu->max - 1))
1526  {
1527  menu->current++;
1528  menu->redraw |= REDRAW_MOTION_RESYNC;
1529  }
1530  else
1531  menu->redraw |= REDRAW_CURRENT;
1532  }
1533  else
1534  mutt_error(_("No entries"));
1535  }
1536  else
1537  mutt_error(_("Tagging is not supported"));
1538  break;
1539 
1540  case OP_SHELL_ESCAPE:
1542  break;
1543 
1544  case OP_WHAT_KEY:
1545  mutt_what_key();
1546  break;
1547 
1548  case OP_CHECK_STATS:
1549  mutt_check_stats();
1550  break;
1551 
1552  case OP_REDRAW:
1553  clearok(stdscr, true);
1554  menu->redraw = REDRAW_FULL;
1555  break;
1556 
1557  case OP_HELP:
1558  mutt_help(menu->menu);
1559  menu->redraw = REDRAW_FULL;
1560  break;
1561 
1562  case OP_NULL:
1563  km_error_key(menu->menu);
1564  break;
1565 
1566  case OP_END_COND:
1567  break;
1568 
1569  default:
1570  if (menu->is_mailbox_list)
1571  last_position = menu->current;
1572  return i;
1573  }
1574  }
1575  /* not reached */
1576 }
#define REDRAW_FULL
Redraw everything.
Definition: mutt_menu.h:47
int km_dokey(int menu)
Determine what a keypress should do.
Definition: keymap.c:569
#define mutt_message(...)
Definition: logging.h:87
int oldcurrent
for driver use only
Definition: mutt_menu.h:110
WHERE bool OptMenuCaller
(pseudo) tell menu to give caller a take
Definition: options.h:37
void mutt_window_clrtoeol(struct MuttWindow *win)
Clear to the end of the line.
Definition: mutt_window.c:81
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:1322
char ** dialog
dialog lines themselves
Definition: mutt_menu.h:104
void mutt_enter_command(void)
enter a neomutt command
Definition: commands.c:815
#define _(a)
Definition: message.h:28
WHERE bool C_BrailleFriendly
Config: Move the cursor to the beginning of the line.
Definition: globals.h:211
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:1033
void mutt_flush_macro_to_endcond(void)
Drop a macro from the input buffer.
Definition: curs_lib.c:724
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:69
void mutt_what_key(void)
Ask the user to press a key.
Definition: keymap.c:1406
void mutt_shell_escape(void)
invoke a command in a subshell
Definition: commands.c:787
WHERE SIG_ATOMIC_VOLATILE_T SigWinch
true after SIGWINCH is received
Definition: globals.h:92
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:141
#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:99
struct MuttWindow * indexwin
Definition: mutt_menu.h:95
int top
entry that is the top of the current page
Definition: mutt_menu.h:109
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:252
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:190
int tagged
number of tagged entries
Definition: mutt_menu.h:112
int mutt_window_move(struct MuttWindow *win, int row, int col)
Move the cursor in a Window.
Definition: mutt_window.c:162
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:138
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:130
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:93
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:42
#define mutt_error(...)
Definition: logging.h:88
struct MuttWindow * messagewin
Definition: mutt_menu.h:98
WHERE bool C_AutoTag
Config: Automatically apply actions to all tagged messages.
Definition: globals.h:208
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:202

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool mutt_menu_listener ( const struct ConfigSet cs,
struct HashElem he,
const char *  name,
enum ConfigEvent  ev 
)

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

Definition at line 1581 of file menu.c.

1583 {
1584  const struct ConfigDef *cdef = he->data;
1585  ConfigRedrawFlags flags = cdef->flags;
1586 
1587  if (flags == 0)
1588  return true;
1589 
1590  if (flags & R_INDEX)
1592  if (flags & R_PAGER)
1594  if (flags & R_PAGER_FLOW)
1595  {
1598  }
1599 
1600  if (flags & R_RESORT_SUB)
1601  OptSortSubthreads = true;
1602  if (flags & R_RESORT)
1603  OptNeedResort = true;
1604  if (flags & R_RESORT_INIT)
1605  OptResortInit = true;
1606  if (flags & R_TREE)
1607  OptRedrawTree = true;
1608 
1609  if (flags & R_REFLOW)
1611 #ifdef USE_SIDEBAR
1612  if (flags & R_SIDEBAR)
1614 #endif
1615  if (flags & R_MENU)
1617 
1618  return true;
1619 }
#define R_PAGER
Redraw the pager menu.
Definition: types.h:62
#define R_PAGER_FLOW
Reflow line_info and redraw the pager menu.
Definition: types.h:63
#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:40
Index panel (list of emails)
Definition: keymap.h:74
Config item definition.
Definition: set.h:161
#define R_RESORT
Resort the mailbox.
Definition: types.h:64
#define REDRAW_SIDEBAR
Redraw the sidebar.
Definition: mutt_menu.h:51
#define R_TREE
Redraw the thread tree.
Definition: types.h:67
Pager pager (email viewer)
Definition: keymap.h:75
void mutt_window_reflow(void)
Resize the Windows to fit the screen.
Definition: mutt_window.c:222
#define R_MENU
Redraw all menus.
Definition: types.h:70
#define R_RESORT_SUB
Resort subthreads.
Definition: types.h:65
#define R_REFLOW
Reflow window layout and full redraw.
Definition: types.h:68
intptr_t flags
Notification flags, see ConfigRedrawFlags.
Definition: set.h:165
WHERE bool OptRedrawTree
(pseudo) redraw the thread tree
Definition: options.h:47
WHERE bool OptResortInit
(pseudo) used to force the next resort to be from scratch
Definition: options.h:48
void * data
Definition: hash.h:46
uint16_t ConfigRedrawFlags
Flags for redraw/resort, e.g. R_INDEX.
Definition: types.h:59
#define R_RESORT_INIT
Resort from scratch.
Definition: types.h:66
WHERE bool OptSortSubthreads
(pseudo) used when $sort_aux changes
Definition: options.h:51
#define R_SIDEBAR
Redraw the sidebar.
Definition: types.h:69
#define R_INDEX
Redraw the index menu (MENU_MAIN)
Definition: types.h:61

+ 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 59 of file menu.c.

bool C_MenuMoveOff

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

Definition at line 60 of file menu.c.

bool C_MenuScroll

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

Definition at line 61 of file menu.c.

char* SearchBuffers[MENU_MAX]

Definition at line 63 of file menu.c.

size_t MenuStackCount = 0
static

Definition at line 66 of file menu.c.

size_t MenuStackLen = 0
static

Definition at line 67 of file menu.c.

struct Menu** MenuStack = NULL
static

Definition at line 68 of file menu.c.