NeoMutt
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 "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.
 
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 45 of file tagging.c.

46{
47 const bool c_auto_tag = cs_subset_bool(menu->sub, "auto_tag");
48 if ((menu->num_tagged != 0) && c_auto_tag)
49 menu->tag_prefix = true;
50
51 mutt_debug(LL_DEBUG1, "tag_prefix = %d\n", menu->tag_prefix);
52
53 // Don't overwrite error messages
54 const char *msg_text = msgwin_get_text(NULL);
55 if (msg_text && !mutt_str_equal(msg_text, "tag-"))
56 return;
57
58 if (menu->tag_prefix)
59 {
60 msgwin_set_text(NULL, "tag-", MT_COLOR_NORMAL);
61 }
62 else
63 {
65 }
66}
@ 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: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:515
void msgwin_set_text(struct MuttWindow *win, const char *text, enum ColorId color)
Set the text for the Message Window.
Definition: msgwin.c:486
const char * msgwin_get_text(struct MuttWindow *win)
Get the text from the Message Window.
Definition: msgwin.c:403
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:798
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 74 of file tagging.c.

75{
76 menu->tag_prefix = false;
77 menu_set_prefix(menu);
78 return FR_SUCCESS;
79}
@ 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:45
+ 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 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 num = menu->tag(menu, menu->current, -1);
111 menu->num_tagged += num;
112
113 const bool c_resolve = cs_subset_bool(menu->sub, "resolve");
114 if ((num != 0) && c_resolve && (menu->current < (menu->max - 1)))
115 {
116 menu_set_index(menu, menu->current + 1);
117 }
118 else
119 {
121 }
122 }
123 else
124 {
125 mutt_error(_("No entries"));
126 rc = FR_ERROR;
127 }
128
129 menu->tag_prefix = ((menu->num_tagged != 0) && c_auto_tag);
130
131 /* give visual indication that the next command is a tag- command */
132 if (menu->tag_prefix)
133 {
134 msgwin_set_text(NULL, "tag-", MT_COLOR_NORMAL);
135 }
136
137 menu->win->actions |= WA_REPAINT;
138 return rc;
139}
@ 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: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:170
#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:121
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 147 of file tagging.c.

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

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

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

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

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