mirror of
https://codeberg.org/adnano/wmenu.git
synced 2025-10-29 05:40:20 -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[]) {
|
||||
const char *usage =
|
||||
"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;
|
||||
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) {
|
||||
case 'b':
|
||||
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);
|
||||
}
|
||||
break;
|
||||
case 'w':
|
||||
menu->minwidth = atoi(optarg);
|
||||
if (menu->minwidth < 0) {
|
||||
fprintf(stderr, "Invalid minimum width: %s", optarg);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "%s", usage);
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
|
|||
2
menu.h
2
menu.h
|
|
@ -39,6 +39,8 @@ typedef enum e_position POSITION;
|
|||
struct menu {
|
||||
// Whether the menu appears at the bottom of the screen
|
||||
POSITION position;
|
||||
// The minimum width of the menu (relevant for center position)
|
||||
int minwidth;
|
||||
// The function used to match menu items
|
||||
int (*strncmp)(const char *, const char *, size_t);
|
||||
// Whether the input is a password
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue