NeoMutt  2018-07-16 +952-a2da0a
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 "menu.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_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 (int menu)
 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 (int 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, int 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 MenuContext
 Config: Number of lines of overlap when changing pages in the index. More...
 
bool MenuMoveOff
 Config: Allow the last menu item to move off the bottom of the screen. More...
 
bool 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->hdrs[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 }
Index: subject field (takes a pattern)
Definition: mutt_curses.h:159
The "current" mailbox.
Definition: context.h:36
The envelope/body of an email.
Definition: email.h:35
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:56
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:374
char * pattern
Definition: mutt_curses.h:182
Match the full address.
Definition: pattern.h:69
struct Email ** hdrs
Definition: mailbox.h:93
struct Mailbox * mailbox
Definition: context.h:50
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:55
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:51
int * v2r
mapping from virtual to real msgno
Definition: mailbox.h:95
struct ColorLineHead ColorIndexSubjectList
List of colours applied to the subject in the index.
Definition: color.c:58
struct ColorLineHead ColorIndexTagList
List of colours applied to tags in the index.
Definition: color.c:59
int index
the absolute (unsorted) message number
Definition: email.h:87
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:1837
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 (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 (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 (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 (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 (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 (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 (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 }
#define MUTT_TREE_ULCORNER
Definition: mutt.h:84
#define MUTT_TREE_MAX
Definition: mutt.h:96
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:663
#define ATTRSET
Definition: mutt_curses.h:228
#define MUTT_TREE_LTEE
Definition: mutt.h:85
Index: default colour (takes a pattern)
Definition: mutt_curses.h:155
#define MUTT_TREE_TTEE
Definition: mutt.h:93
#define MUTT_TREE_SPACE
Definition: mutt.h:88
Index: tree-drawing characters.
Definition: mutt_curses.h:129
#define MUTT_TREE_HLINE
Definition: mutt.h:86
#define MUTT_TREE_LLCORNER
Definition: mutt.h:83
#define MUTT_TREE_VLINE
Definition: mutt.h:87
int ColorDefs[MT_COLOR_MAX]
Array of all fixed colours, see enum ColorId.
Definition: color.c:51
#define MUTT_TREE_HIDDEN
Definition: mutt.h:91
#define SETCOLOR(X)
Definition: mutt_curses.h:220
#define MUTT_TREE_MISSING
Definition: mutt.h:95
bool CharsetIsUtf8
Is the user&#39;s current character set utf-8?
Definition: charset.c:62
#define MUTT_TREE_EQUALS
Definition: mutt.h:92
#define MUTT_TREE_STAR
Definition: mutt.h:90
#define MUTT_SPECIAL_INDEX
Definition: mutt.h:98
int index
the absolute (unsorted) message number
Definition: email.h:87
#define MUTT_TREE_BTEE
Definition: mutt.h:94
#define MUTT_TREE_RARROW
Definition: mutt.h:89
WHERE bool AsciiChars
Config: Use plain ASCII characters, when drawing email threads.
Definition: globals.h:200

+ 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: menu.h:79
void(* menu_make_entry)(char *buf, size_t buflen, struct Menu *menu, int line)
Format a item for a menu.
Definition: menu.h:96
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:742
int current
current entry
Definition: menu.h:61

+ 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 = 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:41
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:663
struct MuttWindow * indexwin
Definition: menu.h:69
WHERE bool ArrowCursor
Config: Use an arrow &#39;->&#39; instead of highlighting in the index.
Definition: globals.h:199
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:384
#define FREE(x)
Definition: memory.h:46

+ 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 (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 }
int redraw
when to redraw the screen
Definition: menu.h:63
#define NORMAL_COLOR
Definition: mutt_curses.h:235
WHERE bool Help
Config: Display a help line with common key bindings.
Definition: globals.h:222
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: menu.h:71
void mutt_window_reflow(void)
Resize the Windows to fit the screen.
Definition: mutt_window.c:222
struct MuttWindow * indexwin
Definition: menu.h:69
int pagelen
number of entries per screen
Definition: menu.h:66
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:220
int offset
row offset within the window to start the index
Definition: menu.h:65
Status bar.
Definition: mutt_curses.h:128
void mutt_show_error(void)
Show the user an error message.
Definition: curs_lib.c:484
char * help
quickref for the current menu
Definition: menu.h:59

+ 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[STRING];
391 
392  snprintf(buf, sizeof(buf), MUTT_MODEFMT, 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 }
int redraw
when to redraw the screen
Definition: menu.h:63
#define NORMAL_COLOR
Definition: mutt_curses.h:235
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: menu.h:70
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:220
char * title
the title of this menu
Definition: menu.h:58
#define STRING
Definition: string2.h:35
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 }
int redraw
when to redraw the screen
Definition: menu.h:63

+ 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[LONG_STRING];
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 (ArrowCursor)
439  {
440  addstr("->");
441  ATTRSET(attr);
442  addch(' ');
443  }
444  else
445  do_color = false;
446  }
447  else if (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 }
int redraw
when to redraw the screen
Definition: menu.h:63
#define NORMAL_COLOR
Definition: mutt_curses.h:235
#define LONG_STRING
Definition: string2.h:36
#define ATTRSET
Definition: mutt_curses.h:228
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:69
struct MuttWindow * indexwin
Definition: menu.h:69
int top
entry that is the top of the current page
Definition: menu.h:84
int pagelen
number of entries per screen
Definition: menu.h:66
int mutt_window_move(struct MuttWindow *win, int row, int col)
Move the cursor in a Window.
Definition: mutt_window.c:162
WHERE bool ArrowCursor
Config: Use an arrow &#39;->&#39; instead of highlighting in the index.
Definition: globals.h:199
int(* menu_color)(int line)
Calculate the colour for a line of the menu.
Definition: menu.h:120
#define SETCOLOR(X)
Definition: mutt_curses.h:220
int offset
row offset within the window to start the index
Definition: menu.h:65
Selected item in list.
Definition: mutt_curses.h:127
int current
current entry
Definition: menu.h:61

+ 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[LONG_STRING];
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 (ArrowCursor)
485  {
486  /* clear the pointer */
487  addstr(" ");
488 
489  if (menu->redraw & REDRAW_MOTION_RESYNCH)
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 redraw
when to redraw the screen
Definition: menu.h:63
int oldcurrent
for driver use only
Definition: menu.h:85
#define NORMAL_COLOR
Definition: mutt_curses.h:235
char ** dialog
dialog lines themselves
Definition: menu.h:79
#define LONG_STRING
Definition: string2.h:36
#define ATTRSET
Definition: mutt_curses.h:228
struct MuttWindow * indexwin
Definition: menu.h:69
int top
entry that is the top of the current page
Definition: menu.h:84
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
WHERE bool ArrowCursor
Config: Use an arrow &#39;->&#39; instead of highlighting in the index.
Definition: globals.h:199
int(* menu_color)(int line)
Calculate the colour for a line of the menu.
Definition: menu.h:120
#define SETCOLOR(X)
Definition: mutt_curses.h:220
int offset
row offset within the window to start the index
Definition: menu.h:65
Selected item in list.
Definition: mutt_curses.h:127
int current
current entry
Definition: menu.h:61

+ 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[LONG_STRING];
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 (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 }
int redraw
when to redraw the screen
Definition: menu.h:63
#define NORMAL_COLOR
Definition: mutt_curses.h:235
#define LONG_STRING
Definition: string2.h:36
#define ATTRSET
Definition: mutt_curses.h:228
struct MuttWindow * indexwin
Definition: menu.h:69
int top
entry that is the top of the current page
Definition: menu.h:84
int mutt_window_move(struct MuttWindow *win, int row, int col)
Move the cursor in a Window.
Definition: mutt_window.c:162
WHERE bool ArrowCursor
Config: Use an arrow &#39;->&#39; instead of highlighting in the index.
Definition: globals.h:199
int(* menu_color)(int line)
Calculate the colour for a line of the menu.
Definition: menu.h:120
#define SETCOLOR(X)
Definition: mutt_curses.h:220
int offset
row offset within the window to start the index
Definition: menu.h:65
Selected item in list.
Definition: mutt_curses.h:127
int current
current entry
Definition: menu.h:61

+ 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: menu.h:80
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: menu.h:79
void mutt_sleep(short s)
Sleep for a while.
Definition: muttlib.c:1478
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: menu.h:72
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(MenuContext, menu->pagelen / 2);
577  int old_top = menu->top;
578 
579  if (!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 (MenuScroll || (menu->pagelen <= 0) || (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 (!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 }
int redraw
when to redraw the screen
Definition: menu.h:63
#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: menu.h:84
int pagelen
number of entries per screen
Definition: menu.h:66
int max
the number of entries in the menu
Definition: menu.h:62
int current
current entry
Definition: menu.h:61

+ 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[SHORT_STRING];
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 }
#define SHORT_STRING
Definition: string2.h:34
int mutt_str_atoi(const char *str, int *dst)
Convert ASCII string to an integer.
Definition: string.c:262
int redraw
when to redraw the screen
Definition: menu.h:63
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
int LastKey
contains the last key the user pressed
Definition: keymap.c:144
#define mutt_get_field(A, B, C, D)
Definition: curs_lib.h:78
int max
the number of entries in the menu
Definition: menu.h:62
#define mutt_error(...)
Definition: logging.h:88
int current
current entry
Definition: menu.h:61

+ 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(MenuContext, menu->pagelen / 2);
660 
661  if (menu->top + 1 < menu->max - c &&
662  (MenuMoveOff || (menu->max > menu->pagelen && menu->top < menu->max - menu->pagelen)))
663  {
664  menu->top++;
665  if (menu->current < menu->top + c && menu->current < menu->max - 1)
666  menu->current++;
667  menu->redraw = REDRAW_INDEX;
668  }
669  else
670  mutt_error(_("You cannot scroll down farther"));
671  }
672  else
673  mutt_error(_("No entries"));
674 }
int redraw
when to redraw the screen
Definition: menu.h:63
#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: menu.h:84
int pagelen
number of entries per screen
Definition: menu.h:66
int max
the number of entries in the menu
Definition: menu.h:62
#define mutt_error(...)
Definition: logging.h:88
int current
current entry
Definition: menu.h:61

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

681 {
682  if (menu->top > 0)
683  {
684  int c = MIN(MenuContext, menu->pagelen / 2);
685 
686  menu->top--;
687  if (menu->current >= menu->top + menu->pagelen - c && menu->current > 1)
688  menu->current--;
689  menu->redraw = REDRAW_INDEX;
690  }
691  else
692  mutt_error(_("You cannot scroll up farther"));
693 }
int redraw
when to redraw the screen
Definition: menu.h:63
#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: menu.h:84
int pagelen
number of entries per screen
Definition: menu.h:66
#define mutt_error(...)
Definition: logging.h:88
int current
current entry
Definition: menu.h:61

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

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

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

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

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

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

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

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

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

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

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

790 {
791  if (menu->current == menu->top)
792  return;
793 
794  menu->current = menu->top;
795  menu->redraw = REDRAW_MOTION;
796 }
int redraw
when to redraw the screen
Definition: menu.h:63
int top
entry that is the top of the current page
Definition: menu.h:84
int current
current entry
Definition: menu.h:61

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

803 {
804  if (menu->max)
805  {
806  menu->current = menu->top + menu->pagelen - 1;
807  if (menu->current > menu->max - 1)
808  menu->current = menu->max - 1;
809  menu->redraw = REDRAW_MOTION;
810  }
811  else
812  mutt_error(_("No entries"));
813 }
int redraw
when to redraw the screen
Definition: menu.h:63
#define _(a)
Definition: message.h:28
int top
entry that is the top of the current page
Definition: menu.h:84
int pagelen
number of entries per screen
Definition: menu.h:66
int max
the number of entries in the menu
Definition: menu.h:62
#define mutt_error(...)
Definition: logging.h:88
int current
current entry
Definition: menu.h:61

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

820 {
821  if (menu->max)
822  {
823  int i = menu->top + menu->pagelen;
824  if (i > menu->max - 1)
825  i = menu->max - 1;
826  menu->current = menu->top + (i - menu->top) / 2;
827  menu->redraw = REDRAW_MOTION;
828  }
829  else
830  mutt_error(_("No entries"));
831 }
int redraw
when to redraw the screen
Definition: menu.h:63
#define _(a)
Definition: message.h:28
int top
entry that is the top of the current page
Definition: menu.h:84
int pagelen
number of entries per screen
Definition: menu.h:66
int max
the number of entries in the menu
Definition: menu.h:62
#define mutt_error(...)
Definition: logging.h:88
int current
current entry
Definition: menu.h:61

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

838 {
839  if (menu->max)
840  {
841  menu->current = 0;
842  menu->redraw = REDRAW_MOTION;
843  }
844  else
845  mutt_error(_("No entries"));
846 }
int redraw
when to redraw the screen
Definition: menu.h:63
#define _(a)
Definition: message.h:28
int max
the number of entries in the menu
Definition: menu.h:62
#define mutt_error(...)
Definition: logging.h:88
int current
current entry
Definition: menu.h:61

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

853 {
854  if (menu->max)
855  {
856  menu->current = menu->max - 1;
857  menu->redraw = REDRAW_MOTION;
858  }
859  else
860  mutt_error(_("No entries"));
861 }
int redraw
when to redraw the screen
Definition: menu.h:63
#define _(a)
Definition: message.h:28
int max
the number of entries in the menu
Definition: menu.h:62
#define mutt_error(...)
Definition: logging.h:88
int current
current entry
Definition: menu.h:61

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

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

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

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

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

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

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

917 {
918  if (menu->current < menu->max - 1)
919  {
920  menu->current++;
921  menu->redraw = REDRAW_MOTION;
922  }
923  else
924  mutt_error(_("You are on the last entry"));
925 }
int redraw
when to redraw the screen
Definition: menu.h:63
#define _(a)
Definition: message.h:28
int max
the number of entries in the menu
Definition: menu.h:62
#define mutt_error(...)
Definition: logging.h:88
int current
current entry
Definition: menu.h:61

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

932 {
933  if (menu->current)
934  {
935  menu->current--;
936  menu->redraw = REDRAW_MOTION;
937  }
938  else
939  mutt_error(_("You are on the first entry"));
940 }
int redraw
when to redraw the screen
Definition: menu.h:63
#define _(a)
Definition: message.h:28
#define mutt_error(...)
Definition: logging.h:88
int current
current entry
Definition: menu.h:61

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

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

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

954 {
955  char buf[LONG_STRING];
956 
957  menu_make_entry(buf, sizeof(buf), menu, line);
958  return regexec(rx, buf, 0, NULL, 0);
959 }
#define LONG_STRING
Definition: string2.h:36
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 964 of file menu.c.

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

+ Here is the caller graph for this function:

struct Menu* mutt_menu_new ( int  menu)

Create a new Menu.

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

Definition at line 975 of file menu.c.

976 {
977  struct Menu *p = mutt_mem_calloc(1, sizeof(struct Menu));
978 
979  if ((menu < 0) || (menu >= MENU_MAX))
980  menu = MENU_GENERIC;
981 
982  p->menu = menu;
983  p->current = 0;
984  p->top = 0;
985  p->offset = 0;
986  p->redraw = REDRAW_FULL;
990  p->helpwin = MuttHelpWindow;
994 
995  return p;
996 }
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:51
int redraw
when to redraw the screen
Definition: menu.h:63
struct MuttWindow * MuttStatusWindow
Status Window.
Definition: mutt_window.c:40
GUI selectable list of items.
Definition: menu.h:56
Generic selection list.
Definition: keymap.h:72
struct MuttWindow * MuttHelpWindow
Help Window.
Definition: mutt_window.c:38
int menu
menu definition for keymap entries.
Definition: menu.h:64
struct MuttWindow * helpwin
Definition: menu.h:71
struct MuttWindow * statuswin
Definition: menu.h:70
struct MuttWindow * MuttIndexWindow
Index Window.
Definition: mutt_window.c:39
struct MuttWindow * indexwin
Definition: menu.h:69
int top
entry that is the top of the current page
Definition: menu.h:84
int pagelen
number of entries per screen
Definition: menu.h:66
int(* menu_color)(int line)
Calculate the colour for a line of the menu.
Definition: menu.h:120
int(* menu_search)(struct Menu *menu, regex_t *rx, int line)
Search a menu for a item matching a regex.
Definition: menu.h:105
int offset
row offset within the window to start the index
Definition: menu.h:65
struct MuttWindow * messagewin
Definition: menu.h:72
struct MuttWindow * MuttMessageWindow
Message Window.
Definition: mutt_window.c:41
int current
current entry
Definition: menu.h:61

+ 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
pMenu to destroy

Definition at line 1002 of file menu.c.

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

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

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

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

1031 {
1033  {
1034  MenuStackLen += 5;
1035  mutt_mem_realloc(&MenuStack, MenuStackLen * sizeof(struct Menu *));
1036  }
1037 
1039  CurrentMenu = menu->menu;
1040 }
GUI selectable list of items.
Definition: menu.h:56
int menu
menu definition for keymap entries.
Definition: menu.h:64
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:93

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

1049 {
1050  struct Menu *prev_menu = NULL;
1051 
1052  if (!MenuStackCount || (MenuStack[MenuStackCount - 1] != menu))
1053  {
1054  mutt_debug(1, "called with inactive menu\n");
1055  return;
1056  }
1057 
1058  MenuStackCount--;
1059  prev_menu = get_current_menu();
1060  if (prev_menu)
1061  {
1062  CurrentMenu = prev_menu->menu;
1063  prev_menu->redraw = REDRAW_FULL;
1064  }
1065  else
1066  {
1068  }
1069 }
int redraw
when to redraw the screen
Definition: menu.h:63
GUI selectable list of items.
Definition: menu.h:56
int menu
menu definition for keymap entries.
Definition: menu.h:64
WHERE int CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: globals.h:93
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
Index panel (list of emails)
Definition: keymap.h:73

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mutt_menu_set_current_redraw ( int  redraw)

Set redraw flags on the current menu.

Parameters
redrawFlags to set, e.g. REDRAW_INDEX

Definition at line 1075 of file menu.c.

1076 {
1077  struct Menu *current_menu = get_current_menu();
1078  if (current_menu)
1079  current_menu->redraw |= redraw;
1080 }
int redraw
when to redraw the screen
Definition: menu.h:63
GUI selectable list of items.
Definition: menu.h:56

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

1086 {
1087  struct Menu *current_menu = get_current_menu();
1088  if (current_menu)
1089  current_menu->redraw = REDRAW_FULL;
1090 }
int redraw
when to redraw the screen
Definition: menu.h:63
GUI selectable list of items.
Definition: menu.h:56

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mutt_menu_set_redraw ( int  menu_type,
int  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 1099 of file menu.c.

1100 {
1101  if (CurrentMenu == menu_type)
1103 }
int redraw
when to redraw the screen
Definition: menu.h:63
WHERE int CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: globals.h:93

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

1112 {
1113  if (CurrentMenu == menu_type)
1115 }
WHERE int CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: globals.h:93

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

1121 {
1122  struct Menu *current_menu = get_current_menu();
1123  if (current_menu)
1124  {
1125  if (menu_redraw(current_menu) == OP_REDRAW)
1126  {
1127  /* On a REDRAW_FULL with a non-customized redraw, menu_redraw()
1128  * will return OP_REDRAW to give the calling menu-loop a chance to
1129  * customize output.
1130  */
1131  menu_redraw(current_menu);
1132  }
1133  }
1134 }
GUI selectable list of items.
Definition: menu.h:56

+ 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 r = 0, wrap = 0;
1146  int search_dir;
1147  regex_t re;
1148  char buf[SHORT_STRING];
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  r = REGCOMP(&re, search_buf, REG_NOSUB | flags);
1180  }
1181 
1182  if (r != 0)
1183  {
1184  regerror(r, &re, buf, sizeof(buf));
1185  mutt_error("%s", buf);
1186  return -1;
1187  }
1188 
1189  r = menu->current + search_dir;
1190 search_next:
1191  if (wrap)
1192  mutt_message(_("Search wrapped to top"));
1193  while (r >= 0 && r < menu->max)
1194  {
1195  if (menu->menu_search(menu, &re, r) == 0)
1196  {
1197  regfree(&re);
1198  return r;
1199  }
1200 
1201  r += search_dir;
1202  }
1203 
1204  if (WrapSearch && wrap++ == 0)
1205  {
1206  r = 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 SHORT_STRING
Definition: string2.h:34
#define MUTT_CLEAR
clear input if printable character is pressed
Definition: mutt.h:63
#define mutt_message(...)
Definition: logging.h:87
#define _(a)
Definition: message.h:28
int menu
menu definition for keymap entries.
Definition: menu.h:64
WHERE bool WrapSearch
Config: Wrap around when the search hits the end.
Definition: globals.h:263
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:742
int search_dir
direction of search
Definition: menu.h:86
#define mutt_get_field(A, B, C, D)
Definition: curs_lib.h:78
void mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:460
int max
the number of entries in the menu
Definition: menu.h:62
int(* menu_search)(struct Menu *menu, regex_t *rx, int line)
Search a menu for a item matching a regex.
Definition: menu.h:105
#define mutt_error(...)
Definition: logging.h:88
int current
current entry
Definition: menu.h:61
bool mutt_mb_is_lower(const char *s)
Does a multi-byte string contain only lowercase characters?
Definition: mbyte.c:346
#define REGCOMP(X, Y, Z)
Compile a regular expression.
Definition: regex3.h:52

+ 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 occured 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: menu.h:81
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_RESYNCH))
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 }
int redraw
when to redraw the screen
Definition: menu.h:63
char ** dialog
dialog lines themselves
Definition: menu.h:79
void(* menu_custom_redraw)(struct Menu *menu)
Redraw the menu.
Definition: menu.h:125

+ 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  */
1348  if (menu->tagprefix && i != OP_TAG_PREFIX && i != OP_TAG_PREFIX_COND && i != -2)
1349  menu->tagprefix = false;
1350 
1351  mutt_curs_set(0);
1352 
1353  if (menu_redraw(menu) == OP_REDRAW)
1354  return OP_REDRAW;
1355 
1356  /* give visual indication that the next command is a tag- command */
1357  if (menu->tagprefix)
1358  {
1359  mutt_window_mvaddstr(menu->messagewin, 0, 0, "tag-");
1361  }
1362 
1363  menu->oldcurrent = menu->current;
1364 
1365  /* move the cursor out of the way */
1366  if (ArrowCursor)
1367  mutt_window_move(menu->indexwin, menu->current - menu->top + menu->offset, 2);
1368  else if (BrailleFriendly)
1369  mutt_window_move(menu->indexwin, menu->current - menu->top + menu->offset, 0);
1370  else
1371  {
1372  mutt_window_move(menu->indexwin, menu->current - menu->top + menu->offset,
1373  menu->indexwin->cols - 1);
1374  }
1375 
1376  mutt_refresh();
1377 
1378  /* try to catch dialog keys before ops */
1379  if (menu->dialog && menu_dialog_dokey(menu, &i) == 0)
1380  return i;
1381 
1382  i = km_dokey(menu->menu);
1383  if (i == OP_TAG_PREFIX || i == OP_TAG_PREFIX_COND)
1384  {
1385  if (menu->tagprefix)
1386  {
1387  menu->tagprefix = false;
1389  continue;
1390  }
1391 
1392  if (menu->tagged)
1393  {
1394  menu->tagprefix = true;
1395  continue;
1396  }
1397  else if (i == OP_TAG_PREFIX)
1398  {
1399  mutt_error(_("No tagged entries"));
1400  i = -1;
1401  }
1402  else /* None tagged, OP_TAG_PREFIX_COND */
1403  {
1405  mutt_message(_("Nothing to do"));
1406  i = -1;
1407  }
1408  }
1409  else if (menu->tagged && AutoTag)
1410  menu->tagprefix = true;
1411 
1412  mutt_curs_set(1);
1413 
1414  if (SigWinch)
1415  {
1417  SigWinch = 0;
1418  clearok(stdscr, true); /* force complete redraw */
1419  }
1420 
1421  if (i < 0)
1422  {
1423  if (menu->tagprefix)
1425  continue;
1426  }
1427 
1428  if (!menu->dialog)
1429  mutt_clear_error();
1430 
1431  /* Convert menubar movement to scrolling */
1432  if (menu->dialog)
1433  i = menu_dialog_translate_op(i);
1434 
1435  switch (i)
1436  {
1437  case OP_NEXT_ENTRY:
1438  menu_next_entry(menu);
1439  break;
1440  case OP_PREV_ENTRY:
1441  menu_prev_entry(menu);
1442  break;
1443  case OP_HALF_DOWN:
1444  menu_half_down(menu);
1445  break;
1446  case OP_HALF_UP:
1447  menu_half_up(menu);
1448  break;
1449  case OP_NEXT_PAGE:
1450  menu_next_page(menu);
1451  break;
1452  case OP_PREV_PAGE:
1453  menu_prev_page(menu);
1454  break;
1455  case OP_NEXT_LINE:
1456  menu_next_line(menu);
1457  break;
1458  case OP_PREV_LINE:
1459  menu_prev_line(menu);
1460  break;
1461  case OP_FIRST_ENTRY:
1462  menu_first_entry(menu);
1463  break;
1464  case OP_LAST_ENTRY:
1465  menu_last_entry(menu);
1466  break;
1467  case OP_TOP_PAGE:
1468  menu_top_page(menu);
1469  break;
1470  case OP_MIDDLE_PAGE:
1471  menu_middle_page(menu);
1472  break;
1473  case OP_BOTTOM_PAGE:
1474  menu_bottom_page(menu);
1475  break;
1476  case OP_CURRENT_TOP:
1477  menu_current_top(menu);
1478  break;
1479  case OP_CURRENT_MIDDLE:
1480  menu_current_middle(menu);
1481  break;
1482  case OP_CURRENT_BOTTOM:
1483  menu_current_bottom(menu);
1484  break;
1485  case OP_SEARCH:
1486  case OP_SEARCH_REVERSE:
1487  case OP_SEARCH_NEXT:
1488  case OP_SEARCH_OPPOSITE:
1489  if (menu->menu_search && !menu->dialog) /* Searching dialogs won't work */
1490  {
1491  menu->oldcurrent = menu->current;
1492  menu->current = menu_search(menu, i);
1493  if (menu->current != -1)
1494  menu->redraw = REDRAW_MOTION;
1495  else
1496  menu->current = menu->oldcurrent;
1497  }
1498  else
1499  mutt_error(_("Search is not implemented for this menu"));
1500  break;
1501 
1502  case OP_JUMP:
1503  if (menu->dialog)
1504  mutt_error(_("Jumping is not implemented for dialogs"));
1505  else
1506  menu_jump(menu);
1507  break;
1508 
1509  case OP_ENTER_COMMAND:
1511  break;
1512 
1513  case OP_TAG:
1514  if (menu->menu_tag && !menu->dialog)
1515  {
1516  if (menu->tagprefix && !AutoTag)
1517  {
1518  for (i = 0; i < menu->max; i++)
1519  menu->tagged += menu->menu_tag(menu, i, 0);
1520  menu->redraw |= REDRAW_INDEX;
1521  }
1522  else if (menu->max)
1523  {
1524  int j = menu->menu_tag(menu, menu->current, -1);
1525  menu->tagged += j;
1526  if (j && Resolve && menu->current < menu->max - 1)
1527  {
1528  menu->current++;
1529  menu->redraw |= REDRAW_MOTION_RESYNCH;
1530  }
1531  else
1532  menu->redraw |= REDRAW_CURRENT;
1533  }
1534  else
1535  mutt_error(_("No entries"));
1536  }
1537  else
1538  mutt_error(_("Tagging is not supported"));
1539  break;
1540 
1541  case OP_SHELL_ESCAPE:
1543  break;
1544 
1545  case OP_WHAT_KEY:
1546  mutt_what_key();
1547  break;
1548 
1549  case OP_CHECK_STATS:
1550  mutt_check_stats();
1551  break;
1552 
1553  case OP_REDRAW:
1554  clearok(stdscr, true);
1555  menu->redraw = REDRAW_FULL;
1556  break;
1557 
1558  case OP_HELP:
1559  mutt_help(menu->menu);
1560  menu->redraw = REDRAW_FULL;
1561  break;
1562 
1563  case OP_NULL:
1564  km_error_key(menu->menu);
1565  break;
1566 
1567  case OP_END_COND:
1568  break;
1569 
1570  default:
1571  if (menu->is_mailbox_list)
1572  last_position = menu->current;
1573  return i;
1574  }
1575  }
1576  /* not reached */
1577 }
int redraw
when to redraw the screen
Definition: menu.h:63
int km_dokey(int menu)
Determine what a keypress should do.
Definition: keymap.c:572
#define mutt_message(...)
Definition: logging.h:87
int oldcurrent
for driver use only
Definition: menu.h:85
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:1260
char ** dialog
dialog lines themselves
Definition: menu.h:79
void mutt_enter_command(void)
enter a neomutt command
Definition: commands.c:731
#define _(a)
Definition: message.h:28
WHERE bool BrailleFriendly
Config: Move the cursor to the beginning of the line.
Definition: globals.h:207
int menu
menu definition for keymap entries.
Definition: menu.h:64
void km_error_key(int menu)
Handle an unbound key sequence.
Definition: keymap.c:1037
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:1410
void mutt_shell_escape(void)
invoke a command in a subshell
Definition: commands.c:703
WHERE SIG_ATOMIC_VOLATILE_T SigWinch
true after SIGWINCH is received
Definition: globals.h:91
WHERE bool Resolve
Config: Move to the next email whenever a command modifies an email.
Definition: globals.h:248
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:141
void mutt_refresh(void)
Force a refresh of the screen.
Definition: curs_lib.c:99
struct MuttWindow * indexwin
Definition: menu.h:69
int top
entry that is the top of the current page
Definition: menu.h:84
bool tagprefix
Definition: menu.h:67
bool is_mailbox_list
Definition: menu.h:68
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: menu.h:87
int mutt_window_move(struct MuttWindow *win, int row, int col)
Move the cursor in a Window.
Definition: mutt_window.c:162
WHERE bool ArrowCursor
Config: Use an arrow &#39;->&#39; instead of highlighting in the index.
Definition: globals.h:199
void mutt_help(int menu)
Display the help menu.
Definition: help.c:438
int max
the number of entries in the menu
Definition: menu.h:62
int(* menu_tag)(struct Menu *menu, int sel, int act)
Tag some menu items.
Definition: menu.h:113
int(* menu_search)(struct Menu *menu, regex_t *rx, int line)
Search a menu for a item matching a regex.
Definition: menu.h:105
int offset
row offset within the window to start the index
Definition: menu.h:65
#define mutt_curs_set(x)
Definition: mutt_curses.h:93
#define mutt_error(...)
Definition: logging.h:88
struct MuttWindow * messagewin
Definition: menu.h:72
WHERE bool AutoTag
Config: Automatically apply actions to all tagged messages.
Definition: globals.h:204
int current
current entry
Definition: menu.h:61

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

1584 {
1585  const struct ConfigDef *cdef = he->data;
1586  int flags = cdef->flags;
1587 
1588  if (flags == 0)
1589  return true;
1590 
1591  if (flags & R_INDEX)
1593  if (flags & R_PAGER)
1595  if (flags & R_PAGER_FLOW)
1596  {
1599  }
1600 
1601  if (flags & R_RESORT_SUB)
1602  OptSortSubthreads = true;
1603  if (flags & R_RESORT)
1604  OptNeedResort = true;
1605  if (flags & R_RESORT_INIT)
1606  OptResortInit = true;
1607  if (flags & R_TREE)
1608  OptRedrawTree = true;
1609 
1610  if (flags & R_REFLOW)
1612 #ifdef USE_SIDEBAR
1613  if (flags & R_SIDEBAR)
1615 #endif
1616  if (flags & R_MENU)
1618 
1619  return true;
1620 }
#define R_PAGER
redraw the pager menu
Definition: types.h:60
#define R_PAGER_FLOW
reflow line_info and redraw the pager menu
Definition: types.h:61
WHERE bool OptNeedResort
(pseudo) used to force a re-sort
Definition: options.h:40
Config item definition.
Definition: set.h:160
#define R_RESORT
resort the mailbox
Definition: types.h:62
#define R_TREE
redraw the thread tree
Definition: types.h:65
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:68
#define R_RESORT_SUB
resort subthreads
Definition: types.h:63
#define R_REFLOW
reflow window layout and full redraw
Definition: types.h:66
intptr_t flags
Notification flags, e.g.
Definition: set.h:164
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
#define R_RESORT_INIT
resort from scratch
Definition: types.h:64
WHERE bool OptSortSubthreads
(pseudo) used when $sort_aux changes
Definition: options.h:51
#define R_SIDEBAR
redraw the sidebar
Definition: types.h:67
Pager pager (email viewer)
Definition: keymap.h:74
Index panel (list of emails)
Definition: keymap.h:73
#define R_INDEX
redraw the index menu (MENU_MAIN)
Definition: types.h:59

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

short MenuContext

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

Definition at line 59 of file menu.c.

bool MenuMoveOff

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

allow menu to scroll past last entry

Definition at line 60 of file menu.c.

bool MenuScroll

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

scroll menu instead of implicit next-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.