AmendHub

Download:

jcs

/

subtext

/

amendments

/

388

session: Move code around in session_menu, don't print title if none


jcs made amendment 388 about 1 year ago
--- session.c Tue Mar 7 22:51:17 2023 +++ session.c Fri Mar 10 16:48:59 2023 @@ -1553,7 +1553,7 @@ session_menu(struct session *s, char *title, char *pro char cn[2], *num_input = NULL; bool last_invalid = false; - if (show_opts) { + if (show_opts && title != NULL) { session_printf(s, "{{B}}%s{{/B}}\r\n", title); session_flush(s); } @@ -1583,33 +1583,35 @@ get_menu_option: goto get_menu_option; for (n = 0; n < nopts; n++) { + if (opts[n].ret == '#' && c >= '0' && c <= '9') { + session_printf(s, "%s:%s>%s ", + ansi(s, ANSI_BACKSPACE, ANSI_BACKSPACE, + ANSI_BOLD, ANSI_END), number_prompt, + ansi(s, ANSI_RESET, ANSI_END)); + session_flush(s); + + cn[0] = c; + cn[1] = '\0'; + num_input = session_field_input(s, 4, 3, (char *)&cn, + false, 0); + session_printf(s, "\r\n"); + session_flush(s); + if (num_input == NULL) + goto show_prompt; + if (num_input[0] == '\0') { + xfree(&num_input); + goto show_prompt; + } + num = atoi(num_input); + xfree(&num_input); + *ret_number = num; + return opts[n].ret; + } + for (j = 0; ; j++) { if (opts[n].key[j] == '\0') break; - if (opts[n].ret == '#' && c >= '0' && c <= '9') { - session_printf(s, "%s:%s>%s ", - ansi(s, ANSI_BACKSPACE, ANSI_BACKSPACE, - ANSI_BOLD, ANSI_END), number_prompt, - ansi(s, ANSI_RESET, ANSI_END)); - session_flush(s); - - cn[0] = c; - cn[1] = '\0'; - num_input = session_field_input(s, 4, 3, (char *)&cn, - false, 0); - session_printf(s, "\r\n"); - session_flush(s); - if (num_input == NULL) - goto show_prompt; - if (num_input[0] == '\0') { - xfree(&num_input); - goto show_prompt; - } - num = atoi(num_input); - xfree(&num_input); - *ret_number = num; - return opts[n].ret; - } else if (opts[n].key[j] == c) { + if (opts[n].key[j] == c) { session_printf(s, "%c\r\n", c); session_flush(s); return opts[n].ret;