/src/neomutt/mutt_history.c
Line | Count | Source (jump to first uncovered line) |
1 | | /** |
2 | | * @file |
3 | | * Read/write command history from/to a file |
4 | | * |
5 | | * @authors |
6 | | * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org> |
7 | | * |
8 | | * @copyright |
9 | | * This program is free software: you can redistribute it and/or modify it under |
10 | | * the terms of the GNU General Public License as published by the Free Software |
11 | | * Foundation, either version 2 of the License, or (at your option) any later |
12 | | * version. |
13 | | * |
14 | | * This program is distributed in the hope that it will be useful, but WITHOUT |
15 | | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
16 | | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
17 | | * details. |
18 | | * |
19 | | * You should have received a copy of the GNU General Public License along with |
20 | | * this program. If not, see <http://www.gnu.org/licenses/>. |
21 | | */ |
22 | | |
23 | | /** |
24 | | * @page neo_mutt_history Read/write command history from/to a file |
25 | | * |
26 | | * Read/write command history from/to a file |
27 | | */ |
28 | | |
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" |
36 | | |
37 | | /** |
38 | | * mutt_hist_complete - Complete a string from a history list |
39 | | * @param buf Buffer in which to save string |
40 | | * @param buflen Buffer length |
41 | | * @param hclass History list to use |
42 | | */ |
43 | | void mutt_hist_complete(char *buf, size_t buflen, enum HistoryClass hclass) |
44 | 0 | { |
45 | 0 | const short c_history = cs_subset_number(NeoMutt->sub, "history"); |
46 | 0 | char **matches = mutt_mem_calloc(c_history, sizeof(char *)); |
47 | 0 | int match_count = mutt_hist_search(buf, hclass, matches); |
48 | 0 | if (match_count) |
49 | 0 | { |
50 | 0 | if (match_count == 1) |
51 | 0 | mutt_str_copy(buf, matches[0], buflen); |
52 | 0 | else |
53 | 0 | dlg_select_history(buf, buflen, matches, match_count); |
54 | 0 | } |
55 | 0 | FREE(&matches); |
56 | 0 | } |
57 | | |
58 | | /** |
59 | | * main_hist_observer - Notification that a Config Variable has changed - Implements ::observer_t - @ingroup observer_api |
60 | | */ |
61 | | int main_hist_observer(struct NotifyCallback *nc) |
62 | 0 | { |
63 | 0 | if (nc->event_type != NT_CONFIG) |
64 | 0 | return 0; |
65 | 0 | if (!nc->event_data) |
66 | 0 | return -1; |
67 | | |
68 | 0 | struct EventConfig *ev_c = nc->event_data; |
69 | |
|
70 | 0 | if (!mutt_str_equal(ev_c->name, "history")) |
71 | 0 | return 0; |
72 | | |
73 | 0 | mutt_hist_init(); |
74 | 0 | mutt_debug(LL_DEBUG5, "history done\n"); |
75 | 0 | return 0; |
76 | 0 | } |