aboutsummaryrefslogtreecommitdiff
path: root/ui_statusbar.c
diff options
context:
space:
mode:
authortoni <matzeton@googlemail.com>2015-11-08 20:28:30 +0100
committertoni <matzeton@googlemail.com>2015-11-11 22:53:07 +0100
commitf2f6ea5029c6c43dc43d714978daca38c03a8a83 (patch)
tree745932f072a5c0246a3a3fb19ad341dcba401eed /ui_statusbar.c
parent5b73c45d46f33610fa1d99c6467e24fa7861075d (diff)
- changed dir structure
- fixed ipc semaphore/mq stuff
Diffstat (limited to 'ui_statusbar.c')
-rw-r--r--ui_statusbar.c78
1 files changed, 0 insertions, 78 deletions
diff --git a/ui_statusbar.c b/ui_statusbar.c
deleted file mode 100644
index 8fcfeb4..0000000
--- a/ui_statusbar.c
+++ /dev/null
@@ -1,78 +0,0 @@
-#include <stdlib.h>
-#include <string.h>
-
-#include "ui.h"
-#include "ui_statusbar.h"
-
-
-struct statusbar *
-init_statusbar(unsigned int y, unsigned int width, chtype attrs, status_func cb_update)
-{
- struct statusbar *a = calloc(1, sizeof(struct statusbar));
-
- a->y = y;
- a->width = width;
- a->text = calloc(a->width, sizeof(char));
- a->attrs = attrs;
- a->status_func = cb_update;
- 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;
- char *tmp;
- unsigned int diff_pos = 0;
- size_t len;
-
- if (a == NULL) return (UICB_ERR_UNDEF);
- if (timed_out == true) {
- if (a->status_func != NULL) {
- a->status_func(win, a);
- }
- }
- attron(a->attrs);
- len = strnlen(a->text, a->width);
- if (len < a->width) {
- diff_pos = (unsigned int) (a->width - len)/2;
- }
- tmp = (char *) malloc(a->width + 1);
- memset(tmp, ' ', a->width);
- tmp[a->width] = '\0';
- strncpy((tmp + diff_pos), a->text, len);
- if (win != NULL) {
- mvwprintw(win, a->y, 0, tmp);
- } else {
- mvprintw(a->y, 0, tmp);
- }
- free(tmp);
- attroff(a->attrs);
- return (UICB_OK);
-}
-
-void
-register_statusbar(struct statusbar *a)
-{
- struct ui_callbacks cbs;
- cbs.ui_element = statusbar_cb;
- cbs.ui_input = NULL;
- register_ui_elt(&cbs, (void *) a, NULL);
-}
-
-inline void
-set_statusbar_text(struct statusbar *a, const char *text)
-{
- size_t len = strlen(text);
-
- strncpy(a->text, text, (len > a->width ? a->width : len));
-}