NeoMutt  2024-04-16-36-g75b6fb
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
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.
 
int alias_array_alias_delete (struct AliasViewArray *ava, const struct Alias *alias)
 Delete an Alias from the AliasViewArray.
 
int alias_array_count_visible (struct AliasViewArray *ava)
 Count number of visible Aliases.
 

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
Return values
numSize of array
-1Error
Note
The Alias is wrapped in an AliasView
Call alias_array_sort() to sort and reindex the AliasViewArray

Definition at line 47 of file array.c.

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

◆ alias_array_alias_delete()

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

Delete an Alias from the AliasViewArray.

Parameters
avaArray of Aliases
aliasAlias to remove
Return values
numSize of array
-1Error
Note
Call alias_array_sort() to sort and reindex the AliasViewArray

Definition at line 73 of file array.c.

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}
#define ARRAY_REMOVE(head, elem)
Remove an entry from the array, shifting down the subsequent entries.
Definition: array.h:267
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition: array.h:212
+ 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 95 of file array.c.

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}
bool is_visible
Is visible?
Definition: gui.h:45
+ Here is the caller graph for this function: