{
char temp[MAX_CONTENTS_LENGTH+1]; // remember null
char* new_contents;
+ int insert_pos;
curs_on();
+ // account for multiline items
+ insert_pos = menu->scroll_offset;
+ for (int i = 0; i < insert_index; i++) {
+ insert_pos += item_height(menu->menu_items[i]);
+ }
+
/* move cursor to right spot */
ungetstr(menu->menu_items[insert_index]->title);
mvwgetnstr(menu->sub_win,
- insert_index, // account for wrap later too
+ insert_pos,
0,
temp,
MAX_CONTENTS_LENGTH
case MENU_APPEND:
insert_item(menu, create_blank_menuitem(), menu->menu_length);
+ render_menu(menu); // refresh after inserting
menu_insert_mode(menu, menu->selected_item);
break;
case MENU_INSERT_ABOVE:
insert_item(menu, create_blank_menuitem(), menu->selected_item);
+ render_menu(menu);
menu_insert_mode(menu, menu->selected_item);
break;
case MENU_INSERT_BELOW:
insert_item(menu, create_blank_menuitem(), menu->selected_item+1);
+ render_menu(menu);
menu_insert_mode(menu, menu->selected_item); // inserted item is cur now
break;
// may be dangerous, assumes render after every action
menu->scroll_offset += 1;
} else if (menu->selected_item < menu->scroll_offset) {
- menu->scroll_offset -= 1;
+ menu->scroll_offset = menu->scroll_offset-1;
+ if (menu->scroll_offset < 0) menu->scroll_offset = 0;
}
/* draw inner menu */
/* also try to jump to a similar position if possible */
/* rn theres a bug if old menu is empty */
new_pos = min(get_selected_item(old_menu), get_menu_length(new_menu)-1);
+ if (new_pos < 0) new_pos = 0;
set_selected_item(new_menu, new_pos);
boardmenu->selected = index;
break;
case BINDING_MOVE_ITEM_LEFT:
if (boardmenu->selected-1 < 0) break;
+ if (get_menu_length(boardmenu->menu_list[boardmenu->selected]) == 0) break;
{
Menu* from_menu;
Menu* to_menu;
break;
case BINDING_MOVE_ITEM_RIGHT:
if (boardmenu->selected >= boardmenu->menu_count-1) break;
+ if (get_menu_length(boardmenu->menu_list[boardmenu->selected]) == 0) break;
// this is legit cpy paste please fix this
{
Menu* from_menu;