diff options
author | tlatorre <tlatorre@uchicago.edu> | 2022-11-12 16:46:57 -0800 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2022-11-12 16:46:57 -0800 |
commit | 389ed1929cd0de17e533b98b0d3b51c8535110e9 (patch) | |
tree | 3b70e4f280cf9cd3f36a14624f9d4a69f63c1f79 | |
parent | a30c97080502c3d7c0b7f5aeae390e596bde181a (diff) | |
download | moji-389ed1929cd0de17e533b98b0d3b51c8535110e9.tar.gz moji-389ed1929cd0de17e533b98b0d3b51c8535110e9.tar.bz2 moji-389ed1929cd0de17e533b98b0d3b51c8535110e9.zip |
add more comments
-rw-r--r-- | moji.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -219,21 +219,33 @@ static int pressed(GtkWidget *widget, gpointer data) return TRUE; } +/* Timer function which runs every 10 ms. This function checks if the left + * mouse button is clicked, and if so, checks if it's been clicked for more + * than CLICK_TIME milliseconds. If so, it adds the current character to the + * buffer and sets processed to TRUE, so that when the mouse button is released + * it doesn't move to the next character. + * + * Always returns TRUE to make sure the function keeps running. */ gboolean timer(gpointer data) { const char *current_char; + /* If the left mouse button isn't clicked, there is nothing to do. */ if (left_click_pressed == FALSE) return TRUE; aeGetTime(&released_time_sec,&released_time_msec); long long diff = (released_time_sec - pressed_time_sec)*1000 + (released_time_msec - pressed_time_msec); if (diff > 10000) { + /* If the mouse button has been clicked for more than 10 seconds, clear + * the screen. */ current_position = 0; current_letter = 0; processed = TRUE; aeGetTime(&pressed_time_sec,&pressed_time_msec); } else if (diff > CLICK_TIME) { + /* If the mouse button has been clicked for more than CLICK_TIME + * milliseconds, add the current character to the buffer. */ current_char = current_chars->characters[current_letter % current_chars->len]; if (!strcmp(current_char,LEFT_ARROW)) { backspace(); |