NeoMutt  2023-11-03-85-g512e01
Teaching an old dog new tricks
No Matches
Go to the documentation of this file.
58#include "config.h"
59#include <stdbool.h>
60#include <stdint.h>
61#include <stdio.h>
62#include "mutt/lib.h"
63#include "config/lib.h"
64#include "core/lib.h"
65#include "gui/lib.h"
66#include "lib.h"
67#include "key/lib.h"
68#include "menu/lib.h"
69#include "format_flags.h"
70#include "functions.h"
71#include "mutt_logging.h"
72#include "muttlib.h"
75static const struct Mapping HistoryHelp[] = {
76 // clang-format off
77 { N_("Exit"), OP_EXIT },
78 { N_("Select"), OP_GENERIC_SELECT_ENTRY },
79 { N_("Search"), OP_SEARCH },
80 { N_("Help"), OP_HELP },
81 { NULL, 0 },
82 // clang-format on
92static const char *history_format_str(char *buf, size_t buflen, size_t col, int cols,
93 char op, const char *src, const char *prec,
94 const char *if_str, const char *else_str,
95 intptr_t data, MuttFormatFlags flags)
97 struct HistoryEntry *h = (struct HistoryEntry *) data;
99 switch (op)
100 {
101 case 'C':
102 {
103 char tmp[32] = { 0 };
104 snprintf(tmp, sizeof(tmp), "%%%sd", prec);
105 snprintf(buf, buflen, tmp, h->num);
106 break;
107 }
108 case 's':
109 {
110 mutt_format_s(buf, buflen, prec, NONULL(h->history));
111 break;
112 }
113 }
115 return src;
123static void history_make_entry(struct Menu *menu, char *buf, size_t buflen, int line)
125 char *entry = ((char **) menu->mdata)[line];
127 struct HistoryEntry h = { line, entry };
129 const char *const c_history_format = cs_subset_string(NeoMutt->sub, "history_format");
130 mutt_expando_format(buf, buflen, 0, menu->win->state.cols, NONULL(c_history_format),
144void dlg_history(char *buf, size_t buflen, char **matches, int match_count)
148 struct MuttWindow *sbar = window_find_child(dlg, WT_STATUS_BAR);
149 char title[256] = { 0 };
150 snprintf(title, sizeof(title), _("History '%s'"), buf);
151 sbar_set_title(sbar, title);
153 struct Menu *menu = dlg->wdata;
155 menu->max = match_count;
156 menu->mdata = matches;
157 menu->mdata_free = NULL; // Menu doesn't own the data
159 struct HistoryData hd = { false, false, buf, buflen,
161 dlg->wdata = &hd;
163 struct MuttWindow *old_focus = window_set_focus(menu->win);
164 // ---------------------------------------------------------------------------
165 // Event Loop
166 int op = OP_NULL;
167 do
168 {
169 menu_tagging_dispatcher(menu->win, op);
170 window_redraw(NULL);
173 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
174 if (op < 0)
175 continue;
176 if (op == OP_NULL)
177 {
179 continue;
180 }
183 int rc = history_function_dispatcher(dlg, op);
184 if (rc == FR_UNKNOWN)
185 rc = menu_function_dispatcher(menu->win, op);
186 if (rc == FR_UNKNOWN)
187 rc = global_function_dispatcher(NULL, op);
188 } while (!hd.done);
189 // ---------------------------------------------------------------------------
191 window_set_focus(old_focus);
192 simple_dialog_free(&dlg);
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:292
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
Unknown function.
Definition: dispatcher.h:33
static const struct Mapping HistoryHelp[]
Help Bar for the History Selection dialog.
Definition: dlg_history.c:75
void mutt_format_s(char *buf, size_t buflen, const char *prec, const char *s)
Format a simple string.
Definition: format.c:215
Flags to control mutt_expando_format()
Reserve space for arrow_cursor.
Definition: format_flags.h:35
uint8_t MuttFormatFlags
Flags for mutt_expando_format(), e.g. MUTT_FORMAT_FORCESUBJ.
Definition: format_flags.h:29
int km_dokey(enum MenuType mtype, GetChFlags flags)
Determine what a keypress should do.
Definition: get.c:475
void km_error_key(enum MenuType mtype)
Handle an unbound key sequence.
Definition: get.c:305
int menu_tagging_dispatcher(struct MuttWindow *win, int op)
Perform tagging operations on the Menu - Implements function_dispatcher_t -.
Definition: tagging.c:230
int global_function_dispatcher(struct MuttWindow *win, int op)
Perform a Global function - Implements function_dispatcher_t -.
Definition: global.c:169
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:75
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 -.
Definition: dlg_history.c:92
void mutt_expando_format(char *buf, size_t buflen, size_t col, int cols, const char *src, format_t callback, intptr_t data, MuttFormatFlags flags)
Expand expandos (x) in a string -.
Definition: muttlib.c:739
void dlg_history(char *buf, size_t buflen, char **matches, int match_count)
Select an item from a history list -.
Definition: dlg_history.c:144
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
static void history_make_entry(struct Menu *menu, char *buf, size_t buflen, int line)
Format a History Item for the Menu - Implements Menu::make_entry() -.
Definition: dlg_history.c:123
Convenience wrapper for the gui headers.
void simple_dialog_free(struct MuttWindow **ptr)
Destroy a simple index Dialog.
Definition: simple.c:168
struct MuttWindow * simple_dialog_new(enum MenuType mtype, enum WindowType wtype, const struct Mapping *help_data)
Create a simple index Dialog.
Definition: simple.c:132
Manage keymappings.
No flags are set.
Definition: lib.h:52
Log at debug level 1.
Definition: logging2.h:43
GUI present the user with a selectable list.
Convenience wrapper for the library headers.
#define N_(a)
Definition: message.h:32
#define _(a)
Definition: message.h:28
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:73
NeoMutt Logging.
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:634
struct MuttWindow * window_set_focus(struct MuttWindow *win)
Set the Window focus.
Definition: mutt_window.c:684
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:533
History Dialog, dlg_history()
Definition: mutt_window.h:85
Status Bar containing extra info about the Index/Pager/etc.
Definition: mutt_window.h:102
Some miscellaneous functions.
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:227
Sidebar functions.
Key value store.
#define NONULL(x)
Definition: string2.h:37
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
A line in the History menu.
Definition: lib.h:65
int num
Index number.
Definition: lib.h:66
const char * history
Description of history.
Definition: lib.h:67
Mapping between user-readable string and a constant.
Definition: mapping.h:32
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:96
void(* mdata_free)(struct Menu *menu, void **ptr)
Definition: lib.h:151
void * mdata
Private data.
Definition: lib.h:137
int max
Number of entries in the menu.
Definition: lib.h:72
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:127
void * wdata
Private data.
Definition: mutt_window.h:145
Container for Accounts, Notifications.
Definition: neomutt.h:41
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:45
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:60
Simple Dialog.
Definition: type.h:43
Generic selection list.
Definition: type.h:46