commit 5caf7d677eb49100dd1522236bcc51b92af5de12 from: Omar Polo date: Mon Jul 12 17:39:59 2021 UTC move utf8 decl. to utf8.h commit - f5407b26b9ad20a9161b13715f8cc698c8c40555 commit + 5caf7d677eb49100dd1522236bcc51b92af5de12 blob - d580dbbc770003ce1c0fd849d124e0a4e5b6c349 blob + 2b7ca226fffbc98db64514d8c3864b9b0bcf4b02 --- Makefile.am +++ Makefile.am @@ -27,6 +27,7 @@ telescope_SOURCES = cmd.c \ ui.c \ ui.h \ utf8.c \ + utf8.h \ util.c \ wrap.c blob - e3c9f948f067616de32c93bbd494d76046e1787e blob + 4921c7cc43fd690351ac45d913b66f08dfe8d63a --- cmd.c +++ cmd.c @@ -21,6 +21,7 @@ #include "minibuffer.h" #include "telescope.h" #include "ui.h" +#include "utf8.h" /* return 1 if moved, 0 otherwise */ static inline int blob - 08e58b71bbcc2a015e99277e2cca513ec26475de blob + b80e645a5b62a0badf23ea3ee74baf7f4f33905d --- minibuffer.c +++ minibuffer.c @@ -19,6 +19,7 @@ #include "minibuffer.h" #include "ui.h" +#include "utf8.h" static void minibuffer_hist_save_entry(void); static void minibuffer_self_insert(void); blob - 61bd2c2060b8693e1a2860d6946df94652d0f97e blob + 240cde0f57e729191bb9dd2071f85561d1d1026c --- telescope.h +++ telescope.h @@ -377,18 +377,6 @@ struct tofu_entry *tofu_lookup(struct ohash*, const ch void tofu_add(struct ohash*, struct tofu_entry*); void tofu_update(struct ohash*, struct tofu_entry*); void tofu_temp_trust(struct ohash *, const char *, const char *, const char *); - -/* utf.8 */ -uint32_t utf8_decode(uint32_t*restrict, uint32_t*restrict, uint8_t); -size_t utf8_encode(uint32_t, char*); -char *utf8_nth(char*, size_t); -size_t utf8_cplen(char*); -size_t utf8_chwidth(uint32_t); -size_t utf8_snwidth(const char*, size_t); -size_t utf8_swidth(const char*); -size_t utf8_swidth_between(const char*, const char*); -char *utf8_next_cp(const char*); -char *utf8_prev_cp(const char*, const char*); /* util.c */ int mark_nonblock(int); blob - 7b5e2eb83e3b3c9ea01dc74ccef33fcf439641f6 blob + 9b67c46604da51226b59254c1a21b435da43d1eb --- ui.c +++ ui.c @@ -43,6 +43,7 @@ #include "minibuffer.h" #include "telescope.h" #include "ui.h" +#include "utf8.h" static struct event stdioev, winchev; blob - 0ea606482b47905c55b84be2416315afe82a5f1a blob + 942ac1f138c65beb8ee09571efd94ddfbf4fc6af --- utf8.c +++ utf8.c @@ -21,13 +21,14 @@ * SOFTWARE. */ -#include "telescope.h" - #include #include #include #include +#include "telescope.h" +#include "utf8.h" + #define UTF8_ACCEPT 0 #define UTF8_REJECT 1 blob - /dev/null blob + 4d2cf2a66355e12fc8d3ecb4c06816005c9d16d3 (mode 644) --- /dev/null +++ utf8.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2021 Omar Polo + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef UTF8_H +#define UTF8_H + +#include +#include + +uint32_t utf8_decode(uint32_t*restrict, uint32_t*restrict, uint8_t); +size_t utf8_encode(uint32_t, char*); +char *utf8_nth(char*, size_t); +size_t utf8_cplen(char*); +size_t utf8_chwidth(uint32_t); +size_t utf8_snwidth(const char*, size_t); +size_t utf8_swidth(const char*); +size_t utf8_swidth_between(const char*, const char*); +char *utf8_next_cp(const char*); +char *utf8_prev_cp(const char*, const char*); + +#endif blob - 491455e3491608b7d1d462e7d1e2c099df0944e7 blob + 04dcedda1c3892437218f86acbe39043880f7986 --- wrap.c +++ wrap.c @@ -14,11 +14,12 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "telescope.h" - #include #include +#include "telescope.h" +#include "utf8.h" + /* * Text wrapping * =============