#define MENU_PAD_LEFT 2
#define MENU_PAD_RIGHT 1
+#define MAX_CONTENTS_LENGTH 256
+
typedef struct MenuItem {
char* contents;
} MenuItem;
int swap_item(Menu* menu, int src_index, int dest_index);
int delete_item(Menu* menu, int index);
+int insert_item(Menu* menu, int index);
MenuItem*
create_menuitem(char* contents)
return 0;
}
+int
+insert_item(Menu* menu, int index)
+{ // note, this func does not validate index
+
+ char* new_content;
+ MenuItem* new_menuitem;
+
+ // remember null char
+ /* new_content = malloc((MAX_CONTENTS_LENGTH+1)*sizeof(char)); */
+ new_content = malloc(10);
+ new_content = "abcdefghi";
+
+ new_menuitem = create_menuitem(new_content);
+
+ /* resize array and insert */
+ /* char out[100]; */
+ /* sprintf(out, "%d\n", menu->menu_length); */
+ /* mvprintw(0, 0, out); */
+ /* menu->menu_items = realloc(menu->menu_items, (menu->menu_length+1)*sizeof(MenuItem*)); */
+
+ /* int temp_size = (menu->menu_length-index)*sizeof(MenuItem*); */
+ /* MenuItem* temp[temp_size]; */
+
+ /* memcpy(temp, menu->menu_items[index], temp_size); */
+ /* menu->menu_items[index] = new_menuitem; */
+ /* memcpy(menu->menu_items[index+1], temp, temp_size); */
+
+ /* menu->menu_items[menu->menu_length] = 0; // remember null at end */
+ /* menu->menu_length += 1; */
+
+
+ /* move cursor pos */
+ /* menu->selected_item = index; */
+
+ return 0;
+}
+
int
menu_driver(Menu* menu, MenuAction action)
{
wclear(menu->sub_win);
break;
+ case MENU_APPEND:
+ /* curs_on(); */
+ /* curs_off(); */
+ /* insert_item(menu, menu->selected_item); */
+ insert_item(menu, 0);
+ wclear(menu->sub_win);
+ break;
+
default: // This is here for debug, disable later
fprintf(stderr, "Invalid menu action");
}
case BINDING_DELETE_ITEM:
menu_driver(active_menu, MENU_DELETE);
break;
+ case BINDING_APPEND_ITEM:
+ menu_driver(active_menu, MENU_APPEND);
+ break;
}
for (int i = 0; i < boardmenu->menu_count; i++) {
render_menu(boardmenu->menu_list[i]);
}
+
}
exit_tscurses();