NeoMutt  2023-05-17-56-ga67199
Teaching an old dog new tricks
dlg_history.c File Reference

History Selection Dialog. More...

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

Go to the source code of this file.


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


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

Detailed Description

History Selection Dialog.

  • 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

Definition in file dlg_history.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.

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

Definition at line 127 of file dlg_history.c.

131 struct MuttWindow *sbar = window_find_child(dlg, WT_STATUS_BAR);
132 char title[256] = { 0 };
133 snprintf(title, sizeof(title), _("History '%s'"), buf);
134 sbar_set_title(sbar, title);
136 struct Menu *menu = dlg->wdata;
138 menu->max = match_count;
139 menu->mdata = matches;
140 menu->mdata_free = NULL; // Menu doesn't own the data
142 struct HistoryData hd = { false, false, buf, buflen,
144 dlg->wdata = &hd;
146 // ---------------------------------------------------------------------------
147 // Event Loop
148 int op = OP_NULL;
149 do
150 {
152 window_redraw(NULL);
154 struct KeyEvent event = km_dokey_event(MENU_GENERIC);
155 if ( == 'q')
156 op = OP_EXIT;
157 else
158 op = event.op;
160 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
161 if (op < 0)
162 continue;
163 if (op == OP_NULL)
164 {
166 continue;
167 }
170 int rc = history_function_dispatcher(dlg, op);
172 if (rc == FR_UNKNOWN)
173 rc = menu_function_dispatcher(menu->win, op);
174 if (rc == FR_UNKNOWN)
175 rc = global_function_dispatcher(NULL, op);
176 } while (!hd.done);
177 // ---------------------------------------------------------------------------
179 simple_dialog_free(&dlg);
Unknown function.
Definition: dispatcher.h:33
static const struct Mapping HistoryHelp[]
Help Bar for the History Selection dialog.
Definition: dlg_history.c:75
int menu_tagging_dispatcher(struct MuttWindow *win, int op)
Perform tagging operations on the Menu - Implements function_dispatcher_t -.
Definition: tagging.c:223
int global_function_dispatcher(struct MuttWindow *win, int op)
Perform a Global function - Implements function_dispatcher_t -.
Definition: global.c:164
int menu_function_dispatcher(struct MuttWindow *win, int op)
Perform a Menu function - Implements function_dispatcher_t -.
Definition: functions.c:317
int history_function_dispatcher(struct MuttWindow *win, int op)
Perform a History function - Implements function_dispatcher_t -.
Definition: functions.c:76
#define mutt_debug(LEVEL,...)
Definition: logging2.h:87
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: dlg_history.c:112
void simple_dialog_free(struct MuttWindow **ptr)
Destroy a simple index Dialog.
Definition: simple.c:166
struct MuttWindow * simple_dialog_new(enum MenuType mtype, enum WindowType wtype, const struct Mapping *help_data)
Create a simple index Dialog.
Definition: simple.c:129
struct KeyEvent km_dokey_event(enum MenuType mtype)
Determine what a keypress should do.
Definition: keymap.c:643
void km_error_key(enum MenuType mtype)
Handle an unbound key sequence.
Definition: keymap.c:1077
Log at debug level 1.
Definition: logging2.h:43
#define _(a)
Definition: message.h:28
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:73
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:605
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:523
History Dialog, dlg_select_history()
Definition: mutt_window.h:85
Status Bar containing extra info about the Index/Pager/etc.
Definition: mutt_window.h:102
const char * opcodes_get_name(int op)
Get the name of an opcode.
Definition: opcodes.c:48
void sbar_set_title(struct MuttWindow *win, const char *title)
Set the title for the Simple Bar.
Definition: sbar.c:224
Data to pass to the History Functions.
Definition: functions.h:35
size_t buflen
Length of the results buffer.
Definition: functions.h:39
struct Menu * menu
History Menu.
Definition: functions.h:40
char ** matches
History entries.
Definition: functions.h:41
bool done
Should we close the Dialog?
Definition: functions.h:36
char * buf
Buffer for the results.
Definition: functions.h:38
int match_count
Number of history entries.
Definition: functions.h:42
An event such as a keypress.
Definition: keymap.h:65
int op
Function opcode, e.g. OP_HELP.
Definition: keymap.h:67
int ch
Raw key pressed.
Definition: keymap.h:66
Definition: lib.h:70
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:77
void(* make_entry)(struct Menu *menu, char *buf, size_t buflen, int line)
Definition: lib.h:97
void(* mdata_free)(struct Menu *menu, void **ptr)
Definition: lib.h:152
void * mdata
Private data.
Definition: lib.h:138
int max
Number of entries in the menu.
Definition: lib.h:72
void * wdata
Private data.
Definition: mutt_window.h:145
Generic selection list.
Definition: type.h:45
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ HistoryHelp

const struct Mapping HistoryHelp[]
Initial value:
= {
{ N_("Exit"), OP_EXIT },
{ 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 75 of file dlg_history.c.