NeoMutt  2020-11-20
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...
 

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_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.

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

771 {
772  if (menu->max)
773  {
774  menu->current = menu->top + menu->pagelen - 1;
775  if (menu->current > menu->max - 1)
776  menu->current = menu->max - 1;
777  menu->redraw = REDRAW_MOTION;
778  }
779  else
780  mutt_error(_("No entries"));
781 }
#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:75
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:60
int max
Number of entries in the menu.
Definition: mutt_menu.h:57
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:58
#define mutt_error(...)
Definition: logging.h:84
int current
Current entry.
Definition: mutt_menu.h:56
+ 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 541 of file menu.c.

542 {
543  int c = MIN(C_MenuContext, menu->pagelen / 2);
544  int old_top = menu->top;
545 
546  if (!C_MenuMoveOff && (menu->max <= menu->pagelen)) /* less entries than lines */
547  {
548  if (menu->top != 0)
549  {
550  menu->top = 0;
551  menu->redraw |= REDRAW_INDEX;
552  }
553  }
554  else
555  {
556  if (C_MenuScroll || (menu->pagelen <= 0) || (c < C_MenuContext))
557  {
558  if (menu->current < menu->top + c)
559  menu->top = menu->current - c;
560  else if (menu->current >= menu->top + menu->pagelen - c)
561  menu->top = menu->current - menu->pagelen + c + 1;
562  }
563  else
564  {
565  if (menu->current < menu->top + c)
566  {
567  menu->top -= (menu->pagelen - c) * ((menu->top + menu->pagelen - 1 - menu->current) /
568  (menu->pagelen - c)) -
569  c;
570  }
571  else if ((menu->current >= menu->top + menu->pagelen - c))
572  {
573  menu->top +=
574  (menu->pagelen - c) * ((menu->current - menu->top) / (menu->pagelen - c)) - c;
575  }
576  }
577  }
578 
579  if (!C_MenuMoveOff) /* make entries stick to bottom */
580  menu->top = MIN(menu->top, menu->max - menu->pagelen);
581  menu->top = MAX(menu->top, 0);
582 
583  if (menu->top != old_top)
584  menu->redraw |= REDRAW_INDEX;
585 }
#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:75
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:60
int max
Number of entries in the menu.
Definition: mutt_menu.h:57
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:58
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:40
int current
Current entry.
Definition: mutt_menu.h:56
+ 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 867 of file menu.c.

868 {
869  if (menu->max)
870  {
871  menu->top = menu->current - menu->pagelen + 1;
872  if (menu->top < 0)
873  menu->top = 0;
874  menu->redraw = REDRAW_INDEX;
875  }
876  else
877  mutt_error(_("No entries"));
878 }
#define _(a)
Definition: message.h:28
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:75
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:60
int max
Number of entries in the menu.
Definition: mutt_menu.h:57
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:58
#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:56
+ 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 850 of file menu.c.

851 {
852  if (menu->max)
853  {
854  menu->top = menu->current - menu->pagelen / 2;
855  if (menu->top < 0)
856  menu->top = 0;
857  menu->redraw = REDRAW_INDEX;
858  }
859  else
860  mutt_error(_("No entries"));
861 }
#define _(a)
Definition: message.h:28
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:75
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:60
int max
Number of entries in the menu.
Definition: mutt_menu.h:57
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:58
#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:56
+ 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 835 of file menu.c.

836 {
837  if (menu->max)
838  {
839  menu->top = menu->current;
840  menu->redraw = REDRAW_INDEX;
841  }
842  else
843  mutt_error(_("No entries"));
844 }
#define _(a)
Definition: message.h:28
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:75
int max
Number of entries in the menu.
Definition: mutt_menu.h:57
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:58
#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:56
+ 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 805 of file menu.c.

806 {
807  if (menu->max)
808  {
809  menu->current = 0;
810  menu->redraw = REDRAW_MOTION;
811  }
812  else
813  mutt_error(_("No entries"));
814 }
#define _(a)
Definition: message.h:28
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:41
int max
Number of entries in the menu.
Definition: mutt_menu.h:57
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:58
#define mutt_error(...)
Definition: logging.h:84
int current
Current entry.
Definition: mutt_menu.h:56
+ 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 739 of file menu.c.

740 {
741  menu_length_jump(menu, menu->pagelen / 2);
742 }
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:60
+ 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 748 of file menu.c.

749 {
750  menu_length_jump(menu, 0 - menu->pagelen / 2);
751 }
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:60
+ 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 820 of file menu.c.

821 {
822  if (menu->max)
823  {
824  menu->current = menu->max - 1;
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:41
int max
Number of entries in the menu.
Definition: mutt_menu.h:57
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:58
#define mutt_error(...)
Definition: logging.h:84
int current
Current entry.
Definition: mutt_menu.h:56
+ 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 787 of file menu.c.

788 {
789  if (menu->max)
790  {
791  int i = menu->top + menu->pagelen;
792  if (i > menu->max - 1)
793  i = menu->max - 1;
794  menu->current = menu->top + (i - menu->top) / 2;
795  menu->redraw = REDRAW_MOTION;
796  }
797  else
798  mutt_error(_("No entries"));
799 }
#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:75
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:60
int max
Number of entries in the menu.
Definition: mutt_menu.h:57
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:58
#define mutt_error(...)
Definition: logging.h:84
int current
Current entry.
Definition: mutt_menu.h:56
+ 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 622 of file menu.c.

623 {
624  if (menu->max)
625  {
626  int c = MIN(C_MenuContext, menu->pagelen / 2);
627 
628  if ((menu->top + 1 < menu->max - c) &&
629  (C_MenuMoveOff ||
630  ((menu->max > menu->pagelen) && (menu->top < menu->max - menu->pagelen))))
631  {
632  menu->top++;
633  if ((menu->current < menu->top + c) && (menu->current < menu->max - 1))
634  menu->current++;
635  menu->redraw = REDRAW_INDEX;
636  }
637  else
638  mutt_message(_("You can't scroll down farther"));
639  }
640  else
641  mutt_error(_("No entries"));
642 }
#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:75
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:60
int max
Number of entries in the menu.
Definition: mutt_menu.h:57
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:58
#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:56
+ 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 721 of file menu.c.

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

649 {
650  if (menu->top > 0)
651  {
652  int c = MIN(C_MenuContext, menu->pagelen / 2);
653 
654  menu->top--;
655  if ((menu->current >= menu->top + menu->pagelen - c) && (menu->current > 1))
656  menu->current--;
657  menu->redraw = REDRAW_INDEX;
658  }
659  else
660  mutt_message(_("You can't scroll up farther"));
661 }
#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:75
int pagelen
Number of entries per screen.
Definition: mutt_menu.h:60
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:58
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:40
int current
Current entry.
Definition: mutt_menu.h:56
+ 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 730 of file menu.c.

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

492 {
493  char buf[1024];
494  int attr = menu->color(menu->current);
495 
496  mutt_window_move(menu->win_index, 0, menu->current - menu->top);
497  make_entry(buf, sizeof(buf), menu, menu->current);
498  menu_pad_string(menu, buf, sizeof(buf));
499 
501  if (C_ArrowCursor)
502  {
504  mutt_curses_set_attr(attr);
505  mutt_window_addch(' ');
506  menu_pad_string(menu, buf, sizeof(buf));
507  print_enriched_string(menu->current, attr, (unsigned char *) buf, true);
508  }
509  else
510  print_enriched_string(menu->current, attr, (unsigned char *) buf, false);
511  menu->redraw &= REDRAW_STATUS;
513 }
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:382
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:115
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:75
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:131
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:58
int mutt_window_addch(int ch)
Write one character to a Window.
Definition: mutt_window.c:492
int mutt_window_addstr(const char *str)
Write a string to a Window.
Definition: mutt_window.c:522
int current
Current entry.
Definition: mutt_menu.h:56
struct MuttWindow * win_index
Definition: mutt_menu.h:63
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:132
+ 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 347 of file menu.c.

348 {
351 
352  window_redraw(RootWindow, true);
353  menu->pagelen = menu->win_index->state.rows;
354 
355  mutt_show_error();
356 
358 }
void mutt_curses_set_color(enum ColorId color)
Set the current colour for text.
Definition: mutt_curses.c:57
void mutt_window_clear(struct MuttWindow *win)
Clear a Window.
Definition: mutt_window.c:806
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
struct MuttWindow * RootWindow
Parent of all Windows.
Definition: mutt_window.c:45
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:60
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:58
#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:747
void mutt_show_error(void)
Show the user an error message.
Definition: curs_lib.c:557
struct MuttWindow * win_index
Definition: mutt_menu.h:63
+ 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 380 of file menu.c.

381 {
382  char buf[1024];
383  bool do_color;
384  int attr;
385 
386  for (int i = menu->top; i < menu->top + menu->pagelen; i++)
387  {
388  if (i < menu->max)
389  {
390  attr = menu->color(i);
391 
392  make_entry(buf, sizeof(buf), menu, i);
393  menu_pad_string(menu, buf, sizeof(buf));
394 
395  mutt_curses_set_attr(attr);
396  mutt_window_move(menu->win_index, 0, i - menu->top);
397  do_color = true;
398 
399  if (i == menu->current)
400  {
402  if (C_ArrowCursor)
403  {
405  mutt_curses_set_attr(attr);
406  mutt_window_addch(' ');
407  }
408  else
409  do_color = false;
410  }
411  else if (C_ArrowCursor)
412  /* Print space chars to match the screen width of `$arrow_string` */
414 
415  print_enriched_string(i, attr, (unsigned char *) buf, do_color);
416  }
417  else
418  {
420  mutt_window_clearline(menu->win_index, i - menu->top);
421  }
422  }
424  menu->redraw = 0;
425 }
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:382
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:115
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:75
Selected item in list.
Definition: color.h:73
int pagelen
Number of entries per screen.
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:131
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:58
int mutt_window_printf(const char *fmt,...)
Write a formatted string to a Window.
Definition: mutt_window.c:550
int mutt_window_addch(int ch)
Write one character to a Window.
Definition: mutt_window.c:492
int mutt_window_addstr(const char *str)
Write a string to a Window.
Definition: mutt_window.c:522
int current
Current entry.
Definition: mutt_menu.h:56
struct MuttWindow * win_index
Definition: mutt_menu.h:63
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:132
+ 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 431 of file menu.c.

432 {
433  char buf[1024];
434 
435  if (!ARRAY_EMPTY(&menu->dialog))
436  {
437  menu->redraw &= ~REDRAW_MOTION;
438  return;
439  }
440 
441  /* Note: menu->color() for the index can end up retrieving a message
442  * over imap (if matching against ~h for instance). This can
443  * generate status messages. So we want to call it *before* we
444  * position the cursor for drawing. */
445  const int old_color = menu->color(menu->oldcurrent);
446  mutt_window_move(menu->win_index, 0, menu->oldcurrent - menu->top);
447  mutt_curses_set_attr(old_color);
448 
449  if (C_ArrowCursor)
450  {
451  /* clear the arrow */
452  /* Print space chars to match the screen width of `$arrow_string` */
454 
455  if (menu->redraw & REDRAW_MOTION_RESYNC)
456  {
457  make_entry(buf, sizeof(buf), menu, menu->oldcurrent);
458  menu_pad_string(menu, buf, sizeof(buf));
460  menu->oldcurrent - menu->top);
461  print_enriched_string(menu->oldcurrent, old_color, (unsigned char *) buf, true);
462  }
463 
464  /* now draw it in the new location */
466  mutt_window_mvaddstr(menu->win_index, 0, menu->current - menu->top, C_ArrowString);
467  }
468  else
469  {
470  /* erase the current indicator */
471  make_entry(buf, sizeof(buf), menu, menu->oldcurrent);
472  menu_pad_string(menu, buf, sizeof(buf));
473  print_enriched_string(menu->oldcurrent, old_color, (unsigned char *) buf, true);
474 
475  /* now draw the new one to reflect the change */
476  const int cur_color = menu->color(menu->current);
477  make_entry(buf, sizeof(buf), menu, menu->current);
478  menu_pad_string(menu, buf, sizeof(buf));
480  mutt_window_move(menu->win_index, 0, menu->current - menu->top);
481  print_enriched_string(menu->current, cur_color, (unsigned char *) buf, false);
482  }
483  menu->redraw &= REDRAW_STATUS;
485 }
int oldcurrent
For driver use only.
Definition: mutt_menu.h:76
void mutt_curses_set_color(enum ColorId color)
Set the current colour for text.
Definition: mutt_curses.c:57
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:396
int mutt_window_move(struct MuttWindow *win, int col, int row)
Move the cursor in a Window.
Definition: mutt_window.c:382
#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:115
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:75
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition: array.h:70
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:131
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:58
int mutt_window_printf(const char *fmt,...)
Write a formatted string to a Window.
Definition: mutt_window.c:550
int current
Current entry.
Definition: mutt_menu.h:56
struct MuttWindow * win_index
Definition: mutt_menu.h:63
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:132
+ 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 364 of file menu.c.

365 {
366  char buf[256];
367 
368  snprintf(buf, sizeof(buf), "-- NeoMutt: %s", menu->title);
370  mutt_window_move(menu->win_ibar, 0, 0);
371  mutt_paddstr(menu->win_ibar->state.cols, buf);
373  menu->redraw &= ~REDRAW_STATUS;
374 }
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:382
struct MuttWindow * win_ibar
Definition: mutt_menu.h:64
const char * title
Title of this menu.
Definition: mutt_menu.h:54
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:58
+ 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 1260 of file menu.c.

1261 {
1262  if (menu->custom_redraw)
1263  {
1264  menu->custom_redraw(menu);
1265  return OP_NULL;
1266  }
1267 
1268  /* See if all or part of the screen needs to be updated. */
1269  if (menu->redraw & REDRAW_FULL)
1270  {
1271  menu_redraw_full(menu);
1272  /* allow the caller to do any local configuration */
1273  return OP_REDRAW;
1274  }
1275 
1276  if (ARRAY_EMPTY(&menu->dialog))
1277  menu_check_recenter(menu);
1278 
1279  if (menu->redraw & REDRAW_STATUS)
1280  menu_redraw_status(menu);
1281  if (menu->redraw & REDRAW_INDEX)
1282  menu_redraw_index(menu);
1283  else if (menu->redraw & (REDRAW_MOTION | REDRAW_MOTION_RESYNC))
1284  menu_redraw_motion(menu);
1285  else if (menu->redraw == REDRAW_CURRENT)
1286  menu_redraw_current(menu);
1287 
1288  if (!ARRAY_EMPTY(&menu->dialog))
1289  menu_redraw_prompt(menu);
1290 
1291  return OP_NULL;
1292 }
#define REDRAW_FULL
Redraw everything.
Definition: mutt_menu.h:45
#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
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition: array.h:70
void(* custom_redraw)(struct Menu *menu)
Redraw the menu.
Definition: mutt_menu.h:121
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:58
#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 757 of file menu.c.

758 {
759  if (menu->current == menu->top)
760  return;
761 
762  menu->current = menu->top;
763  menu->redraw = REDRAW_MOTION;
764 }
#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:75
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:58
int current
Current entry.
Definition: mutt_menu.h:56
+ 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 983 of file menu.c.

984 {
985  ARRAY_SET(&menu->dialog, menu->max, mutt_str_dup(row));
986  menu->max++;
987 }
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:370
int max
Number of entries in the menu.
Definition: mutt_menu.h:57
#define ARRAY_SET(head, idx, elem)
Set an element in the array.
Definition: array.h:119
+ 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 1097 of file menu.c.

1098 {
1099  struct Menu *current_menu = get_current_menu();
1100  if (current_menu)
1101  {
1102  if (menu_redraw(current_menu) == OP_REDRAW)
1103  {
1104  /* On a REDRAW_FULL with a non-customized redraw, menu_redraw()
1105  * will return OP_REDRAW to give the calling menu-loop a chance to
1106  * customize output. */
1107  menu_redraw(current_menu);
1108  }
1109  }
1110 }
GUI selectable list of items.
Definition: mutt_menu.h:52
+ 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 962 of file menu.c.

963 {
964  if (!ptr || !*ptr)
965  return;
966 
967  struct Menu *m = *ptr;
968  char **line = NULL;
969  ARRAY_FOREACH(line, &m->dialog)
970  {
971  FREE(line);
972  }
973  ARRAY_FREE(&m->dialog);
974 
975  FREE(ptr);
976 }
GUI selectable list of items.
Definition: mutt_menu.h:52
#define ARRAY_FREE(head)
Release all memory.
Definition: array.h:198
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition: array.h:206
#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 932 of file menu.c.

933 {
934  for (int i = 0; i < MENU_MAX; i++)
935  SearchBuffers[i] = NULL;
936 }
+ 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 1299 of file menu.c.

1300 {
1301  static int last_position = -1;
1302  int op = OP_NULL;
1303 
1304  if (menu->max && menu->is_mailbox_list)
1305  {
1306  if (last_position > (menu->max - 1))
1307  last_position = -1;
1308  else if (last_position >= 0)
1309  menu->current = last_position;
1310  }
1311 
1312  while (true)
1313  {
1314  /* Clear the tag prefix unless we just started it. Don't clear
1315  * the prefix on a timeout (op==-2), but do clear on an abort (op==-1) */
1316  if (menu->tagprefix && (op != OP_TAG_PREFIX) &&
1317  (op != OP_TAG_PREFIX_COND) && (op != -2))
1318  {
1319  menu->tagprefix = false;
1320  }
1321 
1323 
1324  if (menu_redraw(menu) == OP_REDRAW)
1325  return OP_REDRAW;
1326 
1327  /* give visual indication that the next command is a tag- command */
1328  if (menu->tagprefix)
1329  {
1330  mutt_window_mvaddstr(MessageWindow, 0, 0, "tag-");
1332  }
1333 
1334  menu->oldcurrent = menu->current;
1335 
1336  /* move the cursor out of the way */
1337  if (C_ArrowCursor)
1338  mutt_window_move(menu->win_index, 2, menu->current - menu->top);
1339  else if (C_BrailleFriendly)
1340  mutt_window_move(menu->win_index, 0, menu->current - menu->top);
1341  else
1342  {
1343  mutt_window_move(menu->win_index, menu->win_index->state.cols - 1,
1344  menu->current - menu->top);
1345  }
1346 
1347  mutt_refresh();
1348 
1349  /* try to catch dialog keys before ops */
1350  if (!ARRAY_EMPTY(&menu->dialog) && (menu_dialog_dokey(menu, &op) == 0))
1351  return op;
1352 
1353  op = km_dokey(menu->type);
1354  if ((op == OP_TAG_PREFIX) || (op == OP_TAG_PREFIX_COND))
1355  {
1356  if (menu->tagprefix)
1357  {
1358  menu->tagprefix = false;
1360  continue;
1361  }
1362 
1363  if (menu->tagged)
1364  {
1365  menu->tagprefix = true;
1366  continue;
1367  }
1368  else if (op == OP_TAG_PREFIX)
1369  {
1370  mutt_error(_("No tagged entries"));
1371  op = -1;
1372  }
1373  else /* None tagged, OP_TAG_PREFIX_COND */
1374  {
1376  mutt_message(_("Nothing to do"));
1377  op = -1;
1378  }
1379  }
1380  else if (menu->tagged && C_AutoTag)
1381  menu->tagprefix = true;
1382 
1384 
1385  if (SigWinch)
1386  {
1387  SigWinch = 0;
1389  clearok(stdscr, true); /* force complete redraw */
1390  }
1391 
1392  if (op < 0)
1393  {
1394  if (menu->tagprefix)
1396  continue;
1397  }
1398 
1399  if (ARRAY_EMPTY(&menu->dialog))
1400  mutt_clear_error();
1401 
1402  /* Convert menubar movement to scrolling */
1403  if (!ARRAY_EMPTY(&menu->dialog))
1404  op = menu_dialog_translate_op(op);
1405 
1406  switch (op)
1407  {
1408  case OP_NEXT_ENTRY:
1409  menu_next_entry(menu);
1410  break;
1411  case OP_PREV_ENTRY:
1412  menu_prev_entry(menu);
1413  break;
1414  case OP_HALF_DOWN:
1415  menu_half_down(menu);
1416  break;
1417  case OP_HALF_UP:
1418  menu_half_up(menu);
1419  break;
1420  case OP_NEXT_PAGE:
1421  menu_next_page(menu);
1422  break;
1423  case OP_PREV_PAGE:
1424  menu_prev_page(menu);
1425  break;
1426  case OP_NEXT_LINE:
1427  menu_next_line(menu);
1428  break;
1429  case OP_PREV_LINE:
1430  menu_prev_line(menu);
1431  break;
1432  case OP_FIRST_ENTRY:
1433  menu_first_entry(menu);
1434  break;
1435  case OP_LAST_ENTRY:
1436  menu_last_entry(menu);
1437  break;
1438  case OP_TOP_PAGE:
1439  menu_top_page(menu);
1440  break;
1441  case OP_MIDDLE_PAGE:
1442  menu_middle_page(menu);
1443  break;
1444  case OP_BOTTOM_PAGE:
1445  menu_bottom_page(menu);
1446  break;
1447  case OP_CURRENT_TOP:
1448  menu_current_top(menu);
1449  break;
1450  case OP_CURRENT_MIDDLE:
1451  menu_current_middle(menu);
1452  break;
1453  case OP_CURRENT_BOTTOM:
1454  menu_current_bottom(menu);
1455  break;
1456  case OP_SEARCH:
1457  case OP_SEARCH_REVERSE:
1458  case OP_SEARCH_NEXT:
1459  case OP_SEARCH_OPPOSITE:
1460  if (menu->custom_search)
1461  return op;
1462  else if (menu->search && ARRAY_EMPTY(&menu->dialog)) /* Searching dialogs won't work */
1463  {
1464  menu->oldcurrent = menu->current;
1465  menu->current = search(menu, op);
1466  if (menu->current != -1)
1467  menu->redraw = REDRAW_MOTION;
1468  else
1469  menu->current = menu->oldcurrent;
1470  }
1471  else
1472  mutt_error(_("Search is not implemented for this menu"));
1473  break;
1474 
1475  case OP_JUMP:
1476  if (!ARRAY_EMPTY(&menu->dialog))
1477  mutt_error(_("Jumping is not implemented for dialogs"));
1478  else
1479  menu_jump(menu);
1480  break;
1481 
1482  case OP_ENTER_COMMAND:
1484  window_set_focus(menu->win_index);
1485  window_redraw(RootWindow, false);
1486  break;
1487 
1488  case OP_TAG:
1489  if (menu->tag && ARRAY_EMPTY(&menu->dialog))
1490  {
1491  if (menu->tagprefix && !C_AutoTag)
1492  {
1493  for (int i = 0; i < menu->max; i++)
1494  menu->tagged += menu->tag(menu, i, 0);
1495  menu->redraw |= REDRAW_INDEX;
1496  }
1497  else if (menu->max)
1498  {
1499  int j = menu->tag(menu, menu->current, -1);
1500  menu->tagged += j;
1501  if (j && C_Resolve && (menu->current < menu->max - 1))
1502  {
1503  menu->current++;
1504  menu->redraw |= REDRAW_MOTION_RESYNC;
1505  }
1506  else
1507  menu->redraw |= REDRAW_CURRENT;
1508  }
1509  else
1510  mutt_error(_("No entries"));
1511  }
1512  else
1513  mutt_error(_("Tagging is not supported"));
1514  break;
1515 
1516  case OP_SHELL_ESCAPE:
1518  break;
1519 
1520  case OP_WHAT_KEY:
1521  mutt_what_key();
1522  break;
1523 
1524  case OP_CHECK_STATS:
1525  mutt_check_stats();
1526  break;
1527 
1528  case OP_REDRAW:
1529  clearok(stdscr, true);
1530  menu->redraw = REDRAW_FULL;
1531  break;
1532 
1533  case OP_HELP:
1534  mutt_help(menu->type, menu->win_index->state.cols);
1535  menu->redraw = REDRAW_FULL;
1536  break;
1537 
1538  case OP_NULL:
1539  km_error_key(menu->type);
1540  break;
1541 
1542  case OP_END_COND:
1543  break;
1544 
1545  default:
1546  if (menu->is_mailbox_list)
1547  last_position = menu->current;
1548  return op;
1549  }
1550  }
1551  /* not reached */
1552 }
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:763
#define mutt_message(...)
Definition: logging.h:83
int oldcurrent
For driver use only.
Definition: mutt_menu.h:76
void mutt_window_clrtoeol(struct MuttWindow *win)
Clear to the end of the line.
Definition: mutt_window.c:244
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
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:140
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:396
WHERE bool C_AutoTag
Config: Automatically apply actions to all tagged messages.
Definition: mutt_globals.h:137
int mutt_window_move(struct MuttWindow *win, int col, int row)
Move the cursor in a Window.
Definition: mutt_window.c:382
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:59
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
struct MuttWindow * RootWindow
Parent of all Windows.
Definition: mutt_window.c:45
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:75
bool tagprefix
Definition: mutt_menu.h:61
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition: array.h:70
bool is_mailbox_list
Definition: mutt_menu.h:62
int(* tag)(struct Menu *menu, int sel, int act)
Tag some menu items.
Definition: mutt_menu.h:107
bool custom_search
The menu implements its own non-Menusearch()-compatible search, trickle OP_SEARCH*.
Definition: mutt_menu.h:79
int tagged
Number of tagged entries.
Definition: mutt_menu.h:78
int max
Number of entries in the menu.
Definition: mutt_menu.h:57
WHERE bool C_ArrowCursor
Config: Use an arrow &#39;->&#39; instead of highlighting in the index.
Definition: mutt_globals.h:131
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:58
#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:747
int current
Current entry.
Definition: mutt_menu.h:56
struct MuttWindow * win_index
Definition: mutt_menu.h:63
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:98
#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:155
+ 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 943 of file menu.c.

944 {
945  struct Menu *menu = mutt_mem_calloc(1, sizeof(struct Menu));
946 
947  menu->type = type;
948  menu->current = 0;
949  menu->top = 0;
950  menu->redraw = REDRAW_FULL;
951  menu->color = default_color;
952  menu->search = generic_search;
953  menu->custom_search = false;
954 
955  return menu;
956 }
#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:52
enum MenuType type
Menu definition for keymap entries.
Definition: mutt_menu.h:59
int(* color)(int line)
Calculate the colour for a line of the menu.
Definition: mutt_menu.h:115
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:75
bool custom_search
The menu implements its own non-Menusearch()-compatible search, trickle OP_SEARCH*.
Definition: mutt_menu.h:79
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:58
int current
Current entry.
Definition: mutt_menu.h:56
int(* search)(struct Menu *menu, regex_t *rx, int line)
Search a menu for a item matching a regex.
Definition: mutt_menu.h:98
+ 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 1017 of file menu.c.

1018 {
1019  struct Menu *prev_menu = NULL;
1020 
1021  if (ARRAY_EMPTY(&MenuStack) || (*ARRAY_LAST(&MenuStack) != menu))
1022  {
1023  mutt_debug(LL_DEBUG1, "called with inactive menu\n");
1024  return;
1025  }
1026  ARRAY_SHRINK(&MenuStack, 1);
1027 
1028  prev_menu = get_current_menu();
1029  if (prev_menu)
1030  {
1031  CurrentMenu = prev_menu->type;
1032  prev_menu->redraw = REDRAW_FULL;
1033  }
1034  else
1035  {
1037  /* Clearing when NeoMutt exits would be an annoying change in behavior for
1038  * those who have disabled alternative screens. The option is currently
1039  * set by autocrypt initialization which mixes menus and prompts outside of
1040  * the normal menu system state. */
1042  {
1044  }
1045  }
1046 }
#define REDRAW_FULL
Redraw everything.
Definition: mutt_menu.h:45
GUI selectable list of items.
Definition: mutt_menu.h:52
Index panel (list of emails)
Definition: keymap.h:80
#define ARRAY_SHRINK(head, num)
Mark a number of slots at the end of the array as unused.
Definition: array.h:168
void mutt_window_clear(struct MuttWindow *win)
Clear a Window.
Definition: mutt_window.c:806
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:59
#define ARRAY_LAST(head)
Convenience method to get the last element.
Definition: array.h:140
WHERE bool OptMenuPopClearScreen
(pseudo) clear the screen when popping the last menu
Definition: options.h:40
struct MuttWindow * RootWindow
Parent of all Windows.
Definition: mutt_window.c:45
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition: array.h:70
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:58
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 1005 of file menu.c.

1006 {
1007  ARRAY_ADD(&MenuStack, menu);
1008  CurrentMenu = menu->type;
1009 }
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:59
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
Definition: array.h:152
+ 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 1062 of file menu.c.

1063 {
1064  struct Menu *current_menu = get_current_menu();
1065  if (current_menu)
1066  current_menu->redraw = REDRAW_FULL;
1067 }
#define REDRAW_FULL
Redraw everything.
Definition: mutt_menu.h:45
GUI selectable list of items.
Definition: mutt_menu.h:52
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:58
+ 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 1052 of file menu.c.

1053 {
1054  struct Menu *current_menu = get_current_menu();
1055  if (current_menu)
1056  current_menu->redraw |= redraw;
1057 }
GUI selectable list of items.
Definition: mutt_menu.h:52
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:58
+ 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 1088 of file menu.c.

1089 {
1090  if (CurrentMenu == menu)
1092 }
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 1076 of file menu.c.

1077 {
1078  if (CurrentMenu == menu)
1080 }
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:58
+ 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 1557 of file menu.c.

1558 {
1559  if (!nc->event_data)
1560  return -1;
1561  if (nc->event_type != NT_CONFIG)
1562  return 0;
1563 
1564  struct EventColor *ev_c = nc->event_data;
1565 
1566  int c = ev_c->color;
1567 
1568  bool simple = (c == MT_COLOR_INDEX_COLLAPSED) || (c == MT_COLOR_INDEX_DATE) ||
1569  (c == MT_COLOR_INDEX_LABEL) || (c == MT_COLOR_INDEX_NUMBER) ||
1570  (c == MT_COLOR_INDEX_SIZE) || (c == MT_COLOR_INDEX_TAGS);
1571  bool lists = (c == MT_COLOR_ATTACH_HEADERS) || (c == MT_COLOR_BODY) ||
1572  (c == MT_COLOR_HEADER) || (c == MT_COLOR_INDEX) ||
1573  (c == MT_COLOR_INDEX_AUTHOR) || (c == MT_COLOR_INDEX_FLAGS) ||
1574  (c == MT_COLOR_INDEX_SUBJECT) || (c == MT_COLOR_INDEX_TAG);
1575 
1576  // The changes aren't relevant to the index menu
1577  if (!simple && !lists)
1578  return 0;
1579 
1580  // Colour deleted from a list
1581  if ((nc->event_subtype == NT_COLOR_RESET) && lists && Context && Context->mailbox)
1582  {
1583  struct Mailbox *m = Context->mailbox;
1584  // Force re-caching of index colors
1585  for (int i = 0; i < m->msg_count; i++)
1586  {
1587  struct Email *e = m->emails[i];
1588  if (!e)
1589  break;
1590  e->pair = 0;
1591  }
1592  }
1593 
1595  return 0;
1596 }
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:159
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
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
Color has been reset/removed.
Definition: color.h:172
enum ColorId color
Definition: color.h:161
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 1601 of file menu.c.

1602 {
1603  if (!nc->event_data)
1604  return -1;
1605  if (nc->event_type != NT_CONFIG)
1606  return 0;
1607 
1608  struct EventConfig *ec = nc->event_data;
1609 
1610  const struct ConfigDef *cdef = ec->he->data;
1611  ConfigRedrawFlags flags = cdef->type & R_REDRAW_MASK;
1612 
1613  if (flags == R_REDRAW_NO_FLAGS)
1614  return 0;
1615 
1616  if (flags & R_INDEX)
1618  if (flags & R_PAGER)
1620  if (flags & R_PAGER_FLOW)
1621  {
1624  }
1625 
1626  if (flags & R_RESORT_SUB)
1627  OptSortSubthreads = true;
1628  if (flags & R_RESORT)
1629  OptNeedResort = true;
1630  if (flags & R_RESORT_INIT)
1631  OptResortInit = true;
1632  if (flags & R_TREE)
1633  OptRedrawTree = true;
1634 
1635  if (flags & R_REFLOW)
1636  mutt_window_reflow(NULL);
1637  if (flags & R_MENU)
1639 
1640  return 0;
1641 }
#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 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:433
#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_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 54 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 55 of file menu.c.

◆ C_MenuScroll

bool C_MenuScroll

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

Definition at line 56 of file menu.c.