mirror of
https://codeberg.org/adnano/wmenu.git
synced 2025-10-29 05:40:20 -04:00
Streamline menu callbacks
This commit is contained in:
parent
a0df7959f9
commit
7d717b3696
5 changed files with 42 additions and 36 deletions
11
wmenu.c
11
wmenu.c
|
|
@ -1,5 +1,6 @@
|
|||
#define _POSIX_C_SOURCE 200809L
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "menu.h"
|
||||
|
|
@ -16,8 +17,16 @@ static void read_items(struct menu *menu) {
|
|||
}
|
||||
}
|
||||
|
||||
static void print_item(struct menu *menu, char *text, bool exit) {
|
||||
puts(text);
|
||||
fflush(stdout);
|
||||
if (exit) {
|
||||
menu->exit = true;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
struct menu *menu = menu_create();
|
||||
struct menu *menu = menu_create(print_item);
|
||||
menu_getopts(menu, argc, argv);
|
||||
read_items(menu);
|
||||
int status = menu_run(menu);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue