NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
DOXYGEN
lib.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 "type.h"
+ Include dependency graph for lib.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Menu
 

Macros

#define MENU_REDRAW_NO_FLAGS   0
 No flags are set. More...
 
#define MENU_REDRAW_INDEX   (1 << 0)
 Redraw the index. More...
 
#define MENU_REDRAW_MOTION   (1 << 1)
 Redraw after moving the menu list. More...
 
#define MENU_REDRAW_CURRENT   (1 << 2)
 Redraw the current line of the menu. More...
 
#define MENU_REDRAW_STATUS   (1 << 3)
 Redraw the status bar. More...
 
#define MENU_REDRAW_FULL   (1 << 4)
 Redraw everything. More...
 
#define MENU_REDRAW_BODY   (1 << 5)
 Redraw the pager. More...
 
#define MENU_REDRAW_FLOW   (1 << 6)
 Used by pager to reflow text. More...
 

Typedefs

typedef uint8_t MenuRedrawFlags
 Flags, e.g. MENU_REDRAW_INDEX. More...
 

Functions

MenuRedrawFlags menu_bottom_page (struct Menu *menu)
 Move the focus to the bottom of the page. More...
 
MenuRedrawFlags menu_current_bottom (struct Menu *menu)
 Move the current selection to the bottom of the window. More...
 
MenuRedrawFlags menu_current_middle (struct Menu *menu)
 Move the current selection to the centre of the window. More...
 
MenuRedrawFlags menu_current_top (struct Menu *menu)
 Move the current selection to the top of the window. More...
 
MenuRedrawFlags menu_first_entry (struct Menu *menu)
 Move the focus to the first entry in the menu. More...
 
MenuRedrawFlags menu_half_down (struct Menu *menu)
 Move the focus down half a page in the menu. More...
 
MenuRedrawFlags menu_half_up (struct Menu *menu)
 Move the focus up half a page in the menu. More...
 
MenuRedrawFlags menu_last_entry (struct Menu *menu)
 Move the focus to the last entry in the menu. More...
 
MenuRedrawFlags menu_middle_page (struct Menu *menu)
 Move the focus to the centre of the page. More...
 
MenuRedrawFlags menu_next_entry (struct Menu *menu)
 Move the focus to the next item in the menu. More...
 
MenuRedrawFlags menu_next_line (struct Menu *menu)
 Move the view down one line, keeping the selection the same. More...
 
MenuRedrawFlags menu_next_page (struct Menu *menu)
 Move the focus to the next page in the menu. More...
 
MenuRedrawFlags menu_prev_entry (struct Menu *menu)
 Move the focus to the previous item in the menu. More...
 
MenuRedrawFlags menu_prev_line (struct Menu *menu)
 Move the view up one line, keeping the selection the same. More...
 
MenuRedrawFlags menu_prev_page (struct Menu *menu)
 Move the focus to the previous page in the menu. More...
 
MenuRedrawFlags menu_top_page (struct Menu *menu)
 Move the focus to the top of the page. 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_add_dialog_row (struct Menu *menu, const char *row)
 Add a row to a Menu. More...
 
void menu_cleanup (void)
 Free the saved Menu searches. More...
 
enum MenuType menu_get_current_type (void)
 Get the type of the current Window. More...
 
void menu_init (void)
 Initialise all the Menus. More...
 
int menu_loop (struct Menu *menu)
 Menu event loop. More...
 
struct MuttWindowmenu_new_window (enum MenuType type, struct ConfigSubset *sub)
 Create a new Menu Window. More...
 
int menu_get_index (struct Menu *menu)
 Get the current selection in the Menu. More...
 
MenuRedrawFlags menu_set_index (struct Menu *menu, int index)
 Set the current selection in the Menu. More...
 
MenuRedrawFlags menu_move_selection (struct Menu *menu, int index)
 Move the selection. More...
 
void menu_queue_redraw (struct Menu *menu, MenuRedrawFlags redraw)
 Queue a request for a redraw. More...
 
MenuRedrawFlags menu_move_view_relative (struct Menu *menu, int relative)
 Move the view relatively. More...
 
MenuRedrawFlags menu_set_and_notify (struct Menu *menu, int top, int index)
 Set the Menu selection/view and notify others. More...
 
void menu_adjust (struct Menu *menu)
 Reapply the config to the Menu. 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 lib.h.

Macro Definition Documentation

◆ MENU_REDRAW_NO_FLAGS

#define MENU_REDRAW_NO_FLAGS   0

No flags are set.

Definition at line 51 of file lib.h.

◆ MENU_REDRAW_INDEX

#define MENU_REDRAW_INDEX   (1 << 0)

Redraw the index.

Definition at line 52 of file lib.h.

◆ MENU_REDRAW_MOTION

#define MENU_REDRAW_MOTION   (1 << 1)

Redraw after moving the menu list.

Definition at line 53 of file lib.h.

◆ MENU_REDRAW_CURRENT

#define MENU_REDRAW_CURRENT   (1 << 2)

Redraw the current line of the menu.

Definition at line 54 of file lib.h.

◆ MENU_REDRAW_STATUS

#define MENU_REDRAW_STATUS   (1 << 3)

Redraw the status bar.

Definition at line 55 of file lib.h.

◆ MENU_REDRAW_FULL

#define MENU_REDRAW_FULL   (1 << 4)

Redraw everything.

Definition at line 56 of file lib.h.

◆ MENU_REDRAW_BODY

#define MENU_REDRAW_BODY   (1 << 5)

Redraw the pager.

Definition at line 57 of file lib.h.

◆ MENU_REDRAW_FLOW

#define MENU_REDRAW_FLOW   (1 << 6)

Used by pager to reflow text.

Definition at line 58 of file lib.h.

Typedef Documentation

◆ MenuRedrawFlags

typedef uint8_t MenuRedrawFlags

Flags, e.g. MENU_REDRAW_INDEX.

Definition at line 48 of file lib.h.

Function Documentation

◆ menu_bottom_page()

MenuRedrawFlags menu_bottom_page ( struct Menu menu)

Move the focus to the bottom of the page.

Parameters
menuCurrent Menu
Return values
numMenuRedrawFlags, e.g. MENU_REDRAW_CURRENT

Definition at line 351 of file move.c.

352 {
353  if (menu->max == 0)
354  {
355  mutt_error(_("No entries"));
356  return MENU_REDRAW_NO_FLAGS;
357  }
358 
359  int index = menu->top + menu->pagelen - 1;
360  if (index > (menu->max - 1))
361  index = menu->max - 1;
362  return menu_move_selection(menu, index);
363 }
#define mutt_error(...)
Definition: logging.h:88
MenuRedrawFlags menu_move_selection(struct Menu *menu, int index)
Move the selection.
Definition: move.c:227
#define _(a)
Definition: message.h:28
int top
Entry that is the top of the current page.
Definition: lib.h:89
int pagelen
Number of entries per screen.
Definition: lib.h:74
int max
Number of entries in the menu.
Definition: lib.h:71
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_current_bottom()

MenuRedrawFlags menu_current_bottom ( struct Menu menu)

Move the current selection to the bottom of the window.

Parameters
menuCurrent Menu
Return values
numMenuRedrawFlags, e.g. MENU_REDRAW_CURRENT

Definition at line 472 of file move.c.

473 {
474  if (menu->max == 0)
475  {
476  mutt_error(_("No entries"));
477  return MENU_REDRAW_NO_FLAGS;
478  }
479 
480  short context = cs_subset_number(menu->sub, "menu_context");
481  if (context > (menu->pagelen / 2))
482  return MENU_REDRAW_NO_FLAGS;
483 
484  context = MIN(context, (menu->pagelen / 2));
486  menu, 0 - (menu->top + menu->pagelen - 1 - menu->current - context));
487 }
#define MIN(a, b)
Definition: memory.h:31
#define mutt_error(...)
Definition: logging.h:88
#define _(a)
Definition: message.h:28
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
Definition: helpers.c:169
MenuRedrawFlags menu_move_view_relative(struct Menu *menu, int relative)
Move the view relatively.
Definition: move.c:244
int top
Entry that is the top of the current page.
Definition: lib.h:89
int pagelen
Number of entries per screen.
Definition: lib.h:74
int max
Number of entries in the menu.
Definition: lib.h:71
struct ConfigSubset * sub
Inherited config items.
Definition: lib.h:78
int current
Current entry.
Definition: lib.h:70
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_current_middle()

MenuRedrawFlags menu_current_middle ( struct Menu menu)

Move the current selection to the centre of the window.

Parameters
menuCurrent Menu
Return values
numMenuRedrawFlags, e.g. MENU_REDRAW_CURRENT

Definition at line 452 of file move.c.

453 {
454  if (menu->max == 0)
455  {
456  mutt_error(_("No entries"));
457  return MENU_REDRAW_NO_FLAGS;
458  }
459 
460  short context = cs_subset_number(menu->sub, "menu_context");
461  if (context > (menu->pagelen / 2))
462  return MENU_REDRAW_NO_FLAGS;
463 
464  return menu_move_view_relative(menu, menu->current - (menu->top + (menu->pagelen / 2)));
465 }
#define mutt_error(...)
Definition: logging.h:88
#define _(a)
Definition: message.h:28
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
Definition: helpers.c:169
MenuRedrawFlags menu_move_view_relative(struct Menu *menu, int relative)
Move the view relatively.
Definition: move.c:244
int top
Entry that is the top of the current page.
Definition: lib.h:89
int pagelen
Number of entries per screen.
Definition: lib.h:74
int max
Number of entries in the menu.
Definition: lib.h:71
struct ConfigSubset * sub
Inherited config items.
Definition: lib.h:78
int current
Current entry.
Definition: lib.h:70
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_current_top()

MenuRedrawFlags menu_current_top ( struct Menu menu)

Move the current selection to the top of the window.

Parameters
menuCurrent Menu
Return values
numMenuRedrawFlags, e.g. MENU_REDRAW_CURRENT

Definition at line 431 of file move.c.

432 {
433  if (menu->max == 0)
434  {
435  mutt_error(_("No entries"));
436  return MENU_REDRAW_NO_FLAGS;
437  }
438 
439  short context = cs_subset_number(menu->sub, "menu_context");
440  if (context > (menu->pagelen / 2))
441  return MENU_REDRAW_NO_FLAGS;
442 
443  context = MIN(context, (menu->pagelen / 2));
444  return menu_move_view_relative(menu, menu->current - menu->top - context);
445 }
#define MIN(a, b)
Definition: memory.h:31
#define mutt_error(...)
Definition: logging.h:88
#define _(a)
Definition: message.h:28
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
Definition: helpers.c:169
MenuRedrawFlags menu_move_view_relative(struct Menu *menu, int relative)
Move the view relatively.
Definition: move.c:244
int top
Entry that is the top of the current page.
Definition: lib.h:89
int pagelen
Number of entries per screen.
Definition: lib.h:74
int max
Number of entries in the menu.
Definition: lib.h:71
struct ConfigSubset * sub
Inherited config items.
Definition: lib.h:78
int current
Current entry.
Definition: lib.h:70
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_first_entry()

MenuRedrawFlags menu_first_entry ( struct Menu menu)

Move the focus to the first entry in the menu.

Parameters
menuCurrent Menu
Return values
numMenuRedrawFlags, e.g. MENU_REDRAW_CURRENT

Definition at line 398 of file move.c.

399 {
400  if (menu->max == 0)
401  {
402  mutt_error(_("No entries"));
403  return MENU_REDRAW_NO_FLAGS;
404  }
405 
406  return menu_move_selection(menu, 0);
407 }
#define mutt_error(...)
Definition: logging.h:88
MenuRedrawFlags menu_move_selection(struct Menu *menu, int index)
Move the selection.
Definition: move.c:227
#define _(a)
Definition: message.h:28
int max
Number of entries in the menu.
Definition: lib.h:71
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_half_down()

MenuRedrawFlags menu_half_down ( struct Menu menu)

Move the focus down half a page in the menu.

Parameters
menuCurrent Menu
Return values
numMenuRedrawFlags, e.g. MENU_REDRAW_CURRENT

Definition at line 504 of file move.c.

505 {
506  return menu_move_view_relative(menu, (menu->pagelen / 2));
507 }
MenuRedrawFlags menu_move_view_relative(struct Menu *menu, int relative)
Move the view relatively.
Definition: move.c:244
int pagelen
Number of entries per screen.
Definition: lib.h:74
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_half_up()

MenuRedrawFlags menu_half_up ( struct Menu menu)

Move the focus up half a page in the menu.

Parameters
menuCurrent Menu
Return values
numMenuRedrawFlags, e.g. MENU_REDRAW_CURRENT

Definition at line 494 of file move.c.

495 {
496  return menu_move_view_relative(menu, 0 - (menu->pagelen / 2));
497 }
MenuRedrawFlags menu_move_view_relative(struct Menu *menu, int relative)
Move the view relatively.
Definition: move.c:244
int pagelen
Number of entries per screen.
Definition: lib.h:74
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_last_entry()

MenuRedrawFlags menu_last_entry ( struct Menu menu)

Move the focus to the last entry in the menu.

Parameters
menuCurrent Menu
Return values
numMenuRedrawFlags, e.g. MENU_REDRAW_CURRENT

Definition at line 414 of file move.c.

415 {
416  if (menu->max == 0)
417  {
418  mutt_error(_("No entries"));
419  return MENU_REDRAW_NO_FLAGS;
420  }
421 
422  return menu_move_selection(menu, menu->max - 1);
423 }
#define mutt_error(...)
Definition: logging.h:88
MenuRedrawFlags menu_move_selection(struct Menu *menu, int index)
Move the selection.
Definition: move.c:227
#define _(a)
Definition: message.h:28
int max
Number of entries in the menu.
Definition: lib.h:71
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_middle_page()

MenuRedrawFlags menu_middle_page ( struct Menu menu)

Move the focus to the centre of the page.

Parameters
menuCurrent Menu
Return values
numMenuRedrawFlags, e.g. MENU_REDRAW_CURRENT

Definition at line 331 of file move.c.

332 {
333  if (menu->max == 0)
334  {
335  mutt_error(_("No entries"));
336  return MENU_REDRAW_NO_FLAGS;
337  }
338 
339  int i = menu->top + menu->pagelen;
340  if (i > (menu->max - 1))
341  i = menu->max - 1;
342 
343  return menu_move_selection(menu, menu->top + (i - menu->top) / 2);
344 }
#define mutt_error(...)
Definition: logging.h:88
MenuRedrawFlags menu_move_selection(struct Menu *menu, int index)
Move the selection.
Definition: move.c:227
#define _(a)
Definition: message.h:28
int top
Entry that is the top of the current page.
Definition: lib.h:89
int pagelen
Number of entries per screen.
Definition: lib.h:74
int max
Number of entries in the menu.
Definition: lib.h:71
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_next_entry()

MenuRedrawFlags menu_next_entry ( struct Menu menu)

Move the focus to the next item in the menu.

Parameters
menuCurrent Menu
Return values
numMenuRedrawFlags, e.g. MENU_REDRAW_CURRENT

Definition at line 384 of file move.c.

385 {
386  if (menu->current < (menu->max - 1))
387  return menu_move_selection(menu, menu->current + 1);
388 
389  mutt_message(_("You are on the last entry"));
390  return MENU_REDRAW_NO_FLAGS;
391 }
MenuRedrawFlags menu_move_selection(struct Menu *menu, int index)
Move the selection.
Definition: move.c:227
#define _(a)
Definition: message.h:28
int max
Number of entries in the menu.
Definition: lib.h:71
#define mutt_message(...)
Definition: logging.h:87
int current
Current entry.
Definition: lib.h:70
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_next_line()

MenuRedrawFlags menu_next_line ( struct Menu menu)

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

Parameters
menuCurrent Menu
Return values
numMenuRedrawFlags, e.g. MENU_REDRAW_CURRENT

Definition at line 527 of file move.c.

528 {
529  MenuRedrawFlags flags = menu_move_view_relative(menu, 1);
530  if (flags == MENU_REDRAW_NO_FLAGS)
531  mutt_message(_("You can't scroll down farther"));
532  return flags;
533 }
#define _(a)
Definition: message.h:28
MenuRedrawFlags menu_move_view_relative(struct Menu *menu, int relative)
Move the view relatively.
Definition: move.c:244
#define mutt_message(...)
Definition: logging.h:87
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_next_page()

MenuRedrawFlags menu_next_page ( struct Menu menu)

Move the focus to the next page in the menu.

Parameters
menuCurrent Menu
Return values
numMenuRedrawFlags, e.g. MENU_REDRAW_CURRENT

Definition at line 550 of file move.c.

551 {
552  return menu_move_view_relative(menu, menu->pagelen);
553 }
MenuRedrawFlags menu_move_view_relative(struct Menu *menu, int relative)
Move the view relatively.
Definition: move.c:244
int pagelen
Number of entries per screen.
Definition: lib.h:74
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_prev_entry()

MenuRedrawFlags menu_prev_entry ( struct Menu menu)

Move the focus to the previous item in the menu.

Parameters
menuCurrent Menu
Return values
numMenuRedrawFlags, e.g. MENU_REDRAW_CURRENT

Definition at line 370 of file move.c.

371 {
372  if (menu->current > 0)
373  return menu_move_selection(menu, menu->current - 1);
374 
375  mutt_message(_("You are on the first entry"));
376  return MENU_REDRAW_NO_FLAGS;
377 }
MenuRedrawFlags menu_move_selection(struct Menu *menu, int index)
Move the selection.
Definition: move.c:227
#define _(a)
Definition: message.h:28
#define mutt_message(...)
Definition: logging.h:87
int current
Current entry.
Definition: lib.h:70
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_prev_line()

MenuRedrawFlags menu_prev_line ( struct Menu menu)

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

Parameters
menuCurrent Menu
Return values
numMenuRedrawFlags, e.g. MENU_REDRAW_CURRENT

Definition at line 514 of file move.c.

515 {
516  MenuRedrawFlags flags = menu_move_view_relative(menu, -1);
517  if (flags == MENU_REDRAW_NO_FLAGS)
518  mutt_message(_("You can't scroll up farther"));
519  return flags;
520 }
#define _(a)
Definition: message.h:28
MenuRedrawFlags menu_move_view_relative(struct Menu *menu, int relative)
Move the view relatively.
Definition: move.c:244
#define mutt_message(...)
Definition: logging.h:87
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_prev_page()

MenuRedrawFlags menu_prev_page ( struct Menu menu)

Move the focus to the previous page in the menu.

Parameters
menuCurrent Menu
Return values
numMenuRedrawFlags, e.g. MENU_REDRAW_CURRENT

Definition at line 540 of file move.c.

541 {
542  return menu_move_view_relative(menu, 0 - menu->pagelen);
543 }
MenuRedrawFlags menu_move_view_relative(struct Menu *menu, int relative)
Move the view relatively.
Definition: move.c:244
int pagelen
Number of entries per screen.
Definition: lib.h:74
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_top_page()

MenuRedrawFlags menu_top_page ( struct Menu menu)

Move the focus to the top of the page.

Parameters
menuCurrent Menu
Return values
numMenuRedrawFlags, e.g. MENU_REDRAW_CURRENT

Definition at line 321 of file move.c.

322 {
323  return menu_move_selection(menu, menu->top);
324 }
MenuRedrawFlags menu_move_selection(struct Menu *menu, int index)
Move the selection.
Definition: move.c:227
int top
Entry that is the top of the current page.
Definition: lib.h:89
+ 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 490 of file draw.c.

491 {
492  char buf[1024];
493  int attr = menu->color(menu, menu->current);
494 
495  mutt_window_move(menu->win, 0, menu->current - menu->top);
496  menu_make_entry(menu, buf, sizeof(buf), menu->current);
497  menu_pad_string(menu, buf, sizeof(buf));
498 
500  const bool c_arrow_cursor = cs_subset_bool(menu->sub, "arrow_cursor");
501  const char *const c_arrow_string =
502  cs_subset_string(menu->sub, "arrow_string");
503  if (c_arrow_cursor)
504  {
505  mutt_window_addstr(menu->win, c_arrow_string);
506  mutt_curses_set_attr(attr);
507  mutt_window_addch(menu->win, ' ');
508  menu_pad_string(menu, buf, sizeof(buf));
509  print_enriched_string(menu->win, menu->current, attr, (unsigned char *) buf,
510  true, menu->sub);
511  }
512  else
513  print_enriched_string(menu->win, menu->current, attr, (unsigned char *) buf,
514  false, menu->sub);
515  menu->redraw &= MENU_REDRAW_STATUS;
517 }
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
void menu_make_entry(struct Menu *menu, char *buf, size_t buflen, int i)
Create string to display in a Menu (the index)
Definition: draw.c:299
void mutt_curses_set_color(enum ColorId color)
Set the current colour for text.
Definition: mutt_curses.c:56
MenuRedrawFlags redraw
When to redraw the screen.
Definition: lib.h:72
int mutt_window_move(struct MuttWindow *win, int col, int row)
Move the cursor in a Window.
Definition: mutt_window.c:310
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:76
int mutt_window_addstr(struct MuttWindow *win, const char *str)
Write a string to a Window.
Definition: mutt_window.c:434
Plain text.
Definition: color.h:58
int top
Entry that is the top of the current page.
Definition: lib.h:89
static void menu_pad_string(struct Menu *menu, char *buf, size_t buflen)
Pad a string with spaces for display in the Menu.
Definition: draw.c:318
Selected item in list.
Definition: color.h:54
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:317
static void print_enriched_string(struct MuttWindow *win, int index, int attr, unsigned char *s, bool do_color, struct ConfigSubset *sub)
Display a string with embedded colours and graphics.
Definition: draw.c:112
struct ConfigSubset * sub
Inherited config items.
Definition: lib.h:78
int current
Current entry.
Definition: lib.h:70
void mutt_curses_set_attr(int attr)
Set the attributes for text.
Definition: mutt_curses.c:39
int mutt_window_addch(struct MuttWindow *win, int ch)
Write one character to a Window.
Definition: mutt_window.c:402
int(* color)(struct Menu *menu, int line)
Definition: lib.h:142
+ 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 337 of file draw.c.

338 {
340  mutt_window_clear(menu->win);
341 
342  window_redraw(NULL);
343  menu->pagelen = menu->win->state.rows;
344 
346 }
void mutt_curses_set_color(enum ColorId color)
Set the current colour for text.
Definition: mutt_curses.c:56
MenuRedrawFlags redraw
When to redraw the screen.
Definition: lib.h:72
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:632
void mutt_window_clear(struct MuttWindow *win)
Clear a Window.
Definition: mutt_window.c:716
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:76
Plain text.
Definition: color.h:58
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:127
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:61
int pagelen
Number of entries per screen.
Definition: lib.h:74
+ 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 371 of file draw.c.

372 {
373  char buf[1024];
374  bool do_color;
375  int attr;
376 
377  for (int i = menu->top; i < (menu->top + menu->pagelen); i++)
378  {
379  if (i < menu->max)
380  {
381  attr = menu->color(menu, i);
382 
383  menu_make_entry(menu, buf, sizeof(buf), i);
384  menu_pad_string(menu, buf, sizeof(buf));
385 
386  mutt_curses_set_attr(attr);
387  mutt_window_move(menu->win, 0, i - menu->top);
388  do_color = true;
389 
390  const bool c_arrow_cursor = cs_subset_bool(menu->sub, "arrow_cursor");
391  const char *const c_arrow_string =
392  cs_subset_string(menu->sub, "arrow_string");
393  if (i == menu->current)
394  {
396  if (c_arrow_cursor)
397  {
398  mutt_window_addstr(menu->win, c_arrow_string);
399  mutt_curses_set_attr(attr);
400  mutt_window_addch(menu->win, ' ');
401  }
402  else
403  do_color = false;
404  }
405  else if (c_arrow_cursor)
406  {
407  /* Print space chars to match the screen width of `$arrow_string` */
408  mutt_window_printf(menu->win, "%*s", mutt_strwidth(c_arrow_string) + 1, "");
409  }
410 
411  print_enriched_string(menu->win, i, attr, (unsigned char *) buf, do_color, menu->sub);
412  }
413  else
414  {
416  mutt_window_clearline(menu->win, i - menu->top);
417  }
418  }
421 }
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
void menu_make_entry(struct Menu *menu, char *buf, size_t buflen, int i)
Create string to display in a Menu (the index)
Definition: draw.c:299
void mutt_curses_set_color(enum ColorId color)
Set the current colour for text.
Definition: mutt_curses.c:56
MenuRedrawFlags redraw
When to redraw the screen.
Definition: lib.h:72
int mutt_window_move(struct MuttWindow *win, int col, int row)
Move the cursor in a Window.
Definition: mutt_window.c:310
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:76
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:247
int mutt_window_addstr(struct MuttWindow *win, const char *str)
Write a string to a Window.
Definition: mutt_window.c:434
Plain text.
Definition: color.h:58
int mutt_strwidth(const char *s)
Measure a string&#39;s width in screen cells.
Definition: curs_lib.c:983
int mutt_window_printf(struct MuttWindow *win, const char *fmt,...)
Write a formatted string to a Window.
Definition: mutt_window.c:453
int top
Entry that is the top of the current page.
Definition: lib.h:89
static void menu_pad_string(struct Menu *menu, char *buf, size_t buflen)
Pad a string with spaces for display in the Menu.
Definition: draw.c:318
Selected item in list.
Definition: color.h:54
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:317
int pagelen
Number of entries per screen.
Definition: lib.h:74
static void print_enriched_string(struct MuttWindow *win, int index, int attr, unsigned char *s, bool do_color, struct ConfigSubset *sub)
Display a string with embedded colours and graphics.
Definition: draw.c:112
struct ConfigSubset * sub
Inherited config items.
Definition: lib.h:78
int current
Current entry.
Definition: lib.h:70
void mutt_curses_set_attr(int attr)
Set the attributes for text.
Definition: mutt_curses.c:39
int mutt_window_addch(struct MuttWindow *win, int ch)
Write one character to a Window.
Definition: mutt_window.c:402
int(* color)(struct Menu *menu, int line)
Definition: lib.h:142
+ 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 427 of file draw.c.

428 {
429  char buf[1024];
430 
431  if (!ARRAY_EMPTY(&menu->dialog))
432  {
433  menu->redraw &= ~MENU_REDRAW_MOTION;
434  return;
435  }
436 
437  /* Note: menu->color() for the index can end up retrieving a message
438  * over imap (if matching against ~h for instance). This can
439  * generate status messages. So we want to call it *before* we
440  * position the cursor for drawing. */
441  const int old_color = menu->color(menu, menu->oldcurrent);
442  mutt_window_move(menu->win, 0, menu->oldcurrent - menu->top);
443  mutt_curses_set_attr(old_color);
444 
445  const bool c_arrow_cursor = cs_subset_bool(menu->sub, "arrow_cursor");
446  const char *const c_arrow_string =
447  cs_subset_string(menu->sub, "arrow_string");
448  if (c_arrow_cursor)
449  {
450  /* clear the arrow */
451  /* Print space chars to match the screen width of `$arrow_string` */
452  mutt_window_printf(menu->win, "%*s", mutt_strwidth(c_arrow_string) + 1, "");
453 
454  menu_make_entry(menu, buf, sizeof(buf), menu->oldcurrent);
455  menu_pad_string(menu, buf, sizeof(buf));
456  mutt_window_move(menu->win, mutt_strwidth(c_arrow_string) + 1,
457  menu->oldcurrent - menu->top);
458  print_enriched_string(menu->win, menu->oldcurrent, old_color,
459  (unsigned char *) buf, true, menu->sub);
460 
461  /* now draw it in the new location */
463  mutt_window_mvaddstr(menu->win, 0, menu->current - menu->top, c_arrow_string);
464  }
465  else
466  {
467  /* erase the current indicator */
468  menu_make_entry(menu, buf, sizeof(buf), menu->oldcurrent);
469  menu_pad_string(menu, buf, sizeof(buf));
470  print_enriched_string(menu->win, menu->oldcurrent, old_color,
471  (unsigned char *) buf, true, menu->sub);
472 
473  /* now draw the new one to reflect the change */
474  const int cur_color = menu->color(menu, menu->current);
475  menu_make_entry(menu, buf, sizeof(buf), menu->current);
476  menu_pad_string(menu, buf, sizeof(buf));
478  mutt_window_move(menu->win, 0, menu->current - menu->top);
479  print_enriched_string(menu->win, menu->current, cur_color,
480  (unsigned char *) buf, false, menu->sub);
481  }
482  menu->redraw &= MENU_REDRAW_STATUS;
484 }
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
void menu_make_entry(struct Menu *menu, char *buf, size_t buflen, int i)
Create string to display in a Menu (the index)
Definition: draw.c:299
int oldcurrent
For driver use only.
Definition: lib.h:90
void mutt_curses_set_color(enum ColorId color)
Set the current colour for text.
Definition: mutt_curses.c:56
MenuRedrawFlags redraw
When to redraw the screen.
Definition: lib.h:72
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:324
int mutt_window_move(struct MuttWindow *win, int col, int row)
Move the cursor in a Window.
Definition: mutt_window.c:310
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:76
Plain text.
Definition: color.h:58
int mutt_strwidth(const char *s)
Measure a string&#39;s width in screen cells.
Definition: curs_lib.c:983
int mutt_window_printf(struct MuttWindow *win, const char *fmt,...)
Write a formatted string to a Window.
Definition: mutt_window.c:453
int top
Entry that is the top of the current page.
Definition: lib.h:89
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition: array.h:70
static void menu_pad_string(struct Menu *menu, char *buf, size_t buflen)
Pad a string with spaces for display in the Menu.
Definition: draw.c:318
Selected item in list.
Definition: color.h:54
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:317
static void print_enriched_string(struct MuttWindow *win, int index, int attr, unsigned char *s, bool do_color, struct ConfigSubset *sub)
Display a string with embedded colours and graphics.
Definition: draw.c:112
struct ConfigSubset * sub
Inherited config items.
Definition: lib.h:78
int current
Current entry.
Definition: lib.h:70
void mutt_curses_set_attr(int attr)
Set the attributes for text.
Definition: mutt_curses.c:39
int(* color)(struct Menu *menu, int line)
Definition: lib.h:142
+ 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 352 of file draw.c.

353 {
354  if (!menu || !menu->win_ibar)
355  return;
356 
357  char buf[256];
358 
359  snprintf(buf, sizeof(buf), "-- NeoMutt: %s", menu->title);
361  mutt_window_move(menu->win_ibar, 0, 0);
362  mutt_paddstr(menu->win_ibar, menu->win_ibar->state.cols, buf);
364  menu->redraw &= ~MENU_REDRAW_STATUS;
365 }
void mutt_curses_set_color(enum ColorId color)
Set the current colour for text.
Definition: mutt_curses.c:56
MenuRedrawFlags redraw
When to redraw the screen.
Definition: lib.h:72
int mutt_window_move(struct MuttWindow *win, int col, int row)
Move the cursor in a Window.
Definition: mutt_window.c:310
struct MuttWindow * win_ibar
Definition: lib.h:77
const char * title
Title of this menu.
Definition: lib.h:69
Plain text.
Definition: color.h:58
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:60
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:127
Status bar (takes a pattern)
Definition: color.h:75
void mutt_paddstr(struct MuttWindow *win, int n, const char *s)
Display a string on screen, padded if necessary.
Definition: curs_lib.c:890
+ 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 546 of file draw.c.

547 {
548  if (menu->custom_redraw)
549  {
550  menu->custom_redraw(menu);
551  return OP_NULL;
552  }
553 
554  /* See if all or part of the screen needs to be updated. */
555  if (menu->redraw & MENU_REDRAW_FULL)
556  {
557  menu_redraw_full(menu);
558  /* allow the caller to do any local configuration */
559  return OP_REDRAW;
560  }
561 
562  if (menu->redraw & MENU_REDRAW_STATUS)
563  menu_redraw_status(menu);
564  if (menu->redraw & MENU_REDRAW_INDEX)
565  menu_redraw_index(menu);
566  else if (menu->redraw & MENU_REDRAW_MOTION)
567  menu_redraw_motion(menu);
568  else if (menu->redraw == MENU_REDRAW_CURRENT)
569  menu_redraw_current(menu);
570 
571  if (!ARRAY_EMPTY(&menu->dialog))
572  menu_redraw_prompt(menu);
573 
574  return OP_NULL;
575 }
void menu_redraw_motion(struct Menu *menu)
Force the redraw of the list part of the menu.
Definition: draw.c:427
MenuRedrawFlags redraw
When to redraw the screen.
Definition: lib.h:72
static void menu_redraw_prompt(struct Menu *menu)
Force the redraw of the message window.
Definition: draw.c:523
void menu_redraw_status(struct Menu *menu)
Force the redraw of the status bar.
Definition: draw.c:352
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition: array.h:70
void(* custom_redraw)(struct Menu *menu)
Definition: lib.h:151
void menu_redraw_index(struct Menu *menu)
Force the redraw of the index.
Definition: draw.c:371
void menu_redraw_full(struct Menu *menu)
Force the redraw of the Menu.
Definition: draw.c:337
void menu_redraw_current(struct Menu *menu)
Redraw the current menu.
Definition: draw.c:490
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_add_dialog_row()

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

129 {
130  ARRAY_SET(&menu->dialog, menu->max, mutt_str_dup(row));
131  menu->max++;
132 }
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:370
int max
Number of entries in the menu.
Definition: lib.h:71
#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:

◆ menu_cleanup()

void menu_cleanup ( void  )

Free the saved Menu searches.

Definition at line 108 of file menu.c.

109 {
110  for (int i = 0; i < MENU_MAX; i++)
111  FREE(&SearchBuffers[i]);
112 }
Definition: type.h:59
#define FREE(x)
Definition: memory.h:40
+ Here is the caller graph for this function:

◆ menu_get_current_type()

enum MenuType menu_get_current_type ( void  )

Get the type of the current Window.

Return values
enumMenu Type, e.g. MENU_PAGER

Definition at line 529 of file menu.c.

530 {
531  struct MuttWindow *win = alldialogs_get_current();
532  while (win && win->focus)
533  win = win->focus;
534 
535  if (!win)
536  return MENU_GENERIC;
537 
538  if ((win->type == WT_CUSTOM) && (win->parent->type == WT_PAGER))
539  return MENU_PAGER;
540 
541  if (win->type != WT_MENU)
542  return MENU_GENERIC;
543 
544  struct Menu *menu = win->wdata;
545  if (!menu)
546  return MENU_GENERIC;
547 
548  return menu->type;
549 }
Definition: lib.h:67
Generic selection list.
Definition: type.h:45
struct MuttWindow * focus
Focussed Window.
Definition: mutt_window.h:140
Pager pager (email viewer)
Definition: type.h:54
enum MenuType type
Menu definition for keymap entries.
Definition: lib.h:73
Window with a custom drawing function.
Definition: mutt_window.h:95
struct MuttWindow * alldialogs_get_current(void)
Get the currently active Dialog.
Definition: dialog.c:224
A panel containing the Pager Window.
Definition: mutt_window.h:100
struct MuttWindow * parent
Parent Window.
Definition: mutt_window.h:135
void * wdata
Private data.
Definition: mutt_window.h:145
enum WindowType type
Window type, e.g. WT_SIDEBAR.
Definition: mutt_window.h:144
An Window containing a Menu.
Definition: mutt_window.h:98
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_init()

void menu_init ( void  )

Initialise all the Menus.

Definition at line 117 of file menu.c.

118 {
119  for (int i = 0; i < MENU_MAX; i++)
120  SearchBuffers[i] = NULL;
121 }
Definition: type.h:59
+ Here is the caller graph for this function:

◆ menu_loop()

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

283 {
284  int op = OP_NULL;
285 
286  while (true)
287  {
288  /* Clear the tag prefix unless we just started it. Don't clear
289  * the prefix on a timeout (op==-2), but do clear on an abort (op==-1) */
290  if (menu->tagprefix && (op != OP_TAG_PREFIX) &&
291  (op != OP_TAG_PREFIX_COND) && (op != -2))
292  {
293  menu->tagprefix = false;
294  }
295 
297 
298  if (menu_redraw(menu) == OP_REDRAW)
299  return OP_REDRAW;
300 
301  /* give visual indication that the next command is a tag- command */
302  if (menu->tagprefix)
304 
305  const bool c_arrow_cursor = cs_subset_bool(menu->sub, "arrow_cursor");
306  const bool c_braille_friendly =
307  cs_subset_bool(menu->sub, "braille_friendly");
308 
309  /* move the cursor out of the way */
310  if (c_arrow_cursor)
311  mutt_window_move(menu->win, 2, menu->current - menu->top);
312  else if (c_braille_friendly)
313  mutt_window_move(menu->win, 0, menu->current - menu->top);
314  else
315  {
316  mutt_window_move(menu->win, menu->win->state.cols - 1, menu->current - menu->top);
317  }
318 
319  mutt_refresh();
320 
321  /* try to catch dialog keys before ops */
322  if (!ARRAY_EMPTY(&menu->dialog) && (menu_dialog_dokey(menu, &op) == 0))
323  return op;
324 
325  const bool c_auto_tag = cs_subset_bool(menu->sub, "auto_tag");
326  op = km_dokey(menu->type);
327  if ((op == OP_TAG_PREFIX) || (op == OP_TAG_PREFIX_COND))
328  {
329  if (menu->tagprefix)
330  {
331  menu->tagprefix = false;
333  continue;
334  }
335 
336  if (menu->tagged)
337  {
338  menu->tagprefix = true;
339  continue;
340  }
341  else if (op == OP_TAG_PREFIX)
342  {
343  mutt_error(_("No tagged entries"));
344  op = -1;
345  }
346  else /* None tagged, OP_TAG_PREFIX_COND */
347  {
349  mutt_message(_("Nothing to do"));
350  op = -1;
351  }
352  }
353  else if (menu->tagged && c_auto_tag)
354  menu->tagprefix = true;
355 
357 
358  if (SigWinch)
359  {
360  SigWinch = false;
362  clearok(stdscr, true); /* force complete redraw */
363  }
364 
365  if (op < 0)
366  {
367  if (menu->tagprefix)
369  continue;
370  }
371 
372  if (ARRAY_EMPTY(&menu->dialog))
374 
375  /* Convert menubar movement to scrolling */
376  if (!ARRAY_EMPTY(&menu->dialog))
377  op = menu_dialog_translate_op(op);
378 
379  switch (op)
380  {
381  case OP_NEXT_ENTRY:
382  menu_next_entry(menu);
383  break;
384  case OP_PREV_ENTRY:
385  menu_prev_entry(menu);
386  break;
387  case OP_HALF_DOWN:
388  menu_half_down(menu);
389  break;
390  case OP_HALF_UP:
391  menu_half_up(menu);
392  break;
393  case OP_NEXT_PAGE:
394  menu_next_page(menu);
395  break;
396  case OP_PREV_PAGE:
397  menu_prev_page(menu);
398  break;
399  case OP_NEXT_LINE:
400  menu_next_line(menu);
401  break;
402  case OP_PREV_LINE:
403  menu_prev_line(menu);
404  break;
405  case OP_FIRST_ENTRY:
406  menu_first_entry(menu);
407  break;
408  case OP_LAST_ENTRY:
409  menu_last_entry(menu);
410  break;
411  case OP_TOP_PAGE:
412  menu_top_page(menu);
413  break;
414  case OP_MIDDLE_PAGE:
415  menu_middle_page(menu);
416  break;
417  case OP_BOTTOM_PAGE:
418  menu_bottom_page(menu);
419  break;
420  case OP_CURRENT_TOP:
421  menu_current_top(menu);
422  break;
423  case OP_CURRENT_MIDDLE:
424  menu_current_middle(menu);
425  break;
426  case OP_CURRENT_BOTTOM:
427  menu_current_bottom(menu);
428  break;
429  case OP_SEARCH:
430  case OP_SEARCH_REVERSE:
431  case OP_SEARCH_NEXT:
432  case OP_SEARCH_OPPOSITE:
433  if (menu->custom_search)
434  return op;
435  else if (menu->search && ARRAY_EMPTY(&menu->dialog)) /* Searching dialogs won't work */
436  {
437  int index = search(menu, op);
438  if (index != -1)
439  menu_set_index(menu, index);
440  }
441  else
442  mutt_error(_("Search is not implemented for this menu"));
443  break;
444 
445  case OP_JUMP:
446  if (!ARRAY_EMPTY(&menu->dialog))
447  mutt_error(_("Jumping is not implemented for dialogs"));
448  else
449  menu_jump(menu);
450  break;
451 
452  case OP_ENTER_COMMAND:
454  window_redraw(NULL);
455  break;
456 
457  case OP_TAG:
458  if (menu->tag && ARRAY_EMPTY(&menu->dialog))
459  {
460  const bool c_resolve = cs_subset_bool(menu->sub, "resolve");
461 
462  if (menu->tagprefix && !c_auto_tag)
463  {
464  for (int i = 0; i < menu->max; i++)
465  menu->tagged += menu->tag(menu, i, 0);
466  menu->redraw |= MENU_REDRAW_INDEX;
467  }
468  else if (menu->max != 0)
469  {
470  int j = menu->tag(menu, menu->current, -1);
471  menu->tagged += j;
472  if (j && c_resolve && (menu->current < (menu->max - 1)))
473  {
474  menu_set_index(menu, menu->current + 1);
475  }
476  else
477  menu->redraw |= MENU_REDRAW_CURRENT;
478  }
479  else
480  mutt_error(_("No entries"));
481  }
482  else
483  mutt_error(_("Tagging is not supported"));
484  break;
485 
486  case OP_SHELL_ESCAPE:
487  if (mutt_shell_escape())
488  {
490  }
491  break;
492 
493  case OP_WHAT_KEY:
494  mutt_what_key();
495  break;
496 
497  case OP_CHECK_STATS:
499  break;
500 
501  case OP_REDRAW:
502  clearok(stdscr, true);
503  menu->redraw = MENU_REDRAW_FULL;
504  break;
505 
506  case OP_HELP:
507  mutt_help(menu->type);
508  menu->redraw = MENU_REDRAW_FULL;
509  break;
510 
511  case OP_NULL:
512  km_error_key(menu->type);
513  break;
514 
515  case OP_END_COND:
516  break;
517 
518  default:
519  return op;
520  }
521  }
522  /* not reached */
523 }
The "current" mailbox.
Definition: context.h:37
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
struct Mailbox * ctx_mailbox(struct Context *ctx)
wrapper to get the mailbox in a Context, or NULL
Definition: context.c:444
#define mutt_error(...)
Definition: logging.h:88
bool mutt_shell_escape(void)
invoke a command in a subshell
Definition: commands.c:943
void mutt_resize_screen(void)
Update NeoMutt&#39;s opinion about the window size (CURSES)
Definition: resize.c:101
MenuRedrawFlags redraw
When to redraw the screen.
Definition: lib.h:72
void mutt_enter_command(void)
enter a neomutt command
Definition: commands.c:978
#define _(a)
Definition: message.h:28
int menu_redraw(struct Menu *menu)
Redraw the parts of the screen that have been flagged to be redrawn.
Definition: draw.c:546
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:632
void mutt_help(enum MenuType menu)
Display the help menu.
Definition: help.c:389
void msgwin_clear_text(void)
Clear the text in the Message Window.
Definition: msgwin.c:242
int mutt_window_move(struct MuttWindow *win, int col, int row)
Move the cursor in a Window.
Definition: mutt_window.c:310
void mutt_curses_set_cursor(enum MuttCursorState state)
Set the cursor state.
Definition: mutt_curses.c:71
enum MenuType type
Menu definition for keymap entries.
Definition: lib.h:73
void mutt_flush_macro_to_endcond(void)
Drop a macro from the input buffer.
Definition: curs_lib.c:639
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:76
void mutt_what_key(void)
Ask the user to press a key.
Definition: keymap.c:1718
Display a normal cursor.
Definition: mutt_curses.h:81
void km_error_key(enum MenuType mtype)
Handle an unbound key sequence.
Definition: keymap.c:1144
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:112
Plain text.
Definition: color.h:58
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:60
void mutt_refresh(void)
Force a refresh of the screen.
Definition: curs_lib.c:115
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:127
int mutt_mailbox_check(struct Mailbox *m_cur, int force)
Check all all Mailboxes for new mail.
Definition: mutt_mailbox.c:137
int top
Entry that is the top of the current page.
Definition: lib.h:89
bool tagprefix
User has pressed <tag-prefix>
Definition: lib.h:75
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition: array.h:70
int(* tag)(struct Menu *menu, int sel, int act)
Definition: lib.h:130
bool custom_search
The menu implements its own non-Menusearch()-compatible search, trickle OP_SEARCH*.
Definition: lib.h:93
int tagged
Number of tagged entries.
Definition: lib.h:92
#define MUTT_MAILBOX_CHECK_FORCE
Definition: mutt_mailbox.h:32
int max
Number of entries in the menu.
Definition: lib.h:71
struct ConfigSubset * sub
Inherited config items.
Definition: lib.h:78
void mutt_check_stats(struct Mailbox *m)
Forcibly update mailbox stats.
Definition: commands.c:1590
#define mutt_message(...)
Definition: logging.h:87
Hide the cursor.
Definition: mutt_curses.h:80
int current
Current entry.
Definition: lib.h:70
int km_dokey(enum MenuType mtype)
Determine what a keypress should do.
Definition: keymap.c:635
WHERE SIG_ATOMIC_VOLATILE_T SigWinch
true after SIGWINCH is received
Definition: mutt_globals.h:68
int(* search)(struct Menu *menu, regex_t *rx, int line)
Definition: lib.h:118
void msgwin_set_text(enum ColorId color, const char *text)
Set the text for the Message Window.
Definition: msgwin.c:223
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_new_window()

struct MuttWindow* menu_new_window ( enum MenuType  type,
struct ConfigSubset sub 
)

Create a new Menu Window.

Parameters
typeMenu type, e.g. MENU_PAGER
subConfig items
Return values
ptrNew MuttWindow wrapping a Menu

Definition at line 124 of file window.c.

125 {
126  struct MuttWindow *win =
129 
130  struct Menu *menu = menu_new(type, win, sub);
131 
132  win->recalc = menu_recalc;
133  win->repaint = menu_repaint;
134  win->wdata = menu;
136 
137  return win;
138 }
void(* wdata_free)(struct MuttWindow *win, void **ptr)
Definition: mutt_window.h:160
Definition: lib.h:67
Window uses all available vertical space.
Definition: mutt_window.h:38
static int menu_recalc(struct MuttWindow *win)
Recalculate the Window data - Implements MuttWindow::recalc() -.
Definition: window.c:82
enum MenuType type
Menu definition for keymap entries.
Definition: lib.h:73
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:76
static void menu_wdata_free(struct MuttWindow *win, void **ptr)
Destroy a Menu Window - Implements MuttWindow::wdata_free() -.
Definition: window.c:113
#define MUTT_WIN_SIZE_UNLIMITED
Use as much space as possible.
Definition: mutt_window.h:52
static int menu_repaint(struct MuttWindow *win)
Repaint the Window - Implements MuttWindow::repaint() -.
Definition: window.c:97
int(* repaint)(struct MuttWindow *win)
Definition: mutt_window.h:182
int(* recalc)(struct MuttWindow *win)
Definition: mutt_window.h:171
struct MuttWindow * mutt_window_new(enum WindowType type, enum MuttWindowOrientation orient, enum MuttWindowSize size, int cols, int rows)
Create a new Window.
Definition: mutt_window.c:180
Window wants as much space as possible.
Definition: mutt_window.h:48
void * wdata
Private data.
Definition: mutt_window.h:145
An Window containing a Menu.
Definition: mutt_window.h:98
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_get_index()

int menu_get_index ( struct Menu menu)

Get the current selection in the Menu.

Parameters
menuMenu
Return values
numIndex of selection

Definition at line 605 of file menu.c.

606 {
607  if (!menu)
608  return -1;
609 
610  return menu->current;
611 }
int current
Current entry.
Definition: lib.h:70

◆ menu_set_index()

MenuRedrawFlags menu_set_index ( struct Menu menu,
int  index 
)

Set the current selection in the Menu.

Parameters
menuMenu
indexItem to select
Return values
numMenuRedrawFlags, e.g. MENU_REDRAW_INDEX

Definition at line 619 of file menu.c.

620 {
621  return menu_move_selection(menu, index);
622 }
+ Here is the call graph for this function:

◆ menu_move_selection()

MenuRedrawFlags menu_move_selection ( struct Menu menu,
int  index 
)

Move the selection.

Parameters
menuMenu
indexNew selection

Definition at line 227 of file move.c.

228 {
229  if (index < 0)
230  index = 0;
231  else if (index >= menu->max)
232  index = menu->max - 1;
233 
234  int top = menu_drag_view(menu, menu->top, index);
235 
236  return menu_set_and_notify(menu, top, index);
237 }
int top
Entry that is the top of the current page.
Definition: lib.h:89
MenuRedrawFlags menu_set_and_notify(struct Menu *menu, int top, int index)
Set the Menu selection/view and notify others.
Definition: move.c:65
static int menu_drag_view(struct Menu *menu, int top, int index)
Move the view around the selection.
Definition: move.c:106
int max
Number of entries in the menu.
Definition: lib.h:71
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_queue_redraw()

void menu_queue_redraw ( struct Menu menu,
MenuRedrawFlags  redraw 
)

Queue a request for a redraw.

Parameters
menuMenu
redrawItem to redraw, e.g. MENU_REDRAW_CURRENT

Definition at line 629 of file menu.c.

630 {
631  if (!menu)
632  return;
633 
634  menu->redraw |= redraw;
635  menu->win->actions |= WA_RECALC;
636 }
MenuRedrawFlags redraw
When to redraw the screen.
Definition: lib.h:72
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:132
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:76
#define WA_RECALC
Recalculate the contents of the Window.
Definition: mutt_window.h:110

◆ menu_move_view_relative()

MenuRedrawFlags menu_move_view_relative ( struct Menu menu,
int  relative 
)

Move the view relatively.

Parameters
menuMenu
relativeRelative number of lines to move

Definition at line 244 of file move.c.

245 {
246  const bool c_menu_move_off = cs_subset_bool(menu->sub, "menu_move_off");
247 
248  short context = cs_subset_number(menu->sub, "menu_context");
249  context = MIN(context, (menu->pagelen / 2));
250 
251  // Move and range-check the view
252  int top = menu->top + relative;
253  if (top < 0)
254  {
255  top = 0;
256  }
257  else if (c_menu_move_off && (top >= (menu->max - context)))
258  {
259  top = menu->max - context - 1;
260  }
261  else if (!c_menu_move_off && ((top + menu->pagelen) >= menu->max))
262  {
263  top = menu->max - menu->pagelen;
264  }
265 
266  // Move the selection on-screen
267  int index = menu->current;
268  if (index < top)
269  index = top;
270  else if (index >= (top + menu->pagelen))
271  index = top + menu->pagelen - 1;
272 
273  // Check for top/bottom limits
274  if (index < context)
275  {
276  top = 0;
277  index = menu->current;
278  }
279  else if (!c_menu_move_off && (index > (menu->max - context)))
280  {
281  top = menu->max - menu->pagelen;
282  index = menu->current;
283  }
284 
285  if (top == menu->top)
286  {
287  // Can't move the view; move the selection
288  index = calc_fit_selection_to_view(menu, top, index + relative);
289  }
290  else if (index > (top + menu->pagelen - context - 1))
291  {
292  index = calc_fit_selection_to_view(menu, top, index + relative);
293  }
294  else
295  {
296  // Drag the selection into the view
297  index = calc_fit_selection_to_view(menu, top, index);
298  }
299 
300  return menu_set_and_notify(menu, top, index);
301 }
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
#define MIN(a, b)
Definition: memory.h:31
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
Definition: helpers.c:169
static int calc_fit_selection_to_view(struct Menu *menu, int top, int index)
Move the selection into the view.
Definition: move.c:158
int top
Entry that is the top of the current page.
Definition: lib.h:89
MenuRedrawFlags menu_set_and_notify(struct Menu *menu, int top, int index)
Set the Menu selection/view and notify others.
Definition: move.c:65
int pagelen
Number of entries per screen.
Definition: lib.h:74
int max
Number of entries in the menu.
Definition: lib.h:71
struct ConfigSubset * sub
Inherited config items.
Definition: lib.h:78
int current
Current entry.
Definition: lib.h:70
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_set_and_notify()

MenuRedrawFlags menu_set_and_notify ( struct Menu menu,
int  top,
int  index 
)

Set the Menu selection/view and notify others.

Parameters
menuMenu
topIndex of item at the top of the view
indexSelected item
Return values
numMenuRedrawFlags, e.g. MENU_REDRAW_CURRENT

Definition at line 65 of file move.c.

66 {
68 
69  if (top != menu->top)
70  {
71  menu->top = top;
72  flags |= MENU_REDRAW_FULL;
73  }
74 
75  if (index != menu->current)
76  {
77  menu->oldcurrent = menu->current;
78  menu->current = index;
79 
80  if (menu->redraw == MENU_REDRAW_NO_FLAGS)
81  {
82  // If this is the only change
83  flags |= MENU_REDRAW_MOTION;
84  }
85  else
86  {
87  // otherwise, redraw completely
88  flags |= MENU_REDRAW_FULL;
89  }
90  }
91 
92  menu->redraw |= flags;
93  menu->win->actions |= WA_REPAINT;
94 
95  mutt_debug(LL_NOTIFY, "NT_MENU\n");
96  notify_send(menu->notify, NT_MENU, flags, NULL);
97  return flags;
98 }
#define WA_REPAINT
Redraw the contents of the Window.
Definition: mutt_window.h:111
Log of notifications.
Definition: logging.h:45
int oldcurrent
For driver use only.
Definition: lib.h:90
MenuRedrawFlags redraw
When to redraw the screen.
Definition: lib.h:72
Menu has changed, MenuRedrawFlags.
Definition: notify_type.h:49
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:132
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:76
int top
Entry that is the top of the current page.
Definition: lib.h:89
struct Notify * notify
Notifications.
Definition: lib.h:153
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
int current
Current entry.
Definition: lib.h:70
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
Definition: notify.c:171
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_adjust()

void menu_adjust ( struct Menu menu)

Reapply the config to the Menu.

Parameters
menuMenu

Definition at line 307 of file move.c.

308 {
309  int top = calc_move_view(menu, 0);
310  top = menu_drag_view(menu, top, menu->current);
311 
312  menu_set_and_notify(menu, top, menu->current);
313 }
int top
Entry that is the top of the current page.
Definition: lib.h:89
MenuRedrawFlags menu_set_and_notify(struct Menu *menu, int top, int index)
Set the Menu selection/view and notify others.
Definition: move.c:65
static int menu_drag_view(struct Menu *menu, int top, int index)
Move the view around the selection.
Definition: move.c:106
static int calc_move_view(struct Menu *menu, int relative)
Move the view.
Definition: move.c:186
int current
Current entry.
Definition: lib.h:70
+ Here is the call graph for this function:
+ Here is the caller graph for this function: