Reset inheritable flag of debug log file git_shell_ext_debug.txt
[git-cheetah/kirill.git] / common / menuengine.h
blob098856344b777233ba98aa59b95ac2f01f9558d4
1 #ifndef MENUENGINE_H
2 #define MENUENGINE_H
4 struct git_data {
5 struct git_shell_ext {
6 void *virtual_table;
7 struct git_data *git_data;
8 } shell_ext;
9 struct git_menu {
10 void *virtual_table;
11 struct git_data *git_data;
12 } menu;
13 struct git_columns {
14 void *virtual_table;
15 struct git_data *git_data;
16 } columns;
17 unsigned int count;
18 char name[MAX_PATH];
19 struct strbuf other_files;
23 * flags to match the selection
25 #define MENU_ITEM_ALWAYS 0 /* always insert the menu item */
26 #define MENU_ITEM_CLEANUP (1 << 31) /* menu item requires free() of
27 string and helptext */
28 #define MENU_ITEM_LAST -1 /* the last menu item */
30 struct menu_item;
32 typedef unsigned int selection_to_mask(struct git_data *);
33 typedef int menu_item_handler(struct git_data *, unsigned int);
35 * if platform-specific builder returns TRUE, the menu item
36 * is added to the active menu and can be passed to menu_item_handler
37 * later, e.g. when a user selects the item
39 typedef BOOL menu_item_builder(struct git_data *, const struct menu_item *, void *);
41 #define MI_CHECKED 1
42 #define MI_DISABLED 2
44 struct menu_item {
45 unsigned int selection;
46 unsigned int flags;
47 char *string;
48 char *helptext;
49 menu_item_builder *builder;
50 menu_item_handler *handler;
53 extern struct menu_item *active_menu;
54 extern unsigned int next_active_item;
57 * The main entry point of the menu engine.
59 * Important things to note:
60 * - it resets the active menu;
61 * - it walks menu_def until MENU_ITEM_LAST is found or
62 * menu_def_count times, whatever is earlier.
64 void build_menu_items(struct git_data *data,
65 selection_to_mask *mask_builder,
66 const struct menu_item menu_def[],
67 const unsigned int menu_def_count,
68 void *platform);
70 void reset_active_menu();
72 char *get_menu_item_text(unsigned int id);
75 * Parses a menu entries text and removes the '&' character
76 * which is used to specify the shortcut key. It returns
77 * the first found key or zero if nothing is found
79 static inline int parse_and_remove_shortcuts(char *name)
81 int i,j;
82 char key = 0;
83 for (i=0,j=0; name[i] && name[j]; i++,j++) {
84 if (!key && name[j] == '&') {
85 key = name[j+1];
86 j++;
88 name[i] = name[j];
90 name[i] = '\0';
91 return key;
94 int handle_menu_item(void *data, unsigned int id);
97 * usually, menu engine will append items, based on the return
98 * from menu_item_builder, but a custom builder might need to
99 * instruct the engine to track a particular item
101 void append_active_menu(const struct menu_item *item);
103 #endif /* MENUENGINE_H */