diff options
-rw-r--r-- | ui.c | 5 | ||||
-rw-r--r-- | ui.h | 8 | ||||
-rw-r--r-- | ui_ani.c | 18 | ||||
-rw-r--r-- | ui_ani.h | 2 | ||||
-rw-r--r-- | ui_input.c | 13 | ||||
-rw-r--r-- | ui_input.h | 2 |
6 files changed, 26 insertions, 22 deletions
@@ -37,7 +37,6 @@ register_ui_elt(ui_callback uicb, void *data, WINDOW *wnd) } new = calloc(1, sizeof(struct nask_ui)); new->ui_elt_cb = uicb; - new->do_update = true; new->wnd = wnd; new->data = data; new->next = NULL; @@ -82,7 +81,7 @@ do_ui_update(bool timed_out) while (cur != NULL) { if (cur->ui_elt_cb != NULL) { pthread_mutex_lock(&mtx_cb); - cur->ui_elt_cb(cur->wnd, cur->data, cur->do_update, timed_out); + cur->ui_elt_cb(cur->wnd, cur->data, timed_out); doupdate(); pthread_mutex_unlock(&mtx_cb); } else { @@ -105,7 +104,7 @@ ui_thrd(void *arg) gettimeofday(&now, NULL); wait.tv_sec = now.tv_sec + UILOOP_TIMEOUT; wait.tv_nsec = now.tv_usec * 1000; - do_ui_update(false); + do_ui_update(true); sem_post(&sem_rdy); while (active == true) { pthread_mutex_unlock(&mtx_busy); @@ -6,9 +6,8 @@ #define UICB_OK 0 #define UICB_ERR_UNDEF 1 -#define UICB_ERR_NOP 2 -#define UICB_ERR_CB 3 -#define UICB_ERR_BUF 4 +#define UICB_ERR_CB 2 +#define UICB_ERR_BUF 3 #define UILOOP_TIMEOUT 1 @@ -21,11 +20,10 @@ #define UIKEY_RIGHT 5 -typedef int (*ui_callback)(WINDOW *, void *, bool, bool); +typedef int (*ui_callback)(WINDOW *, void *, bool); struct nask_ui { ui_callback ui_elt_cb; - bool do_update; WINDOW *wnd; void *data; struct nask_ui *next; @@ -25,7 +25,7 @@ free_anic(struct anic *a) } int -anic_cb(WINDOW *win, void *data, bool needs_update, bool timed_out) +anic_cb(WINDOW *win, void *data, bool timed_out) { struct anic *a = (struct anic *) data; @@ -39,15 +39,13 @@ anic_cb(WINDOW *win, void *data, bool needs_update, bool timed_out) case '\\': a->state = '|'; break; } } - if (needs_update == true) { - attron(a->attrs); - if (win != NULL) { - mvwaddch(win, a->y, a->x, a->state); - } else { - mvaddch(a->y, a->x, a->state); - } - attroff(a->attrs); - } else return (UICB_ERR_NOP); + attron(a->attrs); + if (win != NULL) { + mvwaddch(win, a->y, a->x, a->state); + } else { + mvaddch(a->y, a->x, a->state); + } + attroff(a->attrs); return (UICB_OK); } @@ -18,7 +18,7 @@ void free_anic(struct anic *a); int -anic_cb(WINDOW *win, void *data, bool needs_update, bool timed_out); +anic_cb(WINDOW *win, void *data, bool timed_out); void register_anic(struct anic *a); @@ -104,16 +104,25 @@ add_input(WINDOW *win, struct input *a, int key) int del_input(WINDOW *win, struct input *a) { + if (a == NULL) return (UICB_ERR_UNDEF); + memmove((a->input + a->input_pos - 1), (a->input + a->input_pos), a->input_max - a->input_pos); + --a->input_len; + if (a->input_pos == a->input_len) { + --a->input_pos; + } + print_input(win, a); + mvwprintw(win, 10, 1, "w:%d,cp:%d,im:%lu,il:%lu,ip:%lu,s:%s", a->width, a->cur_pos, a->input_max, a->input_len, a->input_pos, a->input); + return (UICB_OK); } int -input_cb(WINDOW *win, void *data, bool needs_update, bool timed_out) +input_cb(WINDOW *win, void *data, bool timed_out) { struct input *a = (struct input *) data; if (a == NULL) return (UICB_ERR_UNDEF); - if (needs_update || timed_out) { + if (timed_out == true) { print_input(win, a); } return (UICB_OK); @@ -33,7 +33,7 @@ int del_input(WINDOW *win, struct input *a); int -input_cb(WINDOW *win, void *data, bool needs_update, bool timed_out); +input_cb(WINDOW *win, void *data, bool timed_out); void register_input(WINDOW *win, struct input *a); |