aboutsummaryrefslogtreecommitdiff
path: root/ui_input.c
blob: 44ce318d60592fd01051503d87e378317977950d (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
#include <stdlib.h>

#include "ui.h"
#include "ui_input.h"


struct input *
init_input(bool box, bool shadow, char *prompt, size_t input_len)
{
  struct input *a = calloc(1, sizeof(struct input));

  a->box = box;
  a->shadow = shadow;
  a->input = calloc(input_len+1, sizeof(char));
  a->input_len = input_len;
  a->prompt = prompt;
  return (a);
}

void
free_input(struct input *a)
{
  if (a->input != NULL) {
    free(a->input);
  }
  free(a);
}

int
input_cb(WINDOW *win, void *data, bool needs_update)
{
  struct input *a = (struct input *) data;

  if (a == NULL) return (UICB_ERR_UNDEF);
mvaddch(7,1,'A');
wrefresh(win);
refresh();
  return (UICB_OK);
}

void
register_input(unsigned int x, unsigned int y, unsigned int width, unsigned int height, struct input *a, chtype attr)
{
  WINDOW *wnd = newwin(height, width, y, x);
  box(wnd, 0, 0);
wrefresh(wnd);
  register_ui_elt(input_cb, (void *) a, wnd, attr);
}