NeoMutt  2024-11-14-34-g5aaf0d
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 "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_order (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_count_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 185 of file sort.c.

186{
187 const enum SortType c_sort_browser = cs_subset_sort(NeoMutt->sub, "sort_browser");
188 switch (c_sort_browser & SORT_MASK)
189 {
190 case SORT_SIZE:
191 case SORT_DATE:
192 if (OptNews)
193 return;
195 default:
196 break;
197 }
198
199 sort_t f = NULL;
200 switch (c_sort_browser & SORT_MASK)
201 {
202 case SORT_COUNT:
204 break;
205 case SORT_DATE:
207 break;
208 case SORT_DESC:
210 break;
211 case SORT_SIZE:
213 break;
214 case SORT_UNREAD:
216 break;
217 case SORT_SUBJECT:
219 break;
220 default:
221 case SORT_ORDER:
223 break;
224 }
225
226 struct CompareData cd = {
227 .sort_fn = f,
228 .sort_reverse = c_sort_browser & SORT_REVERSE,
229 .sort_dirs_first = cs_subset_bool(NeoMutt->sub, "browser_sort_dirs_first"),
230 };
231
232 ARRAY_SORT(&state->entry, browser_sort_helper, &cd);
233}
#define ARRAY_SORT(head, fn, sdata)
Sort an array.
Definition: array.h:279
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
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:83
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:94
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:116
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:105
static int browser_sort_count_new(const void *a, const void *b, void *sdata)
Compare two browser entries by their new count - Implements sort_t -.
Definition: sort.c:135
static int browser_sort_order(const void *a, const void *b, void *sdata)
Compare two browser entries by their order - Implements sort_t -.
Definition: sort.c:72
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:158
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:54
#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
SortType
Methods for sorting.
Definition: sort2.h:34
@ SORT_SUBJECT
Sort by the email's subject.
Definition: sort2.h:38
@ SORT_ORDER
Sort by the order the messages appear in the mailbox.
Definition: sort2.h:40
@ SORT_SIZE
Sort by the size of the email.
Definition: sort2.h:36
@ SORT_DESC
Sort by the folder's description.
Definition: sort2.h:55
@ SORT_DATE
Sort by the date the email was sent.
Definition: sort2.h:35
@ 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 BrowserEntryArray entry
Array of files / dirs / mailboxes.
Definition: lib.h:144
Private data for browser_sort_helper()
Definition: sort.c:45
sort_t sort_fn
Function to perform $browser_sort.
Definition: sort.c:48
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: