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