NeoMutt  2025-12-11-911-gd8d604
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
tagging.c File Reference

Tagging support. More...

#include "config.h"
#include <stdbool.h>
#include <stddef.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "lib.h"
#include "color/lib.h"
#include "key/lib.h"
+ Include dependency graph for tagging.c:

Go to the source code of this file.

Functions

static void menu_set_prefix (struct Menu *menu)
 Set tag_prefix on $auto_tag.
 
static int op_end_cond (struct Menu *menu, int op)
 End of conditional execution (noop)
 
static int op_tag (struct Menu *menu, int op, int count)
 Tag the current entry.
 
static int op_tag_prefix (struct Menu *menu, int op)
 Apply next function to tagged messages.
 
static int op_tag_prefix_cond (struct Menu *menu, int op)
 Apply next function ONLY to tagged messages.
 
static int menu_abort (struct Menu *menu)
 User aborted an operation.
 
static int menu_timeout (struct Menu *menu)
 Timeout waiting for a keypress.
 
static int menu_other (struct Menu *menu)
 Some non-tagging operation occurred.
 
int menu_tagging_dispatcher (struct MuttWindow *win, const struct KeyEvent *event)
 Perform tagging operations on the Menu - Implements function_dispatcher_t -.
 

Detailed Description

Tagging support.

Authors
  • Richard Russon

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 tagging.c.

Function Documentation

◆ menu_set_prefix()

static void menu_set_prefix ( struct Menu * menu)
static

Set tag_prefix on $auto_tag.

Parameters
menuMenu

Definition at line 44 of file tagging.c.

45{
46 const bool c_auto_tag = cs_subset_bool(menu->sub, "auto_tag");
47 if ((menu->num_tagged != 0) && c_auto_tag)
48 menu->tag_prefix = true;
49
50 mutt_debug(LL_DEBUG1, "tag_prefix = %d\n", menu->tag_prefix);
51
52 // Don't overwrite error messages
53 const char *msg_text = msgwin_get_text(NULL);
54 if (msg_text && (msg_text[0] != '\0') && !mutt_str_equal(msg_text, "tag-"))
55 return;
56
57 if (menu->tag_prefix)
58 {
59 msgwin_set_text(NULL, "tag-", MT_COLOR_NORMAL);
60 }
61 else
62 {
64 }
65}
@ MT_COLOR_NORMAL
Plain text.
Definition color.h:53
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
#define mutt_debug(LEVEL,...)
Definition logging2.h:91
@ LL_DEBUG1
Log at debug level 1.
Definition logging2.h:45
void msgwin_clear_text(struct MuttWindow *win)
Clear the text in the Message Window.
Definition msgwin.c:554
void msgwin_set_text(struct MuttWindow *win, const char *text, enum ColorId color)
Set the text for the Message Window.
Definition msgwin.c:500
const char * msgwin_get_text(struct MuttWindow *win)
Get the text from the Message Window.
Definition msgwin.c:413
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:665
int num_tagged
Number of tagged entries.
Definition lib.h:101
struct ConfigSubset * sub
Inherited config items.
Definition lib.h:95
bool tag_prefix
User has pressed <tag-prefix>
Definition lib.h:92
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ op_end_cond()

static int op_end_cond ( struct Menu * menu,
int op )
static

End of conditional execution (noop)

Parameters
menuMenu
opOperation to perform, e.g. OP_END_COND
Return values
enumFunctionRetval

Definition at line 73 of file tagging.c.

74{
75 menu->tag_prefix = false;
76 menu_set_prefix(menu);
77 return FR_SUCCESS;
78}
@ FR_SUCCESS
Valid function - successfully performed.
Definition dispatcher.h:40
static void menu_set_prefix(struct Menu *menu)
Set tag_prefix on $auto_tag.
Definition tagging.c:44
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ op_tag()

static int op_tag ( struct Menu * menu,
int op,
int count )
static

Tag the current entry.

Parameters
menuMenu
opOperation to perform, e.g. OP_TAG
countRepeat count for tagging multiple consecutive entries
Return values
enumFunctionRetval

Definition at line 87 of file tagging.c.

88{
89 const bool c_auto_tag = cs_subset_bool(menu->sub, "auto_tag");
90 int rc = FR_SUCCESS;
91
92 if ((menu->num_tagged != 0) && c_auto_tag)
93 menu->tag_prefix = true;
94
95 if (!menu->tag)
96 {
97 mutt_error(_("Tagging is not supported"));
98 return FR_ERROR;
99 }
100
101 if (menu->tag_prefix && !c_auto_tag)
102 {
103 for (int i = 0; i < menu->max; i++)
104 menu->num_tagged += menu->tag(menu, i, 0);
105
106 menu->redraw |= MENU_REDRAW_INDEX;
107 }
108 else if (menu->max != 0)
109 {
110 int tag_count = MAX(count, 1);
111 for (int i = 0; (i < tag_count) && ((menu->current + i) < menu->max); i++)
112 {
113 int num = menu->tag(menu, menu->current + i, -1);
114 menu->num_tagged += num;
115 }
116
117 const bool c_resolve = cs_subset_bool(menu->sub, "resolve");
118 if (c_resolve)
119 {
120 int next_index = menu->current + tag_count;
121 if (next_index >= menu->max)
122 next_index = menu->max - 1;
123 menu_set_index(menu, next_index);
124 menu->redraw |= MENU_REDRAW_INDEX;
125 }
126 else
127 {
128 menu->redraw |= MENU_REDRAW_INDEX;
129 }
130 }
131 else
132 {
133 mutt_error(_("No entries"));
134 rc = FR_ERROR;
135 }
136
137 menu->tag_prefix = ((menu->num_tagged != 0) && c_auto_tag);
138
139 /* give visual indication that the next command is a tag- command */
140 if (menu->tag_prefix)
141 {
142 msgwin_set_text(NULL, "tag-", MT_COLOR_NORMAL);
143 }
144
145 menu->win->actions |= WA_REPAINT;
146 return rc;
147}
@ FR_ERROR
Valid function - error occurred.
Definition dispatcher.h:39
#define mutt_error(...)
Definition logging2.h:94
#define MAX(a, b)
Return the maximum of two values.
Definition memory.h:38
@ MENU_REDRAW_INDEX
Redraw the index.
Definition lib.h:61
MenuRedrawFlags menu_set_index(struct Menu *menu, int index)
Set the current selection in the Menu.
Definition menu.c:169
#define _(a)
Definition message.h:28
@ WA_REPAINT
Redraw the contents of the Window.
struct MuttWindow * win
Window holding the Menu.
Definition lib.h:94
int current
Current entry.
Definition lib.h:87
MenuRedrawFlags redraw
When to redraw the screen.
Definition lib.h:89
int(* tag)(struct Menu *menu, int sel, int act)
Definition lib.h:139
int max
Number of entries in the menu.
Definition lib.h:88
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ op_tag_prefix()

static int op_tag_prefix ( struct Menu * menu,
int op )
static

Apply next function to tagged messages.

Parameters
menuMenu
opOperation to perform, e.g. OP_TAG_PREFIX
Return values
enumFunctionRetval

Definition at line 155 of file tagging.c.

156{
157 if (menu->tag_prefix)
158 {
159 menu->tag_prefix = false;
160 menu_set_prefix(menu);
161 }
162 else if (menu->num_tagged == 0)
163 {
164 mutt_warning(_("No tagged entries"));
165 }
166 else
167 {
168 menu->tag_prefix = true;
169 menu_set_prefix(menu);
170 }
171
172 return FR_SUCCESS;
173}
#define mutt_warning(...)
Definition logging2.h:92
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ op_tag_prefix_cond()

static int op_tag_prefix_cond ( struct Menu * menu,
int op )
static

Apply next function ONLY to tagged messages.

Parameters
menuMenu
opOperation to perform, e.g. OP_TAG_PREFIX_COND
Return values
enumFunctionRetval

Definition at line 181 of file tagging.c.

182{
183 if (menu->tag_prefix)
184 {
185 menu->tag_prefix = false;
186 }
187 else if (menu->num_tagged == 0)
188 {
190 mutt_debug(LL_DEBUG1, "nothing to do\n");
191 }
192 else
193 {
194 menu->tag_prefix = true;
195 }
196
197 menu_set_prefix(menu);
198 return FR_SUCCESS;
199}
void mutt_flush_macro_to_endcond(void)
Drop a macro from the input buffer.
Definition get.c:185
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_abort()

static int menu_abort ( struct Menu * menu)
static

User aborted an operation.

Parameters
menuMenu
Return values
enumFunctionRetval

Definition at line 206 of file tagging.c.

207{
208 menu->tag_prefix = false;
209 menu_set_prefix(menu);
210 return FR_SUCCESS;
211}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_timeout()

static int menu_timeout ( struct Menu * menu)
static

Timeout waiting for a keypress.

Parameters
menuMenu
Return values
enumFunctionRetval

Definition at line 218 of file tagging.c.

219{
220 menu_set_prefix(menu);
221 return FR_SUCCESS;
222}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_other()

static int menu_other ( struct Menu * menu)
static

Some non-tagging operation occurred.

Parameters
menuMenu
Return values
enumFunctionRetval

Definition at line 229 of file tagging.c.

230{
231 menu->tag_prefix = false;
232 menu_set_prefix(menu);
233 return FR_SUCCESS;
234}
+ Here is the call graph for this function:
+ Here is the caller graph for this function: