NeoMutt  2021-10-29-220-g2b1eec
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:

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_FULL   (1 << 3)
 Redraw everything. More...
 
#define MENU_REDRAW_BODY   (1 << 4)
 Redraw the pager. More...
 
#define MENU_REDRAW_FLOW   (1 << 5)
 Used by pager to reflow text. More...
 

Typedefs

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

Functions

 ARRAY_HEAD (DialogLines, char *)
 
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...
 
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, keeping within between [0, menu->max]. 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_FULL

#define MENU_REDRAW_FULL   (1 << 3)

Redraw everything.

Definition at line 55 of file lib.h.

◆ MENU_REDRAW_BODY

#define MENU_REDRAW_BODY   (1 << 4)

Redraw the pager.

Definition at line 56 of file lib.h.

◆ MENU_REDRAW_FLOW

#define MENU_REDRAW_FLOW   (1 << 5)

Used by pager to reflow text.

Definition at line 57 of file lib.h.

Typedef Documentation

◆ MenuRedrawFlags

typedef uint8_t MenuRedrawFlags

Flags, e.g. MENU_REDRAW_INDEX.

Definition at line 50 of file lib.h.

Function Documentation

◆ ARRAY_HEAD()

ARRAY_HEAD ( DialogLines  ,
char *   
)

◆ 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 358 of file move.c.

359 {
360  if (menu->max == 0)
361  {
362  mutt_error(_("No entries"));
363  return MENU_REDRAW_NO_FLAGS;
364  }
365 
366  int index = menu->top + menu->pagelen - 1;
367  if (index > (menu->max - 1))
368  index = menu->max - 1;
369  return menu_move_selection(menu, index);
370 }
#define mutt_error(...)
Definition: logging.h:87
#define MENU_REDRAW_NO_FLAGS
No flags are set.
Definition: lib.h:51
MenuRedrawFlags menu_move_selection(struct Menu *menu, int index)
Move the selection, keeping within between [0, menu->max].
Definition: move.c:233
#define _(a)
Definition: message.h:28
int top
Entry that is the top of the current page.
Definition: lib.h:88
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 479 of file move.c.

480 {
481  if (menu->max == 0)
482  {
483  mutt_error(_("No entries"));
484  return MENU_REDRAW_NO_FLAGS;
485  }
486 
487  short context = cs_subset_number(menu->sub, "menu_context");
488  if (context > (menu->pagelen / 2))
489  return MENU_REDRAW_NO_FLAGS;
490 
491  context = MIN(context, (menu->pagelen / 2));
493  menu, 0 - (menu->top + menu->pagelen - 1 - menu->current - context));
494 }
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
Definition: helpers.c:169
#define MIN(a, b)
Definition: memory.h:31
MenuRedrawFlags menu_move_view_relative(struct Menu *menu, int relative)
Move the view relatively.
Definition: move.c:251
int current
Current entry.
Definition: lib.h:70
struct ConfigSubset * sub
Inherited config items.
Definition: lib.h:77
+ 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 459 of file move.c.

460 {
461  if (menu->max == 0)
462  {
463  mutt_error(_("No entries"));
464  return MENU_REDRAW_NO_FLAGS;
465  }
466 
467  short context = cs_subset_number(menu->sub, "menu_context");
468  if (context > (menu->pagelen / 2))
469  return MENU_REDRAW_NO_FLAGS;
470 
471  return menu_move_view_relative(menu, menu->current - (menu->top + (menu->pagelen / 2)));
472 }
+ 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 438 of file move.c.

439 {
440  if (menu->max == 0)
441  {
442  mutt_error(_("No entries"));
443  return MENU_REDRAW_NO_FLAGS;
444  }
445 
446  short context = cs_subset_number(menu->sub, "menu_context");
447  if (context > (menu->pagelen / 2))
448  return MENU_REDRAW_NO_FLAGS;
449 
450  context = MIN(context, (menu->pagelen / 2));
451  return menu_move_view_relative(menu, menu->current - menu->top - context);
452 }
+ 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 405 of file move.c.

406 {
407  if (menu->max == 0)
408  {
409  mutt_error(_("No entries"));
410  return MENU_REDRAW_NO_FLAGS;
411  }
412 
413  return menu_move_selection(menu, 0);
414 }
+ 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 511 of file move.c.

512 {
513  return menu_move_view_relative(menu, (menu->pagelen / 2));
514 }
+ 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 501 of file move.c.

502 {
503  return menu_move_view_relative(menu, 0 - (menu->pagelen / 2));
504 }
+ 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 421 of file move.c.

422 {
423  if (menu->max == 0)
424  {
425  mutt_error(_("No entries"));
426  return MENU_REDRAW_NO_FLAGS;
427  }
428 
429  return menu_move_selection(menu, menu->max - 1);
430 }
+ 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 338 of file move.c.

339 {
340  if (menu->max == 0)
341  {
342  mutt_error(_("No entries"));
343  return MENU_REDRAW_NO_FLAGS;
344  }
345 
346  int i = menu->top + menu->pagelen;
347  if (i > (menu->max - 1))
348  i = menu->max - 1;
349 
350  return menu_move_selection(menu, menu->top + (i - menu->top) / 2);
351 }
+ 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 391 of file move.c.

392 {
393  if (menu->current < (menu->max - 1))
394  return menu_move_selection(menu, menu->current + 1);
395 
396  mutt_message(_("You are on the last entry"));
397  return MENU_REDRAW_NO_FLAGS;
398 }
#define mutt_message(...)
Definition: logging.h:86
+ 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 534 of file move.c.

535 {
536  MenuRedrawFlags flags = menu_move_view_relative(menu, 1);
537  if (flags == MENU_REDRAW_NO_FLAGS)
538  mutt_message(_("You can't scroll down farther"));
539  return flags;
540 }
uint8_t MenuRedrawFlags
Flags, e.g. MENU_REDRAW_INDEX.
Definition: lib.h:48
+ 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 557 of file move.c.

558 {
559  return menu_move_view_relative(menu, menu->pagelen);
560 }
+ 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 377 of file move.c.

378 {
379  if (menu->current > 0)
380  return menu_move_selection(menu, menu->current - 1);
381 
382  mutt_message(_("You are on the first entry"));
383  return MENU_REDRAW_NO_FLAGS;
384 }
+ 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 521 of file move.c.

522 {
523  MenuRedrawFlags flags = menu_move_view_relative(menu, -1);
524  if (flags == MENU_REDRAW_NO_FLAGS)
525  mutt_message(_("You can't scroll up farther"));
526  return flags;
527 }
+ 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 547 of file move.c.

548 {
549  return menu_move_view_relative(menu, 0 - menu->pagelen);
550 }
+ 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 328 of file move.c.

329 {
330  return menu_move_selection(menu, menu->top);
331 }
+ 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 464 of file draw.c.

465 {
466  char buf[1024];
467  int attr = menu->color(menu, menu->current);
468 
469  mutt_window_move(menu->win, 0, menu->current - menu->top);
470  menu_make_entry(menu, buf, sizeof(buf), menu->current);
471  menu_pad_string(menu, buf, sizeof(buf));
472 
474  const bool c_arrow_cursor = cs_subset_bool(menu->sub, "arrow_cursor");
475  const char *const c_arrow_string =
476  cs_subset_string(menu->sub, "arrow_string");
477  if (c_arrow_cursor)
478  {
479  mutt_window_addstr(menu->win, c_arrow_string);
480  mutt_curses_set_attr(attr);
481  mutt_window_addch(menu->win, ' ');
482  menu_pad_string(menu, buf, sizeof(buf));
483  print_enriched_string(menu->win, menu->current, attr, (unsigned char *) buf,
484  true, menu->sub);
485  }
486  else
487  print_enriched_string(menu->win, menu->current, attr, (unsigned char *) buf,
488  false, menu->sub);
490 }
@ MT_COLOR_INDICATOR
Selected item in list.
Definition: color.h:49
@ MT_COLOR_NORMAL
Plain text.
Definition: color.h:53
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:313
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:294
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:115
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:317
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
void mutt_curses_set_attr(int attr)
Set the attributes for text.
Definition: mutt_curses.c:39
void mutt_curses_set_color_by_id(enum ColorId cid)
Set the current colour for text.
Definition: mutt_curses.c:52
int mutt_window_move(struct MuttWindow *win, int col, int row)
Move the cursor in a Window.
Definition: mutt_window.c:292
int mutt_window_addstr(struct MuttWindow *win, const char *str)
Write a string to a Window.
Definition: mutt_window.c:408
int mutt_window_addch(struct MuttWindow *win, int ch)
Write one character to a Window.
Definition: mutt_window.c:380
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:76
int(* color)(struct Menu *menu, int line)
Definition: lib.h:141
+ 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 332 of file draw.c.

333 {
335  mutt_window_clear(menu->win);
336 
337  menu->pagelen = menu->win->state.rows;
338 
339  menu->redraw = MENU_REDRAW_INDEX;
340 }
#define MENU_REDRAW_INDEX
Redraw the index.
Definition: lib.h:52
void mutt_window_clear(struct MuttWindow *win)
Clear a Window.
Definition: mutt_window.c:687
MenuRedrawFlags redraw
When to redraw the screen.
Definition: lib.h:72
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
+ 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 346 of file draw.c.

347 {
348  char buf[1024];
349  bool do_color;
350  int attr;
351 
352  for (int i = menu->top; i < (menu->top + menu->pagelen); i++)
353  {
354  if (i < menu->max)
355  {
356  attr = menu->color(menu, i);
357 
358  menu_make_entry(menu, buf, sizeof(buf), i);
359  menu_pad_string(menu, buf, sizeof(buf));
360 
361  mutt_curses_set_attr(attr);
362  mutt_window_move(menu->win, 0, i - menu->top);
363  do_color = true;
364 
365  const bool c_arrow_cursor = cs_subset_bool(menu->sub, "arrow_cursor");
366  const char *const c_arrow_string =
367  cs_subset_string(menu->sub, "arrow_string");
368  if (i == menu->current)
369  {
371  if (c_arrow_cursor)
372  {
373  mutt_window_addstr(menu->win, c_arrow_string);
374  mutt_curses_set_attr(attr);
375  mutt_window_addch(menu->win, ' ');
376  }
377  else
378  do_color = false;
379  }
380  else if (c_arrow_cursor)
381  {
382  /* Print space chars to match the screen width of `$arrow_string` */
383  mutt_window_printf(menu->win, "%*s", mutt_strwidth(c_arrow_string) + 1, "");
384  }
385 
386  print_enriched_string(menu->win, i, attr, (unsigned char *) buf, do_color, menu->sub);
387  }
388  else
389  {
391  mutt_window_clearline(menu->win, i - menu->top);
392  }
393  }
396 }
int mutt_strwidth(const char *s)
Measure a string's width in screen cells.
Definition: curs_lib.c:956
int mutt_window_printf(struct MuttWindow *win, const char *fmt,...)
Write a formatted string to a Window.
Definition: mutt_window.c:423
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:229
+ 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 402 of file draw.c.

403 {
404  char buf[1024];
405 
406  if (!ARRAY_EMPTY(&menu->dialog))
407  {
408  menu->redraw &= ~MENU_REDRAW_MOTION;
409  return;
410  }
411 
412  /* Note: menu->color() for the index can end up retrieving a message
413  * over imap (if matching against ~h for instance). This can
414  * generate status messages. So we want to call it *before* we
415  * position the cursor for drawing. */
416  const int old_color = menu->color(menu, menu->oldcurrent);
417  mutt_window_move(menu->win, 0, menu->oldcurrent - menu->top);
418  mutt_curses_set_attr(old_color);
419 
420  const bool c_arrow_cursor = cs_subset_bool(menu->sub, "arrow_cursor");
421  const char *const c_arrow_string =
422  cs_subset_string(menu->sub, "arrow_string");
423  if (c_arrow_cursor)
424  {
425  /* clear the arrow */
426  /* Print space chars to match the screen width of `$arrow_string` */
427  mutt_window_printf(menu->win, "%*s", mutt_strwidth(c_arrow_string) + 1, "");
428 
429  menu_make_entry(menu, buf, sizeof(buf), menu->oldcurrent);
430  menu_pad_string(menu, buf, sizeof(buf));
431  mutt_window_move(menu->win, mutt_strwidth(c_arrow_string) + 1,
432  menu->oldcurrent - menu->top);
433  print_enriched_string(menu->win, menu->oldcurrent, old_color,
434  (unsigned char *) buf, true, menu->sub);
435 
436  /* now draw it in the new location */
438  mutt_window_mvaddstr(menu->win, 0, menu->current - menu->top, c_arrow_string);
439  }
440  else
441  {
442  /* erase the current indicator */
443  menu_make_entry(menu, buf, sizeof(buf), menu->oldcurrent);
444  menu_pad_string(menu, buf, sizeof(buf));
445  print_enriched_string(menu->win, menu->oldcurrent, old_color,
446  (unsigned char *) buf, true, menu->sub);
447 
448  /* now draw the new one to reflect the change */
449  const int cur_color = menu->color(menu, menu->current);
450  menu_make_entry(menu, buf, sizeof(buf), menu->current);
451  menu_pad_string(menu, buf, sizeof(buf));
453  mutt_window_move(menu->win, 0, menu->current - menu->top);
454  print_enriched_string(menu->win, menu->current, cur_color,
455  (unsigned char *) buf, false, menu->sub);
456  }
458 }
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition: array.h:70
#define MENU_REDRAW_MOTION
Redraw after moving the menu list.
Definition: lib.h:53
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:306
struct DialogLines dialog
Dialog lines themselves.
Definition: lib.h:83
int oldcurrent
For driver use only.
Definition: lib.h:89
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_redraw()

int menu_redraw ( struct Menu menu)

Redraw the parts of the screen that have been flagged to be redrawn.

Parameters
menuMenu to redraw
Return values
OP_NULLMenu was redrawn
OP_REDRAWFull redraw required

Definition at line 519 of file draw.c.

520 {
521  if (menu->custom_redraw)
522  {
523  menu->custom_redraw(menu);
524  return OP_NULL;
525  }
526 
527  /* See if all or part of the screen needs to be updated. */
528  if (menu->redraw & MENU_REDRAW_FULL)
529  {
530  menu_redraw_full(menu);
531  /* allow the caller to do any local configuration */
532  return OP_REDRAW;
533  }
534 
535  if (menu->redraw & MENU_REDRAW_INDEX)
536  menu_redraw_index(menu);
537  else if (menu->redraw & MENU_REDRAW_MOTION)
538  menu_redraw_motion(menu);
539  else if (menu->redraw == MENU_REDRAW_CURRENT)
540  menu_redraw_current(menu);
541 
542  if (!ARRAY_EMPTY(&menu->dialog))
543  menu_redraw_prompt(menu);
544 
545  return OP_NULL;
546 }
void menu_redraw_current(struct Menu *menu)
Redraw the current menu.
Definition: draw.c:464
void menu_redraw_index(struct Menu *menu)
Force the redraw of the index.
Definition: draw.c:346
static void menu_redraw_prompt(struct Menu *menu)
Force the redraw of the message window.
Definition: draw.c:496
void menu_redraw_full(struct Menu *menu)
Force the redraw of the Menu.
Definition: draw.c:332
void menu_redraw_motion(struct Menu *menu)
Force the redraw of the list part of the menu.
Definition: draw.c:402
#define MENU_REDRAW_FULL
Redraw everything.
Definition: lib.h:55
#define MENU_REDRAW_CURRENT
Redraw the current line of the menu.
Definition: lib.h:54
void(* custom_redraw)(struct Menu *menu)
Definition: lib.h:150
+ 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 135 of file menu.c.

136 {
137  ARRAY_SET(&menu->dialog, menu->max, mutt_str_dup(row));
138  menu->max++;
139 }
#define ARRAY_SET(head, idx, elem)
Set an element in the array.
Definition: array.h:119
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:181
+ 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 115 of file menu.c.

116 {
117  for (int i = 0; i < MENU_MAX; i++)
118  FREE(&SearchBuffers[i]);
119 }
#define FREE(x)
Definition: memory.h:40
char * SearchBuffers[MENU_MAX]
Definition: menu.c:53
@ MENU_MAX
Definition: type.h:59
+ 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 295 of file menu.c.

548 {
549  struct MuttWindow *win = alldialogs_get_current();
550  while (win && win->focus)
551  win = win->focus;
552 
553  // This should only happen before the first dialog is created
554  if (!win)
555  return MENU_MAIN;
556 
557  if ((win->type == WT_CUSTOM) && (win->parent->type == WT_PAGER))
558  return MENU_PAGER;
559 
560  if (win->type != WT_MENU)
561  return MENU_GENERIC;
562 
563  struct Menu *menu = win->wdata;
564  if (!menu)
565  return MENU_GENERIC;
566 
567  return menu->type;
568 }
struct MuttWindow * alldialogs_get_current(void)
Get the currently active Dialog.
Definition: dialog.c:222
@ WT_CUSTOM
Window with a custom drawing function.
Definition: mutt_window.h:95
@ WT_PAGER
A panel containing the Pager Window.
Definition: mutt_window.h:100
@ WT_MENU
An Window containing a Menu.
Definition: mutt_window.h:98
Definition: lib.h:69
enum MenuType type
Menu definition for keymap entries.
Definition: lib.h:73
struct MuttWindow * focus
Focused Window.
Definition: mutt_window.h:140
void * wdata
Private data.
Definition: mutt_window.h:145
struct MuttWindow * parent
Parent Window.
Definition: mutt_window.h:135
enum WindowType type
Window type, e.g. WT_SIDEBAR.
Definition: mutt_window.h:144
@ MENU_MAIN
Index panel (list of emails)
Definition: type.h:50
@ MENU_GENERIC
Generic selection list.
Definition: type.h:45
@ MENU_PAGER
Pager pager (email viewer)
Definition: type.h:54
+ 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 124 of file menu.c.

125 {
126  for (int i = 0; i < MENU_MAX; i++)
127  SearchBuffers[i] = NULL;
128 }
+ 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 295 of file menu.c.

296 {
297  int op = OP_NULL;
298 
299  while (true)
300  {
301  /* Clear the tag prefix unless we just started it. Don't clear
302  * the prefix on a timeout (op==-2), but do clear on an abort (op==-1) */
303  if (menu->tagprefix && (op != OP_TAG_PREFIX) &&
304  (op != OP_TAG_PREFIX_COND) && (op != -2))
305  {
306  menu->tagprefix = false;
307  }
308 
310 
311  if (menu_redraw(menu) == OP_REDRAW)
312  return OP_REDRAW;
313 
314  /* give visual indication that the next command is a tag- command */
315  if (menu->tagprefix)
317 
318  const bool c_arrow_cursor = cs_subset_bool(menu->sub, "arrow_cursor");
319  const bool c_braille_friendly =
320  cs_subset_bool(menu->sub, "braille_friendly");
321 
322  /* move the cursor out of the way */
323  if (c_arrow_cursor)
324  mutt_window_move(menu->win, 2, menu->current - menu->top);
325  else if (c_braille_friendly)
326  mutt_window_move(menu->win, 0, menu->current - menu->top);
327  else
328  {
329  mutt_window_move(menu->win, menu->win->state.cols - 1, menu->current - menu->top);
330  }
331 
332  mutt_refresh();
333 
334  if (SigWinch)
335  {
336  SigWinch = false;
338  clearok(stdscr, true); /* force complete redraw */
339  }
340 
341  /* try to catch dialog keys before ops */
342  if (!ARRAY_EMPTY(&menu->dialog) && (menu_dialog_dokey(menu, &op) == 0))
343  return op;
344 
345  window_redraw(NULL);
346  const bool c_auto_tag = cs_subset_bool(menu->sub, "auto_tag");
347  op = km_dokey(menu->type);
348  if ((op == OP_TAG_PREFIX) || (op == OP_TAG_PREFIX_COND))
349  {
350  if (menu->tagprefix)
351  {
352  menu->tagprefix = false;
354  continue;
355  }
356 
357  if (menu->tagged)
358  {
359  menu->tagprefix = true;
360  continue;
361  }
362  else if (op == OP_TAG_PREFIX)
363  {
364  mutt_error(_("No tagged entries"));
365  op = -1;
366  }
367  else /* None tagged, OP_TAG_PREFIX_COND */
368  {
370  mutt_message(_("Nothing to do"));
371  op = -1;
372  }
373  }
374  else if (menu->tagged && c_auto_tag)
375  menu->tagprefix = true;
376 
378 
379  if (op < 0)
380  {
381  if (menu->tagprefix)
383  continue;
384  }
385 
386  if (ARRAY_EMPTY(&menu->dialog))
388 
389  /* Convert menubar movement to scrolling */
390  if (!ARRAY_EMPTY(&menu->dialog))
391  op = menu_dialog_translate_op(op);
392 
393  switch (op)
394  {
395  case OP_NEXT_ENTRY:
396  menu_next_entry(menu);
397  break;
398  case OP_PREV_ENTRY:
399  menu_prev_entry(menu);
400  break;
401  case OP_HALF_DOWN:
402  menu_half_down(menu);
403  break;
404  case OP_HALF_UP:
405  menu_half_up(menu);
406  break;
407  case OP_NEXT_PAGE:
408  menu_next_page(menu);
409  break;
410  case OP_PREV_PAGE:
411  menu_prev_page(menu);
412  break;
413  case OP_NEXT_LINE:
414  menu_next_line(menu);
415  break;
416  case OP_PREV_LINE:
417  menu_prev_line(menu);
418  break;
419  case OP_FIRST_ENTRY:
420  menu_first_entry(menu);
421  break;
422  case OP_LAST_ENTRY:
423  menu_last_entry(menu);
424  break;
425  case OP_TOP_PAGE:
426  menu_top_page(menu);
427  break;
428  case OP_MIDDLE_PAGE:
429  menu_middle_page(menu);
430  break;
431  case OP_BOTTOM_PAGE:
432  menu_bottom_page(menu);
433  break;
434  case OP_CURRENT_TOP:
435  menu_current_top(menu);
436  break;
437  case OP_CURRENT_MIDDLE:
438  menu_current_middle(menu);
439  break;
440  case OP_CURRENT_BOTTOM:
441  menu_current_bottom(menu);
442  break;
443  case OP_SEARCH:
444  case OP_SEARCH_REVERSE:
445  case OP_SEARCH_NEXT:
446  case OP_SEARCH_OPPOSITE:
447  if (menu->custom_search)
448  return op;
449  else if (menu->search && ARRAY_EMPTY(&menu->dialog)) /* Searching dialogs won't work */
450  {
451  int index = search(menu, op);
452  if (index != -1)
453  menu_set_index(menu, index);
454  }
455  else
456  mutt_error(_("Search is not implemented for this menu"));
457  break;
458 
459  case OP_JUMP:
460  if (!ARRAY_EMPTY(&menu->dialog))
461  mutt_error(_("Jumping is not implemented for dialogs"));
462  else
463  menu_jump(menu);
464  break;
465 
466  case OP_ENTER_COMMAND:
468  window_redraw(NULL);
469  break;
470 
471  case OP_TAG:
472  if (menu->tag && ARRAY_EMPTY(&menu->dialog))
473  {
474  const bool c_resolve = cs_subset_bool(menu->sub, "resolve");
475 
476  if (menu->tagprefix && !c_auto_tag)
477  {
478  for (int i = 0; i < menu->max; i++)
479  menu->tagged += menu->tag(menu, i, 0);
480  menu->redraw |= MENU_REDRAW_INDEX;
481  }
482  else if (menu->max != 0)
483  {
484  int j = menu->tag(menu, menu->current, -1);
485  menu->tagged += j;
486  if (j && c_resolve && (menu->current < (menu->max - 1)))
487  {
488  menu_set_index(menu, menu->current + 1);
489  }
490  else
491  menu->redraw |= MENU_REDRAW_CURRENT;
492  }
493  else
494  mutt_error(_("No entries"));
495  }
496  else
497  mutt_error(_("Tagging is not supported"));
498  break;
499 
500  case OP_SHELL_ESCAPE:
501  if (mutt_shell_escape())
502  {
503  struct Mailbox *m_cur = get_current_mailbox();
505  }
506  break;
507 
508  case OP_WHAT_KEY:
509  mutt_what_key();
510  break;
511 
512  case OP_CHECK_STATS:
513  {
514  struct Mailbox *m_cur = get_current_mailbox();
515  mutt_check_stats(m_cur);
516  break;
517  }
518 
519  case OP_REDRAW:
520  clearok(stdscr, true);
521  menu->redraw = MENU_REDRAW_FULL;
522  break;
523 
524  case OP_HELP:
525  mutt_help(menu->type);
526  menu->redraw = MENU_REDRAW_FULL;
527  break;
528 
529  case OP_NULL:
530  km_error_key(menu->type);
531  break;
532 
533  case OP_END_COND:
534  break;
535 
536  default:
537  return op;
538  }
539  }
540  /* not reached */
541 }
void mutt_check_stats(struct Mailbox *m)
Forcibly update mailbox stats.
Definition: commands.c:1268
void mutt_enter_command(void)
Enter a neomutt command.
Definition: commands.c:649
bool mutt_shell_escape(void)
Invoke a command in a subshell.
Definition: commands.c:607
void mutt_refresh(void)
Force a refresh of the screen.
Definition: curs_lib.c:114
void mutt_flush_macro_to_endcond(void)
Drop a macro from the input buffer.
Definition: curs_lib.c:616
int menu_redraw(struct Menu *menu)
Redraw the parts of the screen that have been flagged to be redrawn.
Definition: draw.c:519
void mutt_help(enum MenuType menu)
Display the help menu.
Definition: help.c:387
struct Mailbox * get_current_mailbox(void)
Get the current Mailbox.
Definition: index.c:474
void mutt_what_key(void)
Ask the user to press a key.
Definition: keymap.c:1707
int km_dokey(enum MenuType mtype)
Determine what a keypress should do.
Definition: keymap.c:627
void km_error_key(enum MenuType mtype)
Handle an unbound key sequence.
Definition: keymap.c:1132
MenuRedrawFlags menu_next_page(struct Menu *menu)
Move the focus to the next page in the menu.
Definition: move.c:557
MenuRedrawFlags menu_bottom_page(struct Menu *menu)
Move the focus to the bottom of the page.
Definition: move.c:358
MenuRedrawFlags menu_half_up(struct Menu *menu)
Move the focus up half a page in the menu.
Definition: move.c:501
MenuRedrawFlags menu_prev_line(struct Menu *menu)
Move the view up one line, keeping the selection the same.
Definition: move.c:521
MenuRedrawFlags menu_current_bottom(struct Menu *menu)
Move the current selection to the bottom of the window.
Definition: move.c:479
MenuRedrawFlags menu_current_middle(struct Menu *menu)
Move the current selection to the centre of the window.
Definition: move.c:459
MenuRedrawFlags menu_middle_page(struct Menu *menu)
Move the focus to the centre of the page.
Definition: move.c:338
MenuRedrawFlags menu_first_entry(struct Menu *menu)
Move the focus to the first entry in the menu.
Definition: move.c:405
MenuRedrawFlags menu_half_down(struct Menu *menu)
Move the focus down half a page in the menu.
Definition: move.c:511
MenuRedrawFlags menu_top_page(struct Menu *menu)
Move the focus to the top of the page.
Definition: move.c:328
MenuRedrawFlags menu_last_entry(struct Menu *menu)
Move the focus to the last entry in the menu.
Definition: move.c:421
MenuRedrawFlags menu_prev_page(struct Menu *menu)
Move the focus to the previous page in the menu.
Definition: move.c:547
MenuRedrawFlags menu_next_line(struct Menu *menu)
Move the view down one line, keeping the selection the same.
Definition: move.c:534
MenuRedrawFlags menu_prev_entry(struct Menu *menu)
Move the focus to the previous item in the menu.
Definition: move.c:377
MenuRedrawFlags menu_current_top(struct Menu *menu)
Move the current selection to the top of the window.
Definition: move.c:438
MenuRedrawFlags menu_next_entry(struct Menu *menu)
Move the focus to the next item in the menu.
Definition: move.c:391
static void menu_jump(struct Menu *menu)
Jump to another item in the menu.
Definition: menu.c:64
static int menu_dialog_dokey(struct Menu *menu, int *ip)
Check if there are any menu key events to process.
Definition: menu.c:259
static int menu_dialog_translate_op(int i)
Convert menubar movement to scrolling.
Definition: menu.c:231
static int search(struct Menu *menu, int op)
Search a menu.
Definition: menu.c:148
MenuRedrawFlags menu_set_index(struct Menu *menu, int index)
Set the current selection in the Menu.
Definition: menu.c:638
void msgwin_set_text(enum ColorId cid, const char *text)
Set the text for the Message Window.
Definition: msgwin.c:221
void msgwin_clear_text(void)
Clear the text in the Message Window.
Definition: msgwin.c:240
void mutt_curses_set_cursor(enum MuttCursorState state)
Set the cursor state.
Definition: mutt_curses.c:63
void mutt_resize_screen(void)
Update NeoMutt's opinion about the window size (CURSES)
Definition: resize.c:73
@ MUTT_CURSOR_INVISIBLE
Hide the cursor.
Definition: mutt_curses.h:54
@ MUTT_CURSOR_VISIBLE
Display a normal cursor.
Definition: mutt_curses.h:55
SIG_ATOMIC_VOLATILE_T SigWinch
true after SIGWINCH is received
Definition: mutt_globals.h:72
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:113
int mutt_mailbox_check(struct Mailbox *m_cur, int force)
Check all all Mailboxes for new mail.
Definition: mutt_mailbox.c:162
#define MUTT_MAILBOX_CHECK_FORCE
Definition: mutt_mailbox.h:32
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:603
A mailbox.
Definition: mailbox.h:82
int tagged
Number of tagged entries.
Definition: lib.h:91
int(* search)(struct Menu *menu, regex_t *rx, int line)
Definition: lib.h:117
int(* tag)(struct Menu *menu, int sel, int act)
Definition: lib.h:129
bool tagprefix
User has pressed <tag-prefix>
Definition: lib.h:75
bool custom_search
The menu implements its own non-Menusearch()-compatible search, trickle OP_SEARCH*.
Definition: lib.h:92
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:60
+ 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 122 of file window.c.

123 {
124  struct MuttWindow *win =
127 
128  struct Menu *menu = menu_new(type, win, sub);
129 
132  win->wdata = menu;
134 
135  return win;
136 }
static int menu_recalc(struct MuttWindow *win)
Recalculate the Window data - Implements MuttWindow::recalc() -.
Definition: window.c:80
static int menu_repaint(struct MuttWindow *win)
Repaint the Window - Implements MuttWindow::repaint() -.
Definition: window.c:95
static void menu_wdata_free(struct MuttWindow *win, void **ptr)
Destroy a Menu Window - Implements MuttWindow::wdata_free() -.
Definition: window.c:111
struct Menu * menu_new(enum MenuType type, struct MuttWindow *win, struct ConfigSubset *sub)
Create a new Menu.
Definition: menu.c:600
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
@ MUTT_WIN_ORIENT_VERTICAL
Window uses all available vertical space.
Definition: mutt_window.h:38
#define MUTT_WIN_SIZE_UNLIMITED
Use as much space as possible.
Definition: mutt_window.h:52
@ MUTT_WIN_SIZE_MAXIMISE
Window wants as much space as possible.
Definition: mutt_window.h:48
int(* repaint)(struct MuttWindow *win)
Definition: mutt_window.h:182
int(* recalc)(struct MuttWindow *win)
Definition: mutt_window.h:171
void(* wdata_free)(struct MuttWindow *win, void **ptr)
Definition: mutt_window.h:160
+ 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 624 of file menu.c.

625 {
626  if (!menu)
627  return -1;
628 
629  return menu->current;
630 }

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

639 {
640  return menu_move_selection(menu, index);
641 }
MenuRedrawFlags menu_move_selection(struct Menu *menu, int index)
Move the selection, keeping within between [0, menu->max].
Definition: move.c:233
+ Here is the call graph for this function:

◆ menu_move_selection()

MenuRedrawFlags menu_move_selection ( struct Menu menu,
int  index 
)

Move the selection, keeping within between [0, menu->max].

Parameters
menuMenu
indexNew selection
Return values
numMenuRedrawFlags, e.g. MENU_REDRAW_CURRENT

Definition at line 233 of file move.c.

234 {
235  if (index < 0)
236  index = 0;
237  else if (index >= menu->max)
238  index = menu->max - 1;
239 
240  int top = menu_drag_view(menu, menu->top, index);
241 
242  return menu_set_and_notify(menu, top, index);
243 }
MenuRedrawFlags menu_set_and_notify(struct Menu *menu, int top, int index)
Set the Menu selection/view and notify others.
Definition: move.c:66
static int menu_drag_view(struct Menu *menu, int top, int index)
Move the view around the selection.
Definition: move.c:108
+ 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 648 of file menu.c.

649 {
650  if (!menu)
651  return;
652 
653  menu->redraw |= redraw;
654  menu->win->actions |= WA_RECALC;
655 }
#define WA_RECALC
Recalculate the contents of the Window.
Definition: mutt_window.h:110
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:132

◆ 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
Return values
numMenuRedrawFlags, e.g. MENU_REDRAW_CURRENT

Definition at line 251 of file move.c.

252 {
253  const bool c_menu_move_off = cs_subset_bool(menu->sub, "menu_move_off");
254 
255  short context = cs_subset_number(menu->sub, "menu_context");
256  context = MIN(context, (menu->pagelen / 2));
257 
258  // Move and range-check the view
259  int top = menu->top + relative;
260  if (top < 0)
261  {
262  top = 0;
263  }
264  else if (c_menu_move_off && (top >= (menu->max - context)))
265  {
266  top = menu->max - context - 1;
267  }
268  else if (!c_menu_move_off && ((top + menu->pagelen) >= menu->max))
269  {
270  top = menu->max - menu->pagelen;
271  }
272 
273  // Move the selection on-screen
274  int index = menu->current;
275  if (index < top)
276  index = top;
277  else if (index >= (top + menu->pagelen))
278  index = top + menu->pagelen - 1;
279 
280  // Check for top/bottom limits
281  if (index < context)
282  {
283  top = 0;
284  index = menu->current;
285  }
286  else if (!c_menu_move_off && (index > (menu->max - context)))
287  {
288  top = menu->max - menu->pagelen;
289  index = menu->current;
290  }
291 
292  if (top == menu->top)
293  {
294  // Can't move the view; move the selection
295  index = calc_fit_selection_to_view(menu, top, index + relative);
296  }
297  else if (index > (top + menu->pagelen - context - 1))
298  {
299  index = calc_fit_selection_to_view(menu, top, index + relative);
300  }
301  else
302  {
303  // Drag the selection into the view
304  index = calc_fit_selection_to_view(menu, top, index);
305  }
306 
307  return menu_set_and_notify(menu, top, index);
308 }
static int calc_fit_selection_to_view(struct Menu *menu, int top, int index)
Move the selection into the view.
Definition: move.c:161
+ 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 66 of file move.c.

67 {
69 
70  if (top != menu->top)
71  {
72  menu->top = top;
73  flags |= MENU_REDRAW_FULL;
74  }
75 
76  if (index != menu->current)
77  {
78  menu->oldcurrent = menu->current;
79  menu->current = index;
80 
81  if (menu->redraw == MENU_REDRAW_NO_FLAGS)
82  {
83  // If this is the only change
84  flags |= MENU_REDRAW_MOTION;
85  }
86  else
87  {
88  // otherwise, redraw completely
89  flags |= MENU_REDRAW_FULL;
90  }
91  }
92 
93  menu->redraw |= flags;
94  menu->win->actions |= WA_REPAINT;
95 
96  mutt_debug(LL_NOTIFY, "NT_MENU\n");
97  notify_send(menu->notify, NT_MENU, flags, NULL);
98  return flags;
99 }
#define mutt_debug(LEVEL,...)
Definition: logging.h:84
@ LL_NOTIFY
Log of notifications.
Definition: logging.h:45
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
#define WA_REPAINT
Redraw the contents of the Window.
Definition: mutt_window.h:111
@ NT_MENU
Menu has changed, MenuRedrawFlags.
Definition: notify_type.h:49
struct Notify * notify
Notifications.
Definition: lib.h:152
+ 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 314 of file move.c.

315 {
316  int top = calc_move_view(menu, 0);
317  top = menu_drag_view(menu, top, menu->current);
318 
319  menu_set_and_notify(menu, top, menu->current);
320 }
static int calc_move_view(struct Menu *menu, int relative)
Move the view.
Definition: move.c:191
+ Here is the call graph for this function:
+ Here is the caller graph for this function: