support for truecolor default colors

http-comm
Ondřej Hruška 7 years ago
parent 502babf7b0
commit fa5489ccfc
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 2
      front-end
  2. 58
      user/cgi_term_cfg.c

@ -1 +1 @@
Subproject commit 6c6424877c49e3e23f563067a78e79338226359d
Subproject commit b18a0f389005913a214f4a86efb27e23206fa52e

@ -14,6 +14,22 @@ Cgi/template routines for configuring non-wifi settings
#define SET_REDIR_SUC "/cfg/term"
#define SET_REDIR_ERR SET_REDIR_SUC"?err="
/** convert hex number to int */
static ICACHE_FLASH_ATTR u32
decodehex(const char *buf) {
u32 n = 0;
char c;
while ((c = *buf++) != 0) {
if (c >= '0' && c <= '9') c -= '0';
else if (c >= 'a' && c <= 'f') c -= 'a'-10;
else if (c >= 'A' && c <= 'F') c -= 'A'-10;
else c = 0;
n *= 16;
n += c;
}
return n;
}
/**
* Universal CGI endpoint to set Terminal params.
*/
@ -55,7 +71,7 @@ cgiTermCfgSetParams(HttpdConnData *connData)
if (!GET_ARG("term_height")) {
cgi_warn("Missing height arg!");
// this wont happen normally when the form is used
redir_url += sprintf(redir_url, "term_width,term_height,");
redir_url += sprintf(redir_url, "term_height,");
break;
}
@ -83,29 +99,33 @@ cgiTermCfgSetParams(HttpdConnData *connData)
if (GET_ARG("default_bg")) {
cgi_dbg("Screen default BG: %s", buff);
if (buff[0] == '#') {
// decode hex
n = decodehex(buff+1);
n += 256;
} else {
n = atoi(buff);
if (n >= 0 && n < 16) {
if (termconf->default_bg != n) {
termconf->default_bg = n;
shall_clear_screen = true;
}
} else {
cgi_warn("Bad color %s", buff);
redir_url += sprintf(redir_url, "default_bg,");
if (termconf->default_bg != n) {
termconf->default_bg = n; // this is current not sent through socket, no use to notify
}
}
if (GET_ARG("default_fg")) {
cgi_dbg("Screen default FG: %s", buff);
if (buff[0] == '#') {
// decode hex
n = decodehex(buff+1);
n += 256;
} else {
n = atoi(buff);
if (n >= 0 && n < 16) {
if (termconf->default_fg != n) {
termconf->default_fg = n;
shall_clear_screen = true;
}
} else {
cgi_warn("Bad color %s", buff);
redir_url += sprintf(redir_url, "default_fg,");
if (termconf->default_fg != n) {
termconf->default_fg = n; // this is current not sent through socket, no use to notify
}
}
@ -415,10 +435,18 @@ tplTermCfg(HttpdConnData *connData, char *token, void **arg)
sprintf(buff, "%d", termconf->theme);
}
else if (streq(token, "default_bg")) {
if (termconf->default_bg < 256) {
sprintf(buff, "%d", termconf->default_bg);
} else {
sprintf(buff, "#%06X", termconf->default_bg - 256);
}
}
else if (streq(token, "default_fg")) {
if (termconf->default_fg < 256) {
sprintf(buff, "%d", termconf->default_fg);
} else {
sprintf(buff, "#%06X", termconf->default_fg - 256);
}
}
else if (streq(token, "cursor_shape")) {
sprintf(buff, "%d", termconf->cursor_shape);

Loading…
Cancel
Save