--- newt-0.52.2/checkboxtree.c.focus 2006-06-08 17:05:42.000000000 +0200 +++ newt-0.52.2/checkboxtree.c 2006-06-08 17:05:42.000000000 +0200 @@ -25,6 +25,7 @@ int sbAdjust; int curWidth; int userHasSetWidth; + int isActive; char * seq; char * result; }; @@ -341,6 +342,7 @@ co->width = 0; co->isMapped = 0; ct->curWidth = 0; + ct->isActive = 0; ct->userHasSetWidth = 0; ct->itemlist = NULL; ct->firstItem = NULL; @@ -462,12 +464,7 @@ while (*item && i < co->height) { newtGotorc(co->top + i, co->left); - if (*item == *ct->currItem) { - SLsmg_set_color(NEWT_COLORSET_ACTLISTBOX); - currRow = co->top + i; - } else - SLsmg_set_color(NEWT_COLORSET_LISTBOX); - + SLsmg_set_color(NEWT_COLORSET_LISTBOX); for (j = 0; j < (*item)->depth; j++) SLsmg_write_string(" "); @@ -479,7 +476,7 @@ } else { if (ct->flags & NEWT_CHECKBOXTREE_HIDE_BOX) { if ((*item)->selected) - SLsmg_set_color(NEWT_COLORSET_ACTLISTBOX); + SLsmg_set_color(NEWT_COLORSET_SELLISTBOX); SLsmg_write_string(" "); } else { char tmp[5]; @@ -487,12 +484,15 @@ SLsmg_write_string(tmp); } } + if (*item == *ct->currItem) { + SLsmg_set_color(ct->isActive ? + NEWT_COLORSET_ACTSELLISTBOX : NEWT_COLORSET_ACTLISTBOX); + currRow = co->top + i; + } SLsmg_write_nstring((*item)->text, co->width - 4 - (3 * (*item)->depth)); - SLsmg_set_color(NEWT_COLORSET_LISTBOX); - item++; i++; } @@ -688,11 +688,13 @@ break; case EV_FOCUS: + ct->isActive = 1; ctDraw(co); er.result = ER_SWALLOWED; break; case EV_UNFOCUS: + ct->isActive = 0; ctDraw(co); er.result = ER_SWALLOWED; break; --- newt-0.52.2/textbox.c.focus 2005-09-30 16:05:55.000000000 +0200 +++ newt-0.52.2/textbox.c 2006-06-08 17:50:19.000000000 +0200 @@ -15,9 +15,10 @@ char *blankline; int linesAlloced; int doWrap; - newtComponent sb; + newtComponent sb_act, sb; int topLine; int textWidth; + int isActive; }; static char * expandTabs(const char * text); @@ -43,8 +44,10 @@ struct textbox * tb = co->data; co->isMapped = isMapped; - if (tb->sb) + if (tb->sb) { tb->sb->ops->mapped(tb->sb, isMapped); + tb->sb_act->ops->mapped(tb->sb_act, isMapped); + } } static void textboxPlace(newtComponent co, int newLeft, int newTop) { @@ -53,8 +56,10 @@ co->top = newTop; co->left = newLeft; - if (tb->sb) + if (tb->sb) { tb->sb->ops->place(tb->sb, co->left + co->width - 1, co->top); + tb->sb_act->ops->place(tb->sb_act, co->left + co->width - 1, co->top); + } } void newtTextboxSetHeight(newtComponent co, int height) { @@ -107,16 +112,20 @@ tb->lines = NULL; tb->topLine = 0; tb->textWidth = width; + tb->isActive = 0; tb->blankline = malloc(width+1); memset(tb->blankline,' ',width); tb->blankline[width] = '\0'; if (flags & NEWT_FLAG_SCROLL) { co->width += 2; + tb->sb_act = newtVerticalScrollbar(co->left + co->width - 1, co->top, + co->height, COLORSET_ACTTEXTBOX, COLORSET_TEXTBOX); tb->sb = newtVerticalScrollbar(co->left + co->width - 1, co->top, co->height, COLORSET_TEXTBOX, COLORSET_TEXTBOX); + co->takesFocus = 1; } else { - tb->sb = NULL; + tb->sb_act = tb->sb = NULL; } return co; @@ -342,8 +351,13 @@ if (tb->sb) { size = tb->numLines - c->height; - newtScrollbarSet(tb->sb, tb->topLine, size ? size : 0); - tb->sb->ops->draw(tb->sb); + if (tb->isActive) { + newtScrollbarSet(tb->sb_act, tb->topLine, size ? size : 0); + tb->sb_act->ops->draw(tb->sb_act); + } else { + newtScrollbarSet(tb->sb, tb->topLine, size ? size : 0); + tb->sb->ops->draw(tb->sb); + } } SLsmg_set_color(NEWT_COLORSET_TEXTBOX); @@ -363,7 +377,11 @@ er.result = ER_IGNORED; - if (ev.when == EV_EARLY && ev.event == EV_KEYPRESS && tb->sb) { + if (!tb->sb || ev.when == EV_EARLY || ev.when == EV_LATE) + return er; + + switch(ev.event) { + case EV_KEYPRESS: newtTrashScreen(); switch (ev.u.key) { case NEWT_KEY_UP: @@ -395,8 +413,8 @@ er.result = ER_SWALLOWED; break; } - } - if (ev.when == EV_EARLY && ev.event == EV_MOUSE && tb->sb) { + break; + case EV_MOUSE: /* Top scroll arrow */ if (ev.u.mouse.x == co->width && ev.u.mouse.y == co->top) { if (tb->topLine) tb->topLine--; @@ -412,6 +430,17 @@ er.result = ER_SWALLOWED; } + break; + case EV_FOCUS: + tb->isActive = 1; + textboxDraw(co); + er.result = ER_SWALLOWED; + break; + case EV_UNFOCUS: + tb->isActive = 0; + textboxDraw(co); + er.result = ER_SWALLOWED; + break; } return er; } --- newt-0.52.2/listbox.c.focus 2005-09-30 16:05:55.000000000 +0200 +++ newt-0.52.2/listbox.c 2006-06-08 17:05:42.000000000 +0200 @@ -518,7 +518,7 @@ newtGotorc(co->top + i + li->bdyAdjust, co->left + li->bdxAdjust); if(j + i == li->currItem) { - if(item->isSelected) + if(li->isActive) SLsmg_set_color(NEWT_COLORSET_ACTSELLISTBOX); else SLsmg_set_color(NEWT_COLORSET_ACTLISTBOX); @@ -529,6 +529,12 @@ SLsmg_write_nstring(item->text, li->curWidth); + if (li->flags & NEWT_FLAG_MULTIPLE) { + newtGotorc(co->top + i + li->bdyAdjust, co->left + li->bdxAdjust); + SLsmg_set_color(item->isSelected ? + NEWT_COLORSET_SELLISTBOX : NEWT_COLORSET_LISTBOX); + SLsmg_write_nstring(item->text, 1); + } } newtGotorc(co->top + (li->currItem - li->startShowItem) + li->bdyAdjust, co->left + li->bdxAdjust); --- newt-0.52.2/form.c.focus 2005-09-21 11:32:01.000000000 +0200 +++ newt-0.52.2/form.c 2006-06-27 14:40:19.000000000 +0200 @@ -1027,8 +1027,17 @@ } } - if (key == NEWT_KEY_F1 && form->helpTag && form->helpCb) + if (key == NEWT_KEY_F1 && form->helpTag && form->helpCb) { + if (form->currComp != -1) { + ev.event = EV_UNFOCUS; + sendEvent(form->elements[form->currComp].co, ev); + } form->helpCb(co, form->helpTag); + if (form->currComp != -1) { + ev.event = EV_FOCUS; + sendEvent(form->elements[form->currComp].co, ev); + } + } if (!done) { ev.event = EV_KEYPRESS;