summaryrefslogtreecommitdiff
path: root/menu.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-03-03 15:09:49 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-03-03 15:09:49 -0500
commita1646d84127a199fdacb6c5500d96e8829ebe8c1 (patch)
treeeb7d59e50813108105a5bc4539191a3b008a320d /menu.c
parentd5488ef5c47878e04045a91d204cf1ccbdd9cd05 (diff)
:shell, bugfixes
Diffstat (limited to 'menu.c')
-rw-r--r--menu.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/menu.c b/menu.c
index 868a4a4..24a9af8 100644
--- a/menu.c
+++ b/menu.c
@@ -32,6 +32,9 @@ static void menu_close(Ted *ted) {
buffer_clear(&ted->argument_buffer);
free(selector->entries); selector->entries = NULL; selector->n_entries = 0;
} break;
+ case MENU_SHELL:
+ buffer_clear(&ted->line_buffer);
+ break;
}
ted->menu = MENU_NONE;
ted->selector_open = NULL;
@@ -79,6 +82,9 @@ static void menu_open(Ted *ted, Menu menu) {
selector->enable_cursor = true;
selector->cursor = 0;
} break;
+ case MENU_SHELL:
+ ted_switch_to_buffer(ted, &ted->line_buffer);
+ break;
}
}
@@ -288,6 +294,15 @@ static void menu_update(Ted *ted) {
}
free(search_term);
} break;
+ case MENU_SHELL:
+ if (line_buffer->line_buffer_submitted) {
+ char *command = str32_to_utf8_cstr(buffer_get_line(line_buffer, 0));
+ menu_close(ted);
+ strbuf_cpy(ted->build_dir, ted->cwd);
+ build_start_with_command(ted, command);
+ free(command);
+ }
+ break;
}
}
@@ -405,5 +420,27 @@ static void menu_render(Ted *ted) {
text_render(font_bold);
} break;
+ case MENU_SHELL: {
+ float line_buffer_height = char_height;
+
+ bounds.size.y = line_buffer_height + 2 * padding;
+ rect_coords(bounds, &x1, &y1, &x2, &y2);
+
+ gl_geometry_rect(bounds, colors[COLOR_MENU_BG]);
+ gl_geometry_rect_border(bounds, settings->border_thickness, colors[COLOR_BORDER]);
+ gl_geometry_draw();
+
+ x1 += padding;
+ y1 += padding;
+ x2 -= padding;
+ y2 -= padding;
+
+ char const *text = "Run";
+ text_utf8(font_bold, text, x1, y1, colors[COLOR_TEXT]);
+ x1 += text_get_size_v2(font_bold, text).x + padding;
+ text_render(font_bold);
+
+ buffer_render(&ted->line_buffer, rect4(x1, y1, x2, y2));
+ } break;
}
}