NeoMutt  2025-01-09-104-g5de5ef
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
sort.c File Reference

Sidebar sort functions. More...

#include "config.h"
#include <stdbool.h>
#include <stddef.h>
#include "private.h"
#include "mutt/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "sort.h"
+ Include dependency graph for sort.c:

Go to the source code of this file.

Functions

static int sb_sort_count (const void *a, const void *b, void *sdata)
 Compare two Sidebar entries by count - Implements sort_t -.
 
static int sb_sort_desc (const void *a, const void *b, void *sdata)
 Compare two Sidebar entries by description - Implements sort_t -.
 
static int sb_sort_flagged (const void *a, const void *b, void *sdata)
 Compare two Sidebar entries by flagged - Implements sort_t -.
 
static int sb_sort_path (const void *a, const void *b, void *sdata)
 Compare two Sidebar entries by path - Implements sort_t -.
 
static int sb_sort_unread (const void *a, const void *b, void *sdata)
 Compare two Sidebar entries by unread - Implements sort_t -.
 
static int sb_sort_unsorted (const void *a, const void *b, void *sdata)
 Compare two Sidebar entries by order of creation - Implements sort_t -.
 
void sb_sort_entries (struct SidebarWindowData *wdata, enum EmailSortType sort)
 Sort the Sidebar entries.
 

Detailed Description

Sidebar sort functions.

Authors
  • Pietro Cerutti
  • Richard Russon
  • Dennis Schön

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

Function Documentation

◆ sb_sort_entries()

void sb_sort_entries ( struct SidebarWindowData wdata,
enum EmailSortType  sort 
)

Sort the Sidebar entries.

Parameters
wdataSidebar data
sortSort order, e.g. SB_SORT_PATH

Sort the wdata->entries array according to the current sort config option $sidebar_sort. This calls qsort to do the work which calls our callback function "cb_qsort_sbe".

Once sorted, the prev/next links will be reconstructed.

Definition at line 161 of file sort.c.

162{
163 sort_t fn = NULL;
164
165 switch (sort & SORT_MASK)
166 {
167 case SB_SORT_COUNT:
168 fn = sb_sort_count;
169 break;
170 case SB_SORT_DESC:
171 fn = sb_sort_desc;
172 break;
173 case SB_SORT_FLAGGED:
174 fn = sb_sort_flagged;
175 break;
176 case SB_SORT_PATH:
177 fn = sb_sort_path;
178 break;
179 case SB_SORT_UNREAD:
180 fn = sb_sort_unread;
181 break;
182 case SB_SORT_UNSORTED:
183 default:
184 fn = sb_sort_unsorted;
185 break;
186 }
187
188 bool sort_reverse = (sort & SORT_REVERSE);
189 ARRAY_SORT(&wdata->entries, fn, &sort_reverse);
190}
#define ARRAY_SORT(head, fn, sdata)
Sort an array.
Definition: array.h:335
#define SORT_MASK
Mask for the sort id.
Definition: sort.h:38
#define SORT_REVERSE
Reverse the order of the sort.
Definition: sort.h:39
static int sb_sort_desc(const void *a, const void *b, void *sdata)
Compare two Sidebar entries by description - Implements sort_t -.
Definition: sort.c:64
static int sb_sort_unread(const void *a, const void *b, void *sdata)
Compare two Sidebar entries by unread - Implements sort_t -.
Definition: sort.c:118
static int sb_sort_flagged(const void *a, const void *b, void *sdata)
Compare two Sidebar entries by flagged - Implements sort_t -.
Definition: sort.c:79
static int sb_sort_unsorted(const void *a, const void *b, void *sdata)
Compare two Sidebar entries by order of creation - Implements sort_t -.
Definition: sort.c:138
static int sb_sort_path(const void *a, const void *b, void *sdata)
Compare two Sidebar entries by path - Implements sort_t -.
Definition: sort.c:99
static int sb_sort_count(const void *a, const void *b, void *sdata)
Compare two Sidebar entries by count - Implements sort_t -.
Definition: sort.c:44
int(* sort_t)(const void *a, const void *b, void *sdata)
Definition: qsort_r.h:41
@ SB_SORT_FLAGGED
Sort by count of flagged messages.
Definition: sort.h:33
@ SB_SORT_COUNT
Sort by total message count.
Definition: sort.h:31
@ SB_SORT_DESC
Sort by mailbox description.
Definition: sort.h:32
@ SB_SORT_PATH
Sort by mailbox path (alphabetically)
Definition: sort.h:34
@ SB_SORT_UNREAD
Sort by count of unread messages.
Definition: sort.h:35
@ SB_SORT_UNSORTED
Sort into the order the mailboxes were configured.
Definition: sort.h:36
struct SbEntryArray entries
Items to display in the sidebar.
Definition: private.h:91
+ Here is the call graph for this function:
+ Here is the caller graph for this function: