From c35a83655707c9aae8f728eb850255ad0f115d11 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sat, 31 Oct 2020 21:50:43 +0100 Subject: Added 'exec' demo program --- apps/exec.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 apps/exec.c (limited to 'apps/exec.c') diff --git a/apps/exec.c b/apps/exec.c new file mode 100644 index 0000000..038d2ce --- /dev/null +++ b/apps/exec.c @@ -0,0 +1,29 @@ +#include +#include +#include + +#define HEIGHT 32 +#define WIDTH 300 +#define BORDER 2 + +void on_submit(struct gui_event_keyboard *event, struct element *elem) +{ + (void)event; + char *inp = ((struct element_text_input *)elem->data)->text; + exec(inp, inp, NULL); +} + +int main() +{ + struct element *root = + gui_init("Exec", WIDTH + BORDER * 2, HEIGHT + BORDER * 2, COLOR_BLACK); + struct element *input = + gui_add_text_input(root, BORDER, BORDER, WIDTH, FONT_32, COLOR_WHITE, COLOR_BLACK); + + input->event.on_submit = on_submit; + + gfx_redraw_focused(); // TODO: Remove once partial redrawing is finished + gui_event_loop(root); + + return 0; +} -- cgit v1.2.3