• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

neomutt / neomutt / 21345785562

24 Jan 2026 12:51AM UTC coverage: 42.019% (-0.03%) from 42.051%
21345785562

push

github

flatcap
status: just the version number

11738 of 27935 relevant lines covered (42.02%)

445.24 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/pattern/functions.c
1
/**
2
 * @file
3
 * Pattern functions
4
 *
5
 * @authors
6
 * Copyright (C) 2022-2023 Richard Russon <rich@flatcap.org>
7
 *
8
 * @copyright
9
 * This program is free software: you can redistribute it and/or modify it under
10
 * the terms of the GNU General Public License as published by the Free Software
11
 * Foundation, either version 2 of the License, or (at your option) any later
12
 * version.
13
 *
14
 * This program is distributed in the hope that it will be useful, but WITHOUT
15
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
17
 * details.
18
 *
19
 * You should have received a copy of the GNU General Public License along with
20
 * this program.  If not, see <http://www.gnu.org/licenses/>.
21
 */
22

23
/**
24
 * @page pattern_functions Pattern functions
25
 *
26
 * Pattern functions
27
 */
28

29
#include "config.h"
30
#include <stdbool.h>
31
#include <stdio.h>
32
#include "mutt/lib.h"
33
#include "core/lib.h"
34
#include "gui/lib.h"
35
#include "functions.h"
36
#include "key/lib.h"
37
#include "menu/lib.h"
38
#include "pattern_data.h"
39

40
/**
41
 * op_generic_select_entry - Select the current entry - Implements ::pattern_function_t - @ingroup pattern_function_api
42
 */
43
static int op_generic_select_entry(struct PatternData *pd, const struct KeyEvent *event)
×
44
{
45
  const int index = menu_get_index(pd->menu);
×
46
  struct PatternEntry *entry = ARRAY_GET(&pd->entries, index);
×
47

48
  if (entry)
×
49
    buf_strcpy(pd->buf, entry->tag);
×
50

51
  pd->done = true;
×
52
  pd->selection = true;
×
53
  return FR_SUCCESS;
×
54
}
55

56
/**
57
 * op_quit - Quit this menu - Implements ::pattern_function_t - @ingroup pattern_function_api
58
 */
59
static int op_quit(struct PatternData *pd, const struct KeyEvent *event)
×
60
{
61
  pd->done = true;
×
62
  pd->selection = false;
×
63
  return FR_SUCCESS;
×
64
}
65

66
// -----------------------------------------------------------------------------
67

68
/**
69
 * PatternFunctions - All the NeoMutt functions that the Pattern supports
70
 */
71
static const struct PatternFunction PatternFunctions[] = {
72
  // clang-format off
73
  { OP_GENERIC_SELECT_ENTRY,   op_generic_select_entry },
74
  { OP_QUIT,                   op_quit },
75
  { OP_EXIT,                   op_quit },
76
  { 0, NULL },
77
  // clang-format on
78
};
79

80
/**
81
 * pattern_function_dispatcher - Perform a Pattern function - Implements ::function_dispatcher_t - @ingroup dispatcher_api
82
 */
83
int pattern_function_dispatcher(struct MuttWindow *win, const struct KeyEvent *event)
×
84
{
85
  // The Dispatcher may be called on any Window in the Dialog
86
  struct MuttWindow *dlg = dialog_find(win);
×
87
  if (!event || !dlg || !dlg->wdata)
×
88
    return FR_ERROR;
89

90
  const int op = event->op;
×
91
  struct Menu *menu = dlg->wdata;
92
  struct PatternData *pd = menu->mdata;
×
93
  if (!pd)
×
94
    return FR_ERROR;
95

96
  int rc = FR_UNKNOWN;
97
  for (size_t i = 0; PatternFunctions[i].op != OP_NULL; i++)
×
98
  {
99
    const struct PatternFunction *fn = &PatternFunctions[i];
100
    if (fn->op == op)
×
101
    {
102
      rc = fn->function(pd, event);
×
103
      break;
×
104
    }
105
  }
106

107
  if (rc == FR_UNKNOWN) // Not our function
×
108
    return rc;
109

110
  const char *result = dispatcher_get_retval_name(rc);
×
111
  mutt_debug(LL_DEBUG1, "Handled %s (%d) -> %s\n", opcodes_get_name(op), op, NONULL(result));
×
112

113
  return rc;
×
114
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc