extern int set_menu_win(Menu* menu, WINDOW* win);
extern MenuItem* get_menu_items(Menu* menu);
extern int set_menu_focus(Menu* menu, bool focus);
+extern int get_selected_item(Menu* menu);
+extern int set_selected_item(Menu* menu, int selected_item);
+extern int get_menu_length(Menu* menu);
extern int menu_driver(Menu* menu, MenuAction action);
return 0;
}
+int
+get_selected_item(Menu* menu)
+{
+ return menu->selected_item;
+}
+
+int
+set_selected_item(Menu* menu, int selected_item)
+{
+ menu->selected_item = selected_item;
+
+ return 0;
+}
+
+int
+get_menu_length(Menu* menu)
+{
+ return menu->menu_length;
+}
+
int
swap_item(Menu* menu, int src_index, int dest_index)
{
MenuItem** todolist_to_menuitem(TodoItem** item_list, int list_length);
Menu** make_menus(Board* board, int todolist_length);
-
int
main(int argc, char** argv)
{
case BINDING_DELETE_ITEM:
menu_driver(active_menu, MENU_DELETE);
break;
-
}
for (int i = 0; i < boardmenu->menu_count; i++) {
{
Menu* old_menu;
Menu* new_menu;
+ int new_pos;
old_menu = boardmenu->menu_list[boardmenu->selected];
new_menu = boardmenu->menu_list[index];
set_menu_focus(old_menu, false);
set_menu_focus(new_menu, true);
+ /* also try to jump to a similar position if possible */
+ /* rn theres a bug if old menu is empty */
+ new_pos = (get_selected_item(old_menu) > get_menu_length(new_menu)-1) ?
+ get_menu_length(new_menu)-1 : get_selected_item(old_menu);
+ set_selected_item(new_menu, new_pos);
+
boardmenu->selected = index;
return 0;