download, progress, improved screen updates...
[oftp] / src / tui.c
index 1cdad05..3ad62eb 100644 (file)
--- a/src/tui.c
+++ b/src/tui.c
@@ -79,6 +79,11 @@ struct tui_widget *tui_parent(struct tui_widget *w)
        return w->par;
 }
 
+void tui_invalidate(struct tui_widget *w)
+{
+       w->dirty = 1;
+}
+
 int tui_isdirty(struct tui_widget *w)
 {
        return w->dirty;
@@ -108,6 +113,24 @@ void tui_set_callback(struct tui_widget *w, int type, tui_callback func, void *c
        w->cbcls[type] = cls;
 }
 
+void tui_call_callback(struct tui_widget *w, int type)
+{
+       if(w->cbfunc[type]) {
+               w->cbfunc[type](w, w->cbcls[type]);
+       }
+}
+
+void tui_focus(struct tui_widget *w, int focus)
+{
+       focus = focus ? 1 : 0;
+       if(w->focus == focus) {
+               return;
+       }
+       w->focus = focus;
+       w->dirty = 1;
+       tui_call_callback(w, TUI_ONFOCUS);
+}
+
 int tui_set_title(struct tui_widget *w, const char *s)
 {
        free(w->title);
@@ -188,9 +211,6 @@ void tui_status(int type, const char *fmt, ...)
 void tui_vstatus(int type, const char *fmt, va_list ap)
 {
        /* TODO */
-       tg_color(15);
-       tg_bgcolor(0);
-       tg_vtext(0, 25, fmt, ap);
 }
 
 void tui_msgbox(int type, const char *title, const char *msg, ...)
@@ -204,7 +224,4 @@ void tui_msgbox(int type, const char *title, const char *msg, ...)
 void tui_vmsgbox(int type, const char *title, const char *msg, va_list ap)
 {
        /* TODO */
-       tg_color(15);
-       tg_bgcolor(0);
-       tg_vtext(0, 25, msg, ap);
 }