summaryrefslogtreecommitdiff
path: root/command.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-01-18 16:37:51 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-01-18 16:37:51 -0500
commita3adbe5ea6015a76a3df84ee5942b89fbb762947 (patch)
tree712d0fdfaf23818ebf2b361306dbb9d4452e6540 /command.c
parent37102a766e1913cd0548a981e5c601852ae47963 (diff)
opening files kinda working
Diffstat (limited to 'command.c')
-rw-r--r--command.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/command.c b/command.c
index 6a6b331..684d30a 100644
--- a/command.c
+++ b/command.c
@@ -115,7 +115,7 @@ void command_execute(Ted *ted, Command c, i64 argument) {
break;
case CMD_OPEN:
- ted_menu_open(ted, MENU_OPEN);
+ menu_open(ted, MENU_OPEN);
break;
case CMD_SAVE:
if (buffer) buffer_save(buffer);
@@ -144,11 +144,35 @@ void command_execute(Ted *ted, Command c, i64 argument) {
case CMD_ESCAPE:
if (ted->menu) {
- ted_menu_close(ted, true);
+ menu_close(ted, true);
} else if (buffer) {
buffer_disable_selection(buffer);
}
break;
+ case CMD_SUBMIT_LINE_BUFFER:
+ if (buffer->is_line_buffer) {
+ switch (ted->menu) {
+ case MENU_NONE:
+ assert(0);
+ break;
+ case MENU_OPEN: {
+ TextBuffer *open_to = &ted->main_buffer;
+ String32 filename32 = {.str = buffer->lines[0].str, .len = buffer->lines[0].len};
+
+ char *filename_cstr = str32_to_utf8_cstr(filename32);
+ if (filename_cstr) {
+ buffer_load_file(open_to, filename_cstr);
+ buffer = open_to;
+ if (buffer_haserr(open_to)) {
+ // @TODO: something better
+ }
+ free(filename_cstr);
+ menu_close(ted, true);
+ }
+ } break;
+ }
+ }
+ break;
}
if (buffer && buffer_haserr(buffer)) {