aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortlatorre <tlatorre@uchicago.edu>2022-11-12 13:03:50 -0600
committertlatorre <tlatorre@uchicago.edu>2022-11-12 13:03:50 -0600
commitee2b7d4faaed16df5ed735ea7e36d4173852e8c3 (patch)
tree28ee294af0be636aa9b8510be475d96f726fba47
parent895ff3f3ed5f7c93d33e2c280e57e697143002bf (diff)
downloadmoji-ee2b7d4faaed16df5ed735ea7e36d4173852e8c3.tar.gz
moji-ee2b7d4faaed16df5ed735ea7e36d4173852e8c3.tar.bz2
moji-ee2b7d4faaed16df5ed735ea7e36d4173852e8c3.zip
create struct for different alphabets
-rw-r--r--vito.c23
1 files 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));