NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
DOXYGEN
dlghistory.c File Reference

History Selection Dialog. More...

#include "config.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "mutt/lib.h"
#include "gui/lib.h"
#include "lib.h"
#include "menu/lib.h"
#include "format_flags.h"
#include "muttlib.h"
#include "opcodes.h"
+ Include dependency graph for dlghistory.c:

Go to the source code of this file.

Functions

static const char * history_format_str (char *buf, size_t buflen, size_t col, int cols, char op, const char *src, const char *prec, const char *if_str, const char *else_str, intptr_t data, MuttFormatFlags flags)
 Format a string for the history list - Implements format_t -
Expando Description
%s History match
More...
 
static void history_make_entry (struct Menu *menu, char *buf, size_t buflen, int line)
 Format a menu item for the history list - Implements Menu::make_entry() -. More...
 
void dlg_select_history (char *buf, size_t buflen, char **matches, int match_count)
 Select an item from a history list. More...
 

Variables

static const struct Mapping HistoryHelp []
 Help Bar for the History Selection dialog. More...
 

Detailed Description

History Selection Dialog.

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 dlghistory.c.

Function Documentation

◆ dlg_select_history()

void dlg_select_history ( char *  buf,
size_t  buflen,
char **  matches,
int  match_count 
)

Select an item from a history list.

Parameters
[in]bufBuffer in which to save string
[in]buflenBuffer length
[out]matchesItems to choose from
[in]match_countNumber of items

Definition at line 125 of file dlghistory.c.

126 {
128 
129  struct MuttWindow *sbar = window_find_child(dlg, WT_STATUS_BAR);
130  char title[256];
131  snprintf(title, sizeof(title), _("History '%s'"), buf);
132  sbar_set_title(sbar, title);
133 
134  struct Menu *menu = dlg->wdata;
136  menu->max = match_count;
137  menu->mdata = matches;
138 
139  bool done = false;
140  while (!done)
141  {
142  switch (menu_loop(menu))
143  {
144  case OP_GENERIC_SELECT_ENTRY:
145  {
146  const int index = menu_get_index(menu);
147  mutt_str_copy(buf, matches[index], buflen);
148  done = true;
149  break;
150  }
151 
152  case OP_EXIT:
153  done = true;
154  break;
155  }
156  }
157 
158  simple_dialog_free(&dlg);
159 }
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:550
History Dialog, dlg_select_history()
Definition: mutt_window.h:85
void simple_dialog_free(struct MuttWindow **ptr)
Destroy a simple index Dialog.
Definition: simple.c:165
Definition: lib.h:67
Generic selection list.
Definition: type.h:45
#define _(a)
Definition: message.h:28
Status Bar containing extra info about the Index/Pager/etc.
Definition: mutt_window.h:102
void(* make_entry)(struct Menu *menu, char *buf, size_t buflen, int line)
Definition: lib.h:105
static const struct Mapping HistoryHelp[]
Help Bar for the History Selection dialog.
Definition: dlghistory.c:73
void * mdata
Private data.
Definition: lib.h:155
void sbar_set_title(struct MuttWindow *win, const char *title)
Set the title for the Simple Bar.
Definition: sbar.c:221
static void history_make_entry(struct Menu *menu, char *buf, size_t buflen, int line)
Format a menu item for the history list - Implements Menu::make_entry() -.
Definition: dlghistory.c:110
int max
Number of entries in the menu.
Definition: lib.h:71
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:749
struct MuttWindow * simple_dialog_new(enum MenuType mtype, enum WindowType wtype, const struct Mapping *help_data)
Create a simple index Dialog.
Definition: simple.c:128
void * wdata
Private data.
Definition: mutt_window.h:145
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ HistoryHelp

const struct Mapping HistoryHelp[]
static
Initial value:
= {
{ N_("Exit"), OP_EXIT },
{ N_("Select"), OP_GENERIC_SELECT_ENTRY },
{ N_("Search"), OP_SEARCH },
{ N_("Help"), OP_HELP },
{ NULL, 0 },
}
#define N_(a)
Definition: message.h:32

Help Bar for the History Selection dialog.

Definition at line 73 of file dlghistory.c.