AmendHub

Download:

jcs

/

subtext

/

amendments

/

442

session: Add one-line help option to session_menu

Disable it for now, I'm still not sure when I want it printed

jcs made amendment 442 about 1 year ago
--- session.c Wed Mar 15 18:38:01 2023 +++ session.c Sat Mar 25 21:31:44 2023 @@ -1572,14 +1572,14 @@ session_who(struct session *s) char session_menu(struct session *s, char *title, char *prompt, - const struct session_menu_option *opts, size_t nopts, bool show_opts, - char *number_prompt, short *ret_number) + char *prompt_help, const struct session_menu_option *opts, + size_t nopts, bool show_opts, char *number_prompt, short *ret_number) { size_t n; short j, num; unsigned short c; char cn[2], *num_input = NULL; - bool last_invalid = false; + short invalids = 0; if (show_opts && title != NULL) { session_printf(s, "{{B}}%s{{/B}}\r\n", title); @@ -1597,6 +1597,13 @@ print_options: session_flush(s); } +#if 0 + if (prompt_help) { + session_printf(s, "{{B}}%s{{/B}}\r\n", prompt_help); + session_flush(s); + } +#endif + for (;;) { show_prompt: session_printf(s, "{{B}}%s>{{/B}} ", prompt); @@ -1652,13 +1659,13 @@ get_menu_option: * bogus characters and us having to print 'invalid option' over * and over. */ - if (last_invalid) + if (invalids > 3) goto get_menu_option; session_printf(s, "%c\r\n", c); session_printf(s, invalid_option_help); session_flush(s); - last_invalid = true; + invalids++; } } --- session.h Wed Mar 15 18:37:35 2023 +++ session.h Thu Mar 23 17:53:14 2023 @@ -149,8 +149,8 @@ void session_print_motd(struct session *s, bool force) void session_recents(struct session *s); void session_who(struct session *s); char session_menu(struct session *s, char *title, char *prompt, - const struct session_menu_option *opts, size_t nopts, bool show_opts, - char *number_prompt, short *ret_number); + char *prompt_help, const struct session_menu_option *opts, size_t nopts, + bool show_opts, char *number_prompt, short *ret_number); void session_prune_logs(short days); void session_check_buf_canaries(struct session *session);