implemented loopback option SRM
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
+10
-8
@@ -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<strlen(data); i++) {
|
||||
ansi_parser(data[i]);
|
||||
}
|
||||
#else
|
||||
// pass string verbatim
|
||||
if (termconf_scratch.loopback) {
|
||||
for (int i = 1; i < strlen(data); i++) {
|
||||
ansi_parser(data[i]);
|
||||
}
|
||||
}
|
||||
UART_SendAsync(data+1, -1);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
// action button press
|
||||
btnNum = (u8) (data[1]);
|
||||
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;
|
||||
|
||||
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.");
|
||||
}
|
||||
|
||||
+11
-2
@@ -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);
|
||||
|
||||
+11
-1
@@ -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...
|
||||
|
||||
+6
-3
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user