Loading menu.c +3 −3 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ #include <string.h> #include "menu.h" enum MENU_DIRECTION get_direction(); MENU_DIRECTION get_direction(void); char *menu_prompt(const menu_item *items, const unsigned int num_menu_items) { for (int i = 0; i < num_menu_items; i++) { Loading @@ -31,7 +31,7 @@ char *menu_prompt(const menu_item *items, const unsigned int num_menu_items) { } } enum MENU_DIRECTION direction = get_direction(); MENU_DIRECTION direction = get_direction(); switch (direction) { case DOWN: Loading Loading @@ -62,7 +62,7 @@ char *menu_prompt(const menu_item *items, const unsigned int num_menu_items) { return selected_action; } enum MENU_DIRECTION get_direction() { MENU_DIRECTION get_direction(void) { // todo test (+ fix) all of this character grabbing stuff in windows - use conio.h as included above char key_pressed = (char) getchar(); // with terminal set to raw mode, this will no longer wait for Enter key; note that Enter key is handled with \n case Loading menu.h +3 −3 Original line number Diff line number Diff line Loading @@ -5,12 +5,12 @@ #ifndef MENU_H #define MENU_H enum MENU_DIRECTION { typedef enum { DOWN, UP, SELECT, NONE, }; } MENU_DIRECTION; typedef struct { char *title; Loading @@ -18,6 +18,6 @@ typedef struct { } menu_item; char *menu_prompt(const menu_item *items, unsigned int num_menu_items); enum MENU_DIRECTION get_menu_direction(int selection); MENU_DIRECTION get_menu_direction(int selection); #endif //MENU_H Loading
menu.c +3 −3 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ #include <string.h> #include "menu.h" enum MENU_DIRECTION get_direction(); MENU_DIRECTION get_direction(void); char *menu_prompt(const menu_item *items, const unsigned int num_menu_items) { for (int i = 0; i < num_menu_items; i++) { Loading @@ -31,7 +31,7 @@ char *menu_prompt(const menu_item *items, const unsigned int num_menu_items) { } } enum MENU_DIRECTION direction = get_direction(); MENU_DIRECTION direction = get_direction(); switch (direction) { case DOWN: Loading Loading @@ -62,7 +62,7 @@ char *menu_prompt(const menu_item *items, const unsigned int num_menu_items) { return selected_action; } enum MENU_DIRECTION get_direction() { MENU_DIRECTION get_direction(void) { // todo test (+ fix) all of this character grabbing stuff in windows - use conio.h as included above char key_pressed = (char) getchar(); // with terminal set to raw mode, this will no longer wait for Enter key; note that Enter key is handled with \n case Loading
menu.h +3 −3 Original line number Diff line number Diff line Loading @@ -5,12 +5,12 @@ #ifndef MENU_H #define MENU_H enum MENU_DIRECTION { typedef enum { DOWN, UP, SELECT, NONE, }; } MENU_DIRECTION; typedef struct { char *title; Loading @@ -18,6 +18,6 @@ typedef struct { } menu_item; char *menu_prompt(const menu_item *items, unsigned int num_menu_items); enum MENU_DIRECTION get_menu_direction(int selection); MENU_DIRECTION get_menu_direction(int selection); #endif //MENU_H