diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2020-12-19 00:03:33 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2020-12-19 00:03:38 -0500 |
commit | 9ec5a4752523fe4aa45cc19557370ad8b180d046 (patch) | |
tree | c6f9b7f36844ef329ac40f95794a0273cb5ac177 /main.c | |
parent | ba559cc360162e02cfc79885637c9247bcecc0d8 (diff) |
better errors, saving
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 17 |
1 files changed, 9 insertions, 8 deletions
@@ -68,14 +68,8 @@ int main(void) { TextBuffer text_buffer; buffer_create(&text_buffer, font); - { - FILE *fp = fopen("test.txt", "rb"); - assert(fp); - bool success = buffer_load_file(&text_buffer, fp); - fclose(fp); - if (!success) - die("Error loading file."); - } + if (!buffer_load_file(&text_buffer, "test.txt")) + die("Error loading file: %s", buffer_geterr(&text_buffer)); Uint32 time_at_last_frame = SDL_GetTicks(); @@ -141,6 +135,13 @@ int main(void) { else buffer_backspace_at_cursor(&text_buffer, 1); break; + case SDLK_s: + if (ctrl) { + if (!buffer_save(&text_buffer)) { + printf("Error saving: %s.", buffer_geterr(&text_buffer)); + } + } + break; } } break; case SDL_TEXTINPUT: { |