NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
Go to the documentation of this file.
29 #include "config.h"
30 #include <stdio.h>
31 #include "mutt/lib.h"
32 #include "config/lib.h"
33 #include "core/lib.h"
34 #include "mutt_history.h"
35 #include "history/lib.h"
43 void mutt_hist_complete(char *buf, size_t buflen, enum HistoryClass hclass)
44 {
45  const short c_history = cs_subset_number(NeoMutt->sub, "history");
46  char **matches = mutt_mem_calloc(c_history, sizeof(char *));
47  int match_count = mutt_hist_search(buf, hclass, matches);
48  if (match_count)
49  {
50  if (match_count == 1)
51  mutt_str_copy(buf, matches[0], buflen);
52  else
53  dlg_select_history(buf, buflen, matches, match_count);
54  }
55  FREE(&matches);
56 }
62 {
63  if ((nc->event_type != NT_CONFIG) || !nc->event_data)
64  return -1;
66  struct EventConfig *ev_c = nc->event_data;
68  if (!mutt_str_equal(ev_c->name, "history"))
69  return 0;
72  mutt_debug(LL_DEBUG5, "history done\n");
73  return 0;
74 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:904
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
Data passed to a notification function.
Definition: observer.h:39
void mutt_hist_complete(char *buf, size_t buflen, enum HistoryClass hclass)
Complete a string from a history list.
Definition: mutt_history.c:43
A config-change event.
Definition: subset.h:69
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
Definition: helpers.c:169
Container for Accounts, Notifications.
Definition: neomutt.h:36
Convenience wrapper for the config headers.
enum NotifyType event_type
Send: Event type, e.g. NT_ACCOUNT.
Definition: observer.h:42
int main_hist_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t.
Definition: mutt_history.c:61
Convenience wrapper for the core headers.
Read/write command history from/to a file.
int mutt_hist_search(const char *search_buf, enum HistoryClass hclass, char **matches)
Find matches in a history list.
Definition: history.c:412
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
void mutt_hist_init(void)
Create a set of empty History ring buffers.
Definition: history.c:468
void * event_data
Data from notify_send()
Definition: observer.h:44
Type to differentiate different histories.
Definition: lib.h:46
Read/write command history from/to a file.
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:42
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
#define FREE(x)
Definition: memory.h:40
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
Log at debug level 5.
Definition: logging.h:44
Convenience wrapper for the library headers.
const char * name
Name of config item that changed.
Definition: subset.h:72
void dlg_select_history(char *buf, size_t buflen, char **matches, int match_count)
Select an item from a history list.
Definition: dlghistory.c:125