From 6224030e5b1c7410c1e7da3b3092f11a99342c66 Mon Sep 17 00:00:00 2001 From: Justinas Grigas Date: Sun, 19 Nov 2023 05:08:25 +0000 Subject: [PATCH] feat(twin): get_wc now takes chars simplified get_wc function --- twin.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/twin.c b/twin.c index 826dd9d..cda2a00 100644 --- a/twin.c +++ b/twin.c @@ -15,7 +15,7 @@ static inline int is_wc(char **); /* returns the attributes to draw the current characters with */ static inline int get_attr(const char *, const char *, bool); -static inline char *get_wc(char *, char *); +static inline char *get_wc(char **); static size_t word_length(list_node_t **); static size_t twin_remove_line(TWindow *); static void twin_draw_sentences(TWindow *); @@ -261,14 +261,11 @@ get_attr(const char *iwcs, const char *twcs, bool is_last) } static inline char * -get_wc(char *iwcs, char *twcs) +get_wc(char **chars) { - if (iwcs && *iwcs) { - if (twcs && *twcs && *iwcs != *twcs) - return twcs; - return iwcs; - } - return twcs; + if (!chars[1] || !*chars[1]) + return chars[0]; + return chars[1]; } static size_t @@ -333,7 +330,7 @@ twin_draw_sentences(TWindow *twin) chars[1] = word[1] ? word[1]->val : NULL; while (is_wc(chars)) { /* add the character */ - c = get_wc(chars[0], chars[1]); + c = get_wc(chars); bool last = (word[0]) ? (word[0]->next == NULL) : false; attr = get_attr(chars[0], chars[1], last); if (word_incorrect(word)) -- 2.45.2