added OSC for color buttons

work
Ondřej Hruška 7 years ago
parent d9aa0418fa
commit 5dbb592946
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 2
      front-end
  2. 4
      user/apars_osc.c
  3. 41
      user/screen.c
  4. 1
      user/screen.h

@ -1 +1 @@
Subproject commit 445d78d4e18a976902753375351c2a39337dcac2
Subproject commit 30af1ad2f67cf100541e06ccd3760e9562f2f672

@ -44,6 +44,10 @@ handle_espterm_osc(int n0, int n1, char *buffer)
// Button message
screen_set_button_message(n1, buffer);
}
else if (n0 == 30) {
// Button color
screen_set_button_color(n1, buffer);
}
else goto bad;
return;

@ -1218,12 +1218,13 @@ void ICACHE_FLASH_ATTR
screen_set_button_text(int num, const char *text)
{
NOTIFY_LOCK();
if (num == 1) strncpy(termconf_live.btn1, text, TERM_BTN_LEN);
else if (num == 2) strncpy(termconf_live.btn2, text, TERM_BTN_LEN);
else if (num == 3) strncpy(termconf_live.btn3, text, TERM_BTN_LEN);
else if (num == 4) strncpy(termconf_live.btn4, text, TERM_BTN_LEN);
else if (num == 5) strncpy(termconf_live.btn5, text, TERM_BTN_LEN);
if (num >= 1 && num <= TERM_BTN_COUNT) {
char *buf = TERM_BTN_N(&termconf_live, num - 1);
strncpy(buf, text, TERM_BTN_MSG_LEN);
}
else ansi_warn("Bad button num: %d", num);
NOTIFY_DONE(TOPIC_CHANGE_BUTTONS);
}
@ -1236,12 +1237,32 @@ void ICACHE_FLASH_ATTR
screen_set_button_message(int num, const char *msg)
{
NOTIFY_LOCK();
if (num == 1) strncpy(termconf_live.bm1, msg, TERM_BTN_MSG_LEN);
else if (num == 2) strncpy(termconf_live.bm2, msg, TERM_BTN_MSG_LEN);
else if (num == 3) strncpy(termconf_live.bm3, msg, TERM_BTN_MSG_LEN);
else if (num == 4) strncpy(termconf_live.bm4, msg, TERM_BTN_MSG_LEN);
else if (num == 5) strncpy(termconf_live.bm5, msg, TERM_BTN_MSG_LEN);
if (num >= 1 && num <= TERM_BTN_COUNT) {
char *buf = TERM_BM_N(&termconf_live, num - 1);
strncpy(buf, msg, TERM_BTN_MSG_LEN);
}
else ansi_warn("Bad button num: %d", num);
NOTIFY_DONE(TOPIC_CHANGE_BUTTONS);
}
/**
* Helper function to set terminal button label
* @param num - button number 1-5
* @param str - button text
*/
void ICACHE_FLASH_ATTR
screen_set_button_color(int num, const char *buf)
{
NOTIFY_LOCK();
if (num >= 1 && num <= TERM_BTN_COUNT) {
u32 *fieldptr = &termconf_live.bc1 + (num-1);
xset_term_color("", fieldptr, buf, NULL);
}
else ansi_warn("Bad button num: %d", num);
NOTIFY_DONE(TOPIC_CHANGE_BUTTONS);
}

@ -191,6 +191,7 @@ void screen_set_title(const char *title);
/** Set a button text */
void screen_set_button_text(int num, const char *text);
void screen_set_button_message(int num, const char *msg);
void screen_set_button_color(int num, const char *buf);
void screen_set_button_count(int count);
/** Change backdrop */
void screen_set_backdrop(const char *url);

Loading…
Cancel
Save