NeoMutt  2022-04-29-247-gc6aae8
Teaching an old dog new tricks
DOXYGEN
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.

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

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

Definition at line 129 of file dlg_history.c.

130{
132
133 struct MuttWindow *sbar = window_find_child(dlg, WT_STATUS_BAR);
134 char title[256] = { 0 };
135 snprintf(title, sizeof(title), _("History '%s'"), buf);
136 sbar_set_title(sbar, title);
137
138 struct Menu *menu = dlg->wdata;
140 menu->max = match_count;
141 menu->mdata = matches;
142 menu->mdata_free = NULL; // Menu doesn't own the data
143
144 struct HistoryData hd = { false, false, buf, buflen,
146 dlg->wdata = &hd;
147
148 // ---------------------------------------------------------------------------
149 // Event Loop
150 int op = OP_NULL;
151 do
152 {
154 window_redraw(NULL);
155
156 struct KeyEvent event = km_dokey_event(MENU_GENERIC);
157 if (event.ch == 'q')
158 op = OP_EXIT;
159 else
160 op = event.op;
161
162 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
163 if (op < 0)
164 continue;
165 if (op == OP_NULL)
166 {
168 continue;
169 }
171
172 int rc = history_function_dispatcher(dlg, op);
173
174 if (rc == FR_UNKNOWN)
175 rc = menu_function_dispatcher(menu->win, op);
176 if (rc == FR_UNKNOWN)
177 rc = global_function_dispatcher(NULL, op);
178 } while (!hd.done);
179 // ---------------------------------------------------------------------------
180
181 simple_dialog_free(&dlg);
182}
@ FR_UNKNOWN
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:320
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: logging.h:84
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:114
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:637
void km_error_key(enum MenuType mtype)
Handle an unbound key sequence.
Definition: keymap.c:1061
@ LL_DEBUG1
Log at debug level 1.
Definition: logging.h:40
#define _(a)
Definition: message.h:28
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:74
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:604
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:522
@ WT_DLG_HISTORY
History Dialog, dlg_select_history()
Definition: mutt_window.h:85
@ WT_STATUS_BAR
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:46
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:69
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:76
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:152
void * mdata
Private data.
Definition: lib.h:137
int max
Number of entries in the menu.
Definition: lib.h:71
void * wdata
Private data.
Definition: mutt_window.h:145
@ MENU_GENERIC
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[]
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 75 of file dlg_history.c.