NeoMutt  2024-12-12-14-g7b49f7
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
sort.c File Reference

Browser sorting. More...

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

Go to the source code of this file.

Data Structures

struct  CompareData
 Private data for browser_sort_helper() More...
 

Functions

static int browser_sort_subject (const void *a, const void *b, void *sdata)
 Compare two browser entries by their subject - Implements sort_t -.
 
static int browser_sort_unsorted (const void *a, const void *b, void *sdata)
 Compare two browser entries by their order - Implements sort_t -.
 
static int browser_sort_desc (const void *a, const void *b, void *sdata)
 Compare two browser entries by their descriptions - Implements sort_t -.
 
static int browser_sort_date (const void *a, const void *b, void *sdata)
 Compare two browser entries by their date - Implements sort_t -.
 
static int browser_sort_size (const void *a, const void *b, void *sdata)
 Compare two browser entries by their size - Implements sort_t -.
 
static int browser_sort_count (const void *a, const void *b, void *sdata)
 Compare two browser entries by their message count - Implements sort_t -.
 
static int browser_sort_new (const void *a, const void *b, void *sdata)
 Compare two browser entries by their new count - Implements sort_t -.
 
static int browser_sort_helper (const void *a, const void *b, void *sdata)
 Helper to sort the items in the browser - Implements sort_t -.
 
void browser_sort (struct BrowserState *state)
 Sort the entries in the browser.
 

Detailed Description

Browser sorting.

Authors
  • 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

◆ browser_sort()

void browser_sort ( struct BrowserState state)

Sort the entries in the browser.

Parameters
stateBrowser state

Call to qsort using browser_sort_helper function. Some specific sort methods are not used via NNTP.

Definition at line 186 of file sort.c.

187{
188 const enum EmailSortType c_browser_sort = cs_subset_sort(NeoMutt->sub, "browser_sort");
189 switch (c_browser_sort & SORT_MASK)
190 {
193 if (OptNews)
194 return;
196 default:
197 break;
198 }
199
200 sort_t f = NULL;
201 switch (c_browser_sort & SORT_MASK)
202 {
205 break;
208 break;
211 break;
214 break;
215 case BROWSER_SORT_NEW:
217 break;
220 break;
222 default:
224 break;
225 }
226
227 struct CompareData cd = {
228 .sort_fn = f,
229 .sort_reverse = c_browser_sort & SORT_REVERSE,
230 .sort_dirs_first = cs_subset_bool(NeoMutt->sub, "browser_sort_dirs_first"),
231 };
232
233 ARRAY_SORT(&state->entry, browser_sort_helper, &cd);
234}
#define ARRAY_SORT(head, fn, sdata)
Sort an array.
Definition: array.h:279
@ BROWSER_SORT_ALPHA
Sort alphabetically by name.
Definition: sort.h:31
@ BROWSER_SORT_UNSORTED
Sort into the raw order.
Definition: sort.h:37
@ BROWSER_SORT_COUNT
Sort by total message count.
Definition: sort.h:32
@ BROWSER_SORT_DATE
Sort by date.
Definition: sort.h:33
@ BROWSER_SORT_NEW
Sort by count of new messages.
Definition: sort.h:35
@ BROWSER_SORT_SIZE
Sort by size.
Definition: sort.h:36
@ BROWSER_SORT_DESC
Sort by description.
Definition: sort.h:34
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:47
short cs_subset_sort(const struct ConfigSubset *sub, const char *name)
Get a sort config item by name.
Definition: helpers.c:266
#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
EmailSortType
Methods for sorting Emails.
Definition: sort.h:53
bool OptNews
(pseudo) used to change reader mode
Definition: globals.c:67
static int browser_sort_desc(const void *a, const void *b, void *sdata)
Compare two browser entries by their descriptions - Implements sort_t -.
Definition: sort.c:84
static int browser_sort_date(const void *a, const void *b, void *sdata)
Compare two browser entries by their date - Implements sort_t -.
Definition: sort.c:95
static int browser_sort_count(const void *a, const void *b, void *sdata)
Compare two browser entries by their message count - Implements sort_t -.
Definition: sort.c:117
static int browser_sort_size(const void *a, const void *b, void *sdata)
Compare two browser entries by their size - Implements sort_t -.
Definition: sort.c:106
static int browser_sort_helper(const void *a, const void *b, void *sdata)
Helper to sort the items in the browser - Implements sort_t -.
Definition: sort.c:159
static int browser_sort_new(const void *a, const void *b, void *sdata)
Compare two browser entries by their new count - Implements sort_t -.
Definition: sort.c:136
static int browser_sort_subject(const void *a, const void *b, void *sdata)
Compare two browser entries by their subject - Implements sort_t -.
Definition: sort.c:55
static int browser_sort_unsorted(const void *a, const void *b, void *sdata)
Compare two browser entries by their order - Implements sort_t -.
Definition: sort.c:73
#define FALLTHROUGH
Definition: lib.h:111
int(* sort_t)(const void *a, const void *b, void *sdata)
Definition: qsort_r.h:41
struct BrowserEntryArray entry
Array of files / dirs / mailboxes.
Definition: lib.h:145
Private data for browser_sort_helper()
Definition: sort.c:46
sort_t sort_fn
Function to perform $browser_sort.
Definition: sort.c:49
Container for Accounts, Notifications.
Definition: neomutt.h:42
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function: