From: Daniel Liu Date: Sun, 7 Feb 2021 04:22:39 +0000 (-0500) Subject: rest of insert commands X-Git-Url: https://git.danieliu.xyz/?a=commitdiff_plain;h=500e16bc4c9c43a8ef4ab65e6eb37ff3b0d3093c;p=taskasaur.git rest of insert commands --- diff --git a/config.h b/config.h index 7960e1e..3c94504 100644 --- a/config.h +++ b/config.h @@ -34,10 +34,13 @@ static int menu_non_selected_color = COLOR_GREEN; #define BINDING_JUMP_BOTTOM 'G' #define BINDING_MOVE_ITEM_UP 'K' #define BINDING_MOVE_ITEM_DOWN 'J' +#define BINDING_MOVE_ITEM_LEFT 'H' +#define BINDING_MOVE_ITEM_RIGHT 'L' #define BINDING_DELETE_ITEM 'D' #define BINDING_SELECT '\n' #define BINDING_APPEND_ITEM 'a' #define BINDING_INSERT_ABOVE 'O' #define BINDING_INSERT_BELOW 'o' +#define BINDING_EDIT_ITEM 'i' #endif diff --git a/headers/menu.h b/headers/menu.h index b8ab467..89b46b0 100644 --- a/headers/menu.h +++ b/headers/menu.h @@ -18,7 +18,8 @@ typedef enum { MENU_DELETE, MENU_APPEND, MENU_INSERT_ABOVE, - MENU_INSERT_BELOW + MENU_INSERT_BELOW, + MENU_EDIT } MenuAction; typedef struct Menu Menu; diff --git a/menu.c b/menu.c index eb6d7dc..1013a69 100644 --- a/menu.c +++ b/menu.c @@ -258,23 +258,21 @@ menu_driver(Menu* menu, MenuAction action) case MENU_APPEND: insert_item(menu, menu->menu_length); - wclear(menu->sub_win); + menu_insert_mode(menu, menu->selected_item); break; case MENU_INSERT_ABOVE: - ; - int insert_ind = menu->selected_item; - insert_item(menu, insert_ind); - menu_insert_mode(menu, insert_ind); - + insert_item(menu, menu->selected_item); + menu_insert_mode(menu, menu->selected_item); break; case MENU_INSERT_BELOW: - insert_item(menu, - (menu->selected_item >= menu->menu_length-1) ? menu->menu_length : menu->selected_item+1 - ); - wclear(menu->sub_win); + insert_item(menu, menu->selected_item+1); + menu_insert_mode(menu, menu->selected_item); // inserted item is cur now + break; + case MENU_EDIT: + menu_insert_mode(menu, menu->selected_item); break; default: // This is here for debug, disable later diff --git a/taskasaur.c b/taskasaur.c index b317c9a..8eb2f89 100644 --- a/taskasaur.c +++ b/taskasaur.c @@ -69,6 +69,12 @@ main(int argc, char** argv) break; case BINDING_MOVE_ITEM_DOWN: menu_driver(active_menu, MENU_MOVE_DOWN); + break; + case BINDING_MOVE_ITEM_LEFT: + + break; + case BINDING_MOVE_ITEM_RIGHT: + break; case BINDING_DELETE_ITEM: menu_driver(active_menu, MENU_DELETE); @@ -82,6 +88,9 @@ main(int argc, char** argv) case BINDING_INSERT_BELOW: menu_driver(active_menu, MENU_INSERT_BELOW); break; + case BINDING_EDIT_ITEM: + menu_driver(active_menu, MENU_EDIT); + break; } for (int i = 0; i < boardmenu->menu_count; i++) {