NeoMutt  2021-02-05-89-gabe350
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 
35 struct Alias;
36 
45 int alias_array_alias_add(struct AliasViewArray *ava, struct Alias *alias)
46 {
47  if (!ava || !alias)
48  return -1;
49 
50  struct AliasView av = {
51  .num = 0,
52  .orig_seq = ARRAY_SIZE(ava),
53  .is_tagged = false,
54  .is_deleted = false,
55  .is_visible = true,
56  .alias = alias,
57  };
58  ARRAY_ADD(ava, av);
59  return ARRAY_SIZE(ava);
60 }
61 
69 int alias_array_alias_delete(struct AliasViewArray *ava, struct Alias *alias)
70 {
71  if (!ava || !alias)
72  return -1;
73 
74  struct AliasView *avp = NULL;
75  ARRAY_FOREACH(avp, ava)
76  {
77  if (avp->alias != alias)
78  continue;
79 
80  ARRAY_REMOVE(ava, avp);
81  break;
82  }
83 
84  return ARRAY_SIZE(ava);
85 }
86 
91 int alias_array_count_visible(struct AliasViewArray *ava)
92 {
93  int count = 0;
94 
95  struct AliasView *avp = NULL;
96  ARRAY_FOREACH(avp, ava)
97  {
98  if (avp->is_visible)
99  count++;
100  }
101 
102  return count;
103 }
alias_array_alias_delete
int alias_array_alias_delete(struct AliasViewArray *ava, struct Alias *alias)
Delete an Alias from the AliasViewArray.
Definition: array.c:69
ARRAY_ADD
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
Definition: array.h:152
alias_array_alias_add
int alias_array_alias_add(struct AliasViewArray *ava, struct Alias *alias)
Add an Alias to the AliasViewArray.
Definition: array.c:45
AliasView::is_visible
bool is_visible
Is visible?
Definition: gui.h:44
AliasView::alias
struct Alias * alias
Alias.
Definition: gui.h:45
AliasView::num
int num
Index number in list.
Definition: gui.h:38
ARRAY_SIZE
#define ARRAY_SIZE(head)
The number of elements stored.
Definition: array.h:83
AliasView
GUI data wrapping an Alias.
Definition: gui.h:36
ARRAY_REMOVE
#define ARRAY_REMOVE(head, elem)
Remove an entry from the array, shifting down the subsequent entries.
Definition: array.h:261
ARRAY_FOREACH
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition: array.h:206
lib.h
alias_array_count_visible
int alias_array_count_visible(struct AliasViewArray *ava)
Count number of visible Aliases.
Definition: array.c:91
Alias
A shortcut for an email address or addresses.
Definition: alias.h:33
gui.h