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 8013D138620 for ; Wed, 23 Jan 2013 12:05:40 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A4983E066B; Wed, 23 Jan 2013 12:05:37 +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 26A40E0667 for ; Wed, 23 Jan 2013 12:05:31 +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 00EE433D835 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 9088DE408F for ; Wed, 23 Jan 2013 12:05:27 +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: <1358871832.673a531ca0855bfb855ca62e82f056b6f5ecd1d6.yamakuzure@gentoo> Subject: [gentoo-commits] proj/ufed:master commit in: / X-VCS-Repository: proj/ufed X-VCS-Files: ufed-curses.c ufed-curses.h X-VCS-Directories: / X-VCS-Committer: yamakuzure X-VCS-Committer-Name: Sven Eden X-VCS-Revision: 673a531ca0855bfb855ca62e82f056b6f5ecd1d6 X-VCS-Branch: master Date: Wed, 23 Jan 2013 12:05:27 +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: dccab25f-554f-4713-8d46-24bba12137d6 X-Archives-Hash: 50c69368e047f6107dd8cd7dda7eb486 commit: 673a531ca0855bfb855ca62e82f056b6f5ecd1d6 Author: Sven Eden gmx de> AuthorDate: Tue Jan 22 16:23:52 2013 +0000 Commit: Sven Eden gmx de> CommitDate: Tue Jan 22 16:23:52 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/ufed.git;a=commit;h=673a531c topline must be handled as statically in regards of a fixed lines list like the former topy. Flexible line display is done beneath this. --- ufed-curses.c | 39 +++++++++++++++++++++------------------ ufed-curses.h | 2 +- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/ufed-curses.c b/ufed-curses.c index 1bb26ca..01f5c7d 100644 --- a/ufed-curses.c +++ b/ufed-curses.c @@ -134,10 +134,10 @@ void drawitems(void) { if (!isLegalItem(currentitem)) { while ((currentitem != items) && !isLegalItem(currentitem)) { currentitem = currentitem->prev; - topline -= getItemHeight(currentitem); + topline -= currentitem->ndescr; } while ((currentitem->next != items) && !isLegalItem(currentitem)) { - topline += getItemHeight(currentitem); + topline += currentitem->ndescr; currentitem = currentitem->next; } } // End of sanitizing currentitem @@ -146,8 +146,10 @@ void drawitems(void) { int line = item->listline - topline; /* move to the top of the displayed list */ - for ( ; (item != items) && ((line > 0) || !isLegalItem(item)); line = item->listline - topline) + while ((item != items) && (line > 0)) { item = item->prev; + line = item->listline - topline; + } /* If the above move ended up with item == items * it must be checked whether to move forwards again. @@ -159,8 +161,9 @@ void drawitems(void) { while (!isLegalItem(item) && (item != items)) { if (currentitem == item) currentitem = item->next; + topline += item->ndescr; item = item->next; - topline += getItemHeight(item); + line = item->listline - topline; } } @@ -330,15 +333,16 @@ static void draw(void) { wrefresh(win(List)); } -void scrollcurrent(void) { +bool scrollcurrent(void) { if(currentitem->listline < topline) topline = max(currentitem->listline, currentitem->listline + currentitem->ndescr - wHeight(List)); else if( (currentitem->listline + currentitem->ndescr) > (topline + wHeight(List))) topline = min(currentitem->listline + currentitem->ndescr - wHeight(List), currentitem->listline); else - return; + return false; drawitems(); drawscrollbar(); + return true; } bool yesno(const char *prompt) { @@ -554,20 +558,19 @@ int maineventloop( switch(c) { case KEY_UP: - if(currentitem->listline < topline ) { - (*drawitem)(currentitem, FALSE); - topline--; - (*drawitem)(currentitem, TRUE); + if(currentitem->currline < 0 ) { + --topline; + drawitems(); + drawscrollbar(); } else setPrevItem(1, true); break; case KEY_DOWN: - if( (currentitem->listline + currentitem->ndescr) > (topline + wHeight(List)) ) { - // Scroll through descriptions if their list is longer than the window - (*drawitem)(currentitem, FALSE); + if( (currentitem->currline + getItemHeight(currentitem)) > wHeight(List) ) { ++topline; - (*drawitem)(currentitem, TRUE); + drawitems(); + drawscrollbar(); } else setNextItem(1, true); break; @@ -691,8 +694,8 @@ void setNextItem(int count, bool strict) if ( (result && strict) || (!strict && skipped) ) { (*drawitem)(currentitem, FALSE); currentitem = curr; - scrollcurrent(); - (*drawitem)(currentitem, TRUE); + if (!scrollcurrent()) + (*drawitem)(currentitem, TRUE); } } @@ -721,8 +724,8 @@ void setPrevItem(int count, bool strict) if ( (result && strict) || (!strict && skipped) ) { (*drawitem)(currentitem, FALSE); currentitem = curr; - scrollcurrent(); - (*drawitem)(currentitem, TRUE); + if (!scrollcurrent()) + (*drawitem)(currentitem, TRUE); } } diff --git a/ufed-curses.h b/ufed-curses.h index 71a4b18..a48dad1 100644 --- a/ufed-curses.h +++ b/ufed-curses.h @@ -68,7 +68,7 @@ int maineventloop( struct item *items, const struct key *keys); void drawitems(void); -void scrollcurrent(void); +bool scrollcurrent(void); bool yesno(const char *);