diff -urN cui78/cui_test.c cui79/cui_test.c --- cui78/cui_test.c Wed Mar 26 22:00:00 2014 +++ cui79/cui_test.c Wed Mar 26 23:00:00 2014 @@ -376,6 +376,15 @@ } int +bs_term_hdr(cui obj, int evt, int val, void *prm) +{ + /* CUI_EVT_RESIZE */ + cui term = (cui)prm; + cui_wh_set(term, obj->w, obj->h-2); + return TRUE; +} + +int main() { cui bs = cui_scpanel_new(NULL, 0, 0, 42, 23, "cui_test"); @@ -428,6 +437,8 @@ cui_hide(bs_term); cui_bind(btn_term, CUI_EVT_BUTTON, btn_term_hdr, term); cui_wh_fit(bs_term); + cui_rszbox_new(bs_term); + cui_bind(bs_term, CUI_EVT_RESIZE, bs_term_hdr, term); cui_tab_new(bs, 1, 1, -1, (char *[]){"foo", "bar", "hoge", "term", NULL}, tab_sheets, 0); diff -urN cui78/term.c cui79/term.c --- cui78/term.c Wed Mar 26 22:00:00 2014 +++ cui79/term.c Wed Mar 26 23:00:00 2014 @@ -28,6 +28,8 @@ p->update_all = FALSE; p->esc_buf_n = 0; + p->ow = obj->w; + p->oh = obj->h; cui_bind(obj, CUI_EVT_DRAW|CUI_EVT_RESIZE, cui_term_hdr, NULL); } @@ -83,16 +85,53 @@ p->update_all = FALSE; } +static void +hdr_resize(cui obj) +{ + cui_term p = (cui_term)obj; + struct cui_term ot; + cui o = (cui)&ot; + int x, y; + char *s, *d; + + ot = *p; /* buf share */ + o->w = ot.ow; + o->h = ot.oh; + + cui_term_buf_alloc(obj); + p->ow = obj->w; + p->oh = obj->h; + + for(y=0; yh; y++){ + if(y >= o->h) continue; + for(x=0; xw; x++){ + if(x >= o->w) continue; + s = cui_term_buf(o, x, y); + d = cui_term_buf(obj, x, y); + d[0] = s[0]; + d[1] = s[1]; + } + } + cui_term_buf_free(o); + + if(p->cx >= obj->w) p->cx = obj->w - 1; + if(p->cy >= obj->h) p->cy = obj->h - 1; +} + int cui_term_hdr(cui obj, int evt, int val, void *prm) { + cui_term p = (cui_term)obj; + switch(evt){ case CUI_EVT_DRAW: + p->update_all =TRUE; hdr_update(obj); return TRUE; case CUI_EVT_RESIZE: - // ... - break; + if(p->ow == obj->w && p->oh == obj->h) return TRUE; + hdr_resize(obj); + return TRUE; } return FALSE; } @@ -332,7 +371,7 @@ void cui_term_update(cui obj) { - cui_handler_call(obj, CUI_EVT_DRAW, 0); + hdr_update(obj); } /* EOF */ diff -urN cui78/term.h cui79/term.h --- cui78/term.h Wed Mar 26 22:00:00 2014 +++ cui79/term.h Wed Mar 26 23:00:00 2014 @@ -14,6 +14,7 @@ char esc_buf[16]; int esc_buf_n; + int ow, oh; } *cui_term; cui cui_term_new(cui parent, int x, int y, int w, int h);