NeoMutt  2024-04-16-36-g75b6fb
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
tagging.c File Reference

Tagging support. More...

#include "config.h"
#include <stddef.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/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)
 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, int op)
 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 && !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:59
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:48
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
@ LL_DEBUG1
Log at debug level 1.
Definition: logging2.h:43
void msgwin_clear_text(struct MuttWindow *win)
Clear the text in the Message Window.
Definition: msgwin.c:519
void msgwin_set_text(struct MuttWindow *win, const char *text, enum ColorId color)
Set the text for the Message Window.
Definition: msgwin.c:484
const char * msgwin_get_text(struct MuttWindow *win)
Get the text from the Message Window.
Definition: msgwin.c:401
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:654
int num_tagged
Number of tagged entries.
Definition: lib.h:93
struct ConfigSubset * sub
Inherited config items.
Definition: lib.h:87
bool tag_prefix
User has pressed <tag-prefix>
Definition: lib.h:85
+ 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:39
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 
)
static

Tag the current entry.

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

Definition at line 86 of file tagging.c.

87{
88 const bool c_auto_tag = cs_subset_bool(menu->sub, "auto_tag");
89 int rc = FR_SUCCESS;
90
91 if ((menu->num_tagged != 0) && c_auto_tag)
92 menu->tag_prefix = true;
93
94 if (!menu->tag)
95 {
96 mutt_error(_("Tagging is not supported"));
97 return FR_ERROR;
98 }
99
100 if (menu->tag_prefix && !c_auto_tag)
101 {
102 for (int i = 0; i < menu->max; i++)
103 menu->num_tagged += menu->tag(menu, i, 0);
104
105 menu->redraw |= MENU_REDRAW_INDEX;
106 }
107 else if (menu->max != 0)
108 {
109 int num = menu->tag(menu, menu->current, -1);
110 menu->num_tagged += num;
111
112 const bool c_resolve = cs_subset_bool(menu->sub, "resolve");
113 if ((num != 0) && c_resolve && (menu->current < (menu->max - 1)))
114 {
115 menu_set_index(menu, menu->current + 1);
116 }
117 else
118 {
120 }
121 }
122 else
123 {
124 mutt_error(_("No entries"));
125 rc = FR_ERROR;
126 }
127
128 menu->tag_prefix = ((menu->num_tagged != 0) && c_auto_tag);
129
130 /* give visual indication that the next command is a tag- command */
131 if (menu->tag_prefix)
132 {
133 msgwin_set_text(NULL, "tag-", MT_COLOR_NORMAL);
134 }
135
136 menu->win->actions |= WA_REPAINT;
137 return rc;
138}
@ FR_ERROR
Valid function - error occurred.
Definition: dispatcher.h:38
#define mutt_error(...)
Definition: logging2.h:92
#define MENU_REDRAW_INDEX
Redraw the index.
Definition: lib.h:56
#define MENU_REDRAW_CURRENT
Redraw the current line of the menu.
Definition: lib.h:58
MenuRedrawFlags menu_set_index(struct Menu *menu, int index)
Set the current selection in the Menu.
Definition: menu.c:174
#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:86
int current
Current entry.
Definition: lib.h:80
MenuRedrawFlags redraw
When to redraw the screen.
Definition: lib.h:82
int(* tag)(struct Menu *menu, int sel, int act)
Definition: lib.h:131
int max
Number of entries in the menu.
Definition: lib.h:81
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 146 of file tagging.c.

147{
148 if (menu->tag_prefix)
149 {
150 menu->tag_prefix = false;
151 menu_set_prefix(menu);
152 }
153 else if (menu->num_tagged == 0)
154 {
155 mutt_warning(_("No tagged entries"));
156 }
157 else
158 {
159 menu->tag_prefix = true;
160 menu_set_prefix(menu);
161 }
162
163 return FR_SUCCESS;
164}
#define mutt_warning(...)
Definition: logging2.h:90
+ 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 172 of file tagging.c.

173{
174 if (menu->tag_prefix)
175 {
176 menu->tag_prefix = false;
177 }
178 else if (menu->num_tagged == 0)
179 {
181 mutt_debug(LL_DEBUG1, "nothing to do\n");
182 }
183 else
184 {
185 menu->tag_prefix = true;
186 }
187
188 menu_set_prefix(menu);
189 return FR_SUCCESS;
190}
void mutt_flush_macro_to_endcond(void)
Drop a macro from the input buffer.
Definition: get.c:165
+ 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 197 of file tagging.c.

198{
199 menu->tag_prefix = false;
200 menu_set_prefix(menu);
201 return FR_SUCCESS;
202}
+ 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 209 of file tagging.c.

210{
211 menu_set_prefix(menu);
212 return FR_SUCCESS;
213}
+ 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 220 of file tagging.c.

221{
222 menu->tag_prefix = false;
223 menu_set_prefix(menu);
224 return FR_SUCCESS;
225}
+ Here is the call graph for this function:
+ Here is the caller graph for this function: