From patchwork Tue Dec 18 04:40:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wang yanqing X-Patchwork-Id: 1890111 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 83BA63FC81 for ; Tue, 18 Dec 2012 05:04:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750887Ab2LRFEb (ORCPT ); Tue, 18 Dec 2012 00:04:31 -0500 Received: from mail-pb0-f53.google.com ([209.85.160.53]:56780 "EHLO mail-pb0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750858Ab2LRFEa (ORCPT ); Tue, 18 Dec 2012 00:04:30 -0500 X-Greylist: delayed 952 seconds by postgrey-1.27 at vger.kernel.org; Tue, 18 Dec 2012 00:04:29 EST Received: by mail-pb0-f53.google.com with SMTP id jt11so140116pbb.40 for ; Mon, 17 Dec 2012 21:04:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:date:from:to:cc:subject:message-id:mail-followup-to :mime-version:content-type:content-disposition:user-agent; bh=SfMFxSEbdF75Z7vwztpxeFRbeYInwzFqlxF/UuZnfQo=; b=MjW+y6oCcQSkShoH3GDEjUd14R+Uai2cj8GaRJhSdCo+VxQWOROLkIkTZIygc9Z7Kj pzCtTuqNxyMpo/A0mJyk3dD2m25Jb+TjR5UzB4PZpSSaH104G+QRbMysWqkPIQ9I5L7H LfMEU9bl0KnIIYLO5eFx2sFVgLf+gjznqJNMf4Tvb2ZUWtuBwHfHdsSsTKAll6cSOrzG qrS1lTnAPaVUjjkN7PIk+cJRDZndIdXSOQpWNoF+n5yQARWIlOlMWtaB0nrTDja98Lp2 vVVmPpOBHn2yJjVzdMCsoyniIYc4ygX8LGKf52qrIV19FtIgU+kXkMeF5pW1ED/C8icR ijjQ== X-Received: by 10.66.87.8 with SMTP id t8mr3023757paz.28.1355805616527; Mon, 17 Dec 2012 20:40:16 -0800 (PST) Received: from udknight.localhost ([27.154.55.226]) by mx.google.com with ESMTPS id bt2sm677823pab.15.2012.12.17.20.40.08 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 17 Dec 2012 20:40:15 -0800 (PST) Received: from udknight.localhost (udknight.localhost [127.0.0.1]) by udknight.localhost (8.14.4/8.14.4) with ESMTP id qBI4eYGF007494; Tue, 18 Dec 2012 12:40:35 +0800 Received: (from root@localhost) by udknight.localhost (8.14.4/8.14.4/Submit) id qBI4eM6n007486; Tue, 18 Dec 2012 12:40:22 +0800 Date: Tue, 18 Dec 2012 12:40:21 +0800 From: Wang YanQing To: mmarek@suse.cz Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, rdunlap@xenotime.net, bp@alien8.de, yann.morin.1998@free.fr, sakiwit@gmail.com, lacombar@gmail.com, lucas.demarchi@profusion.mobi, dave@gnu.org, paul.gortmaker@windriver.com, crquan@gmail.com, bpoirier@suse.de Subject: [PATCH 1/2 v2] menuconfig: Add Save/Load buttons Message-ID: <20121218044021.GA7475@udknight> Mail-Followup-To: Wang YanQing , mmarek@suse.cz, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, rdunlap@xenotime.net, bp@alien8.de, yann.morin.1998@free.fr, sakiwit@gmail.com, lacombar@gmail.com, lucas.demarchi@profusion.mobi, dave@gnu.org, paul.gortmaker@windriver.com, crquan@gmail.com, bpoirier@suse.de MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org If menuconfig have Save/Load button like alternative .config editors, xconfig, nconfig, etc.We will have a obvious benefit when use menuconfig just like when we use others, we can Save/Load our .config quickly and conveniently. This patch add the Save/Load button for menuconfig. [remove trailing space while at it for below line: "*) Formerly when I used Page Down and Page Up, the cursor would be set" ] Changes: V1-V2: 1:use PATH_MAX instead of hard code suggested by Yann E. MORIN 2:drop the spurious empty-line removal suggested by Yann E. MORIN Signed-off-by: Wang YanQing Reviewed-by: "Yann E. MORIN" Tested-by: "Yann E. MORIN" --- scripts/kconfig/lxdialog/menubox.c | 20 +++++++++++--------- scripts/kconfig/mconf.c | 30 +++++++++++++++++++++++++----- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/scripts/kconfig/lxdialog/menubox.c b/scripts/kconfig/lxdialog/menubox.c index 1d60473..8b534d5 100644 --- a/scripts/kconfig/lxdialog/menubox.c +++ b/scripts/kconfig/lxdialog/menubox.c @@ -26,7 +26,7 @@ * * *) A bugfix for the Page-Down problem * - * *) Formerly when I used Page Down and Page Up, the cursor would be set + * *) Formerly when I used Page Down and Page Up, the cursor would be set * to the first position in the menu box. Now lxdialog is a bit * smarter and works more like other menu systems (just have a look at * it). @@ -154,12 +154,14 @@ static void print_arrows(WINDOW * win, int item_no, int scroll, int y, int x, */ static void print_buttons(WINDOW * win, int height, int width, int selected) { - int x = width / 2 - 16; + int x = width / 2 - 26; int y = height - 2; print_button(win, gettext("Select"), y, x, selected == 0); print_button(win, gettext(" Exit "), y, x + 12, selected == 1); print_button(win, gettext(" Help "), y, x + 24, selected == 2); + print_button(win, gettext(" Save "), y, x + 36, selected == 3); + print_button(win, gettext(" Load "), y, x + 48, selected == 4); wmove(win, y, x + 1 + 12 * selected); wrefresh(win); @@ -372,7 +374,7 @@ do_resize: case TAB: case KEY_RIGHT: button = ((key == KEY_LEFT ? --button : ++button) < 0) - ? 2 : (button > 2 ? 0 : button); + ? 4 : (button > 4 ? 0 : button); print_buttons(dialog, height, width, button); wrefresh(menu); @@ -399,17 +401,17 @@ do_resize: return 2; case 's': case 'y': - return 3; + return 5; case 'n': - return 4; + return 6; case 'm': - return 5; + return 7; case ' ': - return 6; + return 8; case '/': - return 7; + return 9; case 'z': - return 8; + return 10; case '\n': return button; } diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 53975cf..9fb90f0 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -280,6 +280,7 @@ static struct menu *current_menu; static int child_count; static int single_menu_mode; static int show_all_options; +static int save_and_exit; static void conf(struct menu *menu, struct menu *active_menu); static void conf_choice(struct menu *menu); @@ -651,6 +652,12 @@ static void conf(struct menu *menu, struct menu *active_menu) show_helptext(_("README"), _(mconf_readme)); break; case 3: + conf_save(); + break; + case 4: + conf_load(); + break; + case 5: if (item_is_tag('t')) { if (sym_set_tristate_value(sym, yes)) break; @@ -658,24 +665,24 @@ static void conf(struct menu *menu, struct menu *active_menu) show_textbox(NULL, setmod_text, 6, 74); } break; - case 4: + case 6: if (item_is_tag('t')) sym_set_tristate_value(sym, no); break; - case 5: + case 7: if (item_is_tag('t')) sym_set_tristate_value(sym, mod); break; - case 6: + case 8: if (item_is_tag('t')) sym_toggle_tristate_value(sym); else if (item_is_tag('m')) conf(submenu, NULL); break; - case 7: + case 9: search_conf(); break; - case 8: + case 10: show_all_options = !show_all_options; break; } @@ -702,6 +709,17 @@ static void show_helptext(const char *title, const char *text) show_textbox(title, text, 0, 0); } +static void conf_message_callback(const char *fmt, va_list ap) +{ + char buf[PATH_MAX+1]; + + vsnprintf(buf, sizeof(buf), fmt, ap); + if (save_and_exit) + printf("%s", buf); + else + show_textbox(NULL, buf, 6, 60); +} + static void show_help(struct menu *menu) { struct gstr help = str_new(); @@ -870,6 +888,7 @@ static int handle_exit(void) { int res; + save_and_exit = 1; dialog_clear(); if (conf_get_changed()) res = dialog_yesno(NULL, @@ -941,6 +960,7 @@ int main(int ac, char **av) } set_config_filename(conf_get_configname()); + conf_set_message_callback(conf_message_callback); do { conf(&rootmenu, NULL); res = handle_exit();