+
+
+
+/*
+ * Present a key-menu line choice type of thing
+ */
+char keymenu(char *menuprompt, char *menustring) {
+ int i, c, a;
+ int choices;
+ int do_prompt = 0;
+ char buf[256];
+ int ch;
+ int display_prompt = 1;
+
+ choices = num_tokens(menustring, '|');
+
+ if (menuprompt != NULL) do_prompt = 1;
+ if (menuprompt != NULL) if (strlen(menuprompt)==0) do_prompt = 0;
+
+ while (1) {
+ if (display_prompt) {
+ if (do_prompt) {
+ printf("%s ", menuprompt);
+ }
+ else {
+ for (i=0; i<choices; ++i) {
+ extract(buf, menustring, i);
+ keyopt(buf);
+ printf(" ");
+ }
+ }
+ printf(" -> ");
+ display_prompt = 0;
+ }
+ ch = lkey();
+
+ if ( (do_prompt) && (ch=='?') ) {
+ printf("\rOne of... ");
+ printf(" \n");
+ for (i=0; i<choices; ++i) {
+ extract(buf, menustring, i);
+ printf(" ");
+ keyopt(buf);
+ printf("\n");
+ }
+ printf("\n");
+ display_prompt = 1;
+ }
+
+ for (i=0; i<choices; ++i) {
+ extract(buf, menustring, i);
+ for (c=1; c<strlen(buf); ++c) {
+ if ( (ch == tolower(buf[c]))
+ && (buf[c-1]=='<')
+ && (buf[c+1]=='>') ) {
+ for (a=0; a<strlen(buf); ++a) {
+ if ( (a!=(c-1)) && (a!=(c+1))) {
+ putc(buf[a], stdout);
+ }
+ }
+ printf("\n\n");
+ return ch;
+ }
+ }
+ }
+ }
+}