NeoMutt  2022-04-29-178-g3b62e6
Teaching an old dog new tricks
DOXYGEN
array.c
Go to the documentation of this file.
1
29#include "config.h"
30#include <stddef.h>
31#include <stdbool.h>
32#include "mutt/lib.h"
33#include "gui.h"
34
35struct Alias;
36
47int alias_array_alias_add(struct AliasViewArray *ava, struct Alias *alias)
48{
49 if (!ava || !alias)
50 return -1;
51
52 struct AliasView av = {
53 .num = 0,
54 .orig_seq = ARRAY_SIZE(ava),
55 .is_tagged = false,
56 .is_deleted = false,
57 .is_visible = true,
58 .alias = alias,
59 };
60 ARRAY_ADD(ava, av);
61 return ARRAY_SIZE(ava);
62}
63
73int alias_array_alias_delete(struct AliasViewArray *ava, const struct Alias *alias)
74{
75 if (!ava || !alias)
76 return -1;
77
78 struct AliasView *avp = NULL;
79 ARRAY_FOREACH(avp, ava)
80 {
81 if (avp->alias != alias)
82 continue;
83
84 ARRAY_REMOVE(ava, avp);
85 break;
86 }
87
88 return ARRAY_SIZE(ava);
89}
90
95int alias_array_count_visible(struct AliasViewArray *ava)
96{
97 int count = 0;
98
99 struct AliasView *avp = NULL;
100 ARRAY_FOREACH(avp, ava)
101 {
102 if (avp->is_visible)
103 count++;
104 }
105
106 return count;
107}
int alias_array_count_visible(struct AliasViewArray *ava)
Count number of visible Aliases.
Definition: array.c:95
int alias_array_alias_delete(struct AliasViewArray *ava, const struct Alias *alias)
Delete an Alias from the AliasViewArray.
Definition: array.c:73
int alias_array_alias_add(struct AliasViewArray *ava, struct Alias *alias)
Add an Alias to the AliasViewArray.
Definition: array.c:47
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
Definition: array.h:155
#define ARRAY_REMOVE(head, elem)
Remove an entry from the array, shifting down the subsequent entries.
Definition: array.h:266
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition: array.h:211
#define ARRAY_SIZE(head)
The number of elements stored.
Definition: array.h:86
Shared code for the Alias and Query Dialogs.
Convenience wrapper for the library headers.
GUI data wrapping an Alias.
Definition: gui.h:36
bool is_visible
Is visible?
Definition: gui.h:43
struct Alias * alias
Alias.
Definition: gui.h:44
int num
Index number in list.
Definition: gui.h:37
A shortcut for an email address or addresses.
Definition: alias.h:34