Message ID | 1314776773-9560-7-git-send-email-crquan@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hi. On Wed, Aug 31, 2011 at 10:46 AM, Cheng Renquan <crquan@gmail.com> wrote: > When the string is too long, only show the first COLS/2 bytes wide, > to make sure there is some space to show the menu prompt. > > Signed-off-by: Cheng Renquan <crquan@gmail.com> > --- > scripts/kconfig/nconf.c | 8 +++++++- > 1 files changed, 7 insertions(+), 1 deletions(-) > > diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c > index 4248759..4997ebf 100644 > --- a/scripts/kconfig/nconf.c > +++ b/scripts/kconfig/nconf.c > @@ -887,8 +887,14 @@ static void build_conf(struct menu *menu) > break; > default: > tmp = 2 + strlen(sym_get_string_value(sym)); > - item_make(menu, 's', " (%s)", > + if (tmp < COLS/2) > + item_make(menu, 's', " (%s)", > sym_get_string_value(sym)); > + else { > + char *s = strndupa(sym_get_string_value(sym), COLS/2); > + strcpy(s + COLS/2 - 5, " ..."); > + item_make(menu, 's', " (%s)", s); > + } > tmp = indent - tmp + 4; > if (tmp < 0) > tmp = 0; > -- > 1.7.6 > > Nack. I see several problems with this approach: 1) I do not like the use of strdupa. 2) I think it would be better to put this behavior in item_make(), as it will then be applied to all items, in all code paths. However, I a not sure that using COLS/2 is the best approach. Moreover, I think that this should be implemented inside the ncurses menu library and not worked around. Care to create a patch for ncurses? Cheers, Nir. -- To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index 4248759..4997ebf 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c @@ -887,8 +887,14 @@ static void build_conf(struct menu *menu) break; default: tmp = 2 + strlen(sym_get_string_value(sym)); - item_make(menu, 's', " (%s)", + if (tmp < COLS/2) + item_make(menu, 's', " (%s)", sym_get_string_value(sym)); + else { + char *s = strndupa(sym_get_string_value(sym), COLS/2); + strcpy(s + COLS/2 - 5, " ..."); + item_make(menu, 's', " (%s)", s); + } tmp = indent - tmp + 4; if (tmp < 0) tmp = 0;
When the string is too long, only show the first COLS/2 bytes wide, to make sure there is some space to show the menu prompt. Signed-off-by: Cheng Renquan <crquan@gmail.com> --- scripts/kconfig/nconf.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)