diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-05-31 10:41:07 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-05-31 10:41:07 +0000 |
| commit | c38b9be6a4110da99c45ede3a118c49e790beee9 (patch) | |
| tree | 6ee7dc6c3ecbcfd3d284e8c2e47c40a050668717 /vt.c | |
| parent | readme: cleanup (diff) | |
vt: utf8: don't need one entry action for each UTF8 variant
Diffstat (limited to 'vt.c')
| -rw-r--r-- | vt.c | 26 |
1 files changed, 6 insertions, 20 deletions
@@ -503,24 +503,10 @@ action_put(struct terminal *term, uint8_t c) } static void -action_utf8_2_entry(struct terminal *term, uint8_t c) +action_utf8_entry(struct terminal *term, uint8_t c) { - term->vt.utf8.idx = 0; - term->vt.utf8.data[term->vt.utf8.idx++] = c; -} - -static void -action_utf8_3_entry(struct terminal *term, uint8_t c) -{ - term->vt.utf8.idx = 0; - term->vt.utf8.data[term->vt.utf8.idx++] = c; -} - -static void -action_utf8_4_entry(struct terminal *term, uint8_t c) -{ - term->vt.utf8.idx = 0; - term->vt.utf8.data[term->vt.utf8.idx++] = c; + term->vt.utf8.data[0] = c; + term->vt.utf8.idx = 1; } static void @@ -698,9 +684,9 @@ state_ground_switch(struct terminal *term, uint8_t data) case 0x20 ... 0x7f: action_print(term, data); return STATE_GROUND; - case 0xc0 ... 0xdf: action_utf8_2_entry(term, data); return STATE_UTF8_COLLECT_1; - case 0xe0 ... 0xef: action_utf8_3_entry(term, data); return STATE_UTF8_COLLECT_2; - case 0xf0 ... 0xf7: action_utf8_4_entry(term, data); return STATE_UTF8_COLLECT_3; + case 0xc0 ... 0xdf: action_utf8_entry(term, data); return STATE_UTF8_COLLECT_1; + case 0xe0 ... 0xef: action_utf8_entry(term, data); return STATE_UTF8_COLLECT_2; + case 0xf0 ... 0xf7: action_utf8_entry(term, data); return STATE_UTF8_COLLECT_3; /* Anywhere */ case 0x18: action_execute(term, data); return STATE_GROUND; |
