Adding no sort patch

This commit is contained in:
bakkeby 2021-05-17 11:10:09 +02:00
parent d6894046f1
commit 24ff57a540
3 changed files with 30 additions and 1 deletions

View File

@ -26,7 +26,7 @@ dmenu, how to install it and how it works.
### Changelog:
2021-05-17 - Added the restrict return patch
2021-05-17 - Added the restrict return and no sort patches
2021-05-15 - Added the tsv and printindex patches
@ -137,6 +137,12 @@ dmenu, how to install it and how it works.
- [navhistory](https://tools.suckless.org/dmenu/patches/navhistory/)
- provides dmenu the ability for history navigation similar to that of bash
- [no-sort](https://tools.suckless.org/dmenu/patches/no-sort/)
- adds the -S option to disable sorting menu items after matching
- useful, for example, when menu items are sorted by their frequency of use (using an
external cache) and the most frequently selected items should always appear first regardless
of how they were exact, prefix, or substring matches
- [non-blocking-stdin](https://tools.suckless.org/dmenu/patches/non_blocking_stdin/)
- this is a patch to have dmenu read stdin in a non blocking way, making it wait for input
both from stdin and from X

15
dmenu.c
View File

@ -130,6 +130,9 @@ static int managed = 0;
static int *selid = NULL;
static unsigned int selidsize = 0;
#endif // MULTI_SELECTION_PATCH
#if NO_SORT_PATCH
static unsigned int sortmatches = 1;
#endif // NO_SORT_PATCH
#if PRINTINPUTTEXT_PATCH
static int use_text_input = 0;
#endif // PRINTINPUTTEXT_PATCH
@ -631,6 +634,11 @@ match(void)
#else
/* exact matches go first, then prefixes, then substrings */
#endif // HIGHPRIORITY_PATCH
#if NO_SORT_PATCH
if (!sortmatches)
appenditem(item, &matches, &matchend);
else
#endif // NO_SORT_PATCH
if (!tokc || !fstrncmp(text, item->text, textsize))
appenditem(item, &matches, &matchend);
#if HIGHPRIORITY_PATCH
@ -1513,6 +1521,9 @@ usage(void)
#if PASSWORD_PATCH
"P"
#endif // PASSWORD_PATCH
#if NO_SORT_PATCH
"S"
#endif // NO_SORT_PATCH
#if REJECTNOMATCH_PATCH
"R" // (changed from r to R due to conflict with INCREMENTAL_PATCH)
#endif // REJECTNOMATCH_PATCH
@ -1633,6 +1644,10 @@ main(int argc, char *argv[])
} else if (!strcmp(argv[i], "-R")) { /* reject input which results in no match */
reject_no_match = 1;
#endif // REJECTNOMATCH_PATCH
#if NO_SORT_PATCH
} else if (!strcmp(argv[i], "-S")) { /* do not sort matches */
sortmatches = 0;
#endif // NO_SORT_PATCH
#if PRINTINDEX_PATCH
} else if (!strcmp(argv[i], "-ix")) { /* adds ability to return index in list */
print_index = 1;

View File

@ -141,6 +141,14 @@
*/
#define NAVHISTORY_PATCH 0
/* Adds the -S option to disable sorting menu items after matching. Useful, for example, when menu
* items are sorted by their frequency of use (using an external cache) and the most frequently
* selected items should always appear first regardless of how they were exact, prefix, or
* substring matches.
* https://tools.suckless.org/dmenu/patches/no-sort/
*/
#define NO_SORT_PATCH 0
/* This is a patch to have dmenu read stdin in a non blocking way, making it wait for input both
* from stdin and from X. This means that you can continue feeding dmenu while you type.
* This patch is meant to be used along with the incremental patch, so that you can use stdout