NeoMutt  2024-10-02-37-gfa9146
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 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 171 of file sort.c.

172{
174
175 switch (sort & SORT_MASK)
176 {
177 case SORT_COUNT:
178 fn = sb_sort_count;
179 break;
180 case SORT_DESC:
181 fn = sb_sort_desc;
182 break;
183 case SORT_FLAGGED:
184 fn = sb_sort_flagged;
185 break;
186 case SORT_PATH:
187 fn = sb_sort_path;
188 break;
189 case SORT_UNREAD:
190 fn = sb_sort_unread;
191 break;
192 case SORT_ORDER:
193 fn = sb_sort_order;
195 default:
196 break;
197 }
198
199 bool sort_reverse = (sort & SORT_REVERSE);
200 ARRAY_SORT(&wdata->entries, fn, &sort_reverse);
201}
#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:62
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:116
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:77
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:151
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:136
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:97
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:42
#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: