NeoMutt  2024-11-14-138-ge5ca67
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 */
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", Flags[i].tag);
142 entry.tag = buf_strdup(buf);
143
144 switch (Flags[i].eat_arg)
145 {
146 case EAT_REGEX:
147 /* L10N:
148 Pattern Completion Menu argument type: a regular expression
149 */
150 buf_add_printf(buf, " %s", _("EXPR"));
151 break;
152 case EAT_RANGE:
154 /* L10N:
155 Pattern Completion Menu argument type: a numeric range.
156 Used by ~m, ~n, ~X, ~z.
157 */
158 buf_add_printf(buf, " %s", _("RANGE"));
159 break;
160 case EAT_DATE:
161 /* L10N:
162 Pattern Completion Menu argument type: a date range
163 Used by ~d, ~r.
164 */
165 buf_add_printf(buf, " %s", _("DATERANGE"));
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 default:
175 break;
176 }
177
178 entry.expr = buf_strdup(buf);
179 entry.desc = mutt_str_dup(_(Flags[i].desc));
180
181 ARRAY_ADD(pea, entry);
182 }
183
184 /* Add struct MuttThread patterns manually.
185 * Note we allocated 3 extra slots for these above. */
186
187 /* L10N:
188 Pattern Completion Menu argument type: a nested pattern.
189 Used by ~(), ~<(), ~>().
190 */
191 const char *patternstr = _("PATTERN");
192
193 entry.num = ARRAY_SIZE(pea) + 1;
194 entry.tag = mutt_str_dup("~()");
195 buf_printf(buf, "~(%s)", patternstr);
196 entry.expr = buf_strdup(buf);
197 // L10N: Pattern Completion Menu description for ~()
198 entry.desc = mutt_str_dup(_("messages in threads containing messages matching PATTERN"));
199 ARRAY_ADD(pea, entry);
200
201 entry.num = ARRAY_SIZE(pea) + 1;
202 entry.tag = mutt_str_dup("~<()");
203 buf_printf(buf, "~<(%s)", patternstr);
204 entry.expr = buf_strdup(buf);
205 // L10N: Pattern Completion Menu description for ~<()
206 entry.desc = mutt_str_dup(_("messages whose immediate parent matches PATTERN"));
207 ARRAY_ADD(pea, entry);
208
209 entry.num = ARRAY_SIZE(pea) + 1;
210 entry.tag = mutt_str_dup("~>()");
211 buf_printf(buf, "~>(%s)", patternstr);
212 entry.expr = buf_strdup(buf);
213 // L10N: Pattern Completion Menu description for ~>()
214 entry.desc = mutt_str_dup(_("messages having an immediate child matching PATTERN"));
215 ARRAY_ADD(pea, entry);
216
217 buf_pool_release(&buf);
218}
#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:82
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:96
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

◆ 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.