NeoMutt  2020-08-07-1-gab41a1
Teaching an old dog new tricks
DOXYGEN
mutt_menu.h File Reference

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

#include "config.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "mutt/lib.h"
#include "keymap.h"
+ Include dependency graph for mutt_menu.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Menu
 GUI selectable list of items. More...
 

Macros

#define REDRAW_NO_FLAGS   0
 No flags are set. More...
 
#define REDRAW_INDEX   (1 << 0)
 Redraw the index. More...
 
#define REDRAW_MOTION   (1 << 1)
 Redraw after moving the menu list. More...
 
#define REDRAW_MOTION_RESYNC   (1 << 2)
 Redraw any changing the menu selection. More...
 
#define REDRAW_CURRENT   (1 << 3)
 Redraw the current line of the menu. More...
 
#define REDRAW_STATUS   (1 << 4)
 Redraw the status bar. More...
 
#define REDRAW_FULL   (1 << 5)
 Redraw everything. More...
 
#define REDRAW_BODY   (1 << 6)
 Redraw the pager. More...
 
#define REDRAW_FLOW   (1 << 7)
 Used by pager to reflow text. More...
 
#define REDRAW_SIDEBAR   (1 << 8)
 Redraw the sidebar. More...
 

Typedefs

typedef uint16_t MuttRedrawFlags
 Flags, e.g. REDRAW_INDEX. More...
 

Functions

void menu_bottom_page (struct Menu *menu)
 Move the focus to the bottom of the page. More...
 
void menu_check_recenter (struct Menu *menu)
 Recentre the menu on screen. More...
 
void menu_current_bottom (struct Menu *menu)
 Move the current selection to the bottom 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_top (struct Menu *menu)
 Move the current selection to the top of the window. More...
 
void menu_first_entry (struct Menu *menu)
 Move the focus to the first entry 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_last_entry (struct Menu *menu)
 Move the focus to the last entry in the menu. More...
 
void menu_middle_page (struct Menu *menu)
 Move the focus to the centre of the page. More...
 
void menu_next_line (struct Menu *menu)
 Move the view down one line, keeping the selection the same. More...
 
void menu_next_page (struct Menu *menu)
 Move the focus to the next page in the menu. More...
 
void menu_prev_line (struct Menu *menu)
 Move the view up one line, keeping the selection the same. More...
 
void menu_prev_page (struct Menu *menu)
 Move the focus to the previous page in the menu. More...
 
void menu_redraw_current (struct Menu *menu)
 Redraw the current menu. More...
 
void menu_redraw_full (struct Menu *menu)
 Force the redraw of the Menu. 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_sidebar (struct Menu *menu)
 Force the redraw of the sidebar. More...
 
void menu_redraw_status (struct Menu *menu)
 Force the redraw of the status bar. More...
 
int menu_redraw (struct Menu *menu)
 Redraw the parts of the screen that have been flagged to be redrawn. More...
 
void menu_top_page (struct Menu *menu)
 Move the focus to the top of the page. More...
 
void mutt_menu_add_dialog_row (struct Menu *menu, const char *row)
 Add a row to a Menu. More...
 
void mutt_menu_current_redraw (void)
 Redraw the current menu. More...
 
void mutt_menu_free (struct Menu **ptr)
 Destroy a menu. More...
 
void mutt_menu_init (void)
 Initialise all the Menus. More...
 
int mutt_menu_loop (struct Menu *menu)
 Menu event loop. More...
 
struct Menumutt_menu_new (enum MenuType type)
 Create a new Menu. More...
 
void mutt_menu_pop_current (struct Menu *menu)
 Remove a Menu from the stack. More...
 
void mutt_menu_push_current (struct Menu *menu)
 Add a new Menu to the stack. More...
 
void mutt_menu_set_current_redraw_full (void)
 Flag the current menu to be fully redrawn. More...
 
void mutt_menu_set_current_redraw (MuttRedrawFlags redraw)
 Set redraw flags on the current menu. More...
 
void mutt_menu_set_redraw_full (enum MenuType menu)
 Flag a menu to be fully redrawn. More...
 
void mutt_menu_set_redraw (enum MenuType menu, MuttRedrawFlags redraw)
 Set redraw flags on a menu. More...
 
int mutt_menu_color_observer (struct NotifyCallback *nc)
 Listen for colour changes affecting the menu - Implements observer_t. More...
 
int mutt_menu_config_observer (struct NotifyCallback *nc)
 Listen for config changes affecting the menu - Implements observer_t. More...
 

Variables

short C_MenuContext
 Config: Number of lines of overlap when changing pages in the index. More...
 
bool C_MenuMoveOff
 Config: Allow the last menu item to move off the bottom of the screen. More...
 
bool C_MenuScroll
 Config: Scroll the menu/index by one line, rather than a page. More...
 

Detailed Description

GUI present the user with a selectable list.

Authors
  • Richard Russon

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 mutt_menu.h.

Macro Definition Documentation

◆ REDRAW_NO_FLAGS

#define REDRAW_NO_FLAGS   0

No flags are set.

Definition at line 39 of file mutt_menu.h.

◆ REDRAW_INDEX

#define REDRAW_INDEX   (1 << 0)

Redraw the index.

Definition at line 40 of file mutt_menu.h.

◆ REDRAW_MOTION

#define REDRAW_MOTION   (1 << 1)

Redraw after moving the menu list.

Definition at line 41 of file mutt_menu.h.

◆ REDRAW_MOTION_RESYNC

#define REDRAW_MOTION_RESYNC   (1 << 2)

Redraw any changing the menu selection.

Definition at line 42 of file mutt_menu.h.

◆ REDRAW_CURRENT

#define REDRAW_CURRENT   (1 << 3)

Redraw the current line of the menu.

Definition at line 43 of file mutt_menu.h.

◆ REDRAW_STATUS

#define REDRAW_STATUS   (1 << 4)

Redraw the status bar.

Definition at line 44 of file mutt_menu.h.

◆ REDRAW_FULL

#define REDRAW_FULL   (1 << 5)

Redraw everything.

Definition at line 45 of file mutt_menu.h.

◆ REDRAW_BODY

#define REDRAW_BODY   (1 << 6)

Redraw the pager.

Definition at line 46 of file mutt_menu.h.

◆ REDRAW_FLOW

#define REDRAW_FLOW   (1 << 7)

Used by pager to reflow text.

Definition at line 47 of file mutt_menu.h.

◆ REDRAW_SIDEBAR

#define REDRAW_SIDEBAR   (1 << 8)

Redraw the sidebar.

Definition at line 49 of file mutt_menu.h.

Typedef Documentation

◆ MuttRedrawFlags

typedef uint16_t MuttRedrawFlags

Flags, e.g. REDRAW_INDEX.

Definition at line 38 of file mutt_menu.h.

Function Documentation

◆ menu_bottom_page()

void menu_bottom_page ( struct Menu menu)

Move the focus to the bottom of the page.

Parameters
menuCurrent Menu

Definition at line 794 of file menu.c.

795 {
796  if (menu->max)
797  {
798  menu->current = menu->top + menu->pagelen - 1;
799  if (menu->current > menu->max - 1)
800  menu->current = menu->max - 1;
801  menu->redraw = REDRAW_MOTION;
802  }
803  else
804  mutt_error(_("No entries"));
805 }
#define _(a)
Definition: message.h:28
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:41
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:79
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:63
int max
Number of entries in the menu.
Definition: mutt_menu.h:60
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:61
#define mutt_error(...)
Definition: logging.h:84
int current
Current entry.
Definition: mutt_menu.h:59
+ Here is the caller graph for this function:

◆ menu_check_recenter()

void menu_check_recenter ( struct Menu menu)

Recentre the menu on screen.

Parameters
menuCurrent Menu

Definition at line 565 of file menu.c.

566 {
567  int c = MIN(C_MenuContext, menu->pagelen / 2);
568  int old_top = menu->top;
569 
570  if (!C_MenuMoveOff && (menu->max <= menu->pagelen)) /* less entries than lines */
571  {
572  if (menu->top != 0)
573  {
574  menu->top = 0;
575  menu->redraw |= REDRAW_INDEX;
576  }
577  }
578  else
579  {
580  if (C_MenuScroll || (menu->pagelen <= 0) || (c < C_MenuContext))
581  {
582  if (menu->current < menu->top + c)
583  menu->top = menu->current - c;
584  else if (menu->current >= menu->top + menu->pagelen - c)
585  menu->top = menu->current - menu->pagelen + c + 1;
586  }
587  else
588  {
589  if (menu->current < menu->top + c)
590  {
591  menu->top -= (menu->pagelen - c) * ((menu->top + menu->pagelen - 1 - menu->current) /
592  (menu->pagelen - c)) -
593  c;
594  }
595  else if ((menu->current >= menu->top + menu->pagelen - c))
596  {
597  menu->top +=
598  (menu->pagelen - c) * ((menu->current - menu->top) / (menu->pagelen - c)) - c;
599  }
600  }
601  }
602 
603  if (!C_MenuMoveOff) /* make entries stick to bottom */
604  menu->top = MIN(menu->top, menu->max - menu->pagelen);
605  menu->top = MAX(menu->top, 0);
606 
607  if (menu->top != old_top)
608  menu->redraw |= REDRAW_INDEX;
609 }
#define MIN(a, b)
Definition: memory.h:31
#define MAX(a, b)
Definition: memory.h:30
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:79
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:63
int max
Number of entries in the menu.
Definition: mutt_menu.h:60
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:61
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:40
int current
Current entry.
Definition: mutt_menu.h:59
+ Here is the caller graph for this function:

◆ menu_current_bottom()

void menu_current_bottom ( struct Menu menu)

Move the current selection to the bottom of the window.

Parameters
menuCurrent Menu

Definition at line 891 of file menu.c.

892 {
893  if (menu->max)
894  {
895  menu->top = menu->current - menu->pagelen + 1;
896  if (menu->top < 0)
897  menu->top = 0;
898  menu->redraw = REDRAW_INDEX;
899  }
900  else
901  mutt_error(_("No entries"));
902 }
#define _(a)
Definition: message.h:28
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:79
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:63
int max
Number of entries in the menu.
Definition: mutt_menu.h:60
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:61
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:40
#define mutt_error(...)
Definition: logging.h:84
int current
Current entry.
Definition: mutt_menu.h:59
+ Here is the caller graph for this function:

◆ menu_current_middle()

void menu_current_middle ( struct Menu menu)

Move the current selection to the centre of the window.

Parameters
menuCurrent Menu

Definition at line 874 of file menu.c.

875 {
876  if (menu->max)
877  {
878  menu->top = menu->current - menu->pagelen / 2;
879  if (menu->top < 0)
880  menu->top = 0;
881  menu->redraw = REDRAW_INDEX;
882  }
883  else
884  mutt_error(_("No entries"));
885 }
#define _(a)
Definition: message.h:28
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:79
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:63
int max
Number of entries in the menu.
Definition: mutt_menu.h:60
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:61
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:40
#define mutt_error(...)
Definition: logging.h:84
int current
Current entry.
Definition: mutt_menu.h:59
+ Here is the caller graph for this function:

◆ menu_current_top()

void menu_current_top ( struct Menu menu)

Move the current selection to the top of the window.

Parameters
menuCurrent Menu

Definition at line 859 of file menu.c.

860 {
861  if (menu->max)
862  {
863  menu->top = menu->current;
864  menu->redraw = REDRAW_INDEX;
865  }
866  else
867  mutt_error(_("No entries"));
868 }
#define _(a)
Definition: message.h:28
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:79
int max
Number of entries in the menu.
Definition: mutt_menu.h:60
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:61
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:40
#define mutt_error(...)
Definition: logging.h:84
int current
Current entry.
Definition: mutt_menu.h:59
+ Here is the caller graph for this function:

◆ menu_first_entry()

void menu_first_entry ( struct Menu menu)

Move the focus to the first entry in the menu.

Parameters
menuCurrent Menu

Definition at line 829 of file menu.c.

830 {
831  if (menu->max)
832  {
833  menu->current = 0;
834  menu->redraw = REDRAW_MOTION;
835  }
836  else
837  mutt_error(_("No entries"));
838 }
#define _(a)
Definition: message.h:28
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:41
int max
Number of entries in the menu.
Definition: mutt_menu.h:60
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:61
#define mutt_error(...)
Definition: logging.h:84
int current
Current entry.
Definition: mutt_menu.h:59
+ Here is the caller graph for this function:

◆ menu_half_down()

void menu_half_down ( struct Menu menu)

Move the focus down half a page in the menu.

Parameters
menuCurrent Menu

Definition at line 763 of file menu.c.

764 {
765  menu_length_jump(menu, menu->pagelen / 2);
766 }
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:63
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_half_up()

void menu_half_up ( struct Menu menu)

Move the focus up half a page in the menu.

Parameters
menuCurrent Menu

Definition at line 772 of file menu.c.

773 {
774  menu_length_jump(menu, 0 - menu->pagelen / 2);
775 }
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:63
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_last_entry()

void menu_last_entry ( struct Menu menu)

Move the focus to the last entry in the menu.

Parameters
menuCurrent Menu

Definition at line 844 of file menu.c.

845 {
846  if (menu->max)
847  {
848  menu->current = menu->max - 1;
849  menu->redraw = REDRAW_MOTION;
850  }
851  else
852  mutt_error(_("No entries"));
853 }
#define _(a)
Definition: message.h:28
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:41
int max
Number of entries in the menu.
Definition: mutt_menu.h:60
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:61
#define mutt_error(...)
Definition: logging.h:84
int current
Current entry.
Definition: mutt_menu.h:59
+ Here is the caller graph for this function:

◆ menu_middle_page()

void menu_middle_page ( struct Menu menu)

Move the focus to the centre of the page.

Parameters
menuCurrent Menu

Definition at line 811 of file menu.c.

812 {
813  if (menu->max)
814  {
815  int i = menu->top + menu->pagelen;
816  if (i > menu->max - 1)
817  i = menu->max - 1;
818  menu->current = menu->top + (i - menu->top) / 2;
819  menu->redraw = REDRAW_MOTION;
820  }
821  else
822  mutt_error(_("No entries"));
823 }
#define _(a)
Definition: message.h:28
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:41
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:79
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:63
int max
Number of entries in the menu.
Definition: mutt_menu.h:60
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:61
#define mutt_error(...)
Definition: logging.h:84
int current
Current entry.
Definition: mutt_menu.h:59
+ Here is the caller graph for this function:

◆ menu_next_line()

void menu_next_line ( struct Menu menu)

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

Parameters
menuCurrent Menu

Definition at line 646 of file menu.c.

647 {
648  if (menu->max)
649  {
650  int c = MIN(C_MenuContext, menu->pagelen / 2);
651 
652  if ((menu->top + 1 < menu->max - c) &&
653  (C_MenuMoveOff ||
654  ((menu->max > menu->pagelen) && (menu->top < menu->max - menu->pagelen))))
655  {
656  menu->top++;
657  if ((menu->current < menu->top + c) && (menu->current < menu->max - 1))
658  menu->current++;
659  menu->redraw = REDRAW_INDEX;
660  }
661  else
662  mutt_message(_("You can't scroll down farther"));
663  }
664  else
665  mutt_error(_("No entries"));
666 }
#define MIN(a, b)
Definition: memory.h:31
#define mutt_message(...)
Definition: logging.h:83
#define _(a)
Definition: message.h:28
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:79
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:63
int max
Number of entries in the menu.
Definition: mutt_menu.h:60
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:61
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:40
#define mutt_error(...)
Definition: logging.h:84
int current
Current entry.
Definition: mutt_menu.h:59
+ Here is the caller graph for this function:

◆ menu_next_page()

void menu_next_page ( struct Menu menu)

Move the focus to the next page in the menu.

Parameters
menuCurrent Menu

Definition at line 745 of file menu.c.

746 {
747  menu_length_jump(menu, MAX(menu->pagelen /* - MenuOverlap */, 0));
748 }
#define MAX(a, b)
Definition: memory.h:30
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:63
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_prev_line()

void menu_prev_line ( struct Menu menu)

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

Parameters
menuCurrent Menu

Definition at line 672 of file menu.c.

673 {
674  if (menu->top > 0)
675  {
676  int c = MIN(C_MenuContext, menu->pagelen / 2);
677 
678  menu->top--;
679  if ((menu->current >= menu->top + menu->pagelen - c) && (menu->current > 1))
680  menu->current--;
681  menu->redraw = REDRAW_INDEX;
682  }
683  else
684  mutt_message(_("You can't scroll up farther"));
685 }
#define MIN(a, b)
Definition: memory.h:31
#define mutt_message(...)
Definition: logging.h:83
#define _(a)
Definition: message.h:28
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:79
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:63
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:61
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:40
int current
Current entry.
Definition: mutt_menu.h:59
+ Here is the caller graph for this function:

◆ menu_prev_page()

void menu_prev_page ( struct Menu menu)

Move the focus to the previous page in the menu.

Parameters
menuCurrent Menu

Definition at line 754 of file menu.c.

755 {
756  menu_length_jump(menu, 0 - MAX(menu->pagelen /* - MenuOverlap */, 0));
757 }
#define MAX(a, b)
Definition: memory.h:30
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:63
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_redraw_current()

void menu_redraw_current ( struct Menu menu)

Redraw the current menu.

Parameters
menuCurrent Menu

Definition at line 515 of file menu.c.

516 {
517  char buf[1024];
518  int attr = menu->color(menu->current);
519 
520  mutt_window_move(menu->win_index, 0, menu->current - menu->top);
521  make_entry(buf, sizeof(buf), menu, menu->current);
522  menu_pad_string(menu, buf, sizeof(buf));
523 
525  if (C_ArrowCursor)
526  {
528  mutt_curses_set_attr(attr);
529  mutt_window_addch(' ');
530  menu_pad_string(menu, buf, sizeof(buf));
531  print_enriched_string(menu->current, attr, (unsigned char *) buf, true);
532  }
533  else
534  print_enriched_string(menu->current, attr, (unsigned char *) buf, false);
535  menu->redraw &= REDRAW_STATUS;
537 }
void mutt_curses_set_color(enum ColorId color)
Set the current colour for text.
Definition: mutt_curses.c:57
int mutt_window_move(struct MuttWindow *win, int col, int row)
Move the cursor in a Window.
Definition: mutt_window.c:392
Plain text.
Definition: color.h:77
#define REDRAW_STATUS
Redraw the status bar.
Definition: mutt_menu.h:44
int(* color)(int line)
Calculate the colour for a line of the menu.
Definition: mutt_menu.h:119
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:79
Selected item in list.
Definition: color.h:73
WHERE bool C_ArrowCursor
Config: Use an arrow &#39;->&#39; instead of highlighting in the index.
Definition: mutt_globals.h:133
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:61
int mutt_window_addch(int ch)
Write one character to a Window.
Definition: mutt_window.c:502
int mutt_window_addstr(const char *str)
Write a string to a Window.
Definition: mutt_window.c:532
int current
Current entry.
Definition: mutt_menu.h:59
struct MuttWindow * win_index
Definition: mutt_menu.h:66
void mutt_curses_set_attr(int attr)
Set the attributes for text.
Definition: mutt_curses.c:40
WHERE char * C_ArrowString
Config: Use an custom string for arrow_cursor.
Definition: mutt_globals.h:134
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_redraw_full()

void menu_redraw_full ( struct Menu menu)

Force the redraw of the Menu.

Parameters
menuCurrent Menu

Definition at line 352 of file menu.c.

353 {
355  /* clear() doesn't optimize screen redraws */
356  mutt_window_move_abs(0, 0);
358 
359  window_redraw(RootWindow, true);
360  menu->pagelen = menu->win_index->state.rows;
361 
362  mutt_show_error();
363 
365 #ifdef USE_SIDEBAR
366  menu->redraw |= REDRAW_SIDEBAR;
367 #endif
368 }
void mutt_curses_set_color(enum ColorId color)
Set the current colour for text.
Definition: mutt_curses.c:57
struct MuttWindow * RootWindow
Parent of all Windows.
Definition: mutt_window.c:45
void mutt_window_move_abs(int col, int row)
Move the cursor to an absolute screen position.
Definition: mutt_window.c:549
#define REDRAW_SIDEBAR
Redraw the sidebar.
Definition: mutt_menu.h:49
void mutt_window_clrtobot(void)
Clear to the bottom of the Window.
Definition: mutt_window.c:243
Plain text.
Definition: color.h:77
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:120
#define REDRAW_STATUS
Redraw the status bar.
Definition: mutt_menu.h:44
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:58
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:63
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:61
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:40
void window_redraw(struct MuttWindow *win, bool force)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:757
void mutt_show_error(void)
Show the user an error message.
Definition: curs_lib.c:557
struct MuttWindow * win_index
Definition: mutt_menu.h:66
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_redraw_index()

void menu_redraw_index ( struct Menu menu)

Force the redraw of the index.

Parameters
menuCurrent Menu

Definition at line 404 of file menu.c.

405 {
406  char buf[1024];
407  bool do_color;
408  int attr;
409 
410  for (int i = menu->top; i < menu->top + menu->pagelen; i++)
411  {
412  if (i < menu->max)
413  {
414  attr = menu->color(i);
415 
416  make_entry(buf, sizeof(buf), menu, i);
417  menu_pad_string(menu, buf, sizeof(buf));
418 
419  mutt_curses_set_attr(attr);
420  mutt_window_move(menu->win_index, 0, i - menu->top);
421  do_color = true;
422 
423  if (i == menu->current)
424  {
426  if (C_ArrowCursor)
427  {
429  mutt_curses_set_attr(attr);
430  mutt_window_addch(' ');
431  }
432  else
433  do_color = false;
434  }
435  else if (C_ArrowCursor)
436  /* Print space chars to match the screen width of C_ArrowString */
438 
439  print_enriched_string(i, attr, (unsigned char *) buf, do_color);
440  }
441  else
442  {
444  mutt_window_clearline(menu->win_index, i - menu->top);
445  }
446  }
448  menu->redraw = 0;
449 }
void mutt_curses_set_color(enum ColorId color)
Set the current colour for text.
Definition: mutt_curses.c:57
int mutt_window_move(struct MuttWindow *win, int col, int row)
Move the cursor in a Window.
Definition: mutt_window.c:392
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:232
Plain text.
Definition: color.h:77
int(* color)(int line)
Calculate the colour for a line of the menu.
Definition: mutt_menu.h:119
int mutt_strwidth(const char *s)
Measure a string&#39;s width in screen cells.
Definition: curs_lib.c:1359
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:79
Selected item in list.
Definition: color.h:73
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:63
WHERE bool C_ArrowCursor
Config: Use an arrow &#39;->&#39; instead of highlighting in the index.
Definition: mutt_globals.h:133
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:61
int mutt_window_printf(const char *fmt,...)
Write a formatted string to a Window.
Definition: mutt_window.c:560
int mutt_window_addch(int ch)
Write one character to a Window.
Definition: mutt_window.c:502
int mutt_window_addstr(const char *str)
Write a string to a Window.
Definition: mutt_window.c:532
int current
Current entry.
Definition: mutt_menu.h:59
struct MuttWindow * win_index
Definition: mutt_menu.h:66
void mutt_curses_set_attr(int attr)
Set the attributes for text.
Definition: mutt_curses.c:40
WHERE char * C_ArrowString
Config: Use an custom string for arrow_cursor.
Definition: mutt_globals.h:134
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_redraw_motion()

void menu_redraw_motion ( struct Menu menu)

Force the redraw of the list part of the menu.

Parameters
menuCurrent Menu

Definition at line 455 of file menu.c.

456 {
457  char buf[1024];
458 
459  if (menu->dialog)
460  {
461  menu->redraw &= ~REDRAW_MOTION;
462  return;
463  }
464 
465  /* Note: menu->color() for the index can end up retrieving a message
466  * over imap (if matching against ~h for instance). This can
467  * generate status messages. So we want to call it *before* we
468  * position the cursor for drawing. */
469  const int old_color = menu->color(menu->oldcurrent);
470  mutt_window_move(menu->win_index, 0, menu->oldcurrent - menu->top);
471  mutt_curses_set_attr(old_color);
472 
473  if (C_ArrowCursor)
474  {
475  /* clear the arrow */
476  /* Print space chars to match the screen width of C_ArrowString */
478 
479  if (menu->redraw & REDRAW_MOTION_RESYNC)
480  {
481  make_entry(buf, sizeof(buf), menu, menu->oldcurrent);
482  menu_pad_string(menu, buf, sizeof(buf));
484  menu->oldcurrent - menu->top);
485  print_enriched_string(menu->oldcurrent, old_color, (unsigned char *) buf, true);
486  }
487 
488  /* now draw it in the new location */
490  mutt_window_mvaddstr(menu->win_index, 0, menu->current - menu->top, C_ArrowString);
491  }
492  else
493  {
494  /* erase the current indicator */
495  make_entry(buf, sizeof(buf), menu, menu->oldcurrent);
496  menu_pad_string(menu, buf, sizeof(buf));
497  print_enriched_string(menu->oldcurrent, old_color, (unsigned char *) buf, true);
498 
499  /* now draw the new one to reflect the change */
500  const int cur_color = menu->color(menu->current);
501  make_entry(buf, sizeof(buf), menu, menu->current);
502  menu_pad_string(menu, buf, sizeof(buf));
504  mutt_window_move(menu->win_index, 0, menu->current - menu->top);
505  print_enriched_string(menu->current, cur_color, (unsigned char *) buf, false);
506  }
507  menu->redraw &= REDRAW_STATUS;
509 }
int oldcurrent
For driver use only.
Definition: mutt_menu.h:80
void mutt_curses_set_color(enum ColorId color)
Set the current colour for text.
Definition: mutt_curses.c:57
char ** dialog
Dialog lines themselves.
Definition: mutt_menu.h:73
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:406
int mutt_window_move(struct MuttWindow *win, int col, int row)
Move the cursor in a Window.
Definition: mutt_window.c:392
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:41
Plain text.
Definition: color.h:77
#define REDRAW_MOTION_RESYNC
Redraw any changing the menu selection.
Definition: mutt_menu.h:42
#define REDRAW_STATUS
Redraw the status bar.
Definition: mutt_menu.h:44
int(* color)(int line)
Calculate the colour for a line of the menu.
Definition: mutt_menu.h:119
int mutt_strwidth(const char *s)
Measure a string&#39;s width in screen cells.
Definition: curs_lib.c:1359
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:79
Selected item in list.
Definition: color.h:73
WHERE bool C_ArrowCursor
Config: Use an arrow &#39;->&#39; instead of highlighting in the index.
Definition: mutt_globals.h:133
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:61
int mutt_window_printf(const char *fmt,...)
Write a formatted string to a Window.
Definition: mutt_window.c:560
int current
Current entry.
Definition: mutt_menu.h:59
struct MuttWindow * win_index
Definition: mutt_menu.h:66
void mutt_curses_set_attr(int attr)
Set the attributes for text.
Definition: mutt_curses.c:40
WHERE char * C_ArrowString
Config: Use an custom string for arrow_cursor.
Definition: mutt_globals.h:134
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_redraw_sidebar()

void menu_redraw_sidebar ( struct Menu menu)

Force the redraw of the sidebar.

Parameters
menuCurrent Menu

Definition at line 391 of file menu.c.

392 {
393  menu->redraw &= ~REDRAW_SIDEBAR;
394  struct MuttWindow *dlg = dialog_find(menu->win_index);
395  struct MuttWindow *sidebar = mutt_window_find(dlg, WT_SIDEBAR);
396  sb_draw(sidebar);
397 }
struct MuttWindow * mutt_window_find(struct MuttWindow *root, enum WindowType type)
Find a Window of a given type.
Definition: mutt_window.c:688
A division of the screen.
Definition: mutt_window.h:115
#define REDRAW_SIDEBAR
Redraw the sidebar.
Definition: mutt_menu.h:49
Side panel containing Accounts or groups of data.
Definition: mutt_window.h:99
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:61
struct MuttWindow * win_index
Definition: mutt_menu.h:66
struct MuttWindow * dialog_find(struct MuttWindow *win)
Find the parent Dialog of a Window.
Definition: dialog.c:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_redraw_status()

void menu_redraw_status ( struct Menu menu)

Force the redraw of the status bar.

Parameters
menuCurrent Menu

Definition at line 374 of file menu.c.

375 {
376  char buf[256];
377 
378  snprintf(buf, sizeof(buf), "-- NeoMutt: %s", menu->title);
380  mutt_window_move(menu->win_ibar, 0, 0);
381  mutt_paddstr(menu->win_ibar->state.cols, buf);
383  menu->redraw &= ~REDRAW_STATUS;
384 }
void mutt_curses_set_color(enum ColorId color)
Set the current colour for text.
Definition: mutt_curses.c:57
void mutt_paddstr(int n, const char *s)
Display a string on screen, padded if necessary.
Definition: curs_lib.c:1266
int mutt_window_move(struct MuttWindow *win, int col, int row)
Move the cursor in a Window.
Definition: mutt_window.c:392
struct MuttWindow * win_ibar
Definition: mutt_menu.h:67
const char * title
Title of this menu.
Definition: mutt_menu.h:57
Plain text.
Definition: color.h:77
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:57
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:120
#define REDRAW_STATUS
Redraw the status bar.
Definition: mutt_menu.h:44
Status bar (takes a pattern)
Definition: color.h:94
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:61
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_redraw()

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

1296 {
1297  if (menu->custom_redraw)
1298  {
1299  menu->custom_redraw(menu);
1300  return OP_NULL;
1301  }
1302 
1303  /* See if all or part of the screen needs to be updated. */
1304  if (menu->redraw & REDRAW_FULL)
1305  {
1306  menu_redraw_full(menu);
1307  /* allow the caller to do any local configuration */
1308  return OP_REDRAW;
1309  }
1310 
1311  if (!menu->dialog)
1312  menu_check_recenter(menu);
1313 
1314  if (menu->redraw & REDRAW_STATUS)
1315  menu_redraw_status(menu);
1316 #ifdef USE_SIDEBAR
1317  if (menu->redraw & REDRAW_SIDEBAR)
1318  menu_redraw_sidebar(menu);
1319 #endif
1320  if (menu->redraw & REDRAW_INDEX)
1321  menu_redraw_index(menu);
1322  else if (menu->redraw & (REDRAW_MOTION | REDRAW_MOTION_RESYNC))
1323  menu_redraw_motion(menu);
1324  else if (menu->redraw == REDRAW_CURRENT)
1325  menu_redraw_current(menu);
1326 
1327  if (menu->dialog)
1328  menu_redraw_prompt(menu);
1329 
1330  return OP_NULL;
1331 }
#define REDRAW_FULL
Redraw everything.
Definition: mutt_menu.h:45
char ** dialog
Dialog lines themselves.
Definition: mutt_menu.h:73
#define REDRAW_SIDEBAR
Redraw the sidebar.
Definition: mutt_menu.h:49
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:41
#define REDRAW_MOTION_RESYNC
Redraw any changing the menu selection.
Definition: mutt_menu.h:42
#define REDRAW_STATUS
Redraw the status bar.
Definition: mutt_menu.h:44
void(* custom_redraw)(struct Menu *menu)
Redraw the menu.
Definition: mutt_menu.h:125
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:61
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:40
#define REDRAW_CURRENT
Redraw the current line of the menu.
Definition: mutt_menu.h:43
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_top_page()

void menu_top_page ( struct Menu menu)

Move the focus to the top of the page.

Parameters
menuCurrent Menu

Definition at line 781 of file menu.c.

782 {
783  if (menu->current == menu->top)
784  return;
785 
786  menu->current = menu->top;
787  menu->redraw = REDRAW_MOTION;
788 }
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:41
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:79
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:61
int current
Current entry.
Definition: mutt_menu.h:59
+ Here is the caller graph for this function:

◆ mutt_menu_add_dialog_row()

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

Add a row to a Menu.

Parameters
menuMenu to add to
rowRow of text to add

Definition at line 1008 of file menu.c.

1009 {
1010  if (menu->dsize <= menu->max)
1011  {
1012  menu->dsize += 10;
1013  mutt_mem_realloc(&menu->dialog, menu->dsize * sizeof(char *));
1014  }
1015  menu->dialog[menu->max++] = mutt_str_dup(row);
1016 }
char ** dialog
Dialog lines themselves.
Definition: mutt_menu.h:73
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:375
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Definition: memory.c:114
int max
Number of entries in the menu.
Definition: mutt_menu.h:60
int dsize
Number of allocated dialog lines.
Definition: mutt_menu.h:74
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_menu_current_redraw()

void mutt_menu_current_redraw ( void  )

Redraw the current menu.

Definition at line 1132 of file menu.c.

1133 {
1134  struct Menu *current_menu = get_current_menu();
1135  if (current_menu)
1136  {
1137  if (menu_redraw(current_menu) == OP_REDRAW)
1138  {
1139  /* On a REDRAW_FULL with a non-customized redraw, menu_redraw()
1140  * will return OP_REDRAW to give the calling menu-loop a chance to
1141  * customize output. */
1142  menu_redraw(current_menu);
1143  }
1144  }
1145 }
GUI selectable list of items.
Definition: mutt_menu.h:55
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_menu_free()

void mutt_menu_free ( struct Menu **  ptr)

Destroy a menu.

Parameters
[out]ptrMenu to destroy

Definition at line 986 of file menu.c.

987 {
988  if (!ptr || !*ptr)
989  return;
990 
991  struct Menu *m = *ptr;
992  if (m->dialog)
993  {
994  for (int i = 0; i < m->max; i++)
995  FREE(&m->dialog[i]);
996 
997  FREE(&m->dialog);
998  }
999 
1000  FREE(ptr);
1001 }
GUI selectable list of items.
Definition: mutt_menu.h:55
char ** dialog
Dialog lines themselves.
Definition: mutt_menu.h:73
int max
Number of entries in the menu.
Definition: mutt_menu.h:60
#define FREE(x)
Definition: memory.h:40
+ Here is the caller graph for this function:

◆ mutt_menu_init()

void mutt_menu_init ( void  )

Initialise all the Menus.

Definition at line 956 of file menu.c.

957 {
958  for (int i = 0; i < MENU_MAX; i++)
959  SearchBuffers[i] = NULL;
960 }
+ Here is the caller graph for this function:

◆ mutt_menu_loop()

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

1339 {
1340  static int last_position = -1;
1341  int i = OP_NULL;
1342 
1343  if (menu->max && menu->is_mailbox_list)
1344  {
1345  if (last_position > (menu->max - 1))
1346  last_position = -1;
1347  else if (last_position >= 0)
1348  menu->current = last_position;
1349  }
1350 
1351  while (true)
1352  {
1353  /* Clear the tag prefix unless we just started it. Don't clear
1354  * the prefix on a timeout (i==-2), but do clear on an abort (i==-1) */
1355  if (menu->tagprefix && (i != OP_TAG_PREFIX) && (i != OP_TAG_PREFIX_COND) && (i != -2))
1356  menu->tagprefix = false;
1357 
1359 
1360  if (menu_redraw(menu) == OP_REDRAW)
1361  return OP_REDRAW;
1362 
1363  /* give visual indication that the next command is a tag- command */
1364  if (menu->tagprefix)
1365  {
1366  mutt_window_mvaddstr(MessageWindow, 0, 0, "tag-");
1368  }
1369 
1370  menu->oldcurrent = menu->current;
1371 
1372  /* move the cursor out of the way */
1373  if (C_ArrowCursor)
1374  mutt_window_move(menu->win_index, 2, menu->current - menu->top);
1375  else if (C_BrailleFriendly)
1376  mutt_window_move(menu->win_index, 0, menu->current - menu->top);
1377  else
1378  {
1379  mutt_window_move(menu->win_index, menu->win_index->state.cols - 1,
1380  menu->current - menu->top);
1381  }
1382 
1383  mutt_refresh();
1384 
1385  /* try to catch dialog keys before ops */
1386  if (menu->dialog && (menu_dialog_dokey(menu, &i) == 0))
1387  return i;
1388 
1389  i = km_dokey(menu->type);
1390  if ((i == OP_TAG_PREFIX) || (i == OP_TAG_PREFIX_COND))
1391  {
1392  if (menu->tagprefix)
1393  {
1394  menu->tagprefix = false;
1396  continue;
1397  }
1398 
1399  if (menu->tagged)
1400  {
1401  menu->tagprefix = true;
1402  continue;
1403  }
1404  else if (i == OP_TAG_PREFIX)
1405  {
1406  mutt_error(_("No tagged entries"));
1407  i = -1;
1408  }
1409  else /* None tagged, OP_TAG_PREFIX_COND */
1410  {
1412  mutt_message(_("Nothing to do"));
1413  i = -1;
1414  }
1415  }
1416  else if (menu->tagged && C_AutoTag)
1417  menu->tagprefix = true;
1418 
1420 
1421  if (SigWinch)
1422  {
1423  SigWinch = 0;
1425  clearok(stdscr, true); /* force complete redraw */
1426  }
1427 
1428  if (i < 0)
1429  {
1430  if (menu->tagprefix)
1432  continue;
1433  }
1434 
1435  if (!menu->dialog)
1436  mutt_clear_error();
1437 
1438  /* Convert menubar movement to scrolling */
1439  if (menu->dialog)
1440  i = menu_dialog_translate_op(i);
1441 
1442  switch (i)
1443  {
1444  case OP_NEXT_ENTRY:
1445  menu_next_entry(menu);
1446  break;
1447  case OP_PREV_ENTRY:
1448  menu_prev_entry(menu);
1449  break;
1450  case OP_HALF_DOWN:
1451  menu_half_down(menu);
1452  break;
1453  case OP_HALF_UP:
1454  menu_half_up(menu);
1455  break;
1456  case OP_NEXT_PAGE:
1457  menu_next_page(menu);
1458  break;
1459  case OP_PREV_PAGE:
1460  menu_prev_page(menu);
1461  break;
1462  case OP_NEXT_LINE:
1463  menu_next_line(menu);
1464  break;
1465  case OP_PREV_LINE:
1466  menu_prev_line(menu);
1467  break;
1468  case OP_FIRST_ENTRY:
1469  menu_first_entry(menu);
1470  break;
1471  case OP_LAST_ENTRY:
1472  menu_last_entry(menu);
1473  break;
1474  case OP_TOP_PAGE:
1475  menu_top_page(menu);
1476  break;
1477  case OP_MIDDLE_PAGE:
1478  menu_middle_page(menu);
1479  break;
1480  case OP_BOTTOM_PAGE:
1481  menu_bottom_page(menu);
1482  break;
1483  case OP_CURRENT_TOP:
1484  menu_current_top(menu);
1485  break;
1486  case OP_CURRENT_MIDDLE:
1487  menu_current_middle(menu);
1488  break;
1489  case OP_CURRENT_BOTTOM:
1490  menu_current_bottom(menu);
1491  break;
1492  case OP_SEARCH:
1493  case OP_SEARCH_REVERSE:
1494  case OP_SEARCH_NEXT:
1495  case OP_SEARCH_OPPOSITE:
1496  if (menu->custom_search)
1497  return i;
1498  else if (menu->search && !menu->dialog) /* Searching dialogs won't work */
1499  {
1500  menu->oldcurrent = menu->current;
1501  menu->current = search(menu, i);
1502  if (menu->current != -1)
1503  menu->redraw = REDRAW_MOTION;
1504  else
1505  menu->current = menu->oldcurrent;
1506  }
1507  else
1508  mutt_error(_("Search is not implemented for this menu"));
1509  break;
1510 
1511  case OP_JUMP:
1512  if (menu->dialog)
1513  mutt_error(_("Jumping is not implemented for dialogs"));
1514  else
1515  menu_jump(menu);
1516  break;
1517 
1518  case OP_ENTER_COMMAND:
1520  window_set_focus(menu->win_index);
1521  window_redraw(RootWindow, false);
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 }
int km_dokey(enum MenuType menu)
Determine what a keypress should do.
Definition: keymap.c:658
#define REDRAW_FULL
Redraw everything.
Definition: mutt_menu.h:45
void window_set_focus(struct MuttWindow *win)
Set the Window focus.
Definition: mutt_window.c:773
#define mutt_message(...)
Definition: logging.h:83
int oldcurrent
For driver use only.
Definition: mutt_menu.h:80
void mutt_window_clrtoeol(struct MuttWindow *win)
Clear to the end of the line.
Definition: mutt_window.c:254
void mutt_resize_screen(void)
Update NeoMutt&#39;s opinion about the window size (CURSES)
Definition: resize.c:101
void mutt_check_stats(void)
Forcibly update mailbox stats.
Definition: commands.c:1428
struct MuttWindow * RootWindow
Parent of all Windows.
Definition: mutt_window.c:45
char ** dialog
Dialog lines themselves.
Definition: mutt_menu.h:73
void mutt_enter_command(void)
enter a neomutt command
Definition: commands.c:872
#define _(a)
Definition: message.h:28
WHERE bool C_BrailleFriendly
Config: Move the cursor to the beginning of the line.
Definition: mutt_globals.h:142
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:406
WHERE bool C_AutoTag
Config: Automatically apply actions to all tagged messages.
Definition: mutt_globals.h:139
int mutt_window_move(struct MuttWindow *win, int col, int row)
Move the cursor in a Window.
Definition: mutt_window.c:392
void mutt_curses_set_cursor(enum MuttCursorState state)
Set the cursor state.
Definition: mutt_curses.c:78
enum MenuType type
Menu definition for keymap entries.
Definition: mutt_menu.h:62
void mutt_flush_macro_to_endcond(void)
Drop a macro from the input buffer.
Definition: curs_lib.c:890
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:232
void mutt_what_key(void)
Ask the user to press a key.
Definition: keymap.c:1676
Display a normal cursor.
Definition: mutt_curses.h:81
void mutt_shell_escape(void)
invoke a command in a subshell
Definition: commands.c:844
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:113
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:41
#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
void mutt_refresh(void)
Force a refresh of the screen.
Definition: curs_lib.c:108
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:120
struct MuttWindow * MessageWindow
Message Window, ":set", etc.
Definition: mutt_window.c:47
void km_error_key(enum MenuType menu)
Handle an unbound key sequence.
Definition: keymap.c:1137
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:79
bool tagprefix
Definition: mutt_menu.h:64
bool is_mailbox_list
Definition: mutt_menu.h:65
int(* tag)(struct Menu *menu, int sel, int act)
Tag some menu items.
Definition: mutt_menu.h:111
bool custom_search
The menu implements its own non-Menusearch()-compatible search, trickle OP_SEARCH*.
Definition: mutt_menu.h:83
int tagged
Number of tagged entries.
Definition: mutt_menu.h:82
int max
Number of entries in the menu.
Definition: mutt_menu.h:60
WHERE bool C_ArrowCursor
Config: Use an arrow &#39;->&#39; instead of highlighting in the index.
Definition: mutt_globals.h:133
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:61
#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:386
#define mutt_error(...)
Definition: logging.h:84
Hide the cursor.
Definition: mutt_curses.h:80
void window_redraw(struct MuttWindow *win, bool force)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:757
int current
Current entry.
Definition: mutt_menu.h:59
struct MuttWindow * win_index
Definition: mutt_menu.h:66
WHERE SIG_ATOMIC_VOLATILE_T SigWinch
true after SIGWINCH is received
Definition: mutt_globals.h:75
int(* search)(struct Menu *menu, regex_t *rx, int line)
Search a menu for a item matching a regex.
Definition: mutt_menu.h:102
#define REDRAW_CURRENT
Redraw the current line of the menu.
Definition: mutt_menu.h:43
WHERE bool C_Resolve
Config: Move to the next email whenever a command modifies an email.
Definition: mutt_globals.h:157
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_menu_new()

struct Menu* mutt_menu_new ( enum MenuType  type)

Create a new Menu.

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

Definition at line 967 of file menu.c.

968 {
969  struct Menu *menu = mutt_mem_calloc(1, sizeof(struct Menu));
970 
971  menu->type = type;
972  menu->current = 0;
973  menu->top = 0;
974  menu->redraw = REDRAW_FULL;
975  menu->color = default_color;
976  menu->search = generic_search;
977  menu->custom_search = false;
978 
979  return menu;
980 }
#define REDRAW_FULL
Redraw everything.
Definition: mutt_menu.h:45
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
GUI selectable list of items.
Definition: mutt_menu.h:55
enum MenuType type
Menu definition for keymap entries.
Definition: mutt_menu.h:62
int(* color)(int line)
Calculate the colour for a line of the menu.
Definition: mutt_menu.h:119
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:79
bool custom_search
The menu implements its own non-Menusearch()-compatible search, trickle OP_SEARCH*.
Definition: mutt_menu.h:83
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:61
int current
Current entry.
Definition: mutt_menu.h:59
int(* search)(struct Menu *menu, regex_t *rx, int line)
Search a menu for a item matching a regex.
Definition: mutt_menu.h:102
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_menu_pop_current()

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

1052 {
1053  struct Menu *prev_menu = NULL;
1054 
1055  if (!MenuStackCount || (MenuStack[MenuStackCount - 1] != menu))
1056  {
1057  mutt_debug(LL_DEBUG1, "called with inactive menu\n");
1058  return;
1059  }
1060 
1061  MenuStackCount--;
1062  prev_menu = get_current_menu();
1063  if (prev_menu)
1064  {
1065  CurrentMenu = prev_menu->type;
1066  prev_menu->redraw = REDRAW_FULL;
1067  }
1068  else
1069  {
1071  /* Clearing when NeoMutt exits would be an annoying change in behavior for
1072  * those who have disabled alternative screens. The option is currently
1073  * set by autocrypt initialization which mixes menus and prompts outside of
1074  * the normal menu system state. */
1076  {
1077  mutt_window_move_abs(0, 0);
1079  }
1080  }
1081 }
#define REDRAW_FULL
Redraw everything.
Definition: mutt_menu.h:45
GUI selectable list of items.
Definition: mutt_menu.h:55
void mutt_window_move_abs(int col, int row)
Move the cursor to an absolute screen position.
Definition: mutt_window.c:549
Index panel (list of emails)
Definition: keymap.h:80
WHERE enum MenuType CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: mutt_globals.h:77
enum MenuType type
Menu definition for keymap entries.
Definition: mutt_menu.h:62
WHERE bool OptMenuPopClearScreen
(pseudo) clear the screen when popping the last menu
Definition: options.h:40
void mutt_window_clrtobot(void)
Clear to the bottom of the Window.
Definition: mutt_window.c:243
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:61
Log at debug level 1.
Definition: logging.h:40
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_menu_push_current()

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

1034 {
1036  {
1037  MenuStackLen += 5;
1038  mutt_mem_realloc(&MenuStack, MenuStackLen * sizeof(struct Menu *));
1039  }
1040 
1041  MenuStack[MenuStackCount++] = menu;
1042  CurrentMenu = menu->type;
1043 }
GUI selectable list of items.
Definition: mutt_menu.h:55
WHERE enum MenuType CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: mutt_globals.h:77
enum MenuType type
Menu definition for keymap entries.
Definition: mutt_menu.h:62
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Definition: memory.c:114
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_menu_set_current_redraw_full()

void mutt_menu_set_current_redraw_full ( void  )

Flag the current menu to be fully redrawn.

Definition at line 1097 of file menu.c.

1098 {
1099  struct Menu *current_menu = get_current_menu();
1100  if (current_menu)
1101  current_menu->redraw = REDRAW_FULL;
1102 }
#define REDRAW_FULL
Redraw everything.
Definition: mutt_menu.h:45
GUI selectable list of items.
Definition: mutt_menu.h:55
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:61
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_menu_set_current_redraw()

void mutt_menu_set_current_redraw ( MuttRedrawFlags  redraw)

Set redraw flags on the current menu.

Parameters
redrawFlags to set, see MuttRedrawFlags

Definition at line 1087 of file menu.c.

1088 {
1089  struct Menu *current_menu = get_current_menu();
1090  if (current_menu)
1091  current_menu->redraw |= redraw;
1092 }
GUI selectable list of items.
Definition: mutt_menu.h:55
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:61
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_menu_set_redraw_full()

void mutt_menu_set_redraw_full ( enum MenuType  menu)

Flag a menu to be fully redrawn.

Parameters
menuMenu type, e.g. MENU_ALIAS

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

Definition at line 1123 of file menu.c.

1124 {
1125  if (CurrentMenu == menu)
1127 }
WHERE enum MenuType CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: mutt_globals.h:77
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_menu_set_redraw()

void mutt_menu_set_redraw ( enum MenuType  menu,
MuttRedrawFlags  redraw 
)

Set redraw flags on a menu.

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

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

Definition at line 1111 of file menu.c.

1112 {
1113  if (CurrentMenu == menu)
1115 }
WHERE enum MenuType CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: mutt_globals.h:77
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:61
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_menu_color_observer()

int mutt_menu_color_observer ( struct NotifyCallback nc)

Listen for colour changes affecting the menu - Implements observer_t.

Definition at line 1593 of file menu.c.

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 }
struct Email ** emails
Array of Emails.
Definition: mailbox.h:99
MIME attachment test (takes a pattern)
Definition: color.h:62
The "current" mailbox.
Definition: context.h:38
Index: index number.
Definition: color.h:109
int msg_count
Total number of messages.
Definition: mailbox.h:91
The envelope/body of an email.
Definition: email.h:37
Index: tags field (g, J)
Definition: color.h:111
An Event that happened to a Colour.
Definition: color.h:158
Pager: highlight body of message (takes a pattern)
Definition: color.h:63
Index panel (list of emails)
Definition: keymap.h:80
Index: number of messages in collapsed thread.
Definition: color.h:106
int event_subtype
Send: Event subtype, e.g. NT_ACCOUNT_ADD.
Definition: observer.h:43
enum NotifyType event_type
Send: Event type, e.g. NT_ACCOUNT.
Definition: observer.h:42
Index: author field (takes a pattern)
Definition: color.h:101
bool set
True if a colour has been set/added, false if reset/deleted.
Definition: color.h:160
struct Mailbox * mailbox
Definition: context.h:50
Message headers (takes a pattern)
Definition: color.h:72
Index: tag field (g, takes a pattern)
Definition: color.h:104
Index: date field.
Definition: color.h:107
Index: size field.
Definition: color.h:110
A mailbox.
Definition: mailbox.h:81
void * event_data
Data from notify_send()
Definition: observer.h:44
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:37
Index: label field.
Definition: color.h:108
Index: subject field (takes a pattern)
Definition: color.h:103
Index: default colour (takes a pattern)
Definition: color.h:100
int pair
Color-pair to use when displaying in the index.
Definition: email.h:80
Index: flags field (takes a pattern)
Definition: color.h:102
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_menu_config_observer()

int mutt_menu_config_observer ( struct NotifyCallback nc)

Listen for config changes affecting the menu - Implements observer_t.

Definition at line 1637 of file menu.c.

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 }
#define R_PAGER
Redraw the pager menu.
Definition: types.h:66
#define R_PAGER_FLOW
Reflow line_info and redraw the pager menu.
Definition: types.h:67
#define REDRAW_FLOW
Used by pager to reflow text.
Definition: mutt_menu.h:47
WHERE bool OptNeedResort
(pseudo) used to force a re-sort
Definition: options.h:43
A config-change event.
Definition: subset.h:70
Index panel (list of emails)
Definition: keymap.h:80
Config item definition.
Definition: set.h:61
#define R_RESORT
Resort the mailbox.
Definition: types.h:68
#define REDRAW_SIDEBAR
Redraw the sidebar.
Definition: mutt_menu.h:49
#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:42
Pager pager (email viewer)
Definition: keymap.h:81
#define R_REDRAW_NO_FLAGS
No refresh/resort flags.
Definition: types.h:64
struct HashElem * he
Config item that changed.
Definition: subset.h:74
#define R_MENU
Redraw all menus.
Definition: types.h:74
#define R_RESORT_SUB
Resort subthreads.
Definition: types.h:69
#define R_REFLOW
Reflow window layout and full redraw.
Definition: types.h:72
uint32_t ConfigRedrawFlags
Flags for redraw/resort, e.g. R_INDEX.
Definition: types.h:63
WHERE bool OptRedrawTree
(pseudo) redraw the thread tree
Definition: options.h:50
WHERE bool OptResortInit
(pseudo) used to force the next resort to be from scratch
Definition: options.h:51
void * event_data
Data from notify_send()
Definition: observer.h:44
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:37
void * data
User-supplied data.
Definition: hash.h:47
unsigned int type
Variable type, e.g. DT_STRING.
Definition: set.h:64
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
Definition: mutt_window.c:443
#define R_RESORT_INIT
Resort from scratch.
Definition: types.h:70
WHERE bool OptSortSubthreads
(pseudo) used when $sort_aux changes
Definition: options.h:54
#define R_SIDEBAR
Redraw the sidebar.
Definition: types.h:73
#define R_REDRAW_MASK
Mask for the Redraw Flags.
Definition: types.h:76
#define R_INDEX
Redraw the index menu (MENU_MAIN)
Definition: types.h:65
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ C_MenuContext

short C_MenuContext

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

Definition at line 57 of file menu.c.

◆ C_MenuMoveOff

bool C_MenuMoveOff

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

Definition at line 58 of file menu.c.

◆ C_MenuScroll

bool C_MenuScroll

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

Definition at line 59 of file menu.c.