NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
DOXYGEN
array.c File Reference

Array of Alias Views. More...

#include "config.h"
#include <stddef.h>
#include <stdbool.h>
#include "mutt/lib.h"
#include "gui.h"
+ Include dependency graph for array.c:

Go to the source code of this file.

Functions

int alias_array_alias_add (struct AliasViewArray *ava, struct Alias *alias)
 Add an Alias to the AliasViewArray. More...
 
int alias_array_alias_delete (struct AliasViewArray *ava, struct Alias *alias)
 Delete an Alias from the AliasViewArray. More...
 
int alias_array_count_visible (struct AliasViewArray *ava)
 Count number of visible Aliases. More...
 

Detailed Description

Array of Alias Views.

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 array.c.

Function Documentation

◆ alias_array_alias_add()

int alias_array_alias_add ( struct AliasViewArray *  ava,
struct Alias alias 
)

Add an Alias to the AliasViewArray.

Parameters
avaArray of Aliases
aliasAlias to add
Note
The Alias is wrapped in an AliasView
Call alias_array_sort() to sort and reindex the AliasViewArray

Definition at line 45 of file array.c.

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 }
GUI data wrapping an Alias.
Definition: gui.h:35
struct Alias * alias
Alias.
Definition: gui.h:44
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
Definition: array.h:152
int num
Index number in list.
Definition: gui.h:37
#define ARRAY_SIZE(head)
The number of elements stored.
Definition: array.h:83
+ Here is the caller graph for this function:

◆ alias_array_alias_delete()

int alias_array_alias_delete ( struct AliasViewArray *  ava,
struct Alias alias 
)

Delete an Alias from the AliasViewArray.

Parameters
avaArray of Aliases
aliasAlias to remove
Note
Call alias_array_sort() to sort and reindex the AliasViewArray

Definition at line 69 of file array.c.

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 }
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition: array.h:206
GUI data wrapping an Alias.
Definition: gui.h:35
struct Alias * alias
Alias.
Definition: gui.h:44
#define ARRAY_REMOVE(head, elem)
Remove an entry from the array, shifting down the subsequent entries.
Definition: array.h:261
#define ARRAY_SIZE(head)
The number of elements stored.
Definition: array.h:83
+ Here is the caller graph for this function:

◆ alias_array_count_visible()

int alias_array_count_visible ( struct AliasViewArray *  ava)

Count number of visible Aliases.

Parameters
avaArray of Aliases

Definition at line 91 of file array.c.

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 }
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition: array.h:206
GUI data wrapping an Alias.
Definition: gui.h:35
bool is_visible
Is visible?
Definition: gui.h:43
+ Here is the caller graph for this function: