diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2021-01-19 10:22:52 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2021-01-19 10:22:52 -0500 |
commit | 7ba80aaa38c95fdb84cd8fb51d51b5d897c5de95 (patch) | |
tree | 3bc8daa12db1b25301e775967f2b423386f11e9b /command.c | |
parent | 8a4984e0e15fcfb0be6db242ab3f60325b80abd8 (diff) |
opening files by clicking on them
Diffstat (limited to 'command.c')
-rw-r--r-- | command.c | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -156,16 +156,13 @@ void command_execute(Ted *ted, Command c, i64 argument) { assert(0); break; case MENU_OPEN: { - TextBuffer *open_to = &ted->main_buffer; char *filename_cstr = str32_to_utf8_cstr(buffer_get_line(&ted->line_buffer, 0)); if (filename_cstr) { - buffer_load_file(open_to, filename_cstr); - buffer = open_to; - if (buffer_haserr(open_to)) { - // @TODO: something - } + buffer = ted_open_file(ted, filename_cstr); free(filename_cstr); - menu_close(ted, true); + menu_close(ted, false); + } else { + ted_seterr(ted, "Out of memory."); } } break; } @@ -174,7 +171,7 @@ void command_execute(Ted *ted, Command c, i64 argument) { } if (buffer && buffer_haserr(buffer)) { - strncpy(ted->error, buffer_geterr(buffer), sizeof ted->error - 1); + ted_seterr_to_buferr(ted, buffer); buffer_clearerr(buffer); } } |