NeoMutt  2024-11-14-34-g5aaf0d
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 "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

void pattern_d (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Pattern: pattern description - Implements ExpandoRenderData::get_string() -.
 
void pattern_e (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Pattern: pattern expression - Implements ExpandoRenderData::get_string() -.
 
long pattern_n_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Pattern: Index number - Implements ExpandoRenderData::get_number() -.
 
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

const struct ExpandoRenderData PatternRenderData []
 Callbacks for Pattern Expandos.
 
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 160 of file dlg_pattern.c.

161{
162 int num_entries = 0;
163 while (Flags[num_entries].tag != 0)
164 num_entries++;
165
166 /* Add three more hard-coded entries */
167 ARRAY_RESERVE(pea, num_entries + 3);
168
169 struct Buffer *buf = buf_pool_get();
170
171 struct PatternEntry entry = { 0 };
172 for (int i = 0; Flags[i].tag != '\0'; i++)
173 {
174 entry.num = i + 1;
175
176 buf_printf(buf, "~%c", Flags[i].tag);
177 entry.tag = buf_strdup(buf);
178
179 switch (Flags[i].eat_arg)
180 {
181 case EAT_REGEX:
182 /* L10N:
183 Pattern Completion Menu argument type: a regular expression
184 */
185 buf_add_printf(buf, " %s", _("EXPR"));
186 break;
187 case EAT_RANGE:
189 /* L10N:
190 Pattern Completion Menu argument type: a numeric range.
191 Used by ~m, ~n, ~X, ~z.
192 */
193 buf_add_printf(buf, " %s", _("RANGE"));
194 break;
195 case EAT_DATE:
196 /* L10N:
197 Pattern Completion Menu argument type: a date range
198 Used by ~d, ~r.
199 */
200 buf_add_printf(buf, " %s", _("DATERANGE"));
201 break;
202 case EAT_QUERY:
203 /* L10N:
204 Pattern Completion Menu argument type: a query
205 Used by ~I.
206 */
207 buf_add_printf(buf, " %s", _("QUERY"));
208 break;
209 default:
210 break;
211 }
212
213 entry.expr = buf_strdup(buf);
214 entry.desc = mutt_str_dup(_(Flags[i].desc));
215
216 ARRAY_ADD(pea, entry);
217 }
218
219 /* Add struct MuttThread patterns manually.
220 * Note we allocated 3 extra slots for these above. */
221
222 /* L10N:
223 Pattern Completion Menu argument type: a nested pattern.
224 Used by ~(), ~<(), ~>().
225 */
226 const char *patternstr = _("PATTERN");
227
228 entry.num = ARRAY_SIZE(pea) + 1;
229 entry.tag = mutt_str_dup("~()");
230 buf_printf(buf, "~(%s)", patternstr);
231 entry.expr = buf_strdup(buf);
232 // L10N: Pattern Completion Menu description for ~()
233 entry.desc = mutt_str_dup(_("messages in threads containing messages matching PATTERN"));
234 ARRAY_ADD(pea, entry);
235
236 entry.num = ARRAY_SIZE(pea) + 1;
237 entry.tag = mutt_str_dup("~<()");
238 buf_printf(buf, "~<(%s)", patternstr);
239 entry.expr = buf_strdup(buf);
240 // L10N: Pattern Completion Menu description for ~<()
241 entry.desc = mutt_str_dup(_("messages whose immediate parent matches PATTERN"));
242 ARRAY_ADD(pea, entry);
243
244 entry.num = ARRAY_SIZE(pea) + 1;
245 entry.tag = mutt_str_dup("~>()");
246 buf_printf(buf, "~>(%s)", patternstr);
247 entry.expr = buf_strdup(buf);
248 // L10N: Pattern Completion Menu description for ~>()
249 entry.desc = mutt_str_dup(_("messages having an immediate child matching PATTERN"));
250 ARRAY_ADD(pea, entry);
251
252 buf_pool_release(&buf);
253}
#define ARRAY_RESERVE(head, num)
Reserve memory for the array.
Definition: array.h:189
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
Definition: array.h:156
#define ARRAY_SIZE(head)
The number of elements stored.
Definition: array.h:87
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:253
const struct PatternFlags Flags[]
Lookup table for all patterns.
Definition: flags.c:40
@ EAT_RANGE
Process a number (range)
Definition: private.h:55
@ EAT_MESSAGE_RANGE
Process a message number (range)
Definition: private.h:56
@ EAT_DATE
Process a date (range)
Definition: private.h:54
@ EAT_QUERY
Process a query string.
Definition: private.h:57
@ EAT_REGEX
Process a regex.
Definition: private.h:53
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:81
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:94
String manipulation buffer.
Definition: buffer.h:36
A line in the Pattern Completion menu.
Definition: pattern_data.h:35
const char * desc
Description of pattern.
Definition: pattern_data.h:39
const char * tag
Copied to buffer if selected.
Definition: pattern_data.h:37
int num
Index number.
Definition: pattern_data.h:36
const char * expr
Displayed in the menu.
Definition: pattern_data.h:38
char tag
Character used to represent this operation, e.g. 'A' for '~A'.
Definition: private.h:65
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ PatternRenderData

const struct ExpandoRenderData PatternRenderData
Initial value:
= {
{ -1, -1, NULL, NULL },
}
@ ED_PATTERN
Pattern ED_PAT_ ExpandoDataPattern.
Definition: domain.h:50
long pattern_n_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Pattern: Index number - Implements ExpandoRenderData::get_number() -.
Definition: dlg_pattern.c:125
void pattern_e(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Pattern: pattern expression - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pattern.c:113
void pattern_d(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Pattern: pattern description - Implements ExpandoRenderData::get_string() -.
Definition: dlg_pattern.c:101
@ ED_PAT_DESCRIPTION
PatternEntry.desc.
Definition: private.h:40
@ ED_PAT_EXPRESION
PatternEntry.expr.
Definition: private.h:41
@ ED_PAT_NUMBER
PatternEntry.num.
Definition: private.h:42

Callbacks for Pattern Expandos.

See also
PatternFormatDef, ExpandoDataGlobal, ExpandoDataPattern

Definition at line 86 of file dlg_pattern.c.

◆ 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 89 of file dlg_pattern.c.