NeoMutt  2024-04-25-127-g771158
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
private.h
Go to the documentation of this file.
1
23#ifndef MUTT_PATTERN_PRIVATE_H
24#define MUTT_PATTERN_PRIVATE_H
25
26#include <stdbool.h>
27#include "mutt/lib.h"
28#include "email/lib.h"
29#include "lib.h"
30
31struct MailboxView;
32
37{
38 int num;
39 const char *tag;
40 const char *expr;
41 const char *desc;
42};
43
50{
54};
55
62{
69};
70
75{
76 int tag;
77 int op;
79
81 char *desc;
82};
83
88{
89 const char *raw;
90 int lgrp;
91 int rgrp;
92 bool ready;
93 regex_t cooked;
94};
95
100{
106 /* add new ones HERE */
108};
109
110/* The regexes in a modern format */
111#define RANGE_NUM_RX "([[:digit:]]+|0x[[:xdigit:]]+)[MmKk]?"
112#define RANGE_REL_SLOT_RX "[[:blank:]]*([.^$]|-?" RANGE_NUM_RX ")?[[:blank:]]*"
113#define RANGE_REL_RX "^" RANGE_REL_SLOT_RX "," RANGE_REL_SLOT_RX
114
115/* Almost the same, but no negative numbers allowed */
116#define RANGE_ABS_SLOT_RX "[[:blank:]]*([.^$]|" RANGE_NUM_RX ")?[[:blank:]]*"
117#define RANGE_ABS_RX "^" RANGE_ABS_SLOT_RX "-" RANGE_ABS_SLOT_RX
118
119/* First group is intentionally empty */
120#define RANGE_LT_RX "^()[[:blank:]]*(<[[:blank:]]*" RANGE_NUM_RX ")[[:blank:]]*"
121#define RANGE_GT_RX "^()[[:blank:]]*(>[[:blank:]]*" RANGE_NUM_RX ")[[:blank:]]*"
122
123/* Single group for min and max */
124#define RANGE_BARE_RX "^[[:blank:]]*([.^$]|" RANGE_NUM_RX ")[[:blank:]]*"
125#define RANGE_RX_GROUPS 5
126
127#define RANGE_DOT '.'
128#define RANGE_CIRCUM '^'
129#define RANGE_DOLLAR '$'
130#define RANGE_LT '<'
131#define RANGE_GT '>'
132
137{
140};
141
147static inline int email_msgno(struct Email *e)
148{
149 return e->msgno + 1;
150}
151
152#define MUTT_MAXRANGE -1
153
154extern struct RangeRegex RangeRegexes[];
155extern const struct PatternFlags Flags[];
156
157const struct PatternFlags *lookup_op(int op);
158const struct PatternFlags *lookup_tag(char tag);
159bool eval_date_minmax(struct Pattern *pat, const char *s, struct Buffer *err);
160bool eat_message_range(struct Pattern *pat, PatternCompFlags flags, struct Buffer *s, struct Buffer *err, struct MailboxView *mv);
161
162#endif /* MUTT_PATTERN_PRIVATE_H */
Structs that make up an email.
bool eat_message_range(struct Pattern *pat, PatternCompFlags flags, struct Buffer *s, struct Buffer *err, struct MailboxView *mv)
Parse a range of message numbers - Implements eat_arg_t -.
Definition: message.c:282
Convenience wrapper for the library headers.
uint8_t PatternCompFlags
Flags for mutt_pattern_comp(), e.g. MUTT_PC_FULL_MSG.
Definition: lib.h:67
RangeSide
Which side of the range.
Definition: private.h:137
@ RANGE_S_LEFT
Left side of range.
Definition: private.h:138
@ RANGE_S_RIGHT
Right side of range.
Definition: private.h:139
bool eval_date_minmax(struct Pattern *pat, const char *s, struct Buffer *err)
Evaluate a date-range pattern against 'now'.
Definition: compile.c:496
ExpandoDataPattern
Expando UIDs for Patterns.
Definition: private.h:50
@ ED_PAT_DESCRIPTION
PatternEntry.desc.
Definition: private.h:51
@ ED_PAT_EXPRESION
PatternEntry.expr.
Definition: private.h:52
@ ED_PAT_NUMBER
PatternEntry.num.
Definition: private.h:53
PatternEat
Function to process pattern arguments.
Definition: private.h:62
@ EAT_NONE
No arguments required.
Definition: private.h:63
@ EAT_RANGE
Process a number (range)
Definition: private.h:66
@ EAT_MESSAGE_RANGE
Process a message number (range)
Definition: private.h:67
@ EAT_DATE
Process a date (range)
Definition: private.h:65
@ EAT_QUERY
Process a query string.
Definition: private.h:68
@ EAT_REGEX
Process a regex.
Definition: private.h:64
const struct PatternFlags Flags[]
Lookup table for all patterns.
Definition: flags.c:40
const struct PatternFlags * lookup_tag(char tag)
Lookup a pattern modifier.
Definition: flags.c:198
struct RangeRegex RangeRegexes[]
Set of Regexes for various range types.
Definition: pattern.c:65
const struct PatternFlags * lookup_op(int op)
Lookup the Pattern Flags for an op.
Definition: flags.c:211
static int email_msgno(struct Email *e)
Helper to get the Email's message number.
Definition: private.h:147
RangeType
Type of range.
Definition: private.h:100
@ RANGE_K_REL
Relative range.
Definition: private.h:101
@ RANGE_K_ABS
Absolute range.
Definition: private.h:102
@ RANGE_K_LT
Less-than range.
Definition: private.h:103
@ RANGE_K_INVALID
Range is invalid.
Definition: private.h:107
@ RANGE_K_BARE
Single symbol.
Definition: private.h:105
@ RANGE_K_GT
Greater-than range.
Definition: private.h:104
Key value store.
String manipulation buffer.
Definition: buffer.h:36
The envelope/body of an email.
Definition: email.h:39
int msgno
Number displayed to the user.
Definition: email.h:111
View of a Mailbox.
Definition: mview.h:40
A line in the Pattern Completion menu.
Definition: private.h:37
const char * desc
Description of pattern.
Definition: private.h:41
const char * tag
Copied to buffer if selected.
Definition: private.h:39
int num
Index number.
Definition: private.h:38
const char * expr
Displayed in the menu.
Definition: private.h:40
Mapping between user character and internal constant.
Definition: private.h:75
enum PatternEat eat_arg
Type of function needed to parse flag, e.g. EAT_DATE.
Definition: private.h:80
int tag
Character used to represent this operation, e.g. 'A' for '~A'.
Definition: private.h:76
char * desc
Description of flag.
Definition: private.h:81
PatternCompFlags flags
Pattern flags, e.g. MUTT_PC_FULL_MSG.
Definition: private.h:78
int op
Operation to perform, e.g. MUTT_PAT_SCORE.
Definition: private.h:77
A simple (non-regex) pattern.
Definition: lib.h:77
Regular expression representing a range.
Definition: private.h:88
int lgrp
Paren group matching the left side.
Definition: private.h:90
int rgrp
Paren group matching the right side.
Definition: private.h:91
regex_t cooked
Compiled form.
Definition: private.h:93
bool ready
Compiled yet?
Definition: private.h:92
const char * raw
Regex as string.
Definition: private.h:89