mtm | Ncurses-based terminal multiplexer |
| download: https://git.y1.nz/archives/mtm.tar.gz | |
| Files | Log | Refs |
commit 5f2ec1b0919047b2f6e1c7c1e0fc4cc054cc4821 parent 08a33ccf51fa3d237fc35b951e032698524aec90 Author: Rob King <jking@deadpixi.com> Date: Thu, 20 Apr 2017 15:39:56 -0500 Ensure we encode wide characters correctly. Diffstat:
| M | mtm.c | 13 | +++++++++---- |
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/mtm.c b/mtm.c @@ -15,6 +15,7 @@ */ #include <errno.h> #include <fcntl.h> +#include <limits.h> #include <locale.h> #include <pwd.h> #include <signal.h> @@ -1109,10 +1110,14 @@ handlechar(int r, int k) /* Handle a single input character. */ DO(true, DELETE_NODE_KIND, DELETE_NODE, deletenode(focused)) DO(true, REDRAW_KIND, REDRAW, draw(root)) - char c[] = {(char)k, 0}; - SEND(focused, c); - if (!focused->srm) - print(focused->vp, focused, (wchar_t)k, 0, 0, NULL); + char c[MB_LEN_MAX + 1] = {0}; + if (wctomb(c, k) > 0){ + SEND(focused, c); + + if (!focused->srm) + print(focused->vp, focused, k, 0, 0, NULL); + } + return cmd = false, true; }
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.