diff options
| author | Randy Palamar <randy@rnpnr.xyz> | 2025-12-05 22:36:10 -0700 |
|---|---|---|
| committer | Randy Palamar <randy@rnpnr.xyz> | 2026-01-06 16:52:56 -0700 |
| commit | 0d9bbb74c6de959ab7c6b93b7a97f9f2e643e8e8 (patch) | |
| tree | 25596fd04e3623571a155e9c2b1e2503aa9dd4f6 /main.c | |
| parent | 6ced61ef5f366001877823ed8aff978035fa53c8 (diff) | |
| download | vis-0d9bbb74c6de959ab7c6b93b7a97f9f2e643e8e8.tar.gz vis-0d9bbb74c6de959ab7c6b93b7a97f9f2e643e8e8.tar.xz | |
replace oversized libutf with smaller version
this is taken from one of my other projects. there was no reason
for there to be 2x the code
tests checking for surrogate characters and non characters were
removed. I see no reason why the user shouldn't be allowed to
insert those characters in text (they exist in the standard).
Also, in the case of non-characters only the first two were being
checked and not the other 64.
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -844,7 +844,7 @@ static KEY_ACTION_FN(ka_replace) if (!next) return NULL; - char replacement[UTFmax+1]; + char replacement[4+1]; if (!vis_keys_utf8(vis, keys, replacement)) return next; @@ -897,7 +897,7 @@ static KEY_ACTION_FN(ka_movement_key) const char *next = vis_keys_next(vis, keys); if (!next) return NULL; - char utf8[UTFmax+1]; + char utf8[4+1]; if (vis_keys_utf8(vis, keys, utf8)) vis_motion(vis, arg->i, utf8); return next; @@ -1030,8 +1030,8 @@ static KEY_ACTION_FN(ka_prompt_show) static KEY_ACTION_FN(ka_insert_verbatim) { - Rune rune = 0; - char buf[4], type = keys[0]; + uint32_t rune = 0; + unsigned char buf[4], type = keys[0]; const char *data = NULL; int len = 0, count = 0, base = 0; switch (type) { @@ -1084,22 +1084,22 @@ static KEY_ACTION_FN(ka_insert_verbatim) if (count > 0) return NULL; if (type == 'u' || type == 'U') { - len = runetochar(buf, &rune); + len = utf8_encode(buf, rune); } else { buf[0] = rune; len = 1; } - data = buf; + data = (char *)buf; } else { const char *next = vis_keys_next(vis, keys); if (!next) return NULL; - if ((rune = vis_keys_codepoint(vis, keys)) != (Rune)-1) { - len = runetochar(buf, &rune); + if ((rune = vis_keys_codepoint(vis, keys)) != -1) { + len = utf8_encode(buf, rune); if (buf[0] == '\n') buf[0] = '\r'; - data = buf; + data = (char *)buf; } else { vis_info_show(vis, "Unknown key"); } |
