Returning the character that the user pressed after the reveal.

modified:   src/nms.c
	modified:   src/nms.h
	modified:   src/sneakers.c
This commit is contained in:
Brian Barto 2016-04-20 12:23:37 -04:00
parent 17348f7c85
commit dd50839dae
3 changed files with 29 additions and 4 deletions

View File

@ -47,7 +47,7 @@ char getMaskChar(void);
* Displays the characters stored in the / char * / parameter * Displays the characters stored in the / char * / parameter
* *
*/ */
void nmsexec(char *src) { char nmsexec(char *src) {
struct winpos *list_pointer = NULL; struct winpos *list_pointer = NULL;
struct winpos *start; // Always points to start of list struct winpos *start; // Always points to start of list
struct winpos *temp; // Used for free()ing the list struct winpos *temp; // Used for free()ing the list
@ -56,6 +56,7 @@ void nmsexec(char *src) {
int r_time, r_time_l, r_time_s; int r_time, r_time_l, r_time_s;
int ms, ls; int ms, ls;
bool first = true; bool first = true;
char ret = 0;
// Start and initialize curses mode // Start and initialize curses mode
initscr(); initscr();
@ -216,7 +217,7 @@ void nmsexec(char *src) {
// If stdin is set to the keyboard, user must press a key to continue // If stdin is set to the keyboard, user must press a key to continue
if (isatty(STDIN_FILENO)) if (isatty(STDIN_FILENO))
getch(); ret = getch();
else else
sleep(2); sleep(2);
@ -230,6 +231,8 @@ void nmsexec(char *src) {
list_pointer = list_pointer->next; list_pointer = list_pointer->next;
free(temp); free(temp);
} }
return ret;
} }
/* /*

View File

@ -4,6 +4,6 @@
// Function prototypes // Function prototypes
// Display the characters stored in the display queue // Display the characters stored in the display queue
void nmsexec(char *); char nmsexec(char *);
#endif #endif

View File

@ -6,6 +6,7 @@
int main(void) { int main(void) {
int l, termLines, termCols, spaces = 0; int l, termLines, termCols, spaces = 0;
char input;
char display[2000]; char display[2000];
char *head1Left = "DATANET PROC RECORD: 45-3456-W-3452"; char *head1Left = "DATANET PROC RECORD: 45-3456-W-3452";
char *head1Right = "Transnet on/xc-3"; char *head1Right = "Transnet on/xc-3";
@ -153,7 +154,28 @@ int main(void) {
strcat(display, foot2Center); strcat(display, foot2Center);
// Display characters // Display characters
nmsexec(display); input = nmsexec(display);
switch (input) {
case '1':
printf("User chose 1\n");
break;
case '2':
printf("User chose 2\n");
break;
case '3':
printf("User chose 3\n");
break;
case '4':
printf("User chose 4\n");
break;
case '5':
printf("User chose 5\n");
break;
case '6':
printf("User chose 6\n");
break;
}
return 0; return 0;
} }