aboutsummaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMarvin Borner2020-11-29 22:17:41 +0100
committerMarvin Borner2020-11-29 22:17:41 +0100
commita80021fa96b07d4ae26d9f85099f4bce09a8f5b3 (patch)
treeb3a95aeb91d783de999e22cc825395957c511f23 /apps
parentcb9816c78f25ecc8736cd97c11c839a4c18bcf76 (diff)
Big steps towards working window resizing
Found some other bugs too
Diffstat (limited to 'apps')
-rw-r--r--apps/browser.c7
-rw-r--r--apps/exec.c12
2 files changed, 13 insertions, 6 deletions
diff --git a/apps/browser.c b/apps/browser.c
index ca2ab23..c7c303f 100644
--- a/apps/browser.c
+++ b/apps/browser.c
@@ -17,7 +17,6 @@
#define FONT_HEIGHT 24
#define LABEL_WIDTH 36 // Thx Lars
-static struct element *root;
static struct element *code_label;
static struct element *output;
@@ -101,15 +100,15 @@ void on_submit(void *event, struct element *box)
c->text = strdup("000");
c->color_fg = COLOR_RED;
}
- gui_sync(root, output);
- gui_sync(root, code_label);
+ gui_sync(output);
+ gui_sync(code_label);
net_close(socket);
}
int main()
{
// TODO: Dynamic element positioning
- root = gui_init("browser", WIDTH, HEIGHT, COLOR_BG);
+ struct element *root = gui_init("browser", WIDTH, HEIGHT, COLOR_BG);
code_label = gui_add_label(root, 0, 0, FONT_24, "000", COLOR_BLACK, COLOR_WHITE);
struct element *text_input =
gui_add_text_input(root, LABEL_WIDTH, 0, 100, FONT_24, COLOR_WHITE, COLOR_BLACK);
diff --git a/apps/exec.c b/apps/exec.c
index 51aef91..726544d 100644
--- a/apps/exec.c
+++ b/apps/exec.c
@@ -14,7 +14,8 @@
void on_submit(struct gui_event_keyboard *event, struct element *elem)
{
(void)event;
- char *inp = ((struct element_text_input *)elem->data)->text;
+ 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);
@@ -31,7 +32,14 @@ void on_submit(struct gui_event_keyboard *event, struct element *elem)
char *final = malloc(l);
strcat(final, PATH);
strcat(final, inp);
- exec(final, inp, arg, NULL);
+
+ if (stat(final)) {
+ inp_elem->color_bg = COLOR_WHITE;
+ exec(final, inp, arg, NULL);
+ } else {
+ inp_elem->color_bg = COLOR_BRIGHT_RED;
+ }
+ gui_sync(elem);
}
int main()