NeoMutt  2021-02-05-89-gabe350
Teaching an old dog new tricks
DOXYGEN
mutt_history.c
Go to the documentation of this file.
1 
29 #include "config.h"
30 #include <stdio.h>
31 #include "mutt/lib.h"
32 #include "config/lib.h"
33 #include "mutt_history.h"
34 #include "history/lib.h"
35 
42 void mutt_hist_complete(char *buf, size_t buflen, enum HistoryClass hclass)
43 {
44  char **matches = mutt_mem_calloc(C_History, sizeof(char *));
45  int match_count = mutt_hist_search(buf, hclass, matches);
46  if (match_count)
47  {
48  if (match_count == 1)
49  mutt_str_copy(buf, matches[0], buflen);
50  else
51  dlg_select_history(buf, buflen, matches, match_count);
52  }
53  FREE(&matches);
54 }
55 
60 {
61  if (!nc->event_data)
62  return -1;
63  if (nc->event_type != NT_CONFIG)
64  return 0;
65 
66  struct EventConfig *ec = nc->event_data;
67 
68  if (!mutt_str_equal(ec->name, "history"))
69  return 0;
70 
72  return 0;
73 }
NotifyCallback
Data passed to a notification function.
Definition: observer.h:39
C_History
short C_History
Config: Number of history entries to keep in memory per category.
Definition: config.c:37
mutt_mem_calloc
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
NT_CONFIG
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:37
mutt_hist_complete
void mutt_hist_complete(char *buf, size_t buflen, enum HistoryClass hclass)
Complete a string from a history list.
Definition: mutt_history.c:42
FREE
#define FREE(x)
Definition: memory.h:40
mutt_history.h
mutt_str_equal
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
lib.h
HistoryClass
HistoryClass
Type to differentiate different histories.
Definition: lib.h:52
lib.h
dlg_select_history
void dlg_select_history(char *buf, size_t buflen, char **matches, int match_count)
Select an item from a history list.
Definition: dlghistory.c:96
mutt_hist_init
void mutt_hist_init(void)
Create a set of empty History ring buffers.
Definition: history.c:447
EventConfig
A config-change event.
Definition: subset.h:70
NotifyCallback::event_data
void * event_data
Data from notify_send()
Definition: observer.h:44
mutt_hist_search
int mutt_hist_search(const char *search_buf, enum HistoryClass hclass, char **matches)
Find matches in a history list.
Definition: history.c:396
EventConfig::name
const char * name
Name of config item that changed.
Definition: subset.h:73
NotifyCallback::event_type
enum NotifyType event_type
Send: Event type, e.g. NT_ACCOUNT.
Definition: observer.h:42
lib.h
mutt_hist_observer
int mutt_hist_observer(struct NotifyCallback *nc)
Listen for config changes affecting the history - Implements observer_t.
Definition: mutt_history.c:59
mutt_str_copy
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:716