aboutsummaryrefslogtreecommitdiff
path: root/ui_statusbar.c
blob: 7db27ccaeb13a7f1ccc2ea94f3b52c873dda0eb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#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)
{
  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) {
    mvwprintw(win, a->y, 0, "bla");
  } else {
    mvprintw(a->y, 0, "bla");
  }
  attroff(a->attrs);
  return (UICB_OK);
}

void
register_statusbar(struct statusbar *a)
{
  register_ui_elt(statusbar_cb, (void *) a, NULL);
}

inline void
set_statusbar_text(struct statusbar *a, const char *text)
{
  strncpy(a->text, text, a->width);
}