NeoMutt  2024-03-23-147-g885fbc
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 "private.h"
#include "mutt/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "sort.h"
#include "muttlib.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_order (const void *a, const void *b, void *sdata)
 Compare two Sidebar entries by order of creation - Implements sort_t -.
 
static int sb_sort_unsorted (const void *a, const void *b, void *sdata)
 Compare two Sidebar entries into their original order - Implements sort_t -.
 
void sb_sort_entries (struct SidebarWindowData *wdata, enum SortType 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 SortType  sort 
)

Sort the Sidebar entries.

Parameters
wdataSidebar data
sortSort order, e.g. SORT_PATH

Sort the wdata->entries array according to the current sort config option $sidebar_sort_method. 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 172 of file sort.c.

173{
175
176 switch (sort & SORT_MASK)
177 {
178 case SORT_COUNT:
179 fn = sb_sort_count;
180 break;
181 case SORT_DESC:
182 fn = sb_sort_desc;
183 break;
184 case SORT_FLAGGED:
185 fn = sb_sort_flagged;
186 break;
187 case SORT_PATH:
188 fn = sb_sort_path;
189 break;
190 case SORT_UNREAD:
191 fn = sb_sort_unread;
192 break;
193 case SORT_ORDER:
194 fn = sb_sort_order;
196 default:
197 break;
198 }
199
200 bool sort_reverse = (sort & SORT_REVERSE);
201 ARRAY_SORT(&wdata->entries, fn, &sort_reverse);
202}
#define ARRAY_SORT(head, fn, sdata)
Sort an array.
Definition: array.h:279
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:63
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:117
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:78
static int sb_sort_unsorted(const void *a, const void *b, void *sdata)
Compare two Sidebar entries into their original order - Implements sort_t -.
Definition: sort.c:152
static int sb_sort_order(const void *a, const void *b, void *sdata)
Compare two Sidebar entries by order of creation - Implements sort_t -.
Definition: sort.c:137
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:98
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:43
#define FALLTHROUGH
Definition: lib.h:111
int(* sort_t)(const void *a, const void *b, void *sdata)
Definition: qsort_r.h:41
#define SORT_MASK
Mask for the sort id.
Definition: sort2.h:70
@ SORT_ORDER
Sort by the order the messages appear in the mailbox.
Definition: sort2.h:40
@ SORT_PATH
Sort by the folder's path.
Definition: sort2.h:53
@ SORT_FLAGGED
Sort by the number of flagged emails.
Definition: sort2.h:52
@ SORT_DESC
Sort by the folder's description.
Definition: sort2.h:55
@ SORT_COUNT
Sort by number of emails in a folder.
Definition: sort2.h:50
@ SORT_UNREAD
Sort by the number of unread emails.
Definition: sort2.h:51
#define SORT_REVERSE
Reverse the order of the sort.
Definition: sort2.h:71
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: