From ee2b7d4faaed16df5ed735ea7e36d4173852e8c3 Mon Sep 17 00:00:00 2001 From: tlatorre Date: Sat, 12 Nov 2022 13:03:50 -0600 Subject: create struct for different alphabets --- vito.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/vito.c b/vito.c index 7df02b4..273216d 100644 --- a/vito.c +++ b/vito.c @@ -37,7 +37,13 @@ GtkTextTag *tag; #define LAUGHING "\xf0\x9f\x98\x84" #define NEWLINE "\xe2\x86\xb5" -const char *alphabet[] = { +typedef struct chars +{ + const char **characters; + int len; +} chars; + +const char *emoji_array[] = { THINKING, THUMBS_UP, THUMBS_DOWN, @@ -50,6 +56,13 @@ const char *alphabet[] = { ROLLING_EYES, //DROPLET, //FOOD, + LEFT_ARROW, + CLEAR_SCREEN, +}; + +chars emoji = { emoji_array, LEN(emoji_array)}; + +const char *alphabet_array[] = { "a", "b", "c", @@ -86,6 +99,10 @@ const char *alphabet[] = { "." }; +chars alphabet = {alphabet_array, LEN(alphabet_array)}; + +chars *current_chars = &emoji; + char buf[100000]; /* The current alphabetical letter. */ @@ -116,7 +133,7 @@ static void write_buf(void) GtkTextIter start, end; text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_widget)); - sprintf(buf+current_position,"%s",alphabet[current_letter % LEN(alphabet)]); + sprintf(buf+current_position,"%s",current_chars->characters[current_letter % current_chars->len]); gtk_text_buffer_set_text(text_buffer, buf, -1); @@ -138,7 +155,7 @@ static int released(GtkWidget *widget, gpointer data) current_position = 0; current_letter = 0; } else if (diff > CLICK_TIME) { - current_char = alphabet[current_letter % LEN(alphabet)]; + current_char = current_chars->characters[current_letter % current_chars->len]; if (!strcmp(current_char,LEFT_ARROW)) { if (current_position > 0) { text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_widget)); -- cgit