mirror of
https://codeberg.org/adnano/wmenu.git
synced 2025-10-31 22:25:28 -04:00
add min width option
This commit is contained in:
parent
c726a7307c
commit
6452c98c15
2 changed files with 11 additions and 2 deletions
11
menu.c
11
menu.c
|
|
@ -86,10 +86,10 @@ static bool parse_color(const char *color, uint32_t *result) {
|
||||||
void menu_getopts(struct menu *menu, int argc, char *argv[]) {
|
void menu_getopts(struct menu *menu, int argc, char *argv[]) {
|
||||||
const char *usage =
|
const char *usage =
|
||||||
"Usage: wmenu [-bciPv] [-f font] [-l lines] [-o output] [-p prompt]\n"
|
"Usage: wmenu [-bciPv] [-f font] [-l lines] [-o output] [-p prompt]\n"
|
||||||
"\t[-N color] [-n color] [-M color] [-m color] [-S color] [-s color]\n";
|
"\t[-N color] [-n color] [-M color] [-m color] [-S color] [-s color] [-w minwidth]\n";
|
||||||
|
|
||||||
int opt;
|
int opt;
|
||||||
while ((opt = getopt(argc, argv, "bchiPvf:l:o:p:N:n:M:m:S:s:")) != -1) {
|
while ((opt = getopt(argc, argv, "bchiPvf:l:o:p:N:n:M:m:S:s:w:")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'b':
|
case 'b':
|
||||||
menu->position = POSITION_BOTTOM;
|
menu->position = POSITION_BOTTOM;
|
||||||
|
|
@ -148,6 +148,13 @@ void menu_getopts(struct menu *menu, int argc, char *argv[]) {
|
||||||
fprintf(stderr, "Invalid selection foreground color: %s", optarg);
|
fprintf(stderr, "Invalid selection foreground color: %s", optarg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'w':
|
||||||
|
menu->minwidth = atoi(optarg);
|
||||||
|
if (menu->minwidth < 0) {
|
||||||
|
fprintf(stderr, "Invalid minimum width: %s", optarg);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "%s", usage);
|
fprintf(stderr, "%s", usage);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
||||||
2
menu.h
2
menu.h
|
|
@ -39,6 +39,8 @@ typedef enum e_position POSITION;
|
||||||
struct menu {
|
struct menu {
|
||||||
// Whether the menu appears at the bottom of the screen
|
// Whether the menu appears at the bottom of the screen
|
||||||
POSITION position;
|
POSITION position;
|
||||||
|
// The minimum width of the menu (relevant for center position)
|
||||||
|
int minwidth;
|
||||||
// The function used to match menu items
|
// The function used to match menu items
|
||||||
int (*strncmp)(const char *, const char *, size_t);
|
int (*strncmp)(const char *, const char *, size_t);
|
||||||
// Whether the input is a password
|
// Whether the input is a password
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue