X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=src%2Fclient%2Fmain.c;h=bb159059d1011df5ecffe8ff64552ee08762c36f;hb=4343d1b16536d868dce734fdf3a8debf6f7bf890;hp=315dbd12829e500b79b6cb7f934c45c6c515d0da;hpb=c306be019770cdbe94fbeee0de627d43b1b50248;p=tpg%2Fopendispense2.git diff --git a/src/client/main.c b/src/client/main.c index 315dbd1..bb15905 100644 --- a/src/client/main.c +++ b/src/client/main.c @@ -179,6 +179,7 @@ int ShowNCursesUI(void) int itemCount = displayMinItems; int itemBase = 0; int currentItem = 0; + int ret = -2; // -2: Used for marking "no return yet" int height, width; @@ -186,6 +187,8 @@ int ShowNCursesUI(void) initscr(); raw(); noecho(); + // Get item count + // - 6: randomly chosen (Need at least 3) itemCount = LINES - 6; if( itemCount > giNumItems ) itemCount = giNumItems; @@ -292,7 +295,18 @@ int ShowNCursesUI(void) } } else { - break; + switch(ch) + { + case '\n': + ret = currentItem; + break; + case 'q': + ret = -1; // -1: Return with no dispense + break; + } + + // Check if the return value was changed + if( ret != -2 ) break; } } @@ -300,7 +314,7 @@ int ShowNCursesUI(void) // Leave endwin(); - return -1; + return ret; } /**