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 3B7E3138620 for ; Wed, 23 Jan 2013 12:05:43 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A1A24E066E; Wed, 23 Jan 2013 12:05:38 +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 14BCBE066E for ; Wed, 23 Jan 2013 12:05:37 +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 0EE6C33DB2D 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 D1772E4091 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: <1358877870.23f8640b5cb3f8b6058b7e7f49a74453adae2b86.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 X-VCS-Directories: / X-VCS-Committer: yamakuzure X-VCS-Committer-Name: Sven Eden X-VCS-Revision: 23f8640b5cb3f8b6058b7e7f49a74453adae2b86 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: 492e318c-4194-42da-8b30-8fa57c843d7b X-Archives-Hash: cb9d47b6a378f6d0e71d187292e7fa56 commit: 23f8640b5cb3f8b6058b7e7f49a74453adae2b86 Author: Sven Eden gmx de> AuthorDate: Tue Jan 22 18:04:30 2013 +0000 Commit: Sven Eden gmx de> CommitDate: Tue Jan 22 18:04:30 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/ufed.git;a=commit;h=23f8640b Fix scrollbar --- ufed-curses-checklist.c | 7 ++++++- ufed-curses.c | 26 ++++++++++++++------------ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/ufed-curses-checklist.c b/ufed-curses-checklist.c index 1df84b3..4518375 100644 --- a/ufed-curses-checklist.c +++ b/ufed-curses-checklist.c @@ -61,7 +61,7 @@ int lineCountLocalInstalled; int lineCountMasked; int lineCountMaskedInstalled; int lineCountMasked; -extern int minwidth; +extern int bottomline, minwidth; /* static functions */ static char *getline(FILE *fp) { @@ -272,11 +272,16 @@ static void read_flags(void) { flags->item.prev = (struct item *) flag; } } // loop while input given + fclose(input); + if(flags==NULL) { fputs("No input!\n", stderr); exit(-1); } + + // Save the last line, it is needed in several places + bottomline = lineNum; } static void free_flags(void) { diff --git a/ufed-curses.c b/ufed-curses.c index 01f5c7d..0ce279d 100644 --- a/ufed-curses.c +++ b/ufed-curses.c @@ -25,7 +25,7 @@ static struct item *items, *currentitem; /* external members */ -int topline, minwidth; +int topline, bottomline, minwidth; extern enum mask showMasked; extern enum order pkgOrder; extern enum scope showScope; @@ -38,7 +38,10 @@ extern int lineCountMasked; /* internal prototypes */ -static void checktermsize(void); +int (*drawitem)(struct item *, bool); +void checktermsize(); +void draw(); +void drawscrollbar(); int getListHeight(); void resetDisplay(); void setNextItem(int count, bool strict); @@ -79,7 +82,7 @@ int getListHeight() } -void initcurses(void) { +void initcurses() { setlocale(LC_CTYPE, ""); initscr(); start_color(); @@ -100,14 +103,14 @@ void initcurses(void) { } } } -void cursesdone(void) { +void cursesdone() { enum win w; for(w = (enum win) 0; w != wCount; w++) delwin(window[w].win); endwin(); } -static void checktermsize(void) { +void checktermsize() { while(wHeight(List) < 1 || wWidth(List) < minwidth) { #ifdef KEY_RESIZE @@ -123,9 +126,7 @@ static void checktermsize(void) { } } -static int (*drawitem)(struct item *, bool); - -void drawitems(void) { +void drawitems() { /* sanitize currentitem first. * This is needed, because the currently selected * item may become invalid when a filter is @@ -189,7 +190,7 @@ void drawitems(void) { wnoutrefresh(win(List)); } -static void drawscrollbar(void) { +void drawscrollbar() { WINDOW *w = win(Scrollbar); wattrset(w, COLOR_PAIR(3) | A_BOLD); mvwaddch(w, 0, 0, ACS_UARROW); @@ -203,8 +204,9 @@ static void drawscrollbar(void) { // Only show a scrollbar if the list is actually longer than can be displayed: if (listHeight > wHeight(List)) { int sbHeight = wHeight(Scrollbar) - 3; - int barStart = 1 + (sbHeight / listHeight); + int barStart = 1 + (currentitem->listline * sbHeight / bottomline); int barEnd = barStart + (sbHeight * wHeight(List) / listHeight); + for ( ; barStart <= barEnd; ++barStart) mvwaddch(w, barStart, 0, ACS_BLOCK); } @@ -214,7 +216,7 @@ static void drawscrollbar(void) { wnoutrefresh(w); } -static void draw(void) { +void draw() { size_t bufsize = COLS+1; char buf[bufsize]; WINDOW *w; @@ -333,7 +335,7 @@ static void draw(void) { wrefresh(win(List)); } -bool scrollcurrent(void) { +bool scrollcurrent() { if(currentitem->listline < topline) topline = max(currentitem->listline, currentitem->listline + currentitem->ndescr - wHeight(List)); else if( (currentitem->listline + currentitem->ndescr) > (topline + wHeight(List)))