aboutsummaryrefslogtreecommitdiff
path: root/apps/exec.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/exec.c')
-rw-r--r--apps/exec.c59
1 files changed, 0 insertions, 59 deletions
diff --git a/apps/exec.c b/apps/exec.c
deleted file mode 100644
index ae7ca35..0000000
--- a/apps/exec.c
+++ /dev/null
@@ -1,59 +0,0 @@
-// MIT License, Copyright (c) 2020 Marvin Borner
-
-#include <gui.h>
-#include <mem.h>
-#include <print.h>
-#include <str.h>
-#include <sys.h>
-
-#define PATH "/bin/"
-
-#define HEIGHT 32
-#define WIDTH 300
-
-void on_submit(struct gui_event_keyboard *event, struct element *elem)
-{
- (void)event;
- struct element_text_input *inp_elem = (struct element_text_input *)elem->data;
- char *inp = inp_elem->text;
-
- // TODO: Support more than one arg
- char *inp_copy = strdup(inp);
- char *space = inp_copy;
- char *arg = NULL;
- if ((space = strchr(space, ' '))) {
- inp[space - inp_copy] = '\0';
- space++;
- arg = space;
- }
- free(inp_copy);
-
- u8 l = strlen(PATH) + strlen(inp) + 1;
- char *final = malloc(l);
- final[0] = '\0';
- strcat(final, PATH);
- strcat(final, inp);
-
- struct stat s = { 0 };
- if (stat(final, &s) == 0 && s.size) {
- inp_elem->color_bg = COLOR_WHITE;
- exec(final, inp, arg, NULL);
- } else {
- inp_elem->color_bg = COLOR_BRIGHT_RED;
- }
- gui_sync(elem);
-}
-
-int main()
-{
- log("exec loaded\n");
- struct element *root = gui_init("Exec", WIDTH, HEIGHT, COLOR_BLACK);
- struct element *input =
- gui_add_text_input(root, 0, 0, 100, FONT_32, COLOR_WHITE, COLOR_BLACK);
-
- input->event.on_submit = on_submit;
-
- gui_event_loop(root);
-
- return 0;
-}