From 5f6566a6fd6f11f98e9aaf52cea7e4cef2c65234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Wed, 6 Sep 2017 14:44:42 +0200 Subject: [PATCH] implemented loopback option SRM --- html_orig/lang/en.php | 1 + html_orig/pages/cfg_term.php | 6 ++++++ html_orig/pages/help/cmd_system.php | 12 ++++++++++++ user/apars_csi.c | 4 ++++ user/cgi_sockets.c | 18 ++++++++++-------- user/cgi_term_cfg.c | 13 +++++++++++-- user/screen.c | 12 +++++++++++- user/screen.h | 9 ++++++--- 8 files changed, 61 insertions(+), 14 deletions(-) diff --git a/html_orig/lang/en.php b/html_orig/lang/en.php index 7836b0a..44353d6 100644 --- a/html_orig/lang/en.php +++ b/html_orig/lang/en.php @@ -51,6 +51,7 @@ return [ 'term.fn_alt_mode' => 'SS3 Fn keys', 'term.show_config_links' => 'Show nav links', 'term.show_buttons' => 'Show buttons', + 'term.loopback' => 'Local Echo', // terminal color labels 'color.0' => 'Black', diff --git a/html_orig/pages/cfg_term.php b/html_orig/pages/cfg_term.php index 1292dac..7a9d984 100644 --- a/html_orig/pages/cfg_term.php +++ b/html_orig/pages/cfg_term.php @@ -152,6 +152,12 @@ +
+ + +
+
diff --git a/html_orig/pages/help/cmd_system.php b/html_orig/pages/help/cmd_system.php index a03fbe6..d224676 100644 --- a/html_orig/pages/help/cmd_system.php +++ b/html_orig/pages/help/cmd_system.php @@ -74,6 +74,18 @@ Show (`h`) or hide (`l`) menu/help links under the screen. + + + + \e[12h \\ + \e[12l + + + + Enable (`h`) or disable (`l`) Send-Receive Mode (SRM). + SRM is the opposite of Local Echo, meaning `\e[12h` disables and `\e[12l` enables Local Echo. + + `\e[8;r;ct` Set screen size (this is a command borrowed from xterm) diff --git a/user/apars_csi.c b/user/apars_csi.c index 8361668..69b0f27 100644 --- a/user/apars_csi.c +++ b/user/apars_csi.c @@ -552,6 +552,10 @@ static void ICACHE_FLASH_ATTR do_csi_privattr(CSI_Data *opts) if (n == 4) { screen_set_insert_mode(yn); } + if (n == 12) { + // SRM is inverted, according to vt510 manual + termconf_scratch.loopback = !yn; + } else if (n == 20) { screen_set_newline_mode(yn); } diff --git a/user/cgi_sockets.c b/user/cgi_sockets.c index f2705d3..6744623 100644 --- a/user/cgi_sockets.c +++ b/user/cgi_sockets.c @@ -206,22 +206,23 @@ void ICACHE_FLASH_ATTR updateSockRx(Websock *ws, char *data, int len, int flags) char c = data[0]; switch (c) { case 's': - // pass string verbatim -#if LOOPBACK - for(int i=4;i 0 && btnNum < 10) { - UART_SendAsync((const char *) &btnNum, 1); // TODO this is where we use user-configured codes + UART_SendAsync(termconf->btn_msg[btnNum], -1); } break; + case 'm': case 'p': case 'r': @@ -235,6 +236,7 @@ void ICACHE_FLASH_ATTR updateSockRx(Websock *ws, char *data, int len, int flags) sendMouseAction(c,y,x,b,m); break; + default: ws_warn("Bad command."); } diff --git a/user/cgi_term_cfg.c b/user/cgi_term_cfg.c index 6b42f64..1f7ee62 100644 --- a/user/cgi_term_cfg.c +++ b/user/cgi_term_cfg.c @@ -132,6 +132,12 @@ cgiTermCfgSetParams(HttpdConnData *connData) termconf->show_config_links = (bool)n; } + if (GET_ARG("loopback")) { + dbg("Loopback: %s", buff); + n = atoi(buff); + termconf->loopback = (bool)n; + } + if (GET_ARG("default_fg")) { dbg("Screen default FG: %s", buff); n = atoi(buff); @@ -162,7 +168,7 @@ cgiTermCfgSetParams(HttpdConnData *connData) strncpy_safe(termconf->title, buff, 64); // ATTN those must match the values in } - for (int i = 1; i <= 5; i++) { + for (int i = 1; i <= TERM_BTN_COUNT; i++) { sprintf(buff, "btn%d", i); if (GET_ARG(buff)) { dbg("Button%d default text: \"%s\"", i, buff); @@ -230,6 +236,9 @@ tplTermCfg(HttpdConnData *connData, char *token, void **arg) else if (streq(token, "show_config_links")) { sprintf(buff, "%d", (int)termconf->show_config_links); } + else if (streq(token, "loopback")) { + sprintf(buff, "%d", (int)termconf->loopback); + } else if (streq(token, "theme")) { sprintf(buff, "%d", termconf->theme); } @@ -243,7 +252,7 @@ tplTermCfg(HttpdConnData *connData, char *token, void **arg) strncpy_safe(buff, termconf->title, BUFLEN); } else { - for (int i = 1; i <= 5; i++) { + for (int i = 1; i <= TERM_BTN_COUNT; i++) { sprintf(buff2, "btn%d", i); if (streq(token, buff2)) { strncpy_safe(buff, termconf->btn[i-1], BUFLEN); diff --git a/user/screen.c b/user/screen.c index d4d2c8b..e427e96 100644 --- a/user/screen.c +++ b/user/screen.c @@ -135,8 +135,9 @@ terminal_restore_defaults(void) termconf->default_bg = 0; termconf->default_fg = 7; sprintf(termconf->title, SCR_DEF_TITLE); - for(int i=1; i <= 5; i++) { + for(int i=1; i <= TERM_BTN_COUNT; i++) { sprintf(termconf->btn[i-1], "%d", i); + sprintf(termconf->btn_msg[i-1], "%c", i); } termconf->theme = 0; termconf->parser_tout_ms = SCR_DEF_PARSER_TOUT_MS; @@ -181,6 +182,15 @@ terminal_apply_settings_noclear(void) changed = 1; } + // Migrate to v3 + if (termconf->config_version < 3) { + dbg("termconf: Updating to version 3"); + for(int i=1; i <= TERM_BTN_COUNT; i++) { + sprintf(termconf->btn_msg[i-1], "%c", i); + } + changed = 1; + } + termconf->config_version = TERMCONF_VERSION; // Validation... diff --git a/user/screen.h b/user/screen.h index 116fd6c..5dc6755 100644 --- a/user/screen.h +++ b/user/screen.h @@ -36,10 +36,12 @@ // Size designed for the terminal config structure // Must be constant to avoid corrupting user config after upgrade -#define TERMCONF_SIZE 200 +#define TERMCONF_SIZE 300 #define TERM_BTN_LEN 10 +#define TERM_BTN_MSG_LEN 10 #define TERM_TITLE_LEN 64 +#define TERM_BTN_COUNT 5 #define SCR_DEF_DISPLAY_TOUT_MS 10 #define SCR_DEF_DISPLAY_COOLDOWN_MS 30 @@ -52,7 +54,7 @@ /** Maximum screen size (determines size of the static data array) */ #define MAX_SCREEN_SIZE (80*25) -#define TERMCONF_VERSION 2 +#define TERMCONF_VERSION 3 // --- Persistent Settings --- @@ -62,7 +64,7 @@ typedef struct { u8 default_bg; // should be the Color typedef, but this way the size is more explicit u8 default_fg; char title[TERM_TITLE_LEN]; - char btn[5][TERM_BTN_LEN]; + char btn[TERM_BTN_COUNT][TERM_BTN_LEN]; u8 theme; u32 parser_tout_ms; u32 display_tout_ms; @@ -72,6 +74,7 @@ typedef struct { bool loopback; bool show_buttons; bool show_config_links; + char btn_msg[TERM_BTN_COUNT][TERM_BTN_MSG_LEN]; } TerminalConfigBundle; // Live config