3 #include "menuengine.h"
5 struct menu_item
*active_menu
;
6 unsigned int next_active_item
;
8 void reset_active_menu()
12 struct menu_item item
;
15 item
= active_menu
[next_active_item
];
16 if (MENU_ITEM_CLEANUP
== item
.selection
) {
23 } while (next_active_item
);
32 void append_active_menu(const struct menu_item
*item
)
34 active_menu
= realloc(active_menu
,
35 (next_active_item
+ 1) * sizeof(struct menu_item
));
36 active_menu
[next_active_item
] = *item
;
40 void build_menu_items(struct git_data
*data
,
41 selection_to_mask
*mask_builder
,
42 const struct menu_item menu_def
[],
43 const unsigned int menu_def_count
,
47 const unsigned int selection
= mask_builder(data
);
51 if (MENU_ITEM_LAST
== selection
)
55 i
< menu_def_count
&& MENU_ITEM_LAST
!= menu_def
[i
].selection
;
57 if ((menu_def
[i
].selection
& selection
) ==
58 menu_def
[i
].selection
) {
59 if (menu_def
[i
].builder(data
, &menu_def
[i
], platform
))
60 append_active_menu(&menu_def
[i
]);
64 char *get_menu_item_text(unsigned int id
)
69 if (id
> next_active_item
)
72 return active_menu
[id
].helptext
;
75 int handle_menu_item(void *data
, unsigned int id
)
77 if (id
> next_active_item
)
80 return (active_menu
[id
].handler
)(data
, id
);