NeoMutt  2025-12-11-435-g4ac674
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
dlg_pattern.c File Reference

Pattern Selection Dialog. More...

#include "config.h"
#include <stdbool.h>
#include <stddef.h>
#include "private.h"
#include "mutt/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "lib.h"
#include "expando/lib.h"
#include "key/lib.h"
#include "menu/lib.h"
#include "expando.h"
#include "functions.h"
#include "mutt_logging.h"
#include "pattern_data.h"
+ Include dependency graph for dlg_pattern.c:

Go to the source code of this file.

Functions

static int pattern_make_entry (struct Menu *menu, int line, int max_cols, struct Buffer *buf)
 Create a Pattern for the Menu - Implements Menu::make_entry() -.
 
static void create_pattern_entries (struct PatternEntryArray *pea)
 Create the Pattern Entries.
 
static int pattern_config_observer (struct NotifyCallback *nc)
 Notification that a Config Variable has changed - Implements observer_t -.
 
static int pattern_window_observer (struct NotifyCallback *nc)
 Notification that a Window has changed - Implements observer_t -.
 
bool dlg_pattern (struct Buffer *buf)
 Show menu to select a Pattern -.
 

Variables

static const struct Mapping PatternHelp []
 Help Bar for the Pattern selection dialog.
 

Detailed Description

Pattern Selection Dialog.

Authors
  • Pietro Cerutti
  • Richard Russon
  • Tóth János

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

Function Documentation

◆ create_pattern_entries()

static void create_pattern_entries ( struct PatternEntryArray * pea)
static

Create the Pattern Entries.

Parameters
peaPattern Entry Array to fill

Definition at line 125 of file dlg_pattern.c.

126{
127 int num_entries = 0;
128 while (Flags[num_entries].tag != 0)
129 num_entries++;
130
131 /* Add three more hard-coded entries for thread patterns */
132 ARRAY_RESERVE(pea, num_entries + 3);
133
134 struct Buffer *buf = buf_pool_get();
135
136 struct PatternEntry entry = { 0 };
137 for (int i = 0; Flags[i].tag != '\0'; i++)
138 {
139 entry.num = i + 1;
140
141 buf_printf(buf, "%c%c", Flags[i].prefix, Flags[i].tag);
142 entry.tag = buf_strdup(buf);
143
144 switch (Flags[i].eat_arg)
145 {
146 case EAT_DATE:
147 /* L10N:
148 Pattern Completion Menu argument type: a date range
149 Used by ~d, ~r.
150 */
151 buf_add_printf(buf, " %s", _("DATERANGE"));
152 break;
153 case EAT_GROUP:
154 /* L10N:
155 Pattern Completion Menu argument type: an address group
156 Used by %c, %C, %e, %f, %L.
157 */
158 buf_add_printf(buf, " %s", _("GROUP"));
159 break;
161 /* L10N:
162 Pattern Completion Menu argument type: a message range.
163 Used by ~m.
164 */
165 buf_add_printf(buf, " %s", _("MSGRANGE"));
166 break;
167 case EAT_QUERY:
168 /* L10N:
169 Pattern Completion Menu argument type: a query
170 Used by ~I.
171 */
172 buf_add_printf(buf, " %s", _("QUERY"));
173 break;
174 case EAT_RANGE:
175 /* L10N:
176 Pattern Completion Menu argument type: a numeric range.
177 Used by ~n, ~X, ~z.
178 */
179 buf_add_printf(buf, " %s", _("RANGE"));
180 break;
181 case EAT_REGEX:
182 /* L10N:
183 Pattern Completion Menu argument type: a regular expression
184 */
185 buf_add_printf(buf, " %s", _("REGEX"));
186 break;
187 case EAT_STRING:
188 /* L10N:
189 Pattern Completion Menu argument type: a string (for IMAP patterns)
190 Used by =b, =B, =h, =/.
191 */
192 buf_add_printf(buf, " %s", _("STRING"));
193 break;
194 default:
195 break;
196 }
197
198 entry.expr = buf_strdup(buf);
199 entry.desc = mutt_str_dup(_(Flags[i].desc));
200
201 ARRAY_ADD(pea, entry);
202 }
203
204 /* Add struct MuttThread patterns manually.
205 * Note we allocated 3 extra slots for these above. */
206
207 /* L10N:
208 Pattern Completion Menu argument type: a nested pattern.
209 Used by ~(), ~<(), ~>().
210 */
211 const char *patternstr = _("PATTERN");
212
213 entry.num = ARRAY_SIZE(pea) + 1;
214 entry.tag = mutt_str_dup("~()");
215 buf_printf(buf, "~(%s)", patternstr);
216 entry.expr = buf_strdup(buf);
217 // L10N: Pattern Completion Menu description for ~()
218 entry.desc = mutt_str_dup(_("messages in threads containing messages matching PATTERN"));
219 ARRAY_ADD(pea, entry);
220
221 entry.num = ARRAY_SIZE(pea) + 1;
222 entry.tag = mutt_str_dup("~<()");
223 buf_printf(buf, "~<(%s)", patternstr);
224 entry.expr = buf_strdup(buf);
225 // L10N: Pattern Completion Menu description for ~<()
226 entry.desc = mutt_str_dup(_("messages whose immediate parent matches PATTERN"));
227 ARRAY_ADD(pea, entry);
228
229 entry.num = ARRAY_SIZE(pea) + 1;
230 entry.tag = mutt_str_dup("~>()");
231 buf_printf(buf, "~>(%s)", patternstr);
232 entry.expr = buf_strdup(buf);
233 // L10N: Pattern Completion Menu description for ~>()
234 entry.desc = mutt_str_dup(_("messages having an immediate child matching PATTERN"));
235 ARRAY_ADD(pea, entry);
236
237 buf_pool_release(&buf);
238}
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
Definition array.h:157
#define ARRAY_SIZE(head)
The number of elements stored.
Definition array.h:87
#define ARRAY_RESERVE(head, n)
Reserve memory for the array.
Definition array.h:191
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition buffer.c:161
int buf_add_printf(struct Buffer *buf, const char *fmt,...)
Format a string appending a Buffer.
Definition buffer.c:204
char * buf_strdup(const struct Buffer *buf)
Copy a Buffer's string.
Definition buffer.c:571
#define _(a)
Definition message.h:28
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition string.c:257
const struct PatternFlags Flags[]
Lookup table for all patterns.
Definition flags.c:47
@ EAT_STRING
Process a plain string.
Definition private.h:59
@ EAT_RANGE
Process a number (range)
Definition private.h:57
@ EAT_GROUP
Process a group name.
Definition private.h:54
@ EAT_MESSAGE_RANGE
Process a message number (range)
Definition private.h:55
@ EAT_DATE
Process a date (range)
Definition private.h:53
@ EAT_QUERY
Process a query string.
Definition private.h:56
@ EAT_REGEX
Process a regex.
Definition private.h:58
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition pool.c:91
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition pool.c:111
String manipulation buffer.
Definition buffer.h:36
A line in the Pattern Completion menu.
const char * desc
Description of pattern.
const char * tag
Copied to buffer if selected.
int num
Index number.
const char * expr
Displayed in the menu.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ PatternHelp

const struct Mapping PatternHelp[]
static
Initial value:
= {
{ N_("Exit"), OP_EXIT },
{ N_("Select"), OP_GENERIC_SELECT_ENTRY },
{ N_("Help"), OP_HELP },
{ NULL, 0 },
}
#define N_(a)
Definition message.h:32

Help Bar for the Pattern selection dialog.

Definition at line 88 of file dlg_pattern.c.

88 {
89 // clang-format off
90 { N_("Exit"), OP_EXIT },
91 { N_("Select"), OP_GENERIC_SELECT_ENTRY },
92 { N_("Help"), OP_HELP },
93 { NULL, 0 },
94 // clang-format on
95};