[PATCH V2] Menu: add box style entry

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Thu Sep 16 12:00:29 EDT 2010


On 15:55 Thu 16 Sep     , Sascha Hauer wrote:
> On Thu, Sep 16, 2010 at 02:09:56PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > +		} else {
> > > > +			puts("   ");
> > > > +		}
> > > > +		printf(" %d: %-*s", me->num, m->width, me->display);
> > > > +	}
> > > 
> > > I think this could look a bit simpler if we had a
> > > static int printf_menu(int selected, const char *fmt, ...) function.
> > > 'selected' is a better name for the argument. with 'reverse' my first
> > > thought was that it prints backwards...
> > sorry I do not follow
> 
> The print_menu_entry would look simpler like this:
> 
> static void print_menu_entry(struct menu *m, struct menu_entry *me, int selected)
> {
> 	gotoXY(me->num + 1, 3);
> 
> 	if (selected)
> 		printf("\e[7m");
> 
> 	if (me->type == MENU_ENTRY_BOX) {
> 		if (me->box_state)
> 			printf("[*]");
> 		else
> 			printf("[ ]");
> 	} else {
> 		printf("   ");
> 	}
> 
> 	printf(" %d: %-*s", me->num, m->width, me->display);
> 
> 	if (selected)
> 		printf("\e[m");
> }
> 
> I was confused by the name of the printf_reverse macro. For me it was
> not clear what it should do without looking at the macro definition.
ok

Best Regards,
J.



More information about the barebox mailing list