~jstnas/tt

6f1e3de2145a7b31f7626b33b94a85d41cb62693 — Justinas Grigas 9 months ago b310a72
feat(twin): is_wc now takes chars
1 files changed, 6 insertions(+), 8 deletions(-)

M twin.c
M twin.c => twin.c +6 -8
@@ 12,7 12,7 @@
#include <grapheme.h>

/* checks if pointer is a valid wide character */
static inline bool is_wc(const char *);
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 *);


@@ 236,12 236,10 @@ twin_input(TWindow *twin)
	return -1;
}

static inline bool
is_wc(const char *wc)
static inline int
is_wc(char **chars)
{
	if (!wc)
		return false;
	return *wc;
	return ((chars[0] && *chars[0]) || (chars[1] && *chars[1]));
}

static inline int


@@ 333,7 331,7 @@ twin_draw_sentences(TWindow *twin)
		/* draw word */
		chars[0] = word[0] ? word[0]->val : NULL;
		chars[1] = word[1] ? word[1]->val : NULL;
		while (is_wc(chars[0]) || is_wc(chars[1])) {
		while (is_wc(chars)) {
			/* add the character */
			c = get_wc(chars[0], chars[1]);
			bool last = (word[0]) ? (word[0]->next == NULL) : false;


@@ 452,7 450,7 @@ word_incorrect(list_node_t **words)
	if (!strcmp(words[0]->val, words[1]->val))
		return false;
	char *wc[2] = {words[0]->val, words[1]->val};
	while (is_wc(wc[0]) || is_wc(wc[1])) {
	while (is_wc(wc)) {
		if (wc[0] && *wc[0] && wc[1] && *wc[1] && *wc[0] != *wc[1])
			return true;
		if (wc[0] && *wc[0])