updated protocol, added button themeing and font conf

work
Ondřej Hruška 7 years ago
parent 9008f2e1af
commit d9aa0418fa
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 50
      user/screen.c
  2. 16
      user/screen.h

@ -373,6 +373,8 @@ terminal_restore_defaults(void)
strcpy((char*)termconf->bm4, "\x04");
strcpy((char*)termconf->bm5, "\x05");
termconf->bc1 = termconf->bc2 = termconf->bc3 = termconf->bc4 = termconf->bc5 = 0;
termconf->theme = 0;
termconf->parser_tout_ms = SCR_DEF_PARSER_TOUT_MS;
termconf->display_tout_ms = SCR_DEF_DISPLAY_TOUT_MS;
@ -389,6 +391,8 @@ terminal_restore_defaults(void)
termconf->allow_decopt_12 = SCR_DEF_DECOPT12;
termconf->ascii_debug = SCR_DEF_ASCIIDEBUG;
termconf->backdrop[0] = 0;
termconf->font_stack[0] = 0;
termconf->font_size = 20;
}
/**
@ -440,6 +444,14 @@ terminal_apply_settings_noclear(void)
termconf->button_count = SCR_DEF_BUTTON_COUNT;
changed = 1;
}
if (termconf->config_version < 6) {
persist_dbg("termconf: Updating to version 6");
termconf->backdrop[0] = 0;
termconf->font_stack[0] = 0;
termconf->font_size = 20;
termconf->bc1 = termconf->bc2 = termconf->bc3 = termconf->bc4 = termconf->bc5 = 0;
changed = 1;
}
termconf->config_version = TERMCONF_VERSION;
@ -2143,6 +2155,15 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, ScreenNotifyTopics topics,
bufput_utf8((num)); \
} while(0)
#define bufput_color_utf8(c) do { \
if ((c) < 256) { \
bufput_utf8(c); \
} else { \
bufput_utf8((((c)-256)&0xFFF) | 0x10000); \
bufput_utf8((((c)-256)>>12)&0xFFF); \
} \
} while(0)
// tags for screen serialization
#define SEQ_TAG_SKIP '\x01'
#define SEQ_TAG_REPEAT '\x02'
@ -2153,6 +2174,7 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, ScreenNotifyTopics topics,
#define SEQ_TAG_ATTRS_0 '\x07'
#define TOPICMARK_SCREEN_OPTS 'O'
#define TOPICMARK_STATIC_OPTS 'P'
#define TOPICMARK_TITLE 'T'
#define TOPICMARK_BUTTONS 'B'
#define TOPICMARK_DEBUG 'D'
@ -2250,12 +2272,8 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, ScreenNotifyTopics topics,
bufput_utf8(H);
bufput_utf8(W);
bufput_utf8(termconf_live.theme);
bufput_utf8(termconf_live.default_fg & 0xFFFF);
bufput_utf8((termconf_live.default_fg >> 16) & 0xFFFF);
bufput_utf8(termconf_live.default_bg & 0xFFFF);
bufput_utf8((termconf_live.default_bg >> 16) & 0xFFFF);
bufput_color_utf8(termconf_live.default_fg);
bufput_color_utf8(termconf_live.default_bg);
bufput_utf8(
(scr.cursor_visible << 0) |
@ -2274,6 +2292,20 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, ScreenNotifyTopics topics,
);
END_TOPIC
BEGIN_TOPIC(TOPIC_CHANGE_STATIC_OPTS, 110)
bufput_c(TOPICMARK_STATIC_OPTS);
size_t len = strlen(termconf_live.font_stack);
if (len > 0) {
memcpy(bb, termconf_live.font_stack, len);
bb += len;
remain -= len;
}
bufput_c('\x01');
bufput_utf8(termconf_live.font_size);
END_TOPIC
BEGIN_TOPIC(TOPIC_CHANGE_TITLE, TERM_TITLE_LEN+4+1)
bufput_c(TOPICMARK_TITLE);
@ -2291,7 +2323,11 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, ScreenNotifyTopics topics,
bufput_utf8(termconf_live.button_count);
u32 *cp = &termconf_live.bc1;
for (int i = 0; i < termconf_live.button_count; i++) {
uint32_t c = *cp++;
bufput_color_utf8(c);
size_t len = strlen(TERM_BTN_N(&termconf_live, i));
if (len > 0) {
memcpy(bb, TERM_BTN_N(&termconf_live, i), len);
@ -2333,6 +2369,8 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, ScreenNotifyTopics topics,
bufput_utf8(cursor.charsetN);
bufput_c(cursor.charset0);
bufput_c(cursor.charset1);
bufput_color_utf8(cursor.fg);
bufput_color_utf8(cursor.bg);
bufput_utf8(system_get_free_heap_size());
bufput_utf8(term_active_clients);
END_TOPIC

@ -40,6 +40,7 @@
#define TERM_TITLE_LEN 64
#define TERM_BTN_COUNT 5
#define TERM_BACKDROP_LEN 100
#define TERM_FONTSTACK_LEN 100
#define SCR_DEF_DISPLAY_TOUT_MS 12
#define SCR_DEF_DISPLAY_COOLDOWN_MS 35
@ -77,8 +78,8 @@ enum CursorShape {
// Size designed for the terminal config structure
// Must be constant to avoid corrupting user config after upgrade
#define TERMCONF_SIZE 400
#define TERMCONF_VERSION 5
#define TERMCONF_SIZE 500
#define TERMCONF_VERSION 6
//....Type................Name..Suffix...............Deref..XGET.........Cast..XSET...........NOTIFY..Allow
// Deref is used to pass the field to xget. Cast is used to convert the &'d field to what xset wants (needed for static arrays)
@ -114,7 +115,14 @@ enum CursorShape {
X(bool, allow_decopt_12, /**/, /**/, xget_bool, xset_bool, NULL, /**/, 1) \
X(bool, ascii_debug, /**/, /**/, xget_bool, xset_bool, NULL, /**/, 1) \
X(char, backdrop, [TERM_BACKDROP_LEN], /**/, xget_string, xset_string, TERM_BACKDROP_LEN, /**/, 1) \
X(u8, button_count, /**/, /**/, xget_dec, xset_u8, NULL, /**/, 1)
X(u8, button_count, /**/, /**/, xget_dec, xset_u8, NULL, /**/, 1) \
X(u32, bc1, /**/, /**/, xget_term_color, xset_term_color, NULL, /**/, 1) \
X(u32, bc2, /**/, /**/, xget_term_color, xset_term_color, NULL, /**/, 1) \
X(u32, bc3, /**/, /**/, xget_term_color, xset_term_color, NULL, /**/, 1) \
X(u32, bc4, /**/, /**/, xget_term_color, xset_term_color, NULL, /**/, 1) \
X(u32, bc5, /**/, /**/, xget_term_color, xset_term_color, NULL, /**/, 1) \
X(char, font_stack, [TERM_FONTSTACK_LEN], /**/, xget_string, xset_string, TERM_FONTSTACK_LEN, /**/, 1) \
X(u8, font_size, /**/, /**/, xget_dec, xset_u8, NULL, /**/, 1)
#define TERM_BM_N(tc, n) ((tc)->bm1+(TERM_BTN_MSG_LEN*n))
#define TERM_BTN_N(tc, n) ((tc)->btn1+(TERM_BTN_LEN*n))
@ -208,11 +216,13 @@ enum ScreenSerializeTopic {
TOPIC_INTERNAL = (1<<6), // debugging internal state
TOPIC_BELL = (1<<7), // beep
TOPIC_CHANGE_BACKDROP = (1<<8),
TOPIC_CHANGE_STATIC_OPTS = (1<<9),
TOPIC_FLAG_NOCLEAN = (1<<15), // do not clean dirty extents
// combos
TOPIC_INITIAL =
TOPIC_CHANGE_SCREEN_OPTS |
TOPIC_CHANGE_STATIC_OPTS |
TOPIC_CHANGE_CONTENT_ALL |
TOPIC_CHANGE_CURSOR |
TOPIC_CHANGE_TITLE |

Loading…
Cancel
Save