diff options
-rw-r--r-- | ui_statusbar.c | 54 | ||||
-rw-r--r-- | ui_statusbar.h | 29 |
2 files changed, 83 insertions, 0 deletions
diff --git a/ui_statusbar.c b/ui_statusbar.c new file mode 100644 index 0000000..5e3607f --- /dev/null +++ b/ui_statusbar.c @@ -0,0 +1,54 @@ +#include <stdlib.h> + +#include "ui.h" +#include "ui_statusbar.h" + + +struct statusbar * +init_statusbar(unsigned int y, unsigned int width, chtype attrs) +{ + struct statusbar *a = calloc(1, sizeof(struct statusbar)); + + a->y = y; + a->width = width; + a->text = calloc(width, sizeof(char)); + a->attrs = attrs; + return (a); +} + +void +free_statusbar(struct statusbar *a) +{ + if (a->text) { + free(a->text); + } + free(a); +} + +int +statusbar_cb(WINDOW *win, void *data, bool timed_out) +{ + struct statusbar *a = (struct statusbar *) data; + + if (a == NULL) return (UICB_ERR_UNDEF); + if (timed_out == true) { + } + attron(a->attrs); + if (win != NULL) { + } else { + } + attroff(a->attrs); + return (UICB_OK); +} + +void +register_statusbar(struct statusbar *a) +{ + register_ui_elt(statusbar_cb, (void *) a, NULL); +} + +void +set_statusbar_text(struct statusbar *a, const char *text) +{ + +} diff --git a/ui_statusbar.h b/ui_statusbar.h new file mode 100644 index 0000000..334505a --- /dev/null +++ b/ui_statusbar.h @@ -0,0 +1,29 @@ +#ifndef UI_STATUSBAR_H +#define UI_STATUSBAR_H 1 + +#include <ncurses.h> + + +struct statusbar { + unsigned int y; + unsigned int width; + char *text; + chtype attrs; +}; + +struct statusbar * +init_statusbar(unsigned int y, unsigned int width, chtype attrs); + +void +free_statusbar(struct statusbar *a); + +int +statusbar_cb(WINDOW *win, void *data, bool timed_out); + +void +register_statusbar(struct statusbar *a); + +void +set_statusbar_text(struct statusbar *a, const char *text); + +#endif |