NeoMutt  2023-03-22
Teaching an old dog new tricks
DOXYGEN
tagging.c File Reference

Tagging support. More...

#include "config.h"
#include <stdbool.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "lib.h"
#include "color/color.h"
#include "opcodes.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. More...
 
static int op_end_cond (struct Menu *menu, int op)
 End of conditional execution (noop) More...
 
static int op_tag (struct Menu *menu, int op)
 Tag the current entry. More...
 
static int op_tag_prefix (struct Menu *menu, int op)
 Apply next function to tagged messages. More...
 
static int op_tag_prefix_cond (struct Menu *menu, int op)
 Apply next function ONLY to tagged messages. More...
 
static int menu_abort (struct Menu *menu)
 User aborted an operation. More...
 
static int menu_timeout (struct Menu *menu)
 Timeout waiting for a keypress. More...
 
static int menu_other (struct Menu *menu)
 Some non-tagging operation occurred. More...
 
int menu_tagging_dispatcher (struct MuttWindow *win, int op)
 Perform tagging operations on the Menu - Implements function_dispatcher_t -. More...
 

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 43 of file tagging.c.

44{
45 const bool c_auto_tag = cs_subset_bool(menu->sub, "auto_tag");
46 if ((menu->num_tagged != 0) && c_auto_tag)
47 menu->tag_prefix = true;
48
49 mutt_debug(LL_DEBUG1, "tag_prefix = %d\n", menu->tag_prefix);
50
51 // Don't overwrite error messages
52 const char *msg_text = msgwin_get_text();
53 if (msg_text && !mutt_str_equal(msg_text, "tag-"))
54 return;
55
56 if (menu->tag_prefix)
58 else
60}
@ MT_COLOR_NORMAL
Plain text.
Definition: color.h:57
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
#define mutt_debug(LEVEL,...)
Definition: logging.h:84
@ LL_DEBUG1
Log at debug level 1.
Definition: logging.h:40
void msgwin_set_text(enum ColorId cid, const char *text)
Set the text for the Message Window.
Definition: msgwin.c:233
const char * msgwin_get_text(void)
Get the text from the Message Window.
Definition: msgwin.c:216
void msgwin_clear_text(void)
Clear the text in the Message Window.
Definition: msgwin.c:249
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:807
int num_tagged
Number of tagged entries.
Definition: lib.h:84
struct ConfigSubset * sub
Inherited config items.
Definition: lib.h:78
bool tag_prefix
User has pressed <tag-prefix>
Definition: lib.h:76
+ 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 68 of file tagging.c.

69{
70 menu->tag_prefix = false;
71 menu_set_prefix(menu);
72 return FR_SUCCESS;
73}
@ FR_SUCCESS
Valid function - successfully performed.
Definition: dispatcher.h:39
static void menu_set_prefix(struct Menu *menu)
Set tag_prefix on $auto_tag.
Definition: tagging.c:43
+ 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 
)
static

Tag the current entry.

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

Definition at line 81 of file tagging.c.

82{
83 const bool c_auto_tag = cs_subset_bool(menu->sub, "auto_tag");
84 int rc = FR_SUCCESS;
85
86 if ((menu->num_tagged != 0) && c_auto_tag)
87 menu->tag_prefix = true;
88
89 if (!menu->tag)
90 {
91 mutt_error(_("Tagging is not supported"));
92 return FR_ERROR;
93 }
94
95 if (menu->tag_prefix && !c_auto_tag)
96 {
97 for (int i = 0; i < menu->max; i++)
98 menu->num_tagged += menu->tag(menu, i, 0);
99
100 menu->redraw |= MENU_REDRAW_INDEX;
101 }
102 else if (menu->max != 0)
103 {
104 int num = menu->tag(menu, menu->current, -1);
105 menu->num_tagged += num;
106
107 const bool c_resolve = cs_subset_bool(menu->sub, "resolve");
108 if ((num != 0) && c_resolve && (menu->current < (menu->max - 1)))
109 {
110 menu_set_index(menu, menu->current + 1);
111 }
112 else
113 {
115 }
116 }
117 else
118 {
119 mutt_error(_("No entries"));
120 rc = FR_ERROR;
121 }
122
123 menu->tag_prefix = ((menu->num_tagged != 0) && c_auto_tag);
124
125 /* give visual indication that the next command is a tag- command */
126 if (menu->tag_prefix)
128
129 menu->win->actions |= WA_REPAINT;
130 return rc;
131}
@ FR_ERROR
Valid function - error occurred.
Definition: dispatcher.h:38
#define mutt_error(...)
Definition: logging.h:87
#define MENU_REDRAW_INDEX
Redraw the index.
Definition: lib.h:57
#define MENU_REDRAW_CURRENT
Redraw the current line of the menu.
Definition: lib.h:59
MenuRedrawFlags menu_set_index(struct Menu *menu, int index)
Set the current selection in the Menu.
Definition: menu.c:168
#define _(a)
Definition: message.h:28
#define WA_REPAINT
Redraw the contents of the Window.
Definition: mutt_window.h:111
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:77
int current
Current entry.
Definition: lib.h:71
MenuRedrawFlags redraw
When to redraw the screen.
Definition: lib.h:73
int(* tag)(struct Menu *menu, int sel, int act)
Definition: lib.h:122
int max
Number of entries in the menu.
Definition: lib.h:72
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:132
+ 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 139 of file tagging.c.

140{
141 if (menu->tag_prefix)
142 {
143 menu->tag_prefix = false;
144 menu_set_prefix(menu);
145 }
146 else if (menu->num_tagged == 0)
147 {
148 mutt_warning(_("No tagged entries"));
149 }
150 else
151 {
152 menu->tag_prefix = true;
153 menu_set_prefix(menu);
154 }
155
156 return FR_SUCCESS;
157}
#define mutt_warning(...)
Definition: logging.h:85
+ 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 165 of file tagging.c.

166{
167 if (menu->tag_prefix)
168 {
169 menu->tag_prefix = false;
170 }
171 else if (menu->num_tagged == 0)
172 {
174 mutt_debug(LL_DEBUG1, "nothing to do\n");
175 }
176 else
177 {
178 menu->tag_prefix = true;
179 }
180
181 menu_set_prefix(menu);
182 return FR_SUCCESS;
183}
void mutt_flush_macro_to_endcond(void)
Drop a macro from the input buffer.
Definition: curs_lib.c:571
+ 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 190 of file tagging.c.

191{
192 menu->tag_prefix = false;
193 menu_set_prefix(menu);
194 return FR_SUCCESS;
195}
+ 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 202 of file tagging.c.

203{
204 menu_set_prefix(menu);
205 return FR_SUCCESS;
206}
+ 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 213 of file tagging.c.

214{
215 menu->tag_prefix = false;
216 menu_set_prefix(menu);
217 return FR_SUCCESS;
218}
+ Here is the call graph for this function:
+ Here is the caller graph for this function: