diff --git a/docs/docs.md b/docs/docs.md index 0ebea2d..5328b21 100644 --- a/docs/docs.md +++ b/docs/docs.md @@ -130,6 +130,18 @@ You may use long, descriptive arguments or the shorter arguments. `-nt, --no-allow-typing` : Don't allow typing, the user must select an option +`-ol, --override-lines` +: Allow keybinds to override lines + +`-oc, --override-columns` +: Allow keybinds to override columns + +`-nol, --no-override-lines` +: Don't allow keybinds to override lines + +`-noc, --no-override-columns` +: Don't allow keybinds to override columns + `-x, --x-position x offset` : Offset spmenu x position by x offset (X11 only) diff --git a/docs/example.Xresources b/docs/example.Xresources index 6b58188..daca8ba 100644 --- a/docs/example.Xresources +++ b/docs/example.Xresources @@ -119,6 +119,8 @@ spmenu.alpha: 1 spmenu.lineheight: 1 spmenu.lines: 0 spmenu.columns: 10 +spmenu.overridelines: 1 +spmenu.overridecolumns: 1 spmenu.preselected: 0 spmenu.indentitems: 0 diff --git a/docs/spmenu.conf b/docs/spmenu.conf index ae8afbf..0f93337 100644 --- a/docs/spmenu.conf +++ b/docs/spmenu.conf @@ -181,6 +181,8 @@ spmenu = { line = ( { height = 1; // Height of each line (px) lines = 0; // Number of lines (number) columns = 10; // Number of columns (number) + overridelines = 1; // Allow overriding lines using keybinds (0/1) + overridecolumns = 1; // Allow overriding columns using keybinds (0/1) indentitems = 0; // Indent items to prompt width (0/1) } ); diff --git a/libs/arg.c b/libs/arg.c index 353d5ab..5800247 100644 --- a/libs/arg.c +++ b/libs/arg.c @@ -461,7 +461,7 @@ void defaultimg(Arg *arg) { } void setlines(Arg *arg) { - if (fullscreen) return; + if (fullscreen || !overridelines) return; lines += arg->i; @@ -479,7 +479,7 @@ void setlines(Arg *arg) { } void setcolumns(Arg *arg) { - if (fullscreen) return; + if (fullscreen || !overridecolumns) return; columns += arg->i; diff --git a/libs/argv.c b/libs/argv.c index 70722af..501799c 100644 --- a/libs/argv.c +++ b/libs/argv.c @@ -4,6 +4,12 @@ void readargs(int argc, char *argv[]) { int j = 0; int k = 0; +#if !USEX +#if !USEWAYLAND + die("Why did you think it was a good idea to compile me without support for any display server? You're an idiot. :)"); +#endif +#endif + // check if we should load the xrdb/config, because it needs to be loaded before arguments are checked // priority: internal -> config -> xresources -> arguments for (j = 1; j < argc; j++) { @@ -161,6 +167,14 @@ void readargs(int argc, char *argv[]) { type = 1; } else if (!strcmp(argv[i], "-nt") || (!strcmp(argv[i], "--no-allow-typing"))) { // don't allow the user to type type = 0; + } else if (!strcmp(argv[i], "-ol") || (!strcmp(argv[i], "--override-lines"))) { // allow overriding lines + overridelines = 1; + } else if (!strcmp(argv[i], "-nol") || (!strcmp(argv[i], "--no-override-lines"))) { // don't allow overriding lines + overridelines = 0; + } else if (!strcmp(argv[i], "-oc") || (!strcmp(argv[i], "--override-columns"))) { // allow overriding columns + overridecolumns = 1; + } else if (!strcmp(argv[i], "-noc") || (!strcmp(argv[i], "--no-override-columns"))) { // don't allow overriding columns + overridecolumns = 0; } else if (!strcmp(argv[i], "-P") || (!strcmp(argv[i], "--password"))) { // is the input a password passwd = 1; } else if (!strcmp(argv[i], "-nP") || (!strcmp(argv[i], "--no-password"))) { // is the input a password @@ -604,6 +618,10 @@ void usage(int status) { "spmenu -na, --no-alpha Disable alpha\n" "spmenu -tp, --allow-typing Allow the user to type\n" "spmenu -nt, --no-allow-typing Don't allow typing, the user must select an option\n" + "spmenu -ol, --override-lines Allow keybinds to override lines\n" + "spmenu -oc, --override-columns Allow keybinds to override columns\n" + "spmenu -nol, --no-override-lines Don't allow keybinds to override lines\n" + "spmenu -noc, --no-override-columns Don't allow keybinds to override columns\n" , status ? stderr : stdout); fputs( diff --git a/libs/conf/config.c b/libs/conf/config.c index 4f83e96..e16ce7d 100644 --- a/libs/conf/config.c +++ b/libs/conf/config.c @@ -523,6 +523,8 @@ void conf_init(void) { config_setting_lookup_int(conf, "height", &lineheight); // spmenu.line.height config_setting_lookup_int(conf, "lines", &lines); // spmenu.line.lines config_setting_lookup_int(conf, "columns", &columns); // spmenu.line.columns + config_setting_lookup_int(conf, "overridelines", &overridelines); // spmenu.line.overridelines + config_setting_lookup_int(conf, "overridecolumns", &overridecolumns); // spmenu.line.overridecolumns config_setting_lookup_int(conf, "indentitems", &indentitems); // spmenu.line.indentitems } } diff --git a/libs/options.h b/libs/options.h index f1ab8f9..57b77bd 100644 --- a/libs/options.h +++ b/libs/options.h @@ -98,6 +98,8 @@ static char *listfile = NULL; /* File to read entries from inst static int lineheight = 1; /* Line height (0: Calculate automatically) */ static int lines = 0; /* Default number of lines */ static int columns = 10; /* Default number of columns */ +static int overridelines = 1; /* Allow overriding lines using keybinds */ +static int overridecolumns = 1; /* Allow overriding columns using keybinds */ /* History options */ static int maxhist = 64; /* Max number of history entries */ diff --git a/libs/x11/xresources.h b/libs/x11/xresources.h index 24015a4..3cd2b1a 100644 --- a/libs/x11/xresources.h +++ b/libs/x11/xresources.h @@ -134,6 +134,8 @@ ResourcePref resources[] = { { "lines", INTEGER, &lines }, { "lineheight", INTEGER, &lineheight }, { "columns", INTEGER, &columns }, + { "overridelines", INTEGER, &overridelines }, + { "overridecolumns", INTEGER, &overridecolumns }, { "maxhist", INTEGER, &maxhist }, { "hideitem", INTEGER, &hideitem }, { "hidematchcount", INTEGER, &hidematchcount }, diff --git a/spmenu.1 b/spmenu.1 index da225df..450b1e3 100644 --- a/spmenu.1 +++ b/spmenu.1 @@ -154,6 +154,18 @@ Allow the user to type \f[V]-nt, --no-allow-typing\f[R] Don\[cq]t allow typing, the user must select an option .TP +\f[V]-ol, --override-lines\f[R] +Allow keybinds to override lines +.TP +\f[V]-oc, --override-columns\f[R] +Allow keybinds to override columns +.TP +\f[V]-nol, --no-override-lines\f[R] +Don\[cq]t allow keybinds to override lines +.TP +\f[V]-noc, --no-override-columns\f[R] +Don\[cq]t allow keybinds to override columns +.TP \f[V]-x, --x-position x offset\f[R] Offset spmenu x position by x offset (X11 only) .TP