NeoMutt  2020-04-24
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 "keymap.h"
#include "mutt/regex3.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...
 

Enumerations

enum  TreeChar {
  MUTT_TREE_LLCORNER = 1, MUTT_TREE_ULCORNER, MUTT_TREE_LTEE, MUTT_TREE_HLINE,
  MUTT_TREE_VLINE, MUTT_TREE_SPACE, MUTT_TREE_RARROW, MUTT_TREE_STAR,
  MUTT_TREE_HIDDEN, MUTT_TREE_EQUALS, MUTT_TREE_TTEE, MUTT_TREE_BTEE,
  MUTT_TREE_MISSING, MUTT_TREE_MAX, MUTT_SPECIAL_INDEX = MUTT_TREE_MAX
}
 Tree characters for menus. 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 41 of file mutt_menu.h.

◆ REDRAW_INDEX

#define REDRAW_INDEX   (1 << 0)

Redraw the index.

Definition at line 42 of file mutt_menu.h.

◆ REDRAW_MOTION

#define REDRAW_MOTION   (1 << 1)

Redraw after moving the menu list.

Definition at line 43 of file mutt_menu.h.

◆ REDRAW_MOTION_RESYNC

#define REDRAW_MOTION_RESYNC   (1 << 2)

Redraw any changing the menu selection.

Definition at line 44 of file mutt_menu.h.

◆ REDRAW_CURRENT

#define REDRAW_CURRENT   (1 << 3)

Redraw the current line of the menu.

Definition at line 45 of file mutt_menu.h.

◆ REDRAW_STATUS

#define REDRAW_STATUS   (1 << 4)

Redraw the status bar.

Definition at line 46 of file mutt_menu.h.

◆ REDRAW_FULL

#define REDRAW_FULL   (1 << 5)

Redraw everything.

Definition at line 47 of file mutt_menu.h.

◆ REDRAW_BODY

#define REDRAW_BODY   (1 << 6)

Redraw the pager.

Definition at line 48 of file mutt_menu.h.

◆ REDRAW_FLOW

#define REDRAW_FLOW   (1 << 7)

Used by pager to reflow text.

Definition at line 49 of file mutt_menu.h.

◆ REDRAW_SIDEBAR

#define REDRAW_SIDEBAR   (1 << 8)

Redraw the sidebar.

Definition at line 51 of file mutt_menu.h.

Typedef Documentation

◆ MuttRedrawFlags

typedef uint16_t MuttRedrawFlags

Flags, e.g. REDRAW_INDEX.

Definition at line 40 of file mutt_menu.h.

Enumeration Type Documentation

◆ TreeChar

enum TreeChar

Tree characters for menus.

See also
linearize_tree(), print_enriched_string()
Enumerator
MUTT_TREE_LLCORNER 

Lower left corner.

MUTT_TREE_ULCORNER 

Upper left corner.

MUTT_TREE_LTEE 

Left T-piece.

MUTT_TREE_HLINE 

Horizontal line.

MUTT_TREE_VLINE 

Vertical line.

MUTT_TREE_SPACE 

Blank space.

MUTT_TREE_RARROW 

Right arrow.

MUTT_TREE_STAR 

Star character (for threads)

MUTT_TREE_HIDDEN 

Ampersand character (for threads)

MUTT_TREE_EQUALS 

Equals (for threads)

MUTT_TREE_TTEE 

Top T-piece.

MUTT_TREE_BTEE 

Bottom T-piece.

MUTT_TREE_MISSING 

Question mark.

MUTT_TREE_MAX 
MUTT_SPECIAL_INDEX 

Colour indicator.

Definition at line 59 of file mutt_menu.h.

60 {
61  MUTT_TREE_LLCORNER = 1,
75 
77 };
Lower left corner.
Definition: mutt_menu.h:61
Right arrow.
Definition: mutt_menu.h:67
Bottom T-piece.
Definition: mutt_menu.h:72
Blank space.
Definition: mutt_menu.h:66
Vertical line.
Definition: mutt_menu.h:65
Top T-piece.
Definition: mutt_menu.h:71
Star character (for threads)
Definition: mutt_menu.h:68
Equals (for threads)
Definition: mutt_menu.h:70
Ampersand character (for threads)
Definition: mutt_menu.h:69
Question mark.
Definition: mutt_menu.h:73
Colour indicator.
Definition: mutt_menu.h:76
Left T-piece.
Definition: mutt_menu.h:63
Upper left corner.
Definition: mutt_menu.h:62
Horizontal line.
Definition: mutt_menu.h:64

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

801 {
802  if (menu->max)
803  {
804  menu->current = menu->top + menu->pagelen - 1;
805  if (menu->current > menu->max - 1)
806  menu->current = menu->max - 1;
807  menu->redraw = REDRAW_MOTION;
808  }
809  else
810  mutt_error(_("No entries"));
811 }
#define _(a)
Definition: message.h:28
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:43
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:107
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:91
int max
Number of entries in the menu.
Definition: mutt_menu.h:88
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:89
#define mutt_error(...)
Definition: logging.h:84
int current
Current entry.
Definition: mutt_menu.h:87
+ Here is the caller graph for this function:

◆ menu_check_recenter()

void menu_check_recenter ( struct Menu menu)

Recentre the menu on screen.

Parameters
menuCurrent Menu

Definition at line 571 of file menu.c.

572 {
573  int c = MIN(C_MenuContext, menu->pagelen / 2);
574  int old_top = menu->top;
575 
576  if (!C_MenuMoveOff && (menu->max <= menu->pagelen)) /* less entries than lines */
577  {
578  if (menu->top != 0)
579  {
580  menu->top = 0;
581  menu->redraw |= REDRAW_INDEX;
582  }
583  }
584  else
585  {
586  if (C_MenuScroll || (menu->pagelen <= 0) || (c < C_MenuContext))
587  {
588  if (menu->current < menu->top + c)
589  menu->top = menu->current - c;
590  else if (menu->current >= menu->top + menu->pagelen - c)
591  menu->top = menu->current - menu->pagelen + c + 1;
592  }
593  else
594  {
595  if (menu->current < menu->top + c)
596  {
597  menu->top -= (menu->pagelen - c) * ((menu->top + menu->pagelen - 1 - menu->current) /
598  (menu->pagelen - c)) -
599  c;
600  }
601  else if ((menu->current >= menu->top + menu->pagelen - c))
602  {
603  menu->top +=
604  (menu->pagelen - c) * ((menu->current - menu->top) / (menu->pagelen - c)) - c;
605  }
606  }
607  }
608 
609  if (!C_MenuMoveOff) /* make entries stick to bottom */
610  menu->top = MIN(menu->top, menu->max - menu->pagelen);
611  menu->top = MAX(menu->top, 0);
612 
613  if (menu->top != old_top)
614  menu->redraw |= REDRAW_INDEX;
615 }
#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:107
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:91
int max
Number of entries in the menu.
Definition: mutt_menu.h:88
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:89
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:42
int current
Current entry.
Definition: mutt_menu.h:87
+ Here is the caller graph for this function:

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

898 {
899  if (menu->max)
900  {
901  menu->top = menu->current - menu->pagelen + 1;
902  if (menu->top < 0)
903  menu->top = 0;
904  menu->redraw = REDRAW_INDEX;
905  }
906  else
907  mutt_error(_("No entries"));
908 }
#define _(a)
Definition: message.h:28
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:107
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:91
int max
Number of entries in the menu.
Definition: mutt_menu.h:88
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:89
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:42
#define mutt_error(...)
Definition: logging.h:84
int current
Current entry.
Definition: mutt_menu.h:87
+ Here is the caller graph for this function:

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

881 {
882  if (menu->max)
883  {
884  menu->top = menu->current - menu->pagelen / 2;
885  if (menu->top < 0)
886  menu->top = 0;
887  menu->redraw = REDRAW_INDEX;
888  }
889  else
890  mutt_error(_("No entries"));
891 }
#define _(a)
Definition: message.h:28
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:107
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:91
int max
Number of entries in the menu.
Definition: mutt_menu.h:88
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:89
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:42
#define mutt_error(...)
Definition: logging.h:84
int current
Current entry.
Definition: mutt_menu.h:87
+ Here is the caller graph for this function:

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

866 {
867  if (menu->max)
868  {
869  menu->top = menu->current;
870  menu->redraw = REDRAW_INDEX;
871  }
872  else
873  mutt_error(_("No entries"));
874 }
#define _(a)
Definition: message.h:28
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:107
int max
Number of entries in the menu.
Definition: mutt_menu.h:88
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:89
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:42
#define mutt_error(...)
Definition: logging.h:84
int current
Current entry.
Definition: mutt_menu.h:87
+ Here is the caller graph for this function:

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

836 {
837  if (menu->max)
838  {
839  menu->current = 0;
840  menu->redraw = REDRAW_MOTION;
841  }
842  else
843  mutt_error(_("No entries"));
844 }
#define _(a)
Definition: message.h:28
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:43
int max
Number of entries in the menu.
Definition: mutt_menu.h:88
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:89
#define mutt_error(...)
Definition: logging.h:84
int current
Current entry.
Definition: mutt_menu.h:87
+ Here is the caller graph for this function:

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

770 {
771  menu_length_jump(menu, menu->pagelen / 2);
772 }
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:91
+ 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 778 of file menu.c.

779 {
780  menu_length_jump(menu, 0 - menu->pagelen / 2);
781 }
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:91
+ 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 850 of file menu.c.

851 {
852  if (menu->max)
853  {
854  menu->current = menu->max - 1;
855  menu->redraw = REDRAW_MOTION;
856  }
857  else
858  mutt_error(_("No entries"));
859 }
#define _(a)
Definition: message.h:28
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:43
int max
Number of entries in the menu.
Definition: mutt_menu.h:88
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:89
#define mutt_error(...)
Definition: logging.h:84
int current
Current entry.
Definition: mutt_menu.h:87
+ Here is the caller graph for this function:

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

818 {
819  if (menu->max)
820  {
821  int i = menu->top + menu->pagelen;
822  if (i > menu->max - 1)
823  i = menu->max - 1;
824  menu->current = menu->top + (i - menu->top) / 2;
825  menu->redraw = REDRAW_MOTION;
826  }
827  else
828  mutt_error(_("No entries"));
829 }
#define _(a)
Definition: message.h:28
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:43
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:107
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:91
int max
Number of entries in the menu.
Definition: mutt_menu.h:88
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:89
#define mutt_error(...)
Definition: logging.h:84
int current
Current entry.
Definition: mutt_menu.h:87
+ Here is the caller graph for this function:

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

653 {
654  if (menu->max)
655  {
656  int c = MIN(C_MenuContext, menu->pagelen / 2);
657 
658  if ((menu->top + 1 < menu->max - c) &&
659  (C_MenuMoveOff ||
660  ((menu->max > menu->pagelen) && (menu->top < menu->max - menu->pagelen))))
661  {
662  menu->top++;
663  if ((menu->current < menu->top + c) && (menu->current < menu->max - 1))
664  menu->current++;
665  menu->redraw = REDRAW_INDEX;
666  }
667  else
668  mutt_message(_("You can't scroll down farther"));
669  }
670  else
671  mutt_error(_("No entries"));
672 }
#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:107
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:91
int max
Number of entries in the menu.
Definition: mutt_menu.h:88
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:89
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:42
#define mutt_error(...)
Definition: logging.h:84
int current
Current entry.
Definition: mutt_menu.h:87
+ Here is the caller graph for this function:

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

752 {
753  menu_length_jump(menu, MAX(menu->pagelen /* - MenuOverlap */, 0));
754 }
#define MAX(a, b)
Definition: memory.h:30
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:91
+ 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 678 of file menu.c.

679 {
680  if (menu->top > 0)
681  {
682  int c = MIN(C_MenuContext, menu->pagelen / 2);
683 
684  menu->top--;
685  if ((menu->current >= menu->top + menu->pagelen - c) && (menu->current > 1))
686  menu->current--;
687  menu->redraw = REDRAW_INDEX;
688  }
689  else
690  mutt_message(_("You can't scroll up farther"));
691 }
#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:107
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:91
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:89
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:42
int current
Current entry.
Definition: mutt_menu.h:87
+ Here is the caller graph for this function:

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

761 {
762  menu_length_jump(menu, 0 - MAX(menu->pagelen /* - MenuOverlap */, 0));
763 }
#define MAX(a, b)
Definition: memory.h:30
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:91
+ 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 521 of file menu.c.

522 {
523  char buf[1024];
524  int attr = menu->color(menu->current);
525 
526  mutt_window_move(menu->win_index, menu->current - menu->top, 0);
527  make_entry(buf, sizeof(buf), menu, menu->current);
528  menu_pad_string(menu, buf, sizeof(buf));
529 
531  if (C_ArrowCursor)
532  {
534  mutt_curses_set_attr(attr);
535  mutt_window_addch(' ');
536  menu_pad_string(menu, buf, sizeof(buf));
537  print_enriched_string(menu->current, attr, (unsigned char *) buf, true);
538  }
539  else
540  print_enriched_string(menu->current, attr, (unsigned char *) buf, false);
541  menu->redraw &= REDRAW_STATUS;
543 }
void mutt_curses_set_color(enum ColorId color)
Set the current colour for text.
Definition: mutt_curses.c:55
WHERE char * C_ArrowString
Config: Use an custom string for arrow_cursor.
Definition: globals.h:195
Plain text.
Definition: color.h:77
#define REDRAW_STATUS
Redraw the status bar.
Definition: mutt_menu.h:46
int(* color)(int line)
Calculate the colour for a line of the menu.
Definition: mutt_menu.h:146
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:107
Selected item in list.
Definition: color.h:73
int mutt_window_move(struct MuttWindow *win, int row, int col)
Move the cursor in a Window.
Definition: mutt_window.c:278
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:89
int mutt_window_addch(int ch)
Write one character to a Window.
Definition: mutt_window.c:400
int mutt_window_addstr(const char *str)
Write a string to a Window.
Definition: mutt_window.c:430
int current
Current entry.
Definition: mutt_menu.h:87
struct MuttWindow * win_index
Definition: mutt_menu.h:94
void mutt_curses_set_attr(int attr)
Set the attributes for text.
Definition: mutt_curses.c:40
WHERE bool C_ArrowCursor
Config: Use an arrow &#39;->&#39; instead of highlighting in the index.
Definition: globals.h:194
+ 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  if (C_Help)
360  {
365  }
366  menu->pagelen = menu->win_index->state.rows;
367 
368  mutt_show_error();
369 
371 #ifdef USE_SIDEBAR
372  menu->redraw |= REDRAW_SIDEBAR;
373 #endif
374 }
void mutt_window_move_abs(int row, int col)
Move the cursor to an absolute screen position.
Definition: mutt_window.c:447
void mutt_curses_set_color(enum ColorId color)
Set the current colour for text.
Definition: mutt_curses.c:55
WHERE bool C_Help
Config: Display a help line with common key bindings.
Definition: globals.h:217
struct MuttWindow * MuttHelpWindow
Help Window.
Definition: mutt_window.c:45
#define REDRAW_SIDEBAR
Redraw the sidebar.
Definition: mutt_menu.h:51
void mutt_paddstr(int n, const char *s)
Display a string on screen, padded if necessary.
Definition: curs_lib.c:1243
void mutt_window_clrtobot(void)
Clear to the bottom of the Window.
Definition: mutt_window.c:123
Plain text.
Definition: color.h:77
const char * help
Quickref for the current menu.
Definition: mutt_menu.h:85
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:58
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:93
#define REDRAW_STATUS
Redraw the status bar.
Definition: mutt_menu.h:46
Status bar (takes a pattern)
Definition: color.h:94
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:57
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:91
int mutt_window_move(struct MuttWindow *win, int row, int col)
Move the cursor in a Window.
Definition: mutt_window.c:278
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:89
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:42
void mutt_show_error(void)
Show the user an error message.
Definition: curs_lib.c:532
struct MuttWindow * win_index
Definition: mutt_menu.h:94
+ 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 410 of file menu.c.

411 {
412  char buf[1024];
413  bool do_color;
414  int attr;
415 
416  for (int i = menu->top; i < menu->top + menu->pagelen; i++)
417  {
418  if (i < menu->max)
419  {
420  attr = menu->color(i);
421 
422  make_entry(buf, sizeof(buf), menu, i);
423  menu_pad_string(menu, buf, sizeof(buf));
424 
425  mutt_curses_set_attr(attr);
426  mutt_window_move(menu->win_index, i - menu->top, 0);
427  do_color = true;
428 
429  if (i == menu->current)
430  {
432  if (C_ArrowCursor)
433  {
435  mutt_curses_set_attr(attr);
436  mutt_window_addch(' ');
437  }
438  else
439  do_color = false;
440  }
441  else if (C_ArrowCursor)
442  /* Print space chars to match the screen width of C_ArrowString */
444 
445  print_enriched_string(i, attr, (unsigned char *) buf, do_color);
446  }
447  else
448  {
450  mutt_window_clearline(menu->win_index, i - menu->top);
451  }
452  }
454  menu->redraw = 0;
455 }
void mutt_curses_set_color(enum ColorId color)
Set the current colour for text.
Definition: mutt_curses.c:55
WHERE char * C_ArrowString
Config: Use an custom string for arrow_cursor.
Definition: globals.h:195
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:112
Plain text.
Definition: color.h:77
int(* color)(int line)
Calculate the colour for a line of the menu.
Definition: mutt_menu.h:146
int mutt_strwidth(const char *s)
Measure a string&#39;s width in screen cells.
Definition: curs_lib.c:1336
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:107
Selected item in list.
Definition: color.h:73
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:91
int mutt_window_move(struct MuttWindow *win, int row, int col)
Move the cursor in a Window.
Definition: mutt_window.c:278
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:89
int mutt_window_printf(const char *fmt,...)
Write a formatted string to a Window.
Definition: mutt_window.c:458
int mutt_window_addch(int ch)
Write one character to a Window.
Definition: mutt_window.c:400
int mutt_window_addstr(const char *str)
Write a string to a Window.
Definition: mutt_window.c:430
int current
Current entry.
Definition: mutt_menu.h:87
struct MuttWindow * win_index
Definition: mutt_menu.h:94
void mutt_curses_set_attr(int attr)
Set the attributes for text.
Definition: mutt_curses.c:40
WHERE bool C_ArrowCursor
Config: Use an arrow &#39;->&#39; instead of highlighting in the index.
Definition: globals.h:194
+ 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 461 of file menu.c.

462 {
463  char buf[1024];
464 
465  if (menu->dialog)
466  {
467  menu->redraw &= ~REDRAW_MOTION;
468  return;
469  }
470 
471  /* Note: menu->color() for the index can end up retrieving a message
472  * over imap (if matching against ~h for instance). This can
473  * generate status messages. So we want to call it *before* we
474  * position the cursor for drawing. */
475  const int old_color = menu->color(menu->oldcurrent);
476  mutt_window_move(menu->win_index, menu->oldcurrent - menu->top, 0);
477  mutt_curses_set_attr(old_color);
478 
479  if (C_ArrowCursor)
480  {
481  /* clear the arrow */
482  /* Print space chars to match the screen width of C_ArrowString */
484 
485  if (menu->redraw & REDRAW_MOTION_RESYNC)
486  {
487  make_entry(buf, sizeof(buf), menu, menu->oldcurrent);
488  menu_pad_string(menu, buf, sizeof(buf));
489  mutt_window_move(menu->win_index, menu->oldcurrent - menu->top,
491  print_enriched_string(menu->oldcurrent, old_color, (unsigned char *) buf, true);
492  }
493 
494  /* now draw it in the new location */
496  mutt_window_mvaddstr(menu->win_index, menu->current - menu->top, 0, C_ArrowString);
497  }
498  else
499  {
500  /* erase the current indicator */
501  make_entry(buf, sizeof(buf), menu, menu->oldcurrent);
502  menu_pad_string(menu, buf, sizeof(buf));
503  print_enriched_string(menu->oldcurrent, old_color, (unsigned char *) buf, true);
504 
505  /* now draw the new one to reflect the change */
506  const int cur_color = menu->color(menu->current);
507  make_entry(buf, sizeof(buf), menu, menu->current);
508  menu_pad_string(menu, buf, sizeof(buf));
510  mutt_window_move(menu->win_index, menu->current - menu->top, 0);
511  print_enriched_string(menu->current, cur_color, (unsigned char *) buf, false);
512  }
513  menu->redraw &= REDRAW_STATUS;
515 }
int oldcurrent
For driver use only.
Definition: mutt_menu.h:108
void mutt_curses_set_color(enum ColorId color)
Set the current colour for text.
Definition: mutt_curses.c:55
char ** dialog
Dialog lines themselves.
Definition: mutt_menu.h:101
WHERE char * C_ArrowString
Config: Use an custom string for arrow_cursor.
Definition: globals.h:195
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:43
Plain text.
Definition: color.h:77
#define REDRAW_MOTION_RESYNC
Redraw any changing the menu selection.
Definition: mutt_menu.h:44
#define REDRAW_STATUS
Redraw the status bar.
Definition: mutt_menu.h:46
int(* color)(int line)
Calculate the colour for a line of the menu.
Definition: mutt_menu.h:146
int mutt_strwidth(const char *s)
Measure a string&#39;s width in screen cells.
Definition: curs_lib.c:1336
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:107
Selected item in list.
Definition: color.h:73
int mutt_window_mvaddstr(struct MuttWindow *win, int row, int col, const char *str)
Move the cursor and write a fixed string to a Window.
Definition: mutt_window.c:292
int mutt_window_move(struct MuttWindow *win, int row, int col)
Move the cursor in a Window.
Definition: mutt_window.c:278
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:89
int mutt_window_printf(const char *fmt,...)
Write a formatted string to a Window.
Definition: mutt_window.c:458
int current
Current entry.
Definition: mutt_menu.h:87
struct MuttWindow * win_index
Definition: mutt_menu.h:94
void mutt_curses_set_attr(int attr)
Set the attributes for text.
Definition: mutt_curses.c:40
WHERE bool C_ArrowCursor
Config: Use an arrow &#39;->&#39; instead of highlighting in the index.
Definition: globals.h:194
+ 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 397 of file menu.c.

398 {
399  menu->redraw &= ~REDRAW_SIDEBAR;
400  struct MuttWindow *dlg = mutt_window_dialog(menu->win_index);
401  struct MuttWindow *sidebar = mutt_window_find(dlg, WT_SIDEBAR);
402  mutt_sb_draw(sidebar);
403 }
struct MuttWindow * mutt_window_find(struct MuttWindow *root, enum WindowType type)
Find a Window of a given type.
Definition: mutt_window.c:577
A division of the screen.
Definition: mutt_window.h:88
#define REDRAW_SIDEBAR
Redraw the sidebar.
Definition: mutt_menu.h:51
Side panel containing Accounts or groups of data.
Definition: mutt_window.h:78
struct MuttWindow * mutt_window_dialog(struct MuttWindow *win)
Find the parent Dialog of a Window.
Definition: mutt_window.c:560
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:89
struct MuttWindow * win_index
Definition: mutt_menu.h:94
+ 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 380 of file menu.c.

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

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

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

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

788 {
789  if (menu->current == menu->top)
790  return;
791 
792  menu->current = menu->top;
793  menu->redraw = REDRAW_MOTION;
794 }
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:43
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:107
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:89
int current
Current entry.
Definition: mutt_menu.h:87
+ Here is the caller graph for this function:

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

1014 {
1015  if (menu->dsize <= menu->max)
1016  {
1017  menu->dsize += 10;
1018  mutt_mem_realloc(&menu->dialog, menu->dsize * sizeof(char *));
1019  }
1020  menu->dialog[menu->max++] = mutt_str_strdup(row);
1021 }
char ** dialog
Dialog lines themselves.
Definition: mutt_menu.h:101
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:88
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
int dsize
Number of allocated dialog lines.
Definition: mutt_menu.h:102
+ 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 1137 of file menu.c.

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

◆ mutt_menu_free()

void mutt_menu_free ( struct Menu **  ptr)

Destroy a menu.

Parameters
[out]ptrMenu to destroy

Definition at line 991 of file menu.c.

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

◆ mutt_menu_init()

void mutt_menu_init ( void  )

Initialise all the Menus.

Definition at line 962 of file menu.c.

963 {
964  for (int i = 0; i < MENU_MAX; i++)
965  SearchBuffers[i] = NULL;
966 }
+ 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 1343 of file menu.c.

1344 {
1345  static int last_position = -1;
1346  int i = OP_NULL;
1347 
1348  if (menu->max && menu->is_mailbox_list)
1349  {
1350  if (last_position > (menu->max - 1))
1351  last_position = -1;
1352  else if (last_position >= 0)
1353  menu->current = last_position;
1354  }
1355 
1356  while (true)
1357  {
1358  if (OptMenuCaller)
1359  {
1360  OptMenuCaller = false;
1361  return OP_NULL;
1362  }
1363 
1364  /* Clear the tag prefix unless we just started it. Don't clear
1365  * the prefix on a timeout (i==-2), but do clear on an abort (i==-1) */
1366  if (menu->tagprefix && (i != OP_TAG_PREFIX) && (i != OP_TAG_PREFIX_COND) && (i != -2))
1367  menu->tagprefix = false;
1368 
1370 
1371  if (menu_redraw(menu) == OP_REDRAW)
1372  return OP_REDRAW;
1373 
1374  /* give visual indication that the next command is a tag- command */
1375  if (menu->tagprefix)
1376  {
1377  mutt_window_mvaddstr(MuttMessageWindow, 0, 0, "tag-");
1379  }
1380 
1381  menu->oldcurrent = menu->current;
1382 
1383  /* move the cursor out of the way */
1384  if (C_ArrowCursor)
1385  mutt_window_move(menu->win_index, menu->current - menu->top, 2);
1386  else if (C_BrailleFriendly)
1387  mutt_window_move(menu->win_index, menu->current - menu->top, 0);
1388  else
1389  {
1390  mutt_window_move(menu->win_index, menu->current - menu->top,
1391  menu->win_index->state.cols - 1);
1392  }
1393 
1394  mutt_refresh();
1395 
1396  /* try to catch dialog keys before ops */
1397  if (menu->dialog && (menu_dialog_dokey(menu, &i) == 0))
1398  return i;
1399 
1400  i = km_dokey(menu->type);
1401  if ((i == OP_TAG_PREFIX) || (i == OP_TAG_PREFIX_COND))
1402  {
1403  if (menu->tagprefix)
1404  {
1405  menu->tagprefix = false;
1407  continue;
1408  }
1409 
1410  if (menu->tagged)
1411  {
1412  menu->tagprefix = true;
1413  continue;
1414  }
1415  else if (i == OP_TAG_PREFIX)
1416  {
1417  mutt_error(_("No tagged entries"));
1418  i = -1;
1419  }
1420  else /* None tagged, OP_TAG_PREFIX_COND */
1421  {
1423  mutt_message(_("Nothing to do"));
1424  i = -1;
1425  }
1426  }
1427  else if (menu->tagged && C_AutoTag)
1428  menu->tagprefix = true;
1429 
1431 
1432  if (SigWinch)
1433  {
1434  SigWinch = 0;
1436  clearok(stdscr, true); /* force complete redraw */
1437  }
1438 
1439  if (i < 0)
1440  {
1441  if (menu->tagprefix)
1443  continue;
1444  }
1445 
1446  if (!menu->dialog)
1447  mutt_clear_error();
1448 
1449  /* Convert menubar movement to scrolling */
1450  if (menu->dialog)
1451  i = menu_dialog_translate_op(i);
1452 
1453  switch (i)
1454  {
1455  case OP_NEXT_ENTRY:
1456  menu_next_entry(menu);
1457  break;
1458  case OP_PREV_ENTRY:
1459  menu_prev_entry(menu);
1460  break;
1461  case OP_HALF_DOWN:
1462  menu_half_down(menu);
1463  break;
1464  case OP_HALF_UP:
1465  menu_half_up(menu);
1466  break;
1467  case OP_NEXT_PAGE:
1468  menu_next_page(menu);
1469  break;
1470  case OP_PREV_PAGE:
1471  menu_prev_page(menu);
1472  break;
1473  case OP_NEXT_LINE:
1474  menu_next_line(menu);
1475  break;
1476  case OP_PREV_LINE:
1477  menu_prev_line(menu);
1478  break;
1479  case OP_FIRST_ENTRY:
1480  menu_first_entry(menu);
1481  break;
1482  case OP_LAST_ENTRY:
1483  menu_last_entry(menu);
1484  break;
1485  case OP_TOP_PAGE:
1486  menu_top_page(menu);
1487  break;
1488  case OP_MIDDLE_PAGE:
1489  menu_middle_page(menu);
1490  break;
1491  case OP_BOTTOM_PAGE:
1492  menu_bottom_page(menu);
1493  break;
1494  case OP_CURRENT_TOP:
1495  menu_current_top(menu);
1496  break;
1497  case OP_CURRENT_MIDDLE:
1498  menu_current_middle(menu);
1499  break;
1500  case OP_CURRENT_BOTTOM:
1501  menu_current_bottom(menu);
1502  break;
1503  case OP_SEARCH:
1504  case OP_SEARCH_REVERSE:
1505  case OP_SEARCH_NEXT:
1506  case OP_SEARCH_OPPOSITE:
1507  if (menu->search && !menu->dialog) /* Searching dialogs won't work */
1508  {
1509  menu->oldcurrent = menu->current;
1510  menu->current = search(menu, i);
1511  if (menu->current != -1)
1512  menu->redraw = REDRAW_MOTION;
1513  else
1514  menu->current = menu->oldcurrent;
1515  }
1516  else
1517  mutt_error(_("Search is not implemented for this menu"));
1518  break;
1519 
1520  case OP_JUMP:
1521  if (menu->dialog)
1522  mutt_error(_("Jumping is not implemented for dialogs"));
1523  else
1524  menu_jump(menu);
1525  break;
1526 
1527  case OP_ENTER_COMMAND:
1529  break;
1530 
1531  case OP_TAG:
1532  if (menu->tag && !menu->dialog)
1533  {
1534  if (menu->tagprefix && !C_AutoTag)
1535  {
1536  for (i = 0; i < menu->max; i++)
1537  menu->tagged += menu->tag(menu, i, 0);
1538  menu->redraw |= REDRAW_INDEX;
1539  }
1540  else if (menu->max)
1541  {
1542  int j = menu->tag(menu, menu->current, -1);
1543  menu->tagged += j;
1544  if (j && C_Resolve && (menu->current < menu->max - 1))
1545  {
1546  menu->current++;
1547  menu->redraw |= REDRAW_MOTION_RESYNC;
1548  }
1549  else
1550  menu->redraw |= REDRAW_CURRENT;
1551  }
1552  else
1553  mutt_error(_("No entries"));
1554  }
1555  else
1556  mutt_error(_("Tagging is not supported"));
1557  break;
1558 
1559  case OP_SHELL_ESCAPE:
1561  break;
1562 
1563  case OP_WHAT_KEY:
1564  mutt_what_key();
1565  break;
1566 
1567  case OP_CHECK_STATS:
1568  mutt_check_stats();
1569  break;
1570 
1571  case OP_REDRAW:
1572  clearok(stdscr, true);
1573  menu->redraw = REDRAW_FULL;
1574  break;
1575 
1576  case OP_HELP:
1577  mutt_help(menu->type, menu->win_index->state.cols);
1578  menu->redraw = REDRAW_FULL;
1579  break;
1580 
1581  case OP_NULL:
1582  km_error_key(menu->type);
1583  break;
1584 
1585  case OP_END_COND:
1586  break;
1587 
1588  default:
1589  if (menu->is_mailbox_list)
1590  last_position = menu->current;
1591  return i;
1592  }
1593  }
1594  /* not reached */
1595 }
int km_dokey(enum MenuType menu)
Determine what a keypress should do.
Definition: keymap.c:619
#define REDRAW_FULL
Redraw everything.
Definition: mutt_menu.h:47
#define mutt_message(...)
Definition: logging.h:83
int oldcurrent
For driver use only.
Definition: mutt_menu.h:108
WHERE bool OptMenuCaller
(pseudo) tell menu to give caller a take
Definition: options.h:40
void mutt_window_clrtoeol(struct MuttWindow *win)
Clear to the end of the line.
Definition: mutt_window.c:134
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:1405
char ** dialog
Dialog lines themselves.
Definition: mutt_menu.h:101
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: globals.h:207
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:90
void mutt_flush_macro_to_endcond(void)
Drop a macro from the input buffer.
Definition: curs_lib.c:867
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:112
void mutt_what_key(void)
Ask the user to press a key.
Definition: keymap.c:1621
Display a normal cursor.
Definition: mutt_curses.h:81
void mutt_shell_escape(void)
invoke a command in a subshell
Definition: commands.c:844
WHERE SIG_ATOMIC_VOLATILE_T SigWinch
true after SIGWINCH is received
Definition: globals.h:80
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:43
#define REDRAW_MOTION_RESYNC
Redraw any changing the menu selection.
Definition: mutt_menu.h:44
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:58
void mutt_refresh(void)
Force a refresh of the screen.
Definition: curs_lib.c:106
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:93
void km_error_key(enum MenuType menu)
Handle an unbound key sequence.
Definition: keymap.c:1095
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:107
bool tagprefix
Definition: mutt_menu.h:92
WHERE bool C_Resolve
Config: Move to the next email whenever a command modifies an email.
Definition: globals.h:243
bool is_mailbox_list
Definition: mutt_menu.h:93
int(* tag)(struct Menu *menu, int sel, int act)
Tag some menu items.
Definition: mutt_menu.h:138
int mutt_window_mvaddstr(struct MuttWindow *win, int row, int col, const char *str)
Move the cursor and write a fixed string to a Window.
Definition: mutt_window.c:292
int tagged
Number of tagged entries.
Definition: mutt_menu.h:110
int mutt_window_move(struct MuttWindow *win, int row, int col)
Move the cursor in a Window.
Definition: mutt_window.c:278
int max
Number of entries in the menu.
Definition: mutt_menu.h:88
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:89
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:42
void mutt_help(enum MenuType menu, int wraplen)
Display the help menu.
Definition: help.c:444
#define mutt_error(...)
Definition: logging.h:84
Hide the cursor.
Definition: mutt_curses.h:80
WHERE bool C_AutoTag
Config: Automatically apply actions to all tagged messages.
Definition: globals.h:204
struct MuttWindow * MuttMessageWindow
Message Window.
Definition: mutt_window.c:46
int current
Current entry.
Definition: mutt_menu.h:87
struct MuttWindow * win_index
Definition: mutt_menu.h:94
int(* search)(struct Menu *menu, regex_t *rx, int line)
Search a menu for a item matching a regex.
Definition: mutt_menu.h:129
#define REDRAW_CURRENT
Redraw the current line of the menu.
Definition: mutt_menu.h:45
WHERE bool C_ArrowCursor
Config: Use an arrow &#39;->&#39; instead of highlighting in the index.
Definition: globals.h:194
+ 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 973 of file menu.c.

974 {
975  struct Menu *menu = mutt_mem_calloc(1, sizeof(struct Menu));
976 
977  menu->type = type;
978  menu->current = 0;
979  menu->top = 0;
980  menu->redraw = REDRAW_FULL;
981  menu->color = default_color;
982  menu->search = generic_search;
983 
984  return menu;
985 }
#define REDRAW_FULL
Redraw everything.
Definition: mutt_menu.h:47
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
GUI selectable list of items.
Definition: mutt_menu.h:82
enum MenuType type
Menu definition for keymap entries.
Definition: mutt_menu.h:90
int(* color)(int line)
Calculate the colour for a line of the menu.
Definition: mutt_menu.h:146
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:107
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:89
int current
Current entry.
Definition: mutt_menu.h:87
int(* search)(struct Menu *menu, regex_t *rx, int line)
Search a menu for a item matching a regex.
Definition: mutt_menu.h:129
+ 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 1056 of file menu.c.

1057 {
1058  struct Menu *prev_menu = NULL;
1059 
1060  if (!MenuStackCount || (MenuStack[MenuStackCount - 1] != menu))
1061  {
1062  mutt_debug(LL_DEBUG1, "called with inactive menu\n");
1063  return;
1064  }
1065 
1066  MenuStackCount--;
1067  prev_menu = get_current_menu();
1068  if (prev_menu)
1069  {
1070  CurrentMenu = prev_menu->type;
1071  prev_menu->redraw = REDRAW_FULL;
1072  }
1073  else
1074  {
1076  /* Clearing when NeoMutt exits would be an annoying change in behavior for
1077  * those who have disabled alternative screens. The option is currently
1078  * set by autocrypt initialization which mixes menus and prompts outside of
1079  * the normal menu system state. */
1081  {
1082  mutt_window_move_abs(0, 0);
1084  }
1085  }
1086 }
void mutt_window_move_abs(int row, int col)
Move the cursor to an absolute screen position.
Definition: mutt_window.c:447
#define REDRAW_FULL
Redraw everything.
Definition: mutt_menu.h:47
GUI selectable list of items.
Definition: mutt_menu.h:82
WHERE enum MenuType CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: globals.h:82
Index panel (list of emails)
Definition: keymap.h:77
enum MenuType type
Menu definition for keymap entries.
Definition: mutt_menu.h:90
WHERE bool OptMenuPopClearScreen
(pseudo) clear the screen when popping the last menu
Definition: options.h:41
void mutt_window_clrtobot(void)
Clear to the bottom of the Window.
Definition: mutt_window.c:123
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:89
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 1038 of file menu.c.

1039 {
1041  {
1042  MenuStackLen += 5;
1043  mutt_mem_realloc(&MenuStack, MenuStackLen * sizeof(struct Menu *));
1044  }
1045 
1046  MenuStack[MenuStackCount++] = menu;
1047  CurrentMenu = menu->type;
1048 }
GUI selectable list of items.
Definition: mutt_menu.h:82
WHERE enum MenuType CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: globals.h:82
enum MenuType type
Menu definition for keymap entries.
Definition: mutt_menu.h:90
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Definition: memory.c:114
+ 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 1102 of file menu.c.

1103 {
1104  struct Menu *current_menu = get_current_menu();
1105  if (current_menu)
1106  current_menu->redraw = REDRAW_FULL;
1107 }
#define REDRAW_FULL
Redraw everything.
Definition: mutt_menu.h:47
GUI selectable list of items.
Definition: mutt_menu.h:82
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:89
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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

1093 {
1094  struct Menu *current_menu = get_current_menu();
1095  if (current_menu)
1096  current_menu->redraw |= redraw;
1097 }
GUI selectable list of items.
Definition: mutt_menu.h:82
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:89
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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

1129 {
1130  if (CurrentMenu == menu)
1132 }
WHERE enum MenuType CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: globals.h:82
+ 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 1116 of file menu.c.

1117 {
1118  if (CurrentMenu == menu)
1120 }
WHERE enum MenuType CurrentMenu
Current Menu, e.g. MENU_PAGER.
Definition: globals.h:82
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:89
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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

1601 {
1602  if (!nc->event_data)
1603  return -1;
1604  if (nc->event_type != NT_CONFIG)
1605  return 0;
1606 
1607  int s = nc->event_subtype;
1608 
1609  bool simple = (s == MT_COLOR_INDEX_COLLAPSED) || (s == MT_COLOR_INDEX_DATE) ||
1610  (s == MT_COLOR_INDEX_LABEL) || (s == MT_COLOR_INDEX_NUMBER) ||
1611  (s == MT_COLOR_INDEX_SIZE) || (s == MT_COLOR_INDEX_TAGS);
1612  bool lists = (s == MT_COLOR_ATTACH_HEADERS) || (s == MT_COLOR_BODY) ||
1613  (s == MT_COLOR_HEADER) || (s == MT_COLOR_INDEX) ||
1614  (s == MT_COLOR_INDEX_AUTHOR) || (s == MT_COLOR_INDEX_FLAGS) ||
1615  (s == MT_COLOR_INDEX_SUBJECT) || (s == MT_COLOR_INDEX_TAG);
1616 
1617  // The changes aren't relevant to the index menu
1618  if (!simple && !lists)
1619  return 0;
1620 
1621  struct EventColor *ec = nc->event_data;
1622 
1623  // Colour deleted from a list
1624  if (!ec->set && lists && Context && Context->mailbox)
1625  {
1626  struct Mailbox *m = Context->mailbox;
1627  // Force re-caching of index colors
1628  for (int i = 0; i < m->msg_count; i++)
1629  {
1630  struct Email *e = m->emails[i];
1631  if (!e)
1632  break;
1633  e->pair = 0;
1634  }
1635  }
1636 
1638  return 0;
1639 }
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:37
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 an 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:77
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:42
enum NotifyType event_type
Send: Event type, e.g. NT_ACCOUNT.
Definition: observer.h:41
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:51
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:43
Config has changed.
Definition: notify_type.h:34
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:79
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 1644 of file menu.c.

1645 {
1646  if (!nc->event_data)
1647  return -1;
1648  if (nc->event_type != NT_CONFIG)
1649  return 0;
1650 
1651  struct EventConfig *ec = nc->event_data;
1652 
1653  const struct ConfigDef *cdef = ec->he->data;
1654  ConfigRedrawFlags flags = cdef->type & R_REDRAW_MASK;
1655 
1656  if (flags == R_REDRAW_NO_FLAGS)
1657  return 0;
1658 
1659  if (flags & R_INDEX)
1661  if (flags & R_PAGER)
1663  if (flags & R_PAGER_FLOW)
1664  {
1667  }
1668 
1669  if (flags & R_RESORT_SUB)
1670  OptSortSubthreads = true;
1671  if (flags & R_RESORT)
1672  OptNeedResort = true;
1673  if (flags & R_RESORT_INIT)
1674  OptResortInit = true;
1675  if (flags & R_TREE)
1676  OptRedrawTree = true;
1677 
1678  if (flags & R_REFLOW)
1679  mutt_window_reflow(NULL);
1680 #ifdef USE_SIDEBAR
1681  if (flags & R_SIDEBAR)
1683 #endif
1684  if (flags & R_MENU)
1686 
1687  return 0;
1688 }
#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:49
WHERE bool OptNeedResort
(pseudo) used to force a re-sort
Definition: options.h:44
A config-change event.
Definition: subset.h:70
Index panel (list of emails)
Definition: keymap.h:77
Config item definition.
Definition: set.h:63
#define R_RESORT
Resort the mailbox.
Definition: types.h:68
#define REDRAW_SIDEBAR
Redraw the sidebar.
Definition: mutt_menu.h:51
#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
Pager pager (email viewer)
Definition: keymap.h:78
#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:51
WHERE bool OptResortInit
(pseudo) used to force the next resort to be from scratch
Definition: options.h:52
void * event_data
Data from notify_send()
Definition: observer.h:43
Config has changed.
Definition: notify_type.h:34
void * data
Definition: hash.h:46
unsigned int type
Variable type, e.g. DT_STRING.
Definition: set.h:66
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
Definition: mutt_window.c:345
#define R_RESORT_INIT
Resort from scratch.
Definition: types.h:70
WHERE bool OptSortSubthreads
(pseudo) used when $sort_aux changes
Definition: options.h:55
#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 56 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 57 of file menu.c.

◆ C_MenuScroll

bool C_MenuScroll

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

Definition at line 58 of file menu.c.