changes to terminal settings now have immediate effect via notify

http-comm
Ondřej Hruška 7 years ago
parent ab921d2523
commit 2e004b6048
  1. 47
      user/cgi_term_cfg.c
  2. 2
      user/screen.c

@ -21,6 +21,7 @@ cgiTermCfgSetParams(HttpdConnData *connData)
char buff[50]; char buff[50];
char redir_url_buf[100]; char redir_url_buf[100];
int32 n, w, h; int32 n, w, h;
bool notify_screen_content = 0, notify_screen_labels = 0;
bool shall_clear_screen = false; bool shall_clear_screen = false;
@ -46,7 +47,7 @@ cgiTermCfgSetParams(HttpdConnData *connData)
if (termconf->width != w || termconf->height != h) { if (termconf->width != w || termconf->height != h) {
termconf->width = w; termconf->width = w;
termconf->height = h; termconf->height = h;
shall_clear_screen = true; shall_clear_screen = true; // this causes a notify
} }
} else { } else {
warn("Bad dimensions: %d x %d (total %d)", w, h, w*h); warn("Bad dimensions: %d x %d (total %d)", w, h, w*h);
@ -81,6 +82,20 @@ cgiTermCfgSetParams(HttpdConnData *connData)
} }
} }
if (GET_ARG("default_fg")) {
dbg("Screen default FG: %s", buff);
n = atoi(buff);
if (n >= 0 && n < 16) {
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,");
}
}
if (GET_ARG("parser_tout_ms")) { if (GET_ARG("parser_tout_ms")) {
dbg("Parser timeout: %s ms", buff); dbg("Parser timeout: %s ms", buff);
n = atoi(buff); n = atoi(buff);
@ -118,24 +133,28 @@ cgiTermCfgSetParams(HttpdConnData *connData)
dbg("FN alt mode: %s", buff); dbg("FN alt mode: %s", buff);
n = atoi(buff); n = atoi(buff);
termconf->fn_alt_mode = (bool)n; termconf->fn_alt_mode = (bool)n;
notify_screen_content = true;
} }
if (GET_ARG("crlf_mode")) { if (GET_ARG("crlf_mode")) {
dbg("CRLF mode: %s", buff); dbg("CRLF mode: %s", buff);
n = atoi(buff); n = atoi(buff);
termconf->crlf_mode = (bool)n; termconf->crlf_mode = (bool)n;
notify_screen_content = true;
} }
if (GET_ARG("show_buttons")) { if (GET_ARG("show_buttons")) {
dbg("Show buttons: %s", buff); dbg("Show buttons: %s", buff);
n = atoi(buff); n = atoi(buff);
termconf->show_buttons = (bool)n; termconf->show_buttons = (bool)n;
notify_screen_content = true;
} }
if (GET_ARG("show_config_links")) { if (GET_ARG("show_config_links")) {
dbg("Show config links: %s", buff); dbg("Show config links: %s", buff);
n = atoi(buff); n = atoi(buff);
termconf->show_config_links = (bool)n; termconf->show_config_links = (bool)n;
notify_screen_content = true;
} }
if (GET_ARG("loopback")) { if (GET_ARG("loopback")) {
@ -144,25 +163,12 @@ cgiTermCfgSetParams(HttpdConnData *connData)
termconf->loopback = (bool)n; termconf->loopback = (bool)n;
} }
if (GET_ARG("default_fg")) {
dbg("Screen default FG: %s", buff);
n = atoi(buff);
if (n >= 0 && n < 16) {
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,");
}
}
if (GET_ARG("theme")) { if (GET_ARG("theme")) {
dbg("Screen color theme: %s", buff); dbg("Screen color theme: %s", buff);
n = atoi(buff); n = atoi(buff);
if (n >= 0 && n <= 5) { // ALWAYS ADJUST WHEN ADDING NEW THEME! if (n >= 0 && n <= 5) { // ALWAYS ADJUST WHEN ADDING NEW THEME!
termconf->theme = (u8) n; termconf->theme = (u8) n;
// this can't be notified, page must reload.
} else { } else {
warn("Bad theme num: %s", buff); warn("Bad theme num: %s", buff);
redir_url += sprintf(redir_url, "theme,"); redir_url += sprintf(redir_url, "theme,");
@ -174,6 +180,7 @@ cgiTermCfgSetParams(HttpdConnData *connData)
n = atoi(buff); n = atoi(buff);
if (n >= 0 && n <= 6 && n != 1) { if (n >= 0 && n <= 6 && n != 1) {
termconf->cursor_shape = (enum CursorShape) n; termconf->cursor_shape = (enum CursorShape) n;
notify_screen_content = true;
} else { } else {
warn("Bad cursor_shape num: %s", buff); warn("Bad cursor_shape num: %s", buff);
redir_url += sprintf(redir_url, "cursor_shape,"); redir_url += sprintf(redir_url, "cursor_shape,");
@ -183,6 +190,7 @@ cgiTermCfgSetParams(HttpdConnData *connData)
if (GET_ARG("term_title")) { if (GET_ARG("term_title")) {
dbg("Terminal title default text: \"%s\"", buff); dbg("Terminal title default text: \"%s\"", buff);
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
notify_screen_labels = true;
} }
for (int btn_i = 1; btn_i <= TERM_BTN_COUNT; btn_i++) { for (int btn_i = 1; btn_i <= TERM_BTN_COUNT; btn_i++) {
@ -190,6 +198,7 @@ cgiTermCfgSetParams(HttpdConnData *connData)
if (GET_ARG(buff)) { if (GET_ARG(buff)) {
dbg("Button%d default text: \"%s\"", btn_i, buff); dbg("Button%d default text: \"%s\"", btn_i, buff);
strncpy_safe(termconf->btn[btn_i-1], buff, TERM_BTN_LEN); strncpy_safe(termconf->btn[btn_i-1], buff, TERM_BTN_LEN);
notify_screen_labels = true;
} }
sprintf(buff, "bm%d", btn_i); sprintf(buff, "bm%d", btn_i);
@ -261,6 +270,14 @@ cgiTermCfgSetParams(HttpdConnData *connData)
terminal_apply_settings_noclear(); terminal_apply_settings_noclear();
} }
if (notify_screen_content) {
screen_notifyChange(CHANGE_CONTENT);
}
if (notify_screen_labels) {
screen_notifyChange(CHANGE_LABELS);
}
httpdRedirect(connData, SET_REDIR_SUC); httpdRedirect(connData, SET_REDIR_SUC);
} else { } else {
warn("Some settings did not validate, asking for correction"); warn("Some settings did not validate, asking for correction");

@ -1475,7 +1475,7 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, void **data)
((mouse_tracking.mode>=MTM_NORMAL) << 6) | // disables selecting ((mouse_tracking.mode>=MTM_NORMAL) << 6) | // disables selecting
(termconf_scratch.show_buttons << 7) | (termconf_scratch.show_buttons << 7) |
(termconf_scratch.show_config_links << 8) | (termconf_scratch.show_config_links << 8) |
((termconf_scratch.cursor_shape&0x03) << 9) | // 9,10,11 - cursor shape based on DECSCUSR ((termconf_scratch.cursor_shape&0x07) << 9) | // 9,10,11 - cursor shape based on DECSCUSR
(termconf_scratch.crlf_mode << 12) (termconf_scratch.crlf_mode << 12)
); );
} }

Loading…
Cancel
Save