From: sopwith Date: Tue, 22 Jul 1997 17:21:22 +0000 (+0000) Subject: Redraw fixes. X-Git-Tag: r0-12~54 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aa47774f252c77b49912636ec2571da6bbed7be3;p=thirdparty%2Fnewt.git Redraw fixes. Tiny listbox nav update. --- diff --git a/form.c b/form.c index 06b1ca2..bf7c4a3 100644 --- a/form.c +++ b/form.c @@ -206,6 +206,8 @@ void newtDrawForm(newtComponent co) { struct element * el; int i; + newtDrawCurrentWindow(); + SLsmg_set_color(form->background); newtClearBox(co->left, co->top, co->width, co->height); for (i = 0, el = form->elements; i < form->numComps; i++, el++) { diff --git a/listbox.c b/listbox.c index 23e8f1f..39e6ace 100644 --- a/listbox.c +++ b/listbox.c @@ -461,9 +461,6 @@ static struct eventResult listboxEvent(newtComponent co, struct event ev) { case NEWT_KEY_END: if(li->numItems <= 0) break; - li->currItem = li->numItems - 1; - li->startShowItem = li->numItems - co->height - 1; - newtListboxRealSetCurrent(co); newtListboxSetCurrent(co, li->numItems - 1); er.result = ER_SWALLOWED; break; diff --git a/newt.c b/newt.c index 147ca3a..1c23e9c 100644 --- a/newt.c +++ b/newt.c @@ -14,6 +14,7 @@ struct Window { int height, width, top, left; short * buffer; + char * title; }; struct keymap { @@ -318,6 +319,7 @@ int newtOpenWindow(int left, int top, int width, int height, currentWindow->top = top; currentWindow->width = width; currentWindow->height = height; + currentWindow->title = strdup(title); currentWindow->buffer = malloc(sizeof(short) * (width + 3) * (height + 3)); @@ -331,11 +333,28 @@ int newtOpenWindow(int left, int top, int width, int height, n += currentWindow->width + 3; } + newtDrawCurrentWindow(); + + return 0; +} + +void newtDrawCurrentWindow(void) +{ + int i; + int top, left, height, width; + + if(!currentWindow) return; + + top = currentWindow->top; + left = currentWindow->left; + height = currentWindow->height; + width = currentWindow->width; + SLsmg_set_color(NEWT_COLORSET_BORDER); SLsmg_draw_box(top - 1, left - 1, height + 2, width + 2); - if (title) { - i = strlen(title) + 4; + if (currentWindow->title) { + i = strlen(currentWindow->title) + 4; i = ((width - i) / 2) + left; SLsmg_gotorc(top - 1, i); SLsmg_set_char_set(1); @@ -343,7 +362,7 @@ int newtOpenWindow(int left, int top, int width, int height, SLsmg_set_char_set(0); SLsmg_write_char(' '); SLsmg_set_color(NEWT_COLORSET_TITLE); - SLsmg_write_string(title); + SLsmg_write_string(currentWindow->title); SLsmg_set_color(NEWT_COLORSET_BORDER); SLsmg_write_char(' '); SLsmg_set_char_set(1); @@ -362,8 +381,6 @@ int newtOpenWindow(int left, int top, int width, int height, SLsmg_gotorc(i, left + width + 1); SLsmg_write_string(" "); } - - return 0; } void newtPopWindow(void) { @@ -382,6 +399,7 @@ void newtPopWindow(void) { } free(currentWindow->buffer); + free(currentWindow->title); if (currentWindow == windowStack) currentWindow = NULL; diff --git a/newt_pr.h b/newt_pr.h index 7efa55b..19082c6 100644 --- a/newt_pr.h +++ b/newt_pr.h @@ -23,6 +23,7 @@ void newtGotorc(int row, int col); void newtGetrc(int * row, int * col); void newtDrawBox(int left, int top, int width, int height, int shadow); void newtClearBox(int left, int top, int width, int height); +void newtDrawCurrentWindow(void); int newtGetKey(void);