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 859141384DF for ; Wed, 16 Jan 2013 12:56:54 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 18161E04C8; Wed, 16 Jan 2013 12:56:54 +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 99AA8E04C8 for ; Wed, 16 Jan 2013 12:56:48 +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 7A6BE33D8CC for ; Wed, 16 Jan 2013 12:56:47 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 04C44E408C for ; Wed, 16 Jan 2013 12:56:45 +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: <1358340982.8db257e9c8e2c8fa2bacdf826fc24e00467c7f03.yamakuzure@gentoo> Subject: [gentoo-commits] proj/ufed:master commit in: / X-VCS-Repository: proj/ufed X-VCS-Files: ufed-curses-checklist.c ufed-curses.c ufed-curses.h X-VCS-Directories: / X-VCS-Committer: yamakuzure X-VCS-Committer-Name: Sven Eden X-VCS-Revision: 8db257e9c8e2c8fa2bacdf826fc24e00467c7f03 X-VCS-Branch: master Date: Wed, 16 Jan 2013 12:56:45 +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: 75e4a7ad-a496-433d-9e57-38d81964e00f X-Archives-Hash: b3253a6b9729a762446894c6c75e9864 commit: 8db257e9c8e2c8fa2bacdf826fc24e00467c7f03 Author: Sven Eden gmx de> AuthorDate: Wed Jan 16 12:56:22 2013 +0000 Commit: Sven Eden gmx de> CommitDate: Wed Jan 16 12:56:22 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/ufed.git;a=commit;h=8db257e9 Added the functonality to toggle masked flag display by pressing the tab key. Further added the key description to the bottom display and the current filterstate (normal, masked, all) to the bottom right. --- ufed-curses-checklist.c | 1 + ufed-curses.c | 42 ++++++++++++++++++++++++++++++++++++------ ufed-curses.h | 2 +- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/ufed-curses-checklist.c b/ufed-curses-checklist.c index 2f3432d..b78a773 100644 --- a/ufed-curses-checklist.c +++ b/ufed-curses-checklist.c @@ -32,6 +32,7 @@ static const struct key keys[] = { { '?', mkKey("Help (?)") }, { '\n', mkKey("Save (Return/Enter)") }, { '\033', mkKey("Cancel (Esc)") }, + { '\t', mkKey("Toggle Masked (Tab)") }, { '\0', mkKey("") } }; #undef mkKey diff --git a/ufed-curses.c b/ufed-curses.c index edaef38..d7ff8da 100644 --- a/ufed-curses.c +++ b/ufed-curses.c @@ -208,18 +208,30 @@ static void draw(void) { { char *p = buf; const struct key *key; + const size_t maxAdr = (const size_t)(buf+wWidth(Bottom)-3); *p++ = ' '; for(key=keys; key->key!='\0'; key++) { - int n = (buf+wWidth(Bottom)-3) - p; + size_t n = maxAdr - (size_t)p; if(n > key->length) n = key->length; memcpy(p, key->descr, n); p += n; - *p++ = ' '; - if(p == buf+wWidth(Bottom)-3) + if ((size_t)p == maxAdr) break; + *p++ = ' '; + } + /* If there is enough space, show which kind of flags + * are displayed: normal, masked or all + */ + if ((size_t)p < (maxAdr - 9)) { + memset(p, ' ', maxAdr - 9 - (size_t)p); + p += maxAdr - 9 - (size_t)p; + if (show_unmasked == showMasked) strcpy(p, "[normal]"); + if (show_masked == showMasked) strcpy(p, "[masked]"); + if (show_both == showMasked) strcpy(p, "[ all ]"); + p += 8; } - memset(p, ' ', buf+wWidth(Bottom)-2-p); + memset(p, ' ', maxAdr + 1 - (size_t)p); buf[wWidth(Bottom)-2] = '\0'; } waddstr(w, buf); @@ -434,7 +446,7 @@ int maineventloop( continue; x -= 2; for(key = keys; key->key!='\0'; key++) { - if(x < key->length) { + if((size_t)x < key->length) { event.x -= x; wattrset(win(Bottom), COLOR_PAIR(3) | A_BOLD | A_REVERSE); mvwaddstr(win(Bottom), event.y, event.x, key->descr); @@ -549,7 +561,25 @@ int maineventloop( (*drawitem)(currentitem, TRUE); } break; - + + case '\t': + if (show_masked == showMasked) showMasked = show_unmasked; + else if (show_both == showMasked) showMasked = show_masked; + else if (show_unmasked == showMasked) showMasked = show_both; + currentitem = items; + topy = 0; + draw(); + break; + + case KEY_BTAB: + if (show_masked == showMasked) showMasked = show_both; + else if (show_both == showMasked) showMasked = show_unmasked; + else if (show_unmasked == showMasked) showMasked = show_masked; + currentitem = items; + topy = 0; + draw(); + break; + #ifdef KEY_RESIZE case KEY_RESIZE: resizeterm(LINES, COLS); diff --git a/ufed-curses.h b/ufed-curses.h index 7a97c3e..03bb62a 100644 --- a/ufed-curses.h +++ b/ufed-curses.h @@ -21,7 +21,7 @@ struct item { struct key { char key; const char *descr; - int length; + size_t length; }; extern struct window window[wCount];