diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2019-07-04 17:35:01 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2019-07-04 17:35:01 +0000 |
| commit | befb437411d7393dcbc5be438efb2642727f5dd5 (patch) | |
| tree | 3be8aa8002e9f1887db7e1d04ce4271b5f648e25 /vt.c | |
| parent | vt: implement save/restore cursor+attributes (diff) | |
vt: improve logging of invalid and unimplemented sequences
Diffstat (limited to 'vt.c')
| -rw-r--r-- | vt.c | 29 |
1 files changed, 17 insertions, 12 deletions
@@ -552,19 +552,24 @@ static const enum action exit_actions[] = { [STATE_SOS_PM_APC_STRING] = ACTION_NONE, }; -static bool -esc_dispatch(struct terminal *term, uint8_t final) +static const char * +esc_as_string(struct terminal *term, uint8_t final) { -#if defined(_DEBUG) && defined(LOG_ENABLE_DBG) && LOG_ENABLE_DBG - char log[1024]; - int c = snprintf(log, sizeof(log), "ESC: "); + static char msg[1024]; + int c = snprintf(msg, sizeof(msg), "\E"); for (size_t i = 0; i < term->vt.intermediates.idx; i++) - c += snprintf(&log[c], sizeof(log) - c, "%c", term->vt.intermediates.data[i]); + c += snprintf(&msg[c], sizeof(msg) - c, "%c", term->vt.intermediates.data[i]); - c += snprintf(&log[c], sizeof(log) - c, "%c", final); - LOG_DBG("%s", log); -#endif + c += snprintf(&msg[c], sizeof(msg) - c, "%c", final); + return msg; + +} + +static bool +esc_dispatch(struct terminal *term, uint8_t final) +{ + LOG_DBG("ESC: %s", esc_as_string(term, final)); switch (final) { case '7': @@ -588,7 +593,7 @@ esc_dispatch(struct terminal *term, uint8_t final) case '+': term->charset[3] = CHARSET_ASCII; break; default: - LOG_ERR("<ESC>%cB: invalid charset identifier", param); + LOG_ERR("%s: invalid charset identifier", esc_as_string(term, final)); return false; } break; @@ -605,7 +610,7 @@ esc_dispatch(struct terminal *term, uint8_t final) case '+': term->charset[3] = CHARSET_GRAPHIC; break; default: - LOG_ERR("<ESC>%c0: invalid charset identifier", param); + LOG_ERR("%s: invalid charset identifier", esc_as_string(term, final)); return false; } break; @@ -627,7 +632,7 @@ esc_dispatch(struct terminal *term, uint8_t final) break; default: - LOG_ERR("ESC: unimplemented final: %c", final); + LOG_ERR("unimplemented: ESC: %s", esc_as_string(term, final)); return false; } |
