From 40f7d1a080f6ad2bdda04748046f422b1f8bcf5c Mon Sep 17 00:00:00 2001 From: Brian Barto Date: Wed, 13 Jun 2018 14:06:24 -0400 Subject: [PATCH] Support the esc key for aborting the sneakers menu. modified: src/sneakers.c --- src/sneakers.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/sneakers.c b/src/sneakers.c index 200cde1..aaaa4fa 100644 --- a/src/sneakers.c +++ b/src/sneakers.c @@ -14,7 +14,8 @@ int main(void) { int termCols, spaces = 0; char input; - char display[2000]; + char r_opts[8]; + char display[4000]; char *head1Left = "DATANET PROC RECORD: 45-3456-W-3452"; char *head1Right = "Transnet on/xc-3"; char *head2Center = "FEDERAL RESERVE TRANSFER NODE"; @@ -160,14 +161,25 @@ int main(void) { // Settings nmseffect_set_input_position(((termCols - strlen(foot2Center)) / 2) + 2, 18); - nmseffect_set_returnopts("123456"); + r_opts[0] = 49; + r_opts[1] = 50; + r_opts[2] = 51; + r_opts[3] = 52; + r_opts[4] = 53; + r_opts[5] = 54; + r_opts[6] = 27; + r_opts[7] = 0; + nmseffect_set_returnopts(r_opts); nmseffect_set_clearscr(1); // Execut effect input = nmseffect_exec(display); // Print user choice - printf("You chose %c\n", input); + if (input == 27) + printf("Aborted!\n"); + else + printf("You chose %c\n", input); return 0; }