diff --git a/user/ansi_parser.c b/user/ansi_parser.c index feb687b..6211d92 100644 --- a/user/ansi_parser.c +++ b/user/ansi_parser.c @@ -19,11 +19,11 @@ static const char _ansi_eof_actions[] = { 0, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0 }; static const int ansi_start = 1; -static const int ansi_first_final = 26; +static const int ansi_first_final = 24; static const int ansi_error = 0; static const int ansi_en_CSI_body = 3; @@ -123,7 +123,7 @@ case 2: goto tr2; case 0: goto _out; -case 26: +case 24: if ( (*p) == 27 ) goto tr1; goto tr0; @@ -157,7 +157,7 @@ case 4: } else goto tr11; goto tr2; -case 27: +case 25: goto tr2; case 5: switch( (*p) ) { @@ -183,82 +183,74 @@ case 9: goto tr18; goto tr2; case 10: - if ( (*p) == 27 ) - goto tr2; - goto tr19; -case 11: switch( (*p) ) { case 7: goto tr20; case 27: goto tr21; } goto tr19; -case 28: +case 26: switch( (*p) ) { case 7: goto tr20; case 27: goto tr21; } goto tr19; -case 12: +case 11: if ( (*p) == 92 ) goto tr22; goto tr2; -case 29: +case 27: goto tr2; -case 13: +case 12: if ( (*p) == 73 ) goto tr23; goto tr2; -case 14: +case 13: if ( (*p) == 84 ) goto tr24; goto tr2; -case 15: +case 14: if ( (*p) == 76 ) goto tr25; goto tr2; -case 16: +case 15: if ( (*p) == 69 ) goto tr26; goto tr2; -case 17: +case 16: if ( (*p) == 61 ) goto tr27; goto tr2; -case 18: - if ( (*p) == 27 ) - goto tr2; - goto tr28; -case 19: +case 17: switch( (*p) ) { case 7: goto tr29; case 27: goto tr30; } goto tr28; -case 30: +case 28: switch( (*p) ) { case 7: goto tr29; case 27: goto tr30; } goto tr28; -case 20: +case 18: if ( (*p) == 92 ) goto tr31; goto tr2; -case 21: +case 19: if ( 48 <= (*p) && (*p) <= 57 ) goto tr32; goto tr2; -case 22: +case 20: if ( (*p) == 59 ) goto tr33; if ( 48 <= (*p) && (*p) <= 57 ) goto tr32; goto tr2; -case 23: +case 21: if ( 48 <= (*p) && (*p) <= 57 ) goto tr34; goto tr2; -case 24: +case 22: switch( (*p) ) { case 7: goto tr35; case 27: goto tr36; @@ -266,7 +258,7 @@ case 24: if ( 48 <= (*p) && (*p) <= 57 ) goto tr34; goto tr2; -case 25: +case 23: if ( (*p) == 92 ) goto tr35; goto tr2; @@ -283,32 +275,32 @@ case 25: tr16: cs = 8; goto _again; tr17: cs = 9; goto f8; tr18: cs = 10; goto _again; - tr19: cs = 11; goto f11; - tr21: cs = 12; goto _again; - tr13: cs = 13; goto _again; - tr23: cs = 14; goto _again; - tr24: cs = 15; goto _again; - tr25: cs = 16; goto _again; - tr26: cs = 17; goto _again; - tr27: cs = 18; goto _again; - tr28: cs = 19; goto f11; - tr30: cs = 20; goto _again; - tr14: cs = 21; goto _again; - tr32: cs = 22; goto f8; - tr33: cs = 23; goto f9; - tr34: cs = 24; goto f8; - tr36: cs = 25; goto _again; - tr3: cs = 26; goto f2; - tr4: cs = 26; goto f3; - tr5: cs = 26; goto f4; - tr6: cs = 26; goto f5; - tr7: cs = 26; goto f6; - tr11: cs = 27; goto f10; - tr20: cs = 28; goto f12; - tr22: cs = 29; goto f13; - tr31: cs = 29; goto f15; - tr35: cs = 29; goto f16; - tr29: cs = 30; goto f14; + tr19: cs = 10; goto f11; + tr21: cs = 11; goto _again; + tr13: cs = 12; goto _again; + tr23: cs = 13; goto _again; + tr24: cs = 14; goto _again; + tr25: cs = 15; goto _again; + tr26: cs = 16; goto _again; + tr27: cs = 17; goto _again; + tr28: cs = 17; goto f11; + tr30: cs = 18; goto _again; + tr14: cs = 19; goto _again; + tr32: cs = 20; goto f8; + tr33: cs = 21; goto f9; + tr34: cs = 22; goto f8; + tr36: cs = 23; goto _again; + tr3: cs = 24; goto f2; + tr4: cs = 24; goto f3; + tr5: cs = 24; goto f4; + tr6: cs = 24; goto f5; + tr7: cs = 24; goto f6; + tr11: cs = 25; goto f10; + tr20: cs = 26; goto f12; + tr22: cs = 27; goto f13; + tr31: cs = 27; goto f15; + tr35: cs = 27; goto f16; + tr29: cs = 28; goto f14; f1: _acts = _ansi_actions + 1; goto execFuncs; f4: _acts = _ansi_actions + 3; goto execFuncs; @@ -458,7 +450,7 @@ execFuncs: {cs = 1;goto _again;} } break; -/* #line 462 "user/ansi_parser.c" */ +/* #line 454 "user/ansi_parser.c" */ } } goto _again; @@ -484,7 +476,7 @@ _again: goto _again;} } break; -/* #line 488 "user/ansi_parser.c" */ +/* #line 480 "user/ansi_parser.c" */ } } } diff --git a/user/ansi_parser.rl b/user/ansi_parser.rl index 7c3f35d..af6c13d 100644 --- a/user/ansi_parser.rl +++ b/user/ansi_parser.rl @@ -169,8 +169,8 @@ ansi_parser(const char *newdata, size_t len) } OSC_body := ( - ("BTN" digit @CSI_digit '=' (NOESC @OSC_text_char)+ OSC_END @OSC_button) | - ("TITLE=" (NOESC @OSC_text_char)+ OSC_END @OSC_title) | + ("BTN" digit @CSI_digit '=' (NOESC @OSC_text_char)* OSC_END @OSC_button) | + ("TITLE=" (NOESC @OSC_text_char)* OSC_END @OSC_title) | ('W' (digit @CSI_digit)+ ';' @CSI_semi (digit @CSI_digit)+ OSC_END @OSC_resize) ) $!errBadSeq; diff --git a/user/cgi_term_cfg.c b/user/cgi_term_cfg.c index 7026818..88e8c92 100644 --- a/user/cgi_term_cfg.c +++ b/user/cgi_term_cfg.c @@ -22,6 +22,8 @@ cgiTermCfgSetParams(HttpdConnData *connData) char redir_url_buf[100]; int n, w, h; + bool shall_clear_screen = false; + char *redir_url = redir_url_buf; redir_url += sprintf(redir_url, SET_REDIR_ERR); // we'll test if anything was printed by looking for \0 in failed_keys_buf @@ -41,8 +43,11 @@ cgiTermCfgSetParams(HttpdConnData *connData) h = atoi(buff); if (h > 1) { if (w * h <= MAX_SCREEN_SIZE) { - termconf->width = w; - termconf->height = h; + if (termconf->width != w || termconf->height != h) { + termconf->width = w; + termconf->height = h; + shall_clear_screen = true; + } } else { warn("Bad dimensions: %d x %d (total %d)", w, h, w*h); redir_url += sprintf(redir_url, "term_width,term_height,"); @@ -66,7 +71,10 @@ cgiTermCfgSetParams(HttpdConnData *connData) dbg("Screen default BG: %s", buff); n = atoi(buff); if (n >= 0 && n < 16) { - termconf->default_bg = (u8) n; + if (termconf->default_bg != n) { + termconf->default_bg = (u8) n; + shall_clear_screen = true; + } } else { warn("Bad color %s", buff); redir_url += sprintf(redir_url, "default_bg,"); @@ -88,7 +96,10 @@ cgiTermCfgSetParams(HttpdConnData *connData) dbg("Screen default FG: %s", buff); n = atoi(buff); if (n >= 0 && n < 16) { - termconf->default_fg = (u8) n; + if (termconf->default_fg != n) { + termconf->default_fg = (u8) n; + shall_clear_screen = true; + } } else { warn("Bad color %s", buff); redir_url += sprintf(redir_url, "default_fg,"); @@ -123,9 +134,14 @@ cgiTermCfgSetParams(HttpdConnData *connData) // All was OK info("Set term params - success, saving..."); - terminal_apply_settings(); persist_store(); + if (shall_clear_screen) { + terminal_apply_settings(); + } else { + terminal_apply_settings_noclear(); + } + httpdRedirect(connData, SET_REDIR_SUC); } else { warn("Some settings did not validate, asking for correction"); diff --git a/user/screen.c b/user/screen.c index a7132c1..bb2ed2d 100644 --- a/user/screen.c +++ b/user/screen.c @@ -31,6 +31,12 @@ void terminal_restore_defaults(void) * Apply settings after eg. restore from defaults */ void terminal_apply_settings(void) +{ + terminal_apply_settings_noclear(); + screen_init(); +} + +void terminal_apply_settings_noclear(void) { memcpy(&termconf_scratch, termconf, sizeof(TerminalConfigBundle)); if (W*H >= MAX_SCREEN_SIZE) { @@ -39,8 +45,8 @@ void terminal_apply_settings(void) terminal_restore_defaults(); persist_store(); memcpy(&termconf_scratch, termconf, sizeof(TerminalConfigBundle)); + screen_init(); } - screen_init(); } /** diff --git a/user/screen.h b/user/screen.h index 0e21fbf..c923e37 100644 --- a/user/screen.h +++ b/user/screen.h @@ -70,6 +70,7 @@ extern TerminalConfigBundle termconf_scratch; void terminal_restore_defaults(void); void terminal_apply_settings(void); +void terminal_apply_settings_noclear(void); // the same, but with no screen reset / init /** * Maximum screen size (determines size of the static data array) diff --git a/user/user_main.h b/user/user_main.h index e2a4794..c1c9386 100644 --- a/user/user_main.h +++ b/user/user_main.h @@ -1,7 +1,7 @@ #ifndef USER_MAIN_H_H #define USER_MAIN_H_H -#define FIRMWARE_VERSION "0.6.2+" GIT_HASH +#define FIRMWARE_VERSION "0.6.3+" GIT_HASH #define TERMINAL_GITHUB_REPO "https://github.com/MightyPork/esp-vt100-firmware" #endif //USER_MAIN_H_H