NeoMutt  2023-03-22-27-g3cb248
Teaching an old dog new tricks
DOXYGEN
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 "lib.h"
29
34{
35 int num;
36 const char *tag;
37 const char *expr;
38 const char *desc;
39};
40
47{
54};
55
60{
61 int tag;
62 int op;
64
66 char *desc;
67};
68
73{
74 const char *raw;
75 int lgrp;
76 int rgrp;
77 bool ready;
78 regex_t cooked;
79};
80
85{
91 /* add new ones HERE */
93};
94
95/* The regexes in a modern format */
96#define RANGE_NUM_RX "([[:digit:]]+|0x[[:xdigit:]]+)[MmKk]?"
97#define RANGE_REL_SLOT_RX "[[:blank:]]*([.^$]|-?" RANGE_NUM_RX ")?[[:blank:]]*"
98#define RANGE_REL_RX "^" RANGE_REL_SLOT_RX "," RANGE_REL_SLOT_RX
99
100/* Almost the same, but no negative numbers allowed */
101#define RANGE_ABS_SLOT_RX "[[:blank:]]*([.^$]|" RANGE_NUM_RX ")?[[:blank:]]*"
102#define RANGE_ABS_RX "^" RANGE_ABS_SLOT_RX "-" RANGE_ABS_SLOT_RX
103
104/* First group is intentionally empty */
105#define RANGE_LT_RX "^()[[:blank:]]*(<[[:blank:]]*" RANGE_NUM_RX ")[[:blank:]]*"
106#define RANGE_GT_RX "^()[[:blank:]]*(>[[:blank:]]*" RANGE_NUM_RX ")[[:blank:]]*"
107
108/* Single group for min and max */
109#define RANGE_BARE_RX "^[[:blank:]]*([.^$]|" RANGE_NUM_RX ")[[:blank:]]*"
110#define RANGE_RX_GROUPS 5
111
112#define RANGE_DOT '.'
113#define RANGE_CIRCUM '^'
114#define RANGE_DOLLAR '$'
115#define RANGE_LT '<'
116#define RANGE_GT '>'
117
122{
125};
126
127#define EMSG(e) (((e)->msgno) + 1)
128
129#define MUTT_MAXRANGE -1
130
131extern struct RangeRegex RangeRegexes[];
132extern const struct PatternFlags Flags[];
133
134const struct PatternFlags *lookup_op(int op);
135const struct PatternFlags *lookup_tag(char tag);
136bool eval_date_minmax(struct Pattern *pat, const char *s, struct Buffer *err);
137
138#endif /* MUTT_PATTERN_PRIVATE_H */
Convenience wrapper for the library headers.
uint8_t PatternCompFlags
Flags for mutt_pattern_comp(), e.g. MUTT_PC_FULL_MSG.
Definition: lib.h:60
RangeSide
Which side of the range.
Definition: private.h:122
@ RANGE_S_LEFT
Left side of range.
Definition: private.h:123
@ RANGE_S_RIGHT
Right side of range.
Definition: private.h:124
bool eval_date_minmax(struct Pattern *pat, const char *s, struct Buffer *err)
Evaluate a date-range pattern against 'now'.
Definition: compile.c:507
PatternEat
Function to process pattern arguments.
Definition: private.h:47
@ EAT_NONE
No arguments required.
Definition: private.h:48
@ EAT_RANGE
Process a number (range)
Definition: private.h:51
@ EAT_MESSAGE_RANGE
Process a message number (range)
Definition: private.h:52
@ EAT_DATE
Process a date (range)
Definition: private.h:50
@ EAT_QUERY
Process a query string.
Definition: private.h:53
@ EAT_REGEX
Process a regex.
Definition: private.h:49
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:200
struct RangeRegex RangeRegexes[]
Set of Regexes for various range types.
Definition: pattern.c:64
const struct PatternFlags * lookup_op(int op)
Lookup the Pattern Flags for an op.
Definition: flags.c:213
RangeType
Type of range.
Definition: private.h:85
@ RANGE_K_REL
Relative range.
Definition: private.h:86
@ RANGE_K_ABS
Absolute range.
Definition: private.h:87
@ RANGE_K_LT
Less-than range.
Definition: private.h:88
@ RANGE_K_INVALID
Range is invalid.
Definition: private.h:92
@ RANGE_K_BARE
Single symbol.
Definition: private.h:90
@ RANGE_K_GT
Greater-than range.
Definition: private.h:89
Key value store.
String manipulation buffer.
Definition: buffer.h:34
A line in the Pattern Completion menu.
Definition: private.h:34
const char * desc
Description of pattern.
Definition: private.h:38
const char * tag
Copied to buffer if selected.
Definition: private.h:36
int num
Index number.
Definition: private.h:35
const char * expr
Displayed in the menu.
Definition: private.h:37
Mapping between user character and internal constant.
Definition: private.h:60
enum PatternEat eat_arg
Type of function needed to parse flag, e.g. EAT_DATE.
Definition: private.h:65
int tag
Character used to represent this operation, e.g. 'A' for '~A'.
Definition: private.h:61
char * desc
Description of flag.
Definition: private.h:66
PatternCompFlags flags
Pattern flags, e.g. MUTT_PC_FULL_MSG.
Definition: private.h:63
int op
Operation to perform, e.g. MUTT_PAT_SCORE.
Definition: private.h:62
A simple (non-regex) pattern.
Definition: lib.h:70
Regular expression representing a range.
Definition: private.h:73
int lgrp
Paren group matching the left side.
Definition: private.h:75
int rgrp
Paren group matching the right side.
Definition: private.h:76
regex_t cooked
Compiled form.
Definition: private.h:78
bool ready
Compiled yet?
Definition: private.h:77
const char * raw
Regex as string.
Definition: private.h:74