X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;ds=sidebyside;f=src%2Ftui.c;h=7f20e9480de46054c7287328095c242af39c23b8;hb=e603acae4b6cf020307b149f9874bf41d1da5337;hp=2a4d4315b831bbd9c84a9a452720299694c4023c;hpb=c65c4562a19c45eda17d7d672afe15f5c8ce5fec;p=oftp diff --git a/src/tui.c b/src/tui.c index 2a4d431..7f20e94 100644 --- a/src/tui.c +++ b/src/tui.c @@ -79,6 +79,11 @@ struct tui_widget *tui_parent(struct tui_widget *w) return w->par; } +int tui_isdirty(struct tui_widget *w) +{ + return w->dirty; +} + void tui_draw(struct tui_widget *w) { struct tui_widget *iter; @@ -86,6 +91,7 @@ void tui_draw(struct tui_widget *w) if(w->cbfunc[TUI_DRAW]) { w->cbfunc[TUI_DRAW](w, 0); } + w->dirty = 0; iter = w->child; while(iter) { @@ -102,6 +108,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);