add option to enable/disable setting lines/columns using keybinds

This commit is contained in:
speedie 2023-06-19 01:46:05 +02:00
parent 6083df6736
commit c1058dfb00
9 changed files with 54 additions and 2 deletions

View file

@ -130,6 +130,18 @@ You may use long, descriptive arguments or the shorter arguments.
`-nt, --no-allow-typing` `-nt, --no-allow-typing`
: Don't allow typing, the user must select an option : 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` `-x, --x-position x offset`
: Offset spmenu x position by x offset (X11 only) : Offset spmenu x position by x offset (X11 only)

View file

@ -119,6 +119,8 @@ spmenu.alpha: 1
spmenu.lineheight: 1 spmenu.lineheight: 1
spmenu.lines: 0 spmenu.lines: 0
spmenu.columns: 10 spmenu.columns: 10
spmenu.overridelines: 1
spmenu.overridecolumns: 1
spmenu.preselected: 0 spmenu.preselected: 0
spmenu.indentitems: 0 spmenu.indentitems: 0

View file

@ -181,6 +181,8 @@ spmenu = {
line = ( { height = 1; // Height of each line (px) line = ( { height = 1; // Height of each line (px)
lines = 0; // Number of lines (number) lines = 0; // Number of lines (number)
columns = 10; // Number of columns (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) indentitems = 0; // Indent items to prompt width (0/1)
} ); } );

View file

@ -461,7 +461,7 @@ void defaultimg(Arg *arg) {
} }
void setlines(Arg *arg) { void setlines(Arg *arg) {
if (fullscreen) return; if (fullscreen || !overridelines) return;
lines += arg->i; lines += arg->i;
@ -479,7 +479,7 @@ void setlines(Arg *arg) {
} }
void setcolumns(Arg *arg) { void setcolumns(Arg *arg) {
if (fullscreen) return; if (fullscreen || !overridecolumns) return;
columns += arg->i; columns += arg->i;

View file

@ -4,6 +4,12 @@ void readargs(int argc, char *argv[]) {
int j = 0; int j = 0;
int k = 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 // check if we should load the xrdb/config, because it needs to be loaded before arguments are checked
// priority: internal -> config -> xresources -> arguments // priority: internal -> config -> xresources -> arguments
for (j = 1; j < argc; j++) { for (j = 1; j < argc; j++) {
@ -161,6 +167,14 @@ void readargs(int argc, char *argv[]) {
type = 1; type = 1;
} else if (!strcmp(argv[i], "-nt") || (!strcmp(argv[i], "--no-allow-typing"))) { // don't allow the user to type } else if (!strcmp(argv[i], "-nt") || (!strcmp(argv[i], "--no-allow-typing"))) { // don't allow the user to type
type = 0; 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 } else if (!strcmp(argv[i], "-P") || (!strcmp(argv[i], "--password"))) { // is the input a password
passwd = 1; passwd = 1;
} else if (!strcmp(argv[i], "-nP") || (!strcmp(argv[i], "--no-password"))) { // is the input a password } 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 -na, --no-alpha Disable alpha\n"
"spmenu -tp, --allow-typing Allow the user to type\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 -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); , status ? stderr : stdout);
fputs( fputs(

View file

@ -523,6 +523,8 @@ void conf_init(void) {
config_setting_lookup_int(conf, "height", &lineheight); // spmenu.line.height 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, "lines", &lines); // spmenu.line.lines
config_setting_lookup_int(conf, "columns", &columns); // spmenu.line.columns 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 config_setting_lookup_int(conf, "indentitems", &indentitems); // spmenu.line.indentitems
} }
} }

View file

@ -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 lineheight = 1; /* Line height (0: Calculate automatically) */
static int lines = 0; /* Default number of lines */ static int lines = 0; /* Default number of lines */
static int columns = 10; /* Default number of columns */ 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 */ /* History options */
static int maxhist = 64; /* Max number of history entries */ static int maxhist = 64; /* Max number of history entries */

View file

@ -134,6 +134,8 @@ ResourcePref resources[] = {
{ "lines", INTEGER, &lines }, { "lines", INTEGER, &lines },
{ "lineheight", INTEGER, &lineheight }, { "lineheight", INTEGER, &lineheight },
{ "columns", INTEGER, &columns }, { "columns", INTEGER, &columns },
{ "overridelines", INTEGER, &overridelines },
{ "overridecolumns", INTEGER, &overridecolumns },
{ "maxhist", INTEGER, &maxhist }, { "maxhist", INTEGER, &maxhist },
{ "hideitem", INTEGER, &hideitem }, { "hideitem", INTEGER, &hideitem },
{ "hidematchcount", INTEGER, &hidematchcount }, { "hidematchcount", INTEGER, &hidematchcount },

View file

@ -154,6 +154,18 @@ Allow the user to type
\f[V]-nt, --no-allow-typing\f[R] \f[V]-nt, --no-allow-typing\f[R]
Don\[cq]t allow typing, the user must select an option Don\[cq]t allow typing, the user must select an option
.TP .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] \f[V]-x, --x-position x offset\f[R]
Offset spmenu x position by x offset (X11 only) Offset spmenu x position by x offset (X11 only)
.TP .TP