scroll-multiplier option

This commit is contained in:
djvs 2023-03-29 10:20:06 -04:00
parent 0133697fd2
commit 0b3f7f7bb8
4 changed files with 33 additions and 11 deletions

View File

@ -123,6 +123,8 @@ Settings config = {
.window_match_fields = "all",
/** Monitor */
.monitor = "-5",
/** Multiply scrolling amount **/
.scroll_multiplier = 1,
/** Set filter */
.filter = NULL,
.dpi = -1,

View File

@ -95,6 +95,8 @@ typedef struct {
/** Toggle to enable sorting. */
unsigned int sort;
/** Sorting method. */
unsigned int scroll_multiplier;
/** Sorting method. */
SortingMethod sorting_method_enum;
/** Sorting method. */
char *sorting_method;

View File

@ -819,13 +819,19 @@ static void listview_nav_up_int(listview *lv) {
if (lv == NULL) {
return;
}
if (lv->req_elements == 0 || (lv->selected == 0 && !lv->cycle)) {
return;
unsigned int mult = 1;
if (config.scroll_multiplier){
mult = config.scroll_multiplier;
}
if (lv->selected == 0) {
lv->selected = lv->req_elements;
for (unsigned int i=0; i < mult; i++) {
if (lv->req_elements == 0 || (lv->selected == 0 && !lv->cycle)) {
return;
}
if (lv->selected == 0) {
lv->selected = lv->req_elements;
}
lv->selected--;
}
lv->selected--;
lv->barview.direction = RIGHT_TO_LEFT;
if (lv->sc_callback) {
@ -837,13 +843,19 @@ static void listview_nav_down_int(listview *lv) {
if (lv == NULL) {
return;
}
if (lv->req_elements == 0 ||
(lv->selected == (lv->req_elements - 1) && !lv->cycle)) {
return;
unsigned int mult = 1;
if (config.scroll_multiplier){
mult = config.scroll_multiplier;
}
for (unsigned int i=0; i < mult; i++) {
if (lv->req_elements == 0 ||
(lv->selected == (lv->req_elements - 1) && !lv->cycle)) {
return;
}
lv->selected = lv->selected < lv->req_elements - 1
? MIN(lv->req_elements - 1, lv->selected + 1)
: 0;
}
lv->selected = lv->selected < lv->req_elements - 1
? MIN(lv->req_elements - 1, lv->selected + 1)
: 0;
lv->barview.direction = LEFT_TO_RIGHT;
if (lv->sc_callback) {
lv->sc_callback(lv, lv->selected, lv->sc_udata);

View File

@ -333,6 +333,12 @@ static XrmOption xrmOptions[] = {
NULL,
"Threads to use for string matching",
CONFIG_DEFAULT},
{xrm_Number,
"scroll-multiplier",
{.num = &config.scroll_multiplier},
NULL,
"Scrolling multiplier (how many times as many lines to scroll)",
CONFIG_DEFAULT},
{xrm_Number,
"scroll-method",
{.num = &config.scroll_method},