aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ui.c5
-rw-r--r--ui.h8
-rw-r--r--ui_ani.c18
-rw-r--r--ui_ani.h2
-rw-r--r--ui_input.c13
-rw-r--r--ui_input.h2
6 files changed, 26 insertions, 22 deletions
diff --git a/ui.c b/ui.c
index 5d58d28..8b15e3f 100644
--- a/ui.c
+++ b/ui.c
@@ -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);
diff --git a/ui.h b/ui.h
index b75ad41..c6102e6 100644
--- a/ui.h
+++ b/ui.h
@@ -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;
diff --git a/ui_ani.c b/ui_ani.c
index 1fd308a..2ba395b 100644
--- a/ui_ani.c
+++ b/ui_ani.c
@@ -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);
}
diff --git a/ui_ani.h b/ui_ani.h
index 9622885..3fdd090 100644
--- a/ui_ani.h
+++ b/ui_ani.h
@@ -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);
diff --git a/ui_input.c b/ui_input.c
index 28660cf..13a33b0 100644
--- a/ui_input.c
+++ b/ui_input.c
@@ -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);
diff --git a/ui_input.h b/ui_input.h
index 7b3a623..5aaf22c 100644
--- a/ui_input.h
+++ b/ui_input.h
@@ -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);