implemented loopback option SRM

pull/111/merge
Ondřej Hruška 7 years ago
parent 6d98d2c6da
commit 5f6566a6fd
  1. 1
      html_orig/lang/en.php
  2. 6
      html_orig/pages/cfg_term.php
  3. 12
      html_orig/pages/help/cmd_system.php
  4. 4
      user/apars_csi.c
  5. 12
      user/cgi_sockets.c
  6. 13
      user/cgi_term_cfg.c
  7. 12
      user/screen.c
  8. 9
      user/screen.h

@ -51,6 +51,7 @@ return [
'term.fn_alt_mode' => 'SS3 Fn keys', 'term.fn_alt_mode' => 'SS3 Fn keys',
'term.show_config_links' => 'Show nav links', 'term.show_config_links' => 'Show nav links',
'term.show_buttons' => 'Show buttons', 'term.show_buttons' => 'Show buttons',
'term.loopback' => 'Local Echo',
// terminal color labels // terminal color labels
'color.0' => 'Black', 'color.0' => 'Black',

@ -152,6 +152,12 @@
<input type="hidden" id="show_config_links" name="show_config_links" value="%show_config_links%"> <input type="hidden" id="show_config_links" name="show_config_links" value="%show_config_links%">
</div> </div>
<div class="Row checkbox" >
<label><?= tr('term.loopback') ?></label><!--
--><span class="box" tabindex=0 role=checkbox></span>
<input type="hidden" id="loopback" name="loopback" value="%loopback%">
</div>
<div class="Row buttons"> <div class="Row buttons">
<a class="button icn-ok" href="#" onclick="qs('#form-2').submit()"><?= tr('apply') ?></a> <a class="button icn-ok" href="#" onclick="qs('#form-2').submit()"><?= tr('apply') ?></a>
</div> </div>

@ -74,6 +74,18 @@
Show (`h`) or hide (`l`) menu/help links under the screen. Show (`h`) or hide (`l`) menu/help links under the screen.
</td> </td>
</tr> </tr>
<tr>
<td>
<code>
\e[12h \\
\e[12l
</code>
</td>
<td>
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.
</td>
</tr>
<tr> <tr>
<td>`\e[8;<i>r</i>;<i>c</i>t`</td> <td>`\e[8;<i>r</i>;<i>c</i>t`</td>
<td>Set screen size (this is a command borrowed from xterm)</td> <td>Set screen size (this is a command borrowed from xterm)</td>

@ -552,6 +552,10 @@ static void ICACHE_FLASH_ATTR do_csi_privattr(CSI_Data *opts)
if (n == 4) { if (n == 4) {
screen_set_insert_mode(yn); screen_set_insert_mode(yn);
} }
if (n == 12) {
// SRM is inverted, according to vt510 manual
termconf_scratch.loopback = !yn;
}
else if (n == 20) { else if (n == 20) {
screen_set_newline_mode(yn); screen_set_newline_mode(yn);
} }

@ -207,21 +207,22 @@ void ICACHE_FLASH_ATTR updateSockRx(Websock *ws, char *data, int len, int flags)
switch (c) { switch (c) {
case 's': case 's':
// pass string verbatim // pass string verbatim
#if LOOPBACK if (termconf_scratch.loopback) {
for(int i=4;i<strlen(data); i++) { for (int i = 1; i < strlen(data); i++) {
ansi_parser(data[i]); ansi_parser(data[i]);
} }
#else }
UART_SendAsync(data+1, -1); UART_SendAsync(data+1, -1);
#endif
break; break;
case 'b': case 'b':
// action button press // action button press
btnNum = (u8) (data[1]); btnNum = (u8) (data[1]);
if (btnNum > 0 && btnNum < 10) { if (btnNum > 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; break;
case 'm': case 'm':
case 'p': case 'p':
case 'r': 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); sendMouseAction(c,y,x,b,m);
break; break;
default: default:
ws_warn("Bad command."); ws_warn("Bad command.");
} }

@ -132,6 +132,12 @@ cgiTermCfgSetParams(HttpdConnData *connData)
termconf->show_config_links = (bool)n; 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")) { if (GET_ARG("default_fg")) {
dbg("Screen default FG: %s", buff); dbg("Screen default FG: %s", buff);
n = atoi(buff); n = atoi(buff);
@ -162,7 +168,7 @@ cgiTermCfgSetParams(HttpdConnData *connData)
strncpy_safe(termconf->title, buff, 64); // ATTN those must match the values in 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); sprintf(buff, "btn%d", i);
if (GET_ARG(buff)) { if (GET_ARG(buff)) {
dbg("Button%d default text: \"%s\"", i, 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")) { else if (streq(token, "show_config_links")) {
sprintf(buff, "%d", (int)termconf->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")) { else if (streq(token, "theme")) {
sprintf(buff, "%d", termconf->theme); sprintf(buff, "%d", termconf->theme);
} }
@ -243,7 +252,7 @@ tplTermCfg(HttpdConnData *connData, char *token, void **arg)
strncpy_safe(buff, termconf->title, BUFLEN); strncpy_safe(buff, termconf->title, BUFLEN);
} }
else { else {
for (int i = 1; i <= 5; i++) { for (int i = 1; i <= TERM_BTN_COUNT; i++) {
sprintf(buff2, "btn%d", i); sprintf(buff2, "btn%d", i);
if (streq(token, buff2)) { if (streq(token, buff2)) {
strncpy_safe(buff, termconf->btn[i-1], BUFLEN); strncpy_safe(buff, termconf->btn[i-1], BUFLEN);

@ -135,8 +135,9 @@ terminal_restore_defaults(void)
termconf->default_bg = 0; termconf->default_bg = 0;
termconf->default_fg = 7; termconf->default_fg = 7;
sprintf(termconf->title, SCR_DEF_TITLE); 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[i-1], "%d", i);
sprintf(termconf->btn_msg[i-1], "%c", i);
} }
termconf->theme = 0; termconf->theme = 0;
termconf->parser_tout_ms = SCR_DEF_PARSER_TOUT_MS; termconf->parser_tout_ms = SCR_DEF_PARSER_TOUT_MS;
@ -181,6 +182,15 @@ terminal_apply_settings_noclear(void)
changed = 1; 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; termconf->config_version = TERMCONF_VERSION;
// Validation... // Validation...

@ -36,10 +36,12 @@
// Size designed for the terminal config structure // Size designed for the terminal config structure
// Must be constant to avoid corrupting user config after upgrade // 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_LEN 10
#define TERM_BTN_MSG_LEN 10
#define TERM_TITLE_LEN 64 #define TERM_TITLE_LEN 64
#define TERM_BTN_COUNT 5
#define SCR_DEF_DISPLAY_TOUT_MS 10 #define SCR_DEF_DISPLAY_TOUT_MS 10
#define SCR_DEF_DISPLAY_COOLDOWN_MS 30 #define SCR_DEF_DISPLAY_COOLDOWN_MS 30
@ -52,7 +54,7 @@
/** Maximum screen size (determines size of the static data array) */ /** Maximum screen size (determines size of the static data array) */
#define MAX_SCREEN_SIZE (80*25) #define MAX_SCREEN_SIZE (80*25)
#define TERMCONF_VERSION 2 #define TERMCONF_VERSION 3
// --- Persistent Settings --- // --- 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_bg; // should be the Color typedef, but this way the size is more explicit
u8 default_fg; u8 default_fg;
char title[TERM_TITLE_LEN]; char title[TERM_TITLE_LEN];
char btn[5][TERM_BTN_LEN]; char btn[TERM_BTN_COUNT][TERM_BTN_LEN];
u8 theme; u8 theme;
u32 parser_tout_ms; u32 parser_tout_ms;
u32 display_tout_ms; u32 display_tout_ms;
@ -72,6 +74,7 @@ typedef struct {
bool loopback; bool loopback;
bool show_buttons; bool show_buttons;
bool show_config_links; bool show_config_links;
char btn_msg[TERM_BTN_COUNT][TERM_BTN_MSG_LEN];
} TerminalConfigBundle; } TerminalConfigBundle;
// Live config // Live config

Loading…
Cancel
Save