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 33A58138620 for ; Wed, 23 Jan 2013 12:05:39 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A6549E0656; Wed, 23 Jan 2013 12:05:33 +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 239D4E0656 for ; Wed, 23 Jan 2013 12:05:32 +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 2004633DB52 for ; Wed, 23 Jan 2013 12:05:31 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 208C8E4093 for ; Wed, 23 Jan 2013 12:05:28 +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: <1358931701.a688bacb6c21d00fd091e62cf9c07a789741f02a.yamakuzure@gentoo> Subject: [gentoo-commits] proj/ufed:master commit in: / X-VCS-Repository: proj/ufed X-VCS-Files: ufed-curses.c X-VCS-Directories: / X-VCS-Committer: yamakuzure X-VCS-Committer-Name: Sven Eden X-VCS-Revision: a688bacb6c21d00fd091e62cf9c07a789741f02a X-VCS-Branch: master Date: Wed, 23 Jan 2013 12:05:28 +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: 75c8dd57-3faa-4ff7-9b30-6902f2c0dea3 X-Archives-Hash: 47a32b7590da6293b6626c9780ba3869 commit: a688bacb6c21d00fd091e62cf9c07a789741f02a Author: Sven Eden gmx de> AuthorDate: Wed Jan 23 09:01:41 2013 +0000 Commit: Sven Eden gmx de> CommitDate: Wed Jan 23 09:01:41 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/ufed.git;a=commit;h=a688bacb Fixed wrong number of skipped lines using PgUp/PgDn --- ufed-curses.c | 57 ++++++++++++++++++++++++++++++--------------------------- 1 files changed, 30 insertions(+), 27 deletions(-) diff --git a/ufed-curses.c b/ufed-curses.c index 41b84ea..5bfaac4 100644 --- a/ufed-curses.c +++ b/ufed-curses.c @@ -128,21 +128,13 @@ void checktermsize() { } void drawitems() { - /* sanitize currentitem first. - * This is needed, because the currently selected - * item may become invalid when a filter is - * toggled. + /* this method must not be called if the current + * item is not valid. */ - if (!isLegalItem(currentitem)) { - while ((currentitem != items) && !isLegalItem(currentitem)) { - currentitem = currentitem->prev; - topline -= currentitem->ndescr; - } - while ((currentitem->next != items) && !isLegalItem(currentitem)) { - topline += currentitem->ndescr; - currentitem = currentitem->next; - } - } // End of sanitizing currentitem + if (!isLegalItem(currentitem)) + ERROR_EXIT(-1, + "drawitems() must not be called with a filtered currentitem! (topline %d listline %d)\n", + topline, currentitem->listline) struct item *item = currentitem; int line = item->listline - topline; @@ -150,23 +142,20 @@ void drawitems() { /* move to the top of the displayed list */ while ((item != items) && (line > 0)) { item = item->prev; - line = item->listline - topline; + if (isLegalItem(item)) + line -= getItemHeight(item); } /* If the above move ended up with item == items - * it must be checked whether to move forwards again. + * topline and line must be adapted to the current + * item. * This can happen if the flag filter is toggled * and the current item is the first not filtered item. */ if ((item == items) && !isLegalItem(item)) { - item = currentitem; - while (!isLegalItem(item) && (item != items)) { - if (currentitem == item) - currentitem = item->next; - topline += item->ndescr; - item = item->next; - line = item->listline - topline; - } + item = currentitem; + topline = currentitem->listline; + line = 0; } for( ; line < wHeight(List); ) { @@ -185,7 +174,6 @@ void drawitems() { wattrset(win(List), COLOR_PAIR(3)); while(line++ < wHeight(List)) waddstr(win(List), buf); - break; } } wnoutrefresh(win(List)); @@ -695,10 +683,18 @@ void setNextItem(int count, bool strict) // curr is only counted if it is not filtered out: if (isLegalItem(curr)) - ++skipped; + skipped += getItemHeight(curr); + else + // Otherwise topline must be adapted or scrollcurrent() wreaks havoc! + topline += curr->ndescr; } // End of trying to find a next item if ( (result && strict) || (!strict && skipped) ) { + // Move back again if curr ended up being filtered + while (!isLegalItem(curr)) { + topline -= curr->ndescr; + curr = curr->prev; + } drawitem(currentitem, FALSE); currentitem = curr; if (!scrollcurrent()) @@ -725,10 +721,17 @@ void setPrevItem(int count, bool strict) // curr is only counted if it is not filtered out: if (isLegalItem(curr)) - ++skipped; + skipped += getItemHeight(curr); + else + topline -= curr->ndescr; } // End of trying to find next item if ( (result && strict) || (!strict && skipped) ) { + // Move forth again if curr ended up being filtered + while (!isLegalItem(curr)) { + curr = curr->prev; + topline += curr->ndescr; + } drawitem(currentitem, FALSE); currentitem = curr; if (!scrollcurrent())