NeoMutt  2020-06-26-89-g172cd3
Teaching an old dog new tricks
DOXYGEN
menu.c
Go to the documentation of this file.
1 
29 #include "config.h"
30 #include <stdbool.h>
31 #include <stdio.h>
32 #include <string.h>
33 #include <wchar.h>
34 #include "mutt/lib.h"
35 #include "config/lib.h"
36 #include "email/lib.h"
37 #include "core/lib.h"
38 #include "gui/lib.h"
39 #include "mutt.h"
40 #include "commands.h"
41 #include "context.h"
42 #include "keymap.h"
43 #include "mutt_globals.h"
44 #include "mutt_logging.h"
45 #include "mutt_menu.h"
46 #include "muttlib.h"
47 #include "opcodes.h"
48 #include "options.h"
49 #include "pattern.h"
50 #include "protos.h"
51 #ifdef USE_SIDEBAR
52 #include "sidebar/lib.h"
53 #endif
54 
55 /* These Config Variables are only used in menu.c */
59 
61 
62 /* These are used to track the active menus, for redraw operations. */
63 static size_t MenuStackCount = 0;
64 static size_t MenuStackLen = 0;
65 static struct Menu **MenuStack = NULL;
66 
67 #define DIRECTION ((neg * 2) + 1)
68 
69 #define MUTT_SEARCH_UP 1
70 #define MUTT_SEARCH_DOWN 2
71 
81 static int get_color(int index, unsigned char *s)
82 {
83  struct ColorLineList *color = NULL;
84  struct ColorLine *np = NULL;
85  struct Email *e = mutt_get_virt_email(Context->mailbox, index);
86  int type = *s;
87 
88  switch (type)
89  {
91  color = &Colors->index_author_list;
92  break;
94  color = &Colors->index_flags_list;
95  break;
97  color = &Colors->index_subject_list;
98  break;
99  case MT_COLOR_INDEX_TAG:
100  STAILQ_FOREACH(np, &Colors->index_tag_list, entries)
101  {
102  if (mutt_strn_equal((const char *) (s + 1), np->pattern, strlen(np->pattern)))
103  return np->pair;
104  const char *transform = mutt_hash_find(TagTransforms, np->pattern);
105  if (transform && mutt_strn_equal((const char *) (s + 1), transform, strlen(transform)))
106  {
107  return np->pair;
108  }
109  }
110  return 0;
111  default:
112  return Colors->defs[type];
113  }
114 
115  STAILQ_FOREACH(np, color, entries)
116  {
119  return np->pair;
120  }
121 
122  return 0;
123 }
124 
132 static void print_enriched_string(int index, int attr, unsigned char *s, bool do_color)
133 {
134  wchar_t wc;
135  size_t k;
136  size_t n = mutt_str_len((char *) s);
137  mbstate_t mbstate;
138 
139  memset(&mbstate, 0, sizeof(mbstate));
140  while (*s)
141  {
142  if (*s < MUTT_TREE_MAX)
143  {
144  if (do_color)
145 #if defined(HAVE_COLOR) && defined(HAVE_USE_DEFAULT_COLORS)
146  /* Combining tree fg color and another bg color requires
147  * having use_default_colors, because the other bg color
148  * may be undefined. */
150 #else
152 #endif
153 
154  while (*s && (*s < MUTT_TREE_MAX))
155  {
156  switch (*s)
157  {
158  case MUTT_TREE_LLCORNER:
159  if (C_AsciiChars)
160  mutt_window_addch('`');
161 #ifdef WACS_LLCORNER
162  else
163  add_wch(WACS_LLCORNER);
164 #else
165  else if (CharsetIsUtf8)
166  mutt_window_addstr("\342\224\224"); /* WACS_LLCORNER */
167  else
168  mutt_window_addch(ACS_LLCORNER);
169 #endif
170  break;
171  case MUTT_TREE_ULCORNER:
172  if (C_AsciiChars)
173  mutt_window_addch(',');
174 #ifdef WACS_ULCORNER
175  else
176  add_wch(WACS_ULCORNER);
177 #else
178  else if (CharsetIsUtf8)
179  mutt_window_addstr("\342\224\214"); /* WACS_ULCORNER */
180  else
181  mutt_window_addch(ACS_ULCORNER);
182 #endif
183  break;
184  case MUTT_TREE_LTEE:
185  if (C_AsciiChars)
186  mutt_window_addch('|');
187 #ifdef WACS_LTEE
188  else
189  add_wch(WACS_LTEE);
190 #else
191  else if (CharsetIsUtf8)
192  mutt_window_addstr("\342\224\234"); /* WACS_LTEE */
193  else
194  mutt_window_addch(ACS_LTEE);
195 #endif
196  break;
197  case MUTT_TREE_HLINE:
198  if (C_AsciiChars)
199  mutt_window_addch('-');
200 #ifdef WACS_HLINE
201  else
202  add_wch(WACS_HLINE);
203 #else
204  else if (CharsetIsUtf8)
205  mutt_window_addstr("\342\224\200"); /* WACS_HLINE */
206  else
207  mutt_window_addch(ACS_HLINE);
208 #endif
209  break;
210  case MUTT_TREE_VLINE:
211  if (C_AsciiChars)
212  mutt_window_addch('|');
213 #ifdef WACS_VLINE
214  else
215  add_wch(WACS_VLINE);
216 #else
217  else if (CharsetIsUtf8)
218  mutt_window_addstr("\342\224\202"); /* WACS_VLINE */
219  else
220  mutt_window_addch(ACS_VLINE);
221 #endif
222  break;
223  case MUTT_TREE_TTEE:
224  if (C_AsciiChars)
225  mutt_window_addch('-');
226 #ifdef WACS_TTEE
227  else
228  add_wch(WACS_TTEE);
229 #else
230  else if (CharsetIsUtf8)
231  mutt_window_addstr("\342\224\254"); /* WACS_TTEE */
232  else
233  mutt_window_addch(ACS_TTEE);
234 #endif
235  break;
236  case MUTT_TREE_BTEE:
237  if (C_AsciiChars)
238  mutt_window_addch('-');
239 #ifdef WACS_BTEE
240  else
241  add_wch(WACS_BTEE);
242 #else
243  else if (CharsetIsUtf8)
244  mutt_window_addstr("\342\224\264"); /* WACS_BTEE */
245  else
246  mutt_window_addch(ACS_BTEE);
247 #endif
248  break;
249  case MUTT_TREE_SPACE:
250  mutt_window_addch(' ');
251  break;
252  case MUTT_TREE_RARROW:
253  mutt_window_addch('>');
254  break;
255  case MUTT_TREE_STAR:
256  mutt_window_addch('*'); /* fake thread indicator */
257  break;
258  case MUTT_TREE_HIDDEN:
259  mutt_window_addch('&');
260  break;
261  case MUTT_TREE_EQUALS:
262  mutt_window_addch('=');
263  break;
264  case MUTT_TREE_MISSING:
265  mutt_window_addch('?');
266  break;
267  }
268  s++;
269  n--;
270  }
271  if (do_color)
272  mutt_curses_set_attr(attr);
273  }
274  else if (*s == MUTT_SPECIAL_INDEX)
275  {
276  s++;
277  if (do_color)
278  {
279  if (*s == MT_COLOR_INDEX)
280  {
281  attrset(attr);
282  }
283  else
284  {
285  if (get_color(index, s) == 0)
286  {
287  attron(attr);
288  }
289  else
290  {
291  attron(get_color(index, s));
292  }
293  }
294  }
295  s++;
296  n -= 2;
297  }
298  else if ((k = mbrtowc(&wc, (char *) s, n, &mbstate)) > 0)
299  {
300  mutt_window_addnstr((char *) s, k);
301  s += k;
302  n -= k;
303  }
304  else
305  break;
306  }
307 }
308 
316 static void make_entry(char *buf, size_t buflen, struct Menu *menu, int i)
317 {
318  if (menu->dialog)
319  {
320  mutt_str_copy(buf, NONULL(menu->dialog[i]), buflen);
321  menu->current = -1; /* hide menubar */
322  }
323  else
324  menu->make_entry(buf, buflen, menu, i);
325 }
326 
335 static void menu_pad_string(struct Menu *menu, char *buf, size_t buflen)
336 {
337  char *scratch = mutt_str_dup(buf);
338  int shift = C_ArrowCursor ? mutt_strwidth(C_ArrowString) + 1 : 0;
339  int cols = menu->win_index->state.cols - shift;
340 
341  mutt_simple_format(buf, buflen, cols, cols, JUSTIFY_LEFT, ' ', scratch,
342  mutt_str_len(scratch), true);
343  buf[buflen - 1] = '\0';
344  FREE(&scratch);
345 }
346 
351 void menu_redraw_full(struct Menu *menu)
352 {
354  /* clear() doesn't optimize screen redraws */
355  mutt_window_move_abs(0, 0);
357 
358  if (C_Help)
359  {
364  }
365  menu->pagelen = menu->win_index->state.rows;
366 
367  mutt_show_error();
368 
370 #ifdef USE_SIDEBAR
371  menu->redraw |= REDRAW_SIDEBAR;
372 #endif
373 }
374 
379 void menu_redraw_status(struct Menu *menu)
380 {
381  char buf[256];
382 
383  snprintf(buf, sizeof(buf), "-- NeoMutt: %s", menu->title);
385  mutt_window_move(menu->win_ibar, 0, 0);
386  mutt_paddstr(menu->win_ibar->state.cols, buf);
388  menu->redraw &= ~REDRAW_STATUS;
389 }
390 
391 #ifdef USE_SIDEBAR
392 
396 void menu_redraw_sidebar(struct Menu *menu)
397 {
398  menu->redraw &= ~REDRAW_SIDEBAR;
399  struct MuttWindow *dlg = mutt_window_dialog(menu->win_index);
400  struct MuttWindow *sidebar = mutt_window_find(dlg, WT_SIDEBAR);
401  sb_draw(sidebar);
402 }
403 #endif
404 
409 void menu_redraw_index(struct Menu *menu)
410 {
411  char buf[1024];
412  bool do_color;
413  int attr;
414 
415  for (int i = menu->top; i < menu->top + menu->pagelen; i++)
416  {
417  if (i < menu->max)
418  {
419  attr = menu->color(i);
420 
421  make_entry(buf, sizeof(buf), menu, i);
422  menu_pad_string(menu, buf, sizeof(buf));
423 
424  mutt_curses_set_attr(attr);
425  mutt_window_move(menu->win_index, 0, i - menu->top);
426  do_color = true;
427 
428  if (i == menu->current)
429  {
431  if (C_ArrowCursor)
432  {
434  mutt_curses_set_attr(attr);
435  mutt_window_addch(' ');
436  }
437  else
438  do_color = false;
439  }
440  else if (C_ArrowCursor)
441  /* Print space chars to match the screen width of C_ArrowString */
443 
444  print_enriched_string(i, attr, (unsigned char *) buf, do_color);
445  }
446  else
447  {
449  mutt_window_clearline(menu->win_index, i - menu->top);
450  }
451  }
453  menu->redraw = 0;
454 }
455 
460 void menu_redraw_motion(struct Menu *menu)
461 {
462  char buf[1024];
463 
464  if (menu->dialog)
465  {
466  menu->redraw &= ~REDRAW_MOTION;
467  return;
468  }
469 
470  /* Note: menu->color() for the index can end up retrieving a message
471  * over imap (if matching against ~h for instance). This can
472  * generate status messages. So we want to call it *before* we
473  * position the cursor for drawing. */
474  const int old_color = menu->color(menu->oldcurrent);
475  mutt_window_move(menu->win_index, 0, menu->oldcurrent - menu->top);
476  mutt_curses_set_attr(old_color);
477 
478  if (C_ArrowCursor)
479  {
480  /* clear the arrow */
481  /* Print space chars to match the screen width of C_ArrowString */
483 
484  if (menu->redraw & REDRAW_MOTION_RESYNC)
485  {
486  make_entry(buf, sizeof(buf), menu, menu->oldcurrent);
487  menu_pad_string(menu, buf, sizeof(buf));
489  menu->oldcurrent - menu->top);
490  print_enriched_string(menu->oldcurrent, old_color, (unsigned char *) buf, true);
491  }
492 
493  /* now draw it in the new location */
495  mutt_window_mvaddstr(menu->win_index, 0, menu->current - menu->top, C_ArrowString);
496  }
497  else
498  {
499  /* erase the current indicator */
500  make_entry(buf, sizeof(buf), menu, menu->oldcurrent);
501  menu_pad_string(menu, buf, sizeof(buf));
502  print_enriched_string(menu->oldcurrent, old_color, (unsigned char *) buf, true);
503 
504  /* now draw the new one to reflect the change */
505  const int cur_color = menu->color(menu->current);
506  make_entry(buf, sizeof(buf), menu, menu->current);
507  menu_pad_string(menu, buf, sizeof(buf));
509  mutt_window_move(menu->win_index, 0, menu->current - menu->top);
510  print_enriched_string(menu->current, cur_color, (unsigned char *) buf, false);
511  }
512  menu->redraw &= REDRAW_STATUS;
514 }
515 
520 void menu_redraw_current(struct Menu *menu)
521 {
522  char buf[1024];
523  int attr = menu->color(menu->current);
524 
525  mutt_window_move(menu->win_index, 0, menu->current - menu->top);
526  make_entry(buf, sizeof(buf), menu, menu->current);
527  menu_pad_string(menu, buf, sizeof(buf));
528 
530  if (C_ArrowCursor)
531  {
533  mutt_curses_set_attr(attr);
534  mutt_window_addch(' ');
535  menu_pad_string(menu, buf, sizeof(buf));
536  print_enriched_string(menu->current, attr, (unsigned char *) buf, true);
537  }
538  else
539  print_enriched_string(menu->current, attr, (unsigned char *) buf, false);
540  menu->redraw &= REDRAW_STATUS;
542 }
543 
548 static void menu_redraw_prompt(struct Menu *menu)
549 {
550  if (!menu || !menu->dialog)
551  return;
552 
553  if (OptMsgErr)
554  {
555  mutt_sleep(1);
556  OptMsgErr = false;
557  }
558 
559  if (ErrorBufMessage)
561 
564 }
565 
570 void menu_check_recenter(struct Menu *menu)
571 {
572  int c = MIN(C_MenuContext, menu->pagelen / 2);
573  int old_top = menu->top;
574 
575  if (!C_MenuMoveOff && (menu->max <= menu->pagelen)) /* less entries than lines */
576  {
577  if (menu->top != 0)
578  {
579  menu->top = 0;
580  menu->redraw |= REDRAW_INDEX;
581  }
582  }
583  else
584  {
585  if (C_MenuScroll || (menu->pagelen <= 0) || (c < C_MenuContext))
586  {
587  if (menu->current < menu->top + c)
588  menu->top = menu->current - c;
589  else if (menu->current >= menu->top + menu->pagelen - c)
590  menu->top = menu->current - menu->pagelen + c + 1;
591  }
592  else
593  {
594  if (menu->current < menu->top + c)
595  {
596  menu->top -= (menu->pagelen - c) * ((menu->top + menu->pagelen - 1 - menu->current) /
597  (menu->pagelen - c)) -
598  c;
599  }
600  else if ((menu->current >= menu->top + menu->pagelen - c))
601  {
602  menu->top +=
603  (menu->pagelen - c) * ((menu->current - menu->top) / (menu->pagelen - c)) - c;
604  }
605  }
606  }
607 
608  if (!C_MenuMoveOff) /* make entries stick to bottom */
609  menu->top = MIN(menu->top, menu->max - menu->pagelen);
610  menu->top = MAX(menu->top, 0);
611 
612  if (menu->top != old_top)
613  menu->redraw |= REDRAW_INDEX;
614 }
615 
622 static void menu_jump(struct Menu *menu)
623 {
624  int n;
625 
626  if (menu->max)
627  {
629  char buf[128];
630  buf[0] = '\0';
631  if ((mutt_get_field(_("Jump to: "), buf, sizeof(buf), MUTT_COMP_NO_FLAGS) == 0) && buf[0])
632  {
633  if ((mutt_str_atoi(buf, &n) == 0) && (n > 0) && (n < menu->max + 1))
634  {
635  n--; /* msg numbers are 0-based */
636  menu->current = n;
637  menu->redraw = REDRAW_MOTION;
638  }
639  else
640  mutt_error(_("Invalid index number"));
641  }
642  }
643  else
644  mutt_error(_("No entries"));
645 }
646 
651 void menu_next_line(struct Menu *menu)
652 {
653  if (menu->max)
654  {
655  int c = MIN(C_MenuContext, menu->pagelen / 2);
656 
657  if ((menu->top + 1 < menu->max - c) &&
658  (C_MenuMoveOff ||
659  ((menu->max > menu->pagelen) && (menu->top < menu->max - menu->pagelen))))
660  {
661  menu->top++;
662  if ((menu->current < menu->top + c) && (menu->current < menu->max - 1))
663  menu->current++;
664  menu->redraw = REDRAW_INDEX;
665  }
666  else
667  mutt_message(_("You can't scroll down farther"));
668  }
669  else
670  mutt_error(_("No entries"));
671 }
672 
677 void menu_prev_line(struct Menu *menu)
678 {
679  if (menu->top > 0)
680  {
681  int c = MIN(C_MenuContext, menu->pagelen / 2);
682 
683  menu->top--;
684  if ((menu->current >= menu->top + menu->pagelen - c) && (menu->current > 1))
685  menu->current--;
686  menu->redraw = REDRAW_INDEX;
687  }
688  else
689  mutt_message(_("You can't scroll up farther"));
690 }
691 
702 static void menu_length_jump(struct Menu *menu, int jumplen)
703 {
704  const int neg = (jumplen >= 0) ? 0 : -1;
705  const int c = MIN(C_MenuContext, menu->pagelen / 2);
706 
707  if (menu->max)
708  {
709  /* possible to scroll? */
710  int tmp;
711  if (DIRECTION * menu->top <
712  (tmp = (neg ? 0 : (menu->max /* -1 */) - (menu->pagelen /* -1 */))))
713  {
714  menu->top += jumplen;
715 
716  /* jumped too long? */
717  if ((neg || !C_MenuMoveOff) && (DIRECTION * menu->top > tmp))
718  menu->top = tmp;
719 
720  /* need to move the cursor? */
721  if ((DIRECTION *
722  (tmp = (menu->current - (menu->top + (neg ? (menu->pagelen - 1) - c : c))))) < 0)
723  {
724  menu->current -= tmp;
725  }
726 
727  menu->redraw = REDRAW_INDEX;
728  }
729  else if ((menu->current != (neg ? 0 : menu->max - 1)) && !menu->dialog)
730  {
731  menu->current += jumplen;
732  menu->redraw = REDRAW_MOTION;
733  }
734  else
735  {
736  mutt_message(neg ? _("You are on the first page") : _("You are on the last page"));
737  }
738 
739  menu->current = MIN(menu->current, menu->max - 1);
740  menu->current = MAX(menu->current, 0);
741  }
742  else
743  mutt_error(_("No entries"));
744 }
745 
750 void menu_next_page(struct Menu *menu)
751 {
752  menu_length_jump(menu, MAX(menu->pagelen /* - MenuOverlap */, 0));
753 }
754 
759 void menu_prev_page(struct Menu *menu)
760 {
761  menu_length_jump(menu, 0 - MAX(menu->pagelen /* - MenuOverlap */, 0));
762 }
763 
768 void menu_half_down(struct Menu *menu)
769 {
770  menu_length_jump(menu, menu->pagelen / 2);
771 }
772 
777 void menu_half_up(struct Menu *menu)
778 {
779  menu_length_jump(menu, 0 - menu->pagelen / 2);
780 }
781 
786 void menu_top_page(struct Menu *menu)
787 {
788  if (menu->current == menu->top)
789  return;
790 
791  menu->current = menu->top;
792  menu->redraw = REDRAW_MOTION;
793 }
794 
799 void menu_bottom_page(struct Menu *menu)
800 {
801  if (menu->max)
802  {
803  menu->current = menu->top + menu->pagelen - 1;
804  if (menu->current > menu->max - 1)
805  menu->current = menu->max - 1;
806  menu->redraw = REDRAW_MOTION;
807  }
808  else
809  mutt_error(_("No entries"));
810 }
811 
816 void menu_middle_page(struct Menu *menu)
817 {
818  if (menu->max)
819  {
820  int i = menu->top + menu->pagelen;
821  if (i > menu->max - 1)
822  i = menu->max - 1;
823  menu->current = menu->top + (i - menu->top) / 2;
824  menu->redraw = REDRAW_MOTION;
825  }
826  else
827  mutt_error(_("No entries"));
828 }
829 
834 void menu_first_entry(struct Menu *menu)
835 {
836  if (menu->max)
837  {
838  menu->current = 0;
839  menu->redraw = REDRAW_MOTION;
840  }
841  else
842  mutt_error(_("No entries"));
843 }
844 
849 void menu_last_entry(struct Menu *menu)
850 {
851  if (menu->max)
852  {
853  menu->current = menu->max - 1;
854  menu->redraw = REDRAW_MOTION;
855  }
856  else
857  mutt_error(_("No entries"));
858 }
859 
864 void menu_current_top(struct Menu *menu)
865 {
866  if (menu->max)
867  {
868  menu->top = menu->current;
869  menu->redraw = REDRAW_INDEX;
870  }
871  else
872  mutt_error(_("No entries"));
873 }
874 
879 void menu_current_middle(struct Menu *menu)
880 {
881  if (menu->max)
882  {
883  menu->top = menu->current - menu->pagelen / 2;
884  if (menu->top < 0)
885  menu->top = 0;
886  menu->redraw = REDRAW_INDEX;
887  }
888  else
889  mutt_error(_("No entries"));
890 }
891 
896 void menu_current_bottom(struct Menu *menu)
897 {
898  if (menu->max)
899  {
900  menu->top = menu->current - menu->pagelen + 1;
901  if (menu->top < 0)
902  menu->top = 0;
903  menu->redraw = REDRAW_INDEX;
904  }
905  else
906  mutt_error(_("No entries"));
907 }
908 
913 static void menu_next_entry(struct Menu *menu)
914 {
915  if (menu->current < menu->max - 1)
916  {
917  menu->current++;
918  menu->redraw = REDRAW_MOTION;
919  }
920  else
921  mutt_message(_("You are on the last entry"));
922 }
923 
928 static void menu_prev_entry(struct Menu *menu)
929 {
930  if (menu->current)
931  {
932  menu->current--;
933  menu->redraw = REDRAW_MOTION;
934  }
935  else
936  mutt_message(_("You are on the first entry"));
937 }
938 
942 static int default_color(int line)
943 {
944  return Colors->defs[MT_COLOR_NORMAL];
945 }
946 
950 static int generic_search(struct Menu *menu, regex_t *rx, int line)
951 {
952  char buf[1024];
953 
954  make_entry(buf, sizeof(buf), menu, line);
955  return regexec(rx, buf, 0, NULL, 0);
956 }
957 
961 void mutt_menu_init(void)
962 {
963  for (int i = 0; i < MENU_MAX; i++)
964  SearchBuffers[i] = NULL;
965 }
966 
973 {
974  struct Menu *menu = mutt_mem_calloc(1, sizeof(struct Menu));
975 
976  menu->type = type;
977  menu->current = 0;
978  menu->top = 0;
979  menu->redraw = REDRAW_FULL;
980  menu->color = default_color;
981  menu->search = generic_search;
982 
983  return menu;
984 }
985 
990 void mutt_menu_free(struct Menu **ptr)
991 {
992  if (!ptr || !*ptr)
993  return;
994 
995  struct Menu *m = *ptr;
996  if (m->dialog)
997  {
998  for (int i = 0; i < m->max; i++)
999  FREE(&m->dialog[i]);
1000 
1001  FREE(&m->dialog);
1002  }
1003 
1004  FREE(ptr);
1005 }
1006 
1012 void mutt_menu_add_dialog_row(struct Menu *menu, const char *row)
1013 {
1014  if (menu->dsize <= menu->max)
1015  {
1016  menu->dsize += 10;
1017  mutt_mem_realloc(&menu->dialog, menu->dsize * sizeof(char *));
1018  }
1019  menu->dialog[menu->max++] = mutt_str_dup(row);
1020 }
1021 
1026 static struct Menu *get_current_menu(void)
1027 {
1028  return MenuStackCount ? MenuStack[MenuStackCount - 1] : NULL;
1029 }
1030 
1037 void mutt_menu_push_current(struct Menu *menu)
1038 {
1040  {
1041  MenuStackLen += 5;
1042  mutt_mem_realloc(&MenuStack, MenuStackLen * sizeof(struct Menu *));
1043  }
1044 
1045  MenuStack[MenuStackCount++] = menu;
1046  CurrentMenu = menu->type;
1047 }
1048 
1055 void mutt_menu_pop_current(struct Menu *menu)
1056 {
1057  struct Menu *prev_menu = NULL;
1058 
1059  if (!MenuStackCount || (MenuStack[MenuStackCount - 1] != menu))
1060  {
1061  mutt_debug(LL_DEBUG1, "called with inactive menu\n");
1062  return;
1063  }
1064 
1065  MenuStackCount--;
1066  prev_menu = get_current_menu();
1067  if (prev_menu)
1068  {
1069  CurrentMenu = prev_menu->type;
1070  prev_menu->redraw = REDRAW_FULL;
1071  }
1072  else
1073  {
1075  /* Clearing when NeoMutt exits would be an annoying change in behavior for
1076  * those who have disabled alternative screens. The option is currently
1077  * set by autocrypt initialization which mixes menus and prompts outside of
1078  * the normal menu system state. */
1080  {
1081  mutt_window_move_abs(0, 0);
1083  }
1084  }
1085 }
1086 
1092 {
1093  struct Menu *current_menu = get_current_menu();
1094  if (current_menu)
1095  current_menu->redraw |= redraw;
1096 }
1097 
1102 {
1103  struct Menu *current_menu = get_current_menu();
1104  if (current_menu)
1105  current_menu->redraw = REDRAW_FULL;
1106 }
1107 
1116 {
1117  if (CurrentMenu == menu)
1119 }
1120 
1128 {
1129  if (CurrentMenu == menu)
1131 }
1132 
1137 {
1138  struct Menu *current_menu = get_current_menu();
1139  if (current_menu)
1140  {
1141  if (menu_redraw(current_menu) == OP_REDRAW)
1142  {
1143  /* On a REDRAW_FULL with a non-customized redraw, menu_redraw()
1144  * will return OP_REDRAW to give the calling menu-loop a chance to
1145  * customize output. */
1146  menu_redraw(current_menu);
1147  }
1148  }
1149 }
1150 
1158 static int search(struct Menu *menu, int op)
1159 {
1160  int rc = 0, wrap = 0;
1161  int search_dir;
1162  regex_t re;
1163  char buf[128];
1164  char *search_buf = ((menu->type < MENU_MAX)) ? SearchBuffers[menu->type] : NULL;
1165 
1166  if (!(search_buf && *search_buf) || ((op != OP_SEARCH_NEXT) && (op != OP_SEARCH_OPPOSITE)))
1167  {
1168  mutt_str_copy(buf, search_buf && (search_buf[0] != '\0') ? search_buf : "",
1169  sizeof(buf));
1170  if ((mutt_get_field(((op == OP_SEARCH) || (op == OP_SEARCH_NEXT)) ?
1171  _("Search for: ") :
1172  _("Reverse search for: "),
1173  buf, sizeof(buf), MUTT_CLEAR) != 0) ||
1174  (buf[0] == '\0'))
1175  {
1176  return -1;
1177  }
1178  if (menu->type < MENU_MAX)
1179  {
1180  mutt_str_replace(&SearchBuffers[menu->type], buf);
1181  search_buf = SearchBuffers[menu->type];
1182  }
1183  menu->search_dir =
1184  ((op == OP_SEARCH) || (op == OP_SEARCH_NEXT)) ? MUTT_SEARCH_DOWN : MUTT_SEARCH_UP;
1185  }
1186 
1187  search_dir = (menu->search_dir == MUTT_SEARCH_UP) ? -1 : 1;
1188  if (op == OP_SEARCH_OPPOSITE)
1189  search_dir = -search_dir;
1190 
1191  if (search_buf)
1192  {
1193  int flags = mutt_mb_is_lower(search_buf) ? REG_ICASE : 0;
1194  rc = REG_COMP(&re, search_buf, REG_NOSUB | flags);
1195  }
1196 
1197  if (rc != 0)
1198  {
1199  regerror(rc, &re, buf, sizeof(buf));
1200  mutt_error("%s", buf);
1201  return -1;
1202  }
1203 
1204  rc = menu->current + search_dir;
1205 search_next:
1206  if (wrap)
1207  mutt_message(_("Search wrapped to top"));
1208  while ((rc >= 0) && (rc < menu->max))
1209  {
1210  if (menu->search(menu, &re, rc) == 0)
1211  {
1212  regfree(&re);
1213  return rc;
1214  }
1215 
1216  rc += search_dir;
1217  }
1218 
1219  if (C_WrapSearch && (wrap++ == 0))
1220  {
1221  rc = (search_dir == 1) ? 0 : menu->max - 1;
1222  goto search_next;
1223  }
1224  regfree(&re);
1225  mutt_error(_("Not found"));
1226  return -1;
1227 }
1228 
1234 static int menu_dialog_translate_op(int i)
1235 {
1236  switch (i)
1237  {
1238  case OP_NEXT_ENTRY:
1239  return OP_NEXT_LINE;
1240  case OP_PREV_ENTRY:
1241  return OP_PREV_LINE;
1242  case OP_CURRENT_TOP:
1243  case OP_FIRST_ENTRY:
1244  return OP_TOP_PAGE;
1245  case OP_CURRENT_BOTTOM:
1246  case OP_LAST_ENTRY:
1247  return OP_BOTTOM_PAGE;
1248  case OP_CURRENT_MIDDLE:
1249  return OP_MIDDLE_PAGE;
1250  }
1251 
1252  return i;
1253 }
1254 
1262 static int menu_dialog_dokey(struct Menu *menu, int *ip)
1263 {
1264  struct KeyEvent ch;
1265  char *p = NULL;
1266 
1267  do
1268  {
1269  ch = mutt_getch();
1270  } while (ch.ch == -2);
1271 
1272  if (ch.ch < 0)
1273  {
1274  *ip = -1;
1275  return 0;
1276  }
1277 
1278  if (ch.ch && (p = strchr(menu->keys, ch.ch)))
1279  {
1280  *ip = OP_MAX + (p - menu->keys + 1);
1281  return 0;
1282  }
1283  else
1284  {
1285  if (ch.op == OP_NULL)
1286  mutt_unget_event(ch.ch, 0);
1287  else
1288  mutt_unget_event(0, ch.op);
1289  return -1;
1290  }
1291 }
1292 
1299 int menu_redraw(struct Menu *menu)
1300 {
1301  if (menu->custom_redraw)
1302  {
1303  menu->custom_redraw(menu);
1304  return OP_NULL;
1305  }
1306 
1307  /* See if all or part of the screen needs to be updated. */
1308  if (menu->redraw & REDRAW_FULL)
1309  {
1310  menu_redraw_full(menu);
1311  /* allow the caller to do any local configuration */
1312  return OP_REDRAW;
1313  }
1314 
1315  if (!menu->dialog)
1316  menu_check_recenter(menu);
1317 
1318  if (menu->redraw & REDRAW_STATUS)
1319  menu_redraw_status(menu);
1320 #ifdef USE_SIDEBAR
1321  if (menu->redraw & REDRAW_SIDEBAR)
1322  menu_redraw_sidebar(menu);
1323 #endif
1324  if (menu->redraw & REDRAW_INDEX)
1325  menu_redraw_index(menu);
1326  else if (menu->redraw & (REDRAW_MOTION | REDRAW_MOTION_RESYNC))
1327  menu_redraw_motion(menu);
1328  else if (menu->redraw == REDRAW_CURRENT)
1329  menu_redraw_current(menu);
1330 
1331  if (menu->dialog)
1332  menu_redraw_prompt(menu);
1333 
1334  return OP_NULL;
1335 }
1336 
1342 int mutt_menu_loop(struct Menu *menu)
1343 {
1344  static int last_position = -1;
1345  int i = OP_NULL;
1346 
1347  if (menu->max && menu->is_mailbox_list)
1348  {
1349  if (last_position > (menu->max - 1))
1350  last_position = -1;
1351  else if (last_position >= 0)
1352  menu->current = last_position;
1353  }
1354 
1355  while (true)
1356  {
1357  /* Clear the tag prefix unless we just started it. Don't clear
1358  * the prefix on a timeout (i==-2), but do clear on an abort (i==-1) */
1359  if (menu->tagprefix && (i != OP_TAG_PREFIX) && (i != OP_TAG_PREFIX_COND) && (i != -2))
1360  menu->tagprefix = false;
1361 
1363 
1364  if (menu_redraw(menu) == OP_REDRAW)
1365  return OP_REDRAW;
1366 
1367  /* give visual indication that the next command is a tag- command */
1368  if (menu->tagprefix)
1369  {
1370  mutt_window_mvaddstr(MuttMessageWindow, 0, 0, "tag-");
1372  }
1373 
1374  menu->oldcurrent = menu->current;
1375 
1376  /* move the cursor out of the way */
1377  if (C_ArrowCursor)
1378  mutt_window_move(menu->win_index, 2, menu->current - menu->top);
1379  else if (C_BrailleFriendly)
1380  mutt_window_move(menu->win_index, 0, menu->current - menu->top);
1381  else
1382  {
1383  mutt_window_move(menu->win_index, menu->win_index->state.cols - 1,
1384  menu->current - menu->top);
1385  }
1386 
1387  mutt_refresh();
1388 
1389  /* try to catch dialog keys before ops */
1390  if (menu->dialog && (menu_dialog_dokey(menu, &i) == 0))
1391  return i;
1392 
1393  i = km_dokey(menu->type);
1394  if ((i == OP_TAG_PREFIX) || (i == OP_TAG_PREFIX_COND))
1395  {
1396  if (menu->tagprefix)
1397  {
1398  menu->tagprefix = false;
1400  continue;
1401  }
1402 
1403  if (menu->tagged)
1404  {
1405  menu->tagprefix = true;
1406  continue;
1407  }
1408  else if (i == OP_TAG_PREFIX)
1409  {
1410  mutt_error(_("No tagged entries"));
1411  i = -1;
1412  }
1413  else /* None tagged, OP_TAG_PREFIX_COND */
1414  {
1416  mutt_message(_("Nothing to do"));
1417  i = -1;
1418  }
1419  }
1420  else if (menu->tagged && C_AutoTag)
1421  menu->tagprefix = true;
1422 
1424 
1425  if (SigWinch)
1426  {
1427  SigWinch = 0;
1429  clearok(stdscr, true); /* force complete redraw */
1430  }
1431 
1432  if (i < 0)
1433  {
1434  if (menu->tagprefix)
1436  continue;
1437  }
1438 
1439  if (!menu->dialog)
1440  mutt_clear_error();
1441 
1442  /* Convert menubar movement to scrolling */
1443  if (menu->dialog)
1444  i = menu_dialog_translate_op(i);
1445 
1446  switch (i)
1447  {
1448  case OP_NEXT_ENTRY:
1449  menu_next_entry(menu);
1450  break;
1451  case OP_PREV_ENTRY:
1452  menu_prev_entry(menu);
1453  break;
1454  case OP_HALF_DOWN:
1455  menu_half_down(menu);
1456  break;
1457  case OP_HALF_UP:
1458  menu_half_up(menu);
1459  break;
1460  case OP_NEXT_PAGE:
1461  menu_next_page(menu);
1462  break;
1463  case OP_PREV_PAGE:
1464  menu_prev_page(menu);
1465  break;
1466  case OP_NEXT_LINE:
1467  menu_next_line(menu);
1468  break;
1469  case OP_PREV_LINE:
1470  menu_prev_line(menu);
1471  break;
1472  case OP_FIRST_ENTRY:
1473  menu_first_entry(menu);
1474  break;
1475  case OP_LAST_ENTRY:
1476  menu_last_entry(menu);
1477  break;
1478  case OP_TOP_PAGE:
1479  menu_top_page(menu);
1480  break;
1481  case OP_MIDDLE_PAGE:
1482  menu_middle_page(menu);
1483  break;
1484  case OP_BOTTOM_PAGE:
1485  menu_bottom_page(menu);
1486  break;
1487  case OP_CURRENT_TOP:
1488  menu_current_top(menu);
1489  break;
1490  case OP_CURRENT_MIDDLE:
1491  menu_current_middle(menu);
1492  break;
1493  case OP_CURRENT_BOTTOM:
1494  menu_current_bottom(menu);
1495  break;
1496  case OP_SEARCH:
1497  case OP_SEARCH_REVERSE:
1498  case OP_SEARCH_NEXT:
1499  case OP_SEARCH_OPPOSITE:
1500  if (menu->search && !menu->dialog) /* Searching dialogs won't work */
1501  {
1502  menu->oldcurrent = menu->current;
1503  menu->current = search(menu, i);
1504  if (menu->current != -1)
1505  menu->redraw = REDRAW_MOTION;
1506  else
1507  menu->current = menu->oldcurrent;
1508  }
1509  else
1510  mutt_error(_("Search is not implemented for this menu"));
1511  break;
1512 
1513  case OP_JUMP:
1514  if (menu->dialog)
1515  mutt_error(_("Jumping is not implemented for dialogs"));
1516  else
1517  menu_jump(menu);
1518  break;
1519 
1520  case OP_ENTER_COMMAND:
1522  break;
1523 
1524  case OP_TAG:
1525  if (menu->tag && !menu->dialog)
1526  {
1527  if (menu->tagprefix && !C_AutoTag)
1528  {
1529  for (i = 0; i < menu->max; i++)
1530  menu->tagged += menu->tag(menu, i, 0);
1531  menu->redraw |= REDRAW_INDEX;
1532  }
1533  else if (menu->max)
1534  {
1535  int j = menu->tag(menu, menu->current, -1);
1536  menu->tagged += j;
1537  if (j && C_Resolve && (menu->current < menu->max - 1))
1538  {
1539  menu->current++;
1540  menu->redraw |= REDRAW_MOTION_RESYNC;
1541  }
1542  else
1543  menu->redraw |= REDRAW_CURRENT;
1544  }
1545  else
1546  mutt_error(_("No entries"));
1547  }
1548  else
1549  mutt_error(_("Tagging is not supported"));
1550  break;
1551 
1552  case OP_SHELL_ESCAPE:
1554  break;
1555 
1556  case OP_WHAT_KEY:
1557  mutt_what_key();
1558  break;
1559 
1560  case OP_CHECK_STATS:
1561  mutt_check_stats();
1562  break;
1563 
1564  case OP_REDRAW:
1565  clearok(stdscr, true);
1566  menu->redraw = REDRAW_FULL;
1567  break;
1568 
1569  case OP_HELP:
1570  mutt_help(menu->type, menu->win_index->state.cols);
1571  menu->redraw = REDRAW_FULL;
1572  break;
1573 
1574  case OP_NULL:
1575  km_error_key(menu->type);
1576  break;
1577 
1578  case OP_END_COND:
1579  break;
1580 
1581  default:
1582  if (menu->is_mailbox_list)
1583  last_position = menu->current;
1584  return i;
1585  }
1586  }
1587  /* not reached */
1588 }
1589 
1594 {
1595  if (!nc->event_data)
1596  return -1;
1597  if (nc->event_type != NT_CONFIG)
1598  return 0;
1599 
1600  int s = nc->event_subtype;
1601 
1602  bool simple = (s == MT_COLOR_INDEX_COLLAPSED) || (s == MT_COLOR_INDEX_DATE) ||
1603  (s == MT_COLOR_INDEX_LABEL) || (s == MT_COLOR_INDEX_NUMBER) ||
1604  (s == MT_COLOR_INDEX_SIZE) || (s == MT_COLOR_INDEX_TAGS);
1605  bool lists = (s == MT_COLOR_ATTACH_HEADERS) || (s == MT_COLOR_BODY) ||
1606  (s == MT_COLOR_HEADER) || (s == MT_COLOR_INDEX) ||
1607  (s == MT_COLOR_INDEX_AUTHOR) || (s == MT_COLOR_INDEX_FLAGS) ||
1608  (s == MT_COLOR_INDEX_SUBJECT) || (s == MT_COLOR_INDEX_TAG);
1609 
1610  // The changes aren't relevant to the index menu
1611  if (!simple && !lists)
1612  return 0;
1613 
1614  struct EventColor *ec = nc->event_data;
1615 
1616  // Colour deleted from a list
1617  if (!ec->set && lists && Context && Context->mailbox)
1618  {
1619  struct Mailbox *m = Context->mailbox;
1620  // Force re-caching of index colors
1621  for (int i = 0; i < m->msg_count; i++)
1622  {
1623  struct Email *e = m->emails[i];
1624  if (!e)
1625  break;
1626  e->pair = 0;
1627  }
1628  }
1629 
1631  return 0;
1632 }
1633 
1638 {
1639  if (!nc->event_data)
1640  return -1;
1641  if (nc->event_type != NT_CONFIG)
1642  return 0;
1643 
1644  struct EventConfig *ec = nc->event_data;
1645 
1646  const struct ConfigDef *cdef = ec->he->data;
1647  ConfigRedrawFlags flags = cdef->type & R_REDRAW_MASK;
1648 
1649  if (flags == R_REDRAW_NO_FLAGS)
1650  return 0;
1651 
1652  if (flags & R_INDEX)
1654  if (flags & R_PAGER)
1656  if (flags & R_PAGER_FLOW)
1657  {
1660  }
1661 
1662  if (flags & R_RESORT_SUB)
1663  OptSortSubthreads = true;
1664  if (flags & R_RESORT)
1665  OptNeedResort = true;
1666  if (flags & R_RESORT_INIT)
1667  OptResortInit = true;
1668  if (flags & R_TREE)
1669  OptRedrawTree = true;
1670 
1671  if (flags & R_REFLOW)
1672  mutt_window_reflow(NULL);
1673 #ifdef USE_SIDEBAR
1674  if (flags & R_SIDEBAR)
1676 #endif
1677  if (flags & R_MENU)
1679 
1680  return 0;
1681 }
int km_dokey(enum MenuType menu)
Determine what a keypress should do.
Definition: keymap.c:620
void * mutt_hash_find(const struct HashTable *table, const char *strkey)
Find the HashElem data in a Hash Table element using a key.
Definition: hash.c:354
struct Email ** emails
Array of Emails.
Definition: mailbox.h:99
Convenience wrapper for the gui headers.
struct ColorLineList index_tag_list
List of colours applied to tags in the index.
Definition: color.h:140
MIME attachment test (takes a pattern)
Definition: color.h:62
The "current" mailbox.
Definition: context.h:37
#define R_PAGER
Redraw the pager menu.
Definition: types.h:66
Index: index number.
Definition: color.h:109
#define REDRAW_FULL
Redraw everything.
Definition: mutt_menu.h:45
Manage keymappings.
#define NONULL(x)
Definition: string2.h:37
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
int msg_count
Total number of messages.
Definition: mailbox.h:91
Lower left corner.
Definition: mutt_menu.h:59
int mutt_str_atoi(const char *str, int *dst)
Convert ASCII string to an integer.
Definition: string.c:257
Left justify the text.
Definition: curs_lib.h:47
The envelope/body of an email.
Definition: email.h:37
#define MUTT_CLEAR
Clear input if printable character is pressed.
Definition: mutt.h:62
Index: tags field (g, J)
Definition: color.h:111
struct Email * mutt_get_virt_email(struct Mailbox *m, int vnum)
Get a virtual Email.
Definition: context.c:406
#define MIN(a, b)
Definition: memory.h:31
GUI selectable list of items.
Definition: mutt_menu.h:80
Data passed to a notification function.
Definition: observer.h:39
#define R_PAGER_FLOW
Reflow line_info and redraw the pager menu.
Definition: types.h:67
Structs that make up an email.
An Event that happened to a Colour.
Definition: color.h:158
The "currently-open" mailbox.
MenuType
Types of GUI selections.
Definition: keymap.h:70
#define mutt_message(...)
Definition: logging.h:83
Pager: highlight body of message (takes a pattern)
Definition: color.h:63
int oldcurrent
For driver use only.
Definition: mutt_menu.h:106
void mutt_curses_set_color(enum ColorId color)
Set the current colour for text.
Definition: mutt_curses.c:55
#define REDRAW_FLOW
Used by pager to reflow text.
Definition: mutt_menu.h:47
int * defs
Array of all fixed colours, see enum ColorId.
Definition: color.h:131
char * prompt
Prompt for user, similar to mutt_multi_choice.
Definition: mutt_menu.h:101
struct MuttWindow * mutt_window_find(struct MuttWindow *root, enum WindowType type)
Find a Window of a given type.
Definition: mutt_window.c:692
void mutt_window_clrtoeol(struct MuttWindow *win)
Clear to the end of the line.
Definition: mutt_window.c:216
struct PatternList * color_pattern
Compiled pattern to speed up index color calculation.
Definition: color.h:40
void mutt_resize_screen(void)
Update NeoMutt&#39;s opinion about the window size (CURSES)
Definition: resize.c:101
NeoMutt Logging.
WHERE bool OptNeedResort
(pseudo) used to force a re-sort
Definition: options.h:43
struct ColorLineList index_flags_list
List of colours applied to the flags in the index.
Definition: color.h:137
void mutt_check_stats(void)
Forcibly update mailbox stats.
Definition: commands.c:1404
char ** dialog
Dialog lines themselves.
Definition: mutt_menu.h:99
A config-change event.
Definition: subset.h:70
char * pattern
Pattern to match.
Definition: color.h:39
int pair
Colour pair index.
Definition: color.h:43
void mutt_enter_command(void)
enter a neomutt command
Definition: commands.c:871
struct ColorLineList index_subject_list
List of colours applied to the subject in the index.
Definition: color.h:139
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:375
void mutt_unget_event(int ch, int op)
Return a keystroke to the input buffer.
Definition: curs_lib.c:831
#define _(a)
Definition: message.h:28
struct MuttWindow * MuttHelpWindow
Help Window.
Definition: mutt_window.c:45
int op
function op
Definition: keymap.h:64
int ch
raw key pressed
Definition: keymap.h:63
A division of the screen.
Definition: mutt_window.h:114
void mutt_window_move_abs(int col, int row)
Move the cursor to an absolute screen position.
Definition: mutt_window.c:535
WHERE bool C_BrailleFriendly
Config: Move the cursor to the beginning of the line.
Definition: mutt_globals.h:144
Index panel (list of emails)
Definition: keymap.h:78
int mutt_window_mvaddstr(struct MuttWindow *win, int col, int row, const char *str)
Move the cursor and write a fixed string to a Window.
Definition: mutt_window.c:376
Config item definition.
Definition: set.h:63
WHERE bool C_AutoTag
Config: Automatically apply actions to all tagged messages.
Definition: mutt_globals.h:141
Index: number of messages in collapsed thread.
Definition: color.h:106
All user-callable functions.
#define R_RESORT
Resort the mailbox.
Definition: types.h:68
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:91
#define REDRAW_SIDEBAR
Redraw the sidebar.
Definition: mutt_menu.h:49
Convenience wrapper for the config headers.
void mutt_paddstr(int n, const char *s)
Display a string on screen, padded if necessary.
Definition: curs_lib.c:1263
int mutt_window_move(struct MuttWindow *win, int col, int row)
Move the cursor in a Window.
Definition: mutt_window.c:362
Right arrow.
Definition: mutt_menu.h:65
Bottom T-piece.
Definition: mutt_menu.h:70
int event_subtype
Send: Event subtype, e.g. NT_ACCOUNT_ADD.
Definition: observer.h:42
#define R_TREE
Redraw the thread tree.
Definition: types.h:71
enum NotifyType event_type
Send: Event type, e.g. NT_ACCOUNT.
Definition: observer.h:41
Some miscellaneous functions.
#define MAX(a, b)
Definition: memory.h:30
Pager pager (email viewer)
Definition: keymap.h:79
Index: author field (takes a pattern)
Definition: color.h:101
int mutt_window_addnstr(const char *str, int num)
Write a partial string to a Window.
Definition: mutt_window.c:500
Blank space.
Definition: mutt_menu.h:64
#define R_REDRAW_NO_FLAGS
No refresh/resort flags.
Definition: types.h:64
WHERE enum MenuType CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: mutt_globals.h:78
bool set
True if a colour has been set/added, false if reset/deleted.
Definition: color.h:160
Vertical line.
Definition: mutt_menu.h:63
void mutt_sleep(short s)
Sleep for a while.
Definition: muttlib.c:1446
struct HashElem * he
Config item that changed.
Definition: subset.h:74
void mutt_curses_set_cursor(enum MuttCursorState state)
Set the cursor state.
Definition: mutt_curses.c:76
enum MenuType type
Menu definition for keymap entries.
Definition: mutt_menu.h:88
struct Mailbox * mailbox
Definition: context.h:50
Many unsorted constants and some structs.
Top T-piece.
Definition: mutt_menu.h:69
Message headers (takes a pattern)
Definition: color.h:72
void mutt_flush_macro_to_endcond(void)
Drop a macro from the input buffer.
Definition: curs_lib.c:887
#define MUTT_COMP_NO_FLAGS
No flags are set.
Definition: mutt.h:56
struct MuttWindow * win_ibar
Definition: mutt_menu.h:93
const char * title
Title of this menu.
Definition: mutt_menu.h:82
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:194
WHERE bool OptMenuPopClearScreen
(pseudo) clear the screen when popping the last menu
Definition: options.h:40
void mutt_what_key(void)
Ask the user to press a key.
Definition: keymap.c:1622
Display a normal cursor.
Definition: mutt_curses.h:81
int LastKey
contains the last key the user pressed
Definition: keymap.c:146
Index: tag field (g, takes a pattern)
Definition: color.h:104
Convenience wrapper for the core headers.
#define REG_COMP(preg, regex, cflags)
Compile a regular expression.
Definition: regex3.h:53
Star character (for threads)
Definition: mutt_menu.h:66
Equals (for threads)
Definition: mutt_menu.h:68
void mutt_shell_escape(void)
invoke a command in a subshell
Definition: commands.c:843
Index: tree-drawing characters.
Definition: color.h:96
void mutt_window_clrtobot(void)
Clear to the bottom of the Window.
Definition: mutt_window.c:205
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:113
Ampersand character (for threads)
Definition: mutt_menu.h:67
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:41
Plain text.
Definition: color.h:77
const char * help
Quickref for the current menu.
Definition: mutt_menu.h:83
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Definition: memory.c:114
#define R_MENU
Redraw all menus.
Definition: types.h:74
#define REDRAW_MOTION_RESYNC
Redraw any changing the menu selection.
Definition: mutt_menu.h:42
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:57
int mutt_pattern_exec(struct Pattern *pat, PatternExecFlags flags, struct Mailbox *m, struct Email *e, struct PatternCache *cache)
Match a pattern against an email header.
Definition: pattern.c:2129
#define R_RESORT_SUB
Resort subthreads.
Definition: types.h:69
void mutt_refresh(void)
Force a refresh of the screen.
Definition: curs_lib.c:106
Side panel containing Accounts or groups of data.
Definition: mutt_window.h:98
Index: date field.
Definition: color.h:107
Prototypes for many functions.
#define R_REFLOW
Reflow window layout and full redraw.
Definition: types.h:72
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:119
Question mark.
Definition: mutt_menu.h:71
#define REDRAW_STATUS
Redraw the status bar.
Definition: mutt_menu.h:44
#define SLIST_FIRST(head)
Definition: queue.h:228
Index: size field.
Definition: color.h:110
void km_error_key(enum MenuType menu)
Handle an unbound key sequence.
Definition: keymap.c:1096
int(* color)(int line)
Calculate the colour for a line of the menu.
Definition: mutt_menu.h:144
Status bar (takes a pattern)
Definition: color.h:94
A mailbox.
Definition: mailbox.h:81
int mutt_strwidth(const char *s)
Measure a string&#39;s width in screen cells.
Definition: curs_lib.c:1356
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:58
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:105
bool tagprefix
Definition: mutt_menu.h:90
Manage where the email is piped to external commands.
struct ColorLineList index_author_list
List of colours applied to the author in the index.
Definition: color.h:136
bool is_mailbox_list
Definition: mutt_menu.h:91
Selected item in list.
Definition: color.h:73
GUI present the user with a selectable list.
struct HashTable * TagTransforms
Lookup table of alternative tag names.
Definition: tags.c:38
uint32_t ConfigRedrawFlags
Flags for redraw/resort, e.g. R_INDEX.
Definition: types.h:63
int search_dir
Direction of search.
Definition: mutt_menu.h:107
void(* custom_redraw)(struct Menu *menu)
Redraw the menu.
Definition: mutt_menu.h:150
An event such as a keypress.
Definition: keymap.h:61
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
int(* tag)(struct Menu *menu, int sel, int act)
Tag some menu items.
Definition: mutt_menu.h:136
struct KeyEvent mutt_getch(void)
Read a character from the input buffer.
Definition: curs_lib.c:187
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:89
char * keys
Keys used in the prompt.
Definition: mutt_menu.h:102
WHERE bool OptRedrawTree
(pseudo) redraw the thread tree
Definition: options.h:50
Definition: color.h:129
WHERE bool OptResortInit
(pseudo) used to force the next resort to be from scratch
Definition: options.h:51
#define MUTT_MATCH_FULL_ADDRESS
Match the full address.
Definition: pattern.h:76
int tagged
Number of tagged entries.
Definition: mutt_menu.h:108
WHERE bool C_WrapSearch
Config: Wrap around when the search hits the end.
Definition: mutt_globals.h:172
void * event_data
Data from notify_send()
Definition: observer.h:43
int max
Number of entries in the menu.
Definition: mutt_menu.h:86
WHERE bool C_ArrowCursor
Config: Use an arrow &#39;->&#39; instead of highlighting in the index.
Definition: mutt_globals.h:135
WHERE bool C_AsciiChars
Config: Use plain ASCII characters, when drawing email threads.
Definition: mutt_globals.h:137
struct MuttWindow * mutt_window_dialog(struct MuttWindow *win)
Find the parent Dialog of a Window.
Definition: mutt_window.c:674
bool mutt_strn_equal(const char *a, const char *b, size_t l)
Check for equality of two strings (to a maximum), safely.
Definition: string.c:598
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:87
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:36
void * data
User-supplied data.
Definition: hash.h:47
Colour indicator.
Definition: mutt_menu.h:74
int mutt_window_printf(const char *fmt,...)
Write a formatted string to a Window.
Definition: mutt_window.c:546
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
Definition: string.c:636
int mutt_window_addch(int ch)
Write one character to a Window.
Definition: mutt_window.c:488
Index: label field.
Definition: color.h:108
unsigned int type
Variable type, e.g. DT_STRING.
Definition: set.h:66
bool CharsetIsUtf8
Is the user&#39;s current character set utf-8?
Definition: charset.c:63
Index: subject field (takes a pattern)
Definition: color.h:103
Log at debug level 1.
Definition: logging.h:40
int n
Definition: acutest.h:492
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:721
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:40
void mutt_help(enum MenuType menu, int wraplen)
Display the help menu.
Definition: help.c:439
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:451
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
Definition: mutt_window.c:429
#define mutt_error(...)
Definition: logging.h:84
int index
The absolute (unsorted) message number.
Definition: email.h:85
#define FREE(x)
Definition: memory.h:40
WHERE bool OptMsgErr
(pseudo) used by mutt_error/mutt_message
Definition: options.h:41
int dsize
Number of allocated dialog lines.
Definition: mutt_menu.h:100
Hide the cursor.
Definition: mutt_curses.h:80
#define R_RESORT_INIT
Resort from scratch.
Definition: types.h:70
WHERE bool OptSortSubthreads
(pseudo) used when $sort_aux changes
Definition: options.h:54
void mutt_show_error(void)
Show the user an error message.
Definition: curs_lib.c:555
struct MuttWindow * MuttMessageWindow
Message Window.
Definition: mutt_window.c:46
int mutt_window_addstr(const char *str)
Write a string to a Window.
Definition: mutt_window.c:518
#define R_SIDEBAR
Redraw the sidebar.
Definition: types.h:73
Hundreds of global variables to back the user variables.
Handling of global boolean variables.
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
WHERE bool ErrorBufMessage
true if the last message was an error
Definition: mutt_globals.h:45
int mutt_color_combine(struct Colors *c, uint32_t fg_attr, uint32_t bg_attr)
Combine two colours.
Definition: color.c:576
Index: default colour (takes a pattern)
Definition: color.h:100
int const char int line
Definition: acutest.h:617
int current
Current entry.
Definition: mutt_menu.h:85
struct MuttWindow * win_index
Definition: mutt_menu.h:92
Convenience wrapper for the library headers.
void mutt_curses_set_attr(int attr)
Set the attributes for text.
Definition: mutt_curses.c:40
Match patterns to emails.
WHERE bool C_Help
Config: Display a help line with common key bindings.
Definition: mutt_globals.h:153
bool mutt_mb_is_lower(const char *s)
Does a multi-byte string contain only lowercase characters?
Definition: mbyte.c:358
WHERE SIG_ATOMIC_VOLATILE_T SigWinch
true after SIGWINCH is received
Definition: mutt_globals.h:76
int(* search)(struct Menu *menu, regex_t *rx, int line)
Search a menu for a item matching a regex.
Definition: mutt_menu.h:127
void(* make_entry)(char *buf, size_t buflen, struct Menu *menu, int line)
Format a item for a menu.
Definition: mutt_menu.h:117
Left T-piece.
Definition: mutt_menu.h:61
int pair
Color-pair to use when displaying in the index.
Definition: email.h:79
WHERE char * C_ArrowString
Config: Use an custom string for arrow_cursor.
Definition: mutt_globals.h:136
#define REDRAW_CURRENT
Redraw the current line of the menu.
Definition: mutt_menu.h:43
Index: flags field (takes a pattern)
Definition: color.h:102
A regular expression and a color to highlight a line.
Definition: color.h:35
WHERE bool C_Resolve
Config: Move to the next email whenever a command modifies an email.
Definition: mutt_globals.h:157
#define R_REDRAW_MASK
Mask for the Redraw Flags.
Definition: types.h:76
void mutt_simple_format(char *buf, size_t buflen, int min_width, int max_width, enum FormatJustify justify, char pad_char, const char *s, size_t n, bool arboreal)
Format a string, like snprintf()
Definition: curs_lib.c:1090
#define R_INDEX
Redraw the index menu (MENU_MAIN)
Definition: types.h:65
Upper left corner.
Definition: mutt_menu.h:60
uint16_t MuttRedrawFlags
Flags, e.g. REDRAW_INDEX.
Definition: mutt_menu.h:38
Horizontal line.
Definition: mutt_menu.h:62