From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 2AB45138202 for ; Tue, 10 Sep 2013 06:36:43 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B1121E09F6; Tue, 10 Sep 2013 06:36:39 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 1F63DE09C2 for ; Tue, 10 Sep 2013 06:36:39 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 2E37C33EB20 for ; Tue, 10 Sep 2013 06:36:38 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 24E9FE5465 for ; Tue, 10 Sep 2013 06:36:35 +0000 (UTC) From: "Sven Eden" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sven Eden" Message-ID: <1378790885.5f5e7e3b80f211c76d2f3872f063c288f34fa780.yamakuzure@gentoo> Subject: [gentoo-commits] proj/ufed:master commit in: / X-VCS-Repository: proj/ufed X-VCS-Files: ufed-curses-checklist.c X-VCS-Directories: / X-VCS-Committer: yamakuzure X-VCS-Committer-Name: Sven Eden X-VCS-Revision: 5f5e7e3b80f211c76d2f3872f063c288f34fa780 X-VCS-Branch: master Date: Tue, 10 Sep 2013 06:36:35 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: ca407fd8-e90a-41ff-9e3b-9ec3b39a2095 X-Archives-Hash: 52f9539e95509bec6dff93891846b472 commit: 5f5e7e3b80f211c76d2f3872f063c288f34fa780 Author: Sven Eden gmx net> AuthorDate: Tue Sep 10 05:28:05 2013 +0000 Commit: Sven Eden gmx de> CommitDate: Tue Sep 10 05:28:05 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/ufed.git;a=commit;h=5f5e7e3b If read only mode is set, both Enter and ESC help show "Exit" and the key presses show a correct prompt. --- ufed-curses-checklist.c | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/ufed-curses-checklist.c b/ufed-curses-checklist.c index 1586263..5d7179e 100644 --- a/ufed-curses-checklist.c +++ b/ufed-curses-checklist.c @@ -18,21 +18,6 @@ static size_t maxDescWidth = 0; static char* lineBuf = NULL; static sFlag* flags = NULL; -#define mkKey(x) x, sizeof(x)-1 -static const sKey keys[] = { - { '?', mkKey("?: Help"), 0 }, - { '\n', mkKey("Enter: Save"), 0 }, - { '\033', mkKey("Esc: Cancel"), 0 }, - { -1, mkKey("Toggle"), 1 }, - { KEY_F(5), mkKey("F5: Local/Global"), 1 }, - { KEY_F(6), mkKey("F6: Installed"), 1 }, - { KEY_F(7), mkKey("F7: Masked/Forced"), 1 }, - { KEY_F(9), mkKey("F9: Pkg/Desc Order"), 1 }, - { '\0', mkKey(""), 0 } -}; -#undef mkKey - - /* internal prototypes */ static void free_flags(void); @@ -432,11 +417,17 @@ static int callback(sFlag** curr, int key) break; case '\n': case KEY_ENTER: - if(yesno("Save and exit? (Y/N) ")) + if (ro_mode) { + if (yesno("Exit? (Y/N) ")) + return 0; + } else if (yesno("Save and exit? (Y/N) ")) return 0; break; case '\033': - if(yesno("Cancel? (Y/N) ")) + if (ro_mode) { + if (yesno("Exit? (Y/N) ")) + return 0; + } else if (yesno("Cancel? (Y/N) ")) return 1; break; case ' ': @@ -627,6 +618,25 @@ int main(void) initcurses(); + /* The keys to use differ whether ro_mode is true or false */ +#define mkKey(x) x, sizeof(x)-1 + sKey keys[] = { + { '?', mkKey("?: Help"), 0 }, + { '\n', mkKey(ro_mode ? + "Enter: Exit" + : "Enter: Save"), 0 }, + { '\033', mkKey(ro_mode ? + "Esc: Exit" + : "Esc: Cancel"), 0 }, + { -1, mkKey("Toggle"), 1 }, + { KEY_F(5), mkKey("F5: Local/Global"), 1 }, + { KEY_F(6), mkKey("F6: Installed"), 1 }, + { KEY_F(7), mkKey("F7: Masked/Forced"), 1 }, + { KEY_F(9), mkKey("F9: Pkg/Desc Order"), 1 }, + { '\0', mkKey(""), 0 } + }; +#undef mkKey + result = maineventloop(ro_mode ? subtitle_ro : subtitle_rw, &callback, &drawflag, flags, keys, true);