Go to the documentation of this file.
79 #define HC_FIRST HC_CMD
124 for (
int i = 0; i <=
OldSize; i++)
153 uintptr_t count = (uintptr_t) elem->
data;
161 elem->
data = (
void *) count;
185 count = (uintptr_t) elem->
data;
187 elem->
data = (
void *) count;
198 int line, hclass, read;
199 char *linebuf = NULL, *p = NULL;
201 bool regen_file =
false;
209 for (hclass = 0; hclass <
HC_MAX; hclass++)
215 if ((sscanf(linebuf,
"%d:%n", &hclass, &read) < 1) || (read == 0) ||
216 (*(p = linebuf + strlen(linebuf) - 1) !=
'|') || (hclass < 0))
218 mutt_error(
_(
"Bad history file format (line %d)"), line);
257 if ((sscanf(linebuf,
"%d:%n", &hclass, &read) < 1) || (read == 0) ||
258 (*(p = linebuf + strlen(linebuf) - 1) !=
'|') || (hclass < 0))
260 mutt_error(
_(
"Bad history file format (line %d)"), line);
272 fprintf(fp_tmp,
"%s\n", linebuf);
290 for (hclass = 0; hclass <
HC_MAX; hclass++)
304 if (!str || (*str ==
'\0'))
316 fprintf(fp,
"%d:", (
int) hclass);
317 for (
char *p = tmp; *p; p++)
323 putc((
unsigned char) *p, fp);
356 while (source < h->
last)
361 h->
hist[dest++] = h->
hist[source++];
366 int old_last = h->
last;
370 while (source > h->
last)
371 h->
hist[source--] = NULL;
376 while (source > old_last)
381 h->
hist[dest--] = h->
hist[source--];
385 while (dest > old_last)
386 h->
hist[dest--] = NULL;
398 if (!search_buf || !matches)
415 matches[match_count++] = h->
hist[
cur];
472 int prev = h->
last - 1;
514 }
while (!h->
hist[next]);
541 }
while (!h->
hist[prev]);
570 int line = 0, hclass, read;
571 char *linebuf = NULL, *p = NULL;
584 if ((sscanf(linebuf,
"%d:%n", &hclass, &read) < 1) || (read == 0) ||
585 (*(p = linebuf + strlen(linebuf) - 1) !=
'|') || (hclass < 0))
587 mutt_error(
_(
"Bad history file format (line %d)"), line);
void mutt_hist_reset_state(enum HistoryClass hclass)
Move the 'current' position to the end of the History.
static struct History Histories[HC_MAX]
struct HashTable * mutt_hash_new(size_t num_elems, HashFlags flags)
Create a new Hash Table (with string keys)
short C_History
Config: Number of history entries to keep in memory per category.
void mutt_hist_free(void)
Free all the history lists.
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
void mutt_hash_delete(struct HashTable *table, const char *strkey, const void *data)
Remove an element from a Hash Table.
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
#define MUTT_ICONV_NO_FLAGS
No flags are set.
Saved list of user-entered commands/searches.
void * data
User-supplied data.
short C_SaveHistory
Config: Number of history entries to save per category.
void mutt_hist_read_file(void)
Read the History from a file.
void mutt_hist_add(enum HistoryClass hclass, const char *str, bool save)
Add a string to a history.
char * mutt_str_dup(const char *str)
Copy a string, safely.
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
static void save_history(enum HistoryClass hclass, const char *str)
Save one history string to a file.
int mutt_ch_convert_string(char **ps, const char *from, const char *to, uint8_t flags)
Convert a string between encodings.
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
bool mutt_hist_at_scratch(enum HistoryClass hclass)
Is the current History position at the 'scratch' place?
#define MUTT_RL_NO_FLAGS
No flags are set.
HistoryClass
Type to differentiate different histories.
int mutt_file_copy_stream(FILE *fp_in, FILE *fp_out)
Copy the contents of one file into another.
struct HashElem * mutt_hash_insert(struct HashTable *table, const char *strkey, void *data)
Add a new element to the Hash Table (with string keys)
void mutt_hist_save_scratch(enum HistoryClass hclass, const char *str)
Save a temporary string to the History.
void mutt_hist_init(void)
Create a set of empty History ring buffers.
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
static struct History * get_history(enum HistoryClass hclass)
Get a particular history.
bool C_HistoryRemoveDups
Config: Remove duplicate entries from the history.
The item stored in a Hash Table.
static void shrink_histfile(void)
Read, de-dupe and write the history file.
static void init_history(struct History *h)
Set up a new History ring buffer.
int mutt_hist_search(const char *search_buf, enum HistoryClass hclass, char **matches)
Find matches in a history list.
const char * mutt_istr_find(const char *haystack, const char *needle)
Find first occurrence of string (ignoring case)
static int dup_hash_dec(struct HashTable *dup_hash, char *str)
Decrease the refcount of a history string.
#define MUTT_HASH_STRDUP_KEYS
make a copy of the keys
static void remove_history_dups(enum HistoryClass hclass, const char *str)
De-dupe the history.
char * mutt_hist_prev(enum HistoryClass hclass)
Get the previous string in a History.
char * C_Charset
Config: Default character set for displaying text on screen.
static int dup_hash_inc(struct HashTable *dup_hash, char *str)
Increase the refcount of a history string.
#define mutt_file_mkstemp()
char * mutt_hist_next(enum HistoryClass hclass)
Get the next string in a History.
char * C_HistoryFile
Config: File to save history in.
void mutt_hash_free(struct HashTable **ptr)
Free a hash table.
struct HashElem * mutt_hash_find_elem(const struct HashTable *table, const char *strkey)
Find the HashElem in a Hash Table element using a key.
char * mutt_file_read_line(char *line, size_t *size, FILE *fp, int *line_num, ReadLineFlags flags)
Read a line from a file.