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 DBA37138623 for ; Wed, 23 Jan 2013 12:05:31 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 11CE1E062D; Wed, 23 Jan 2013 12:05:31 +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 631EBE064B for ; Wed, 23 Jan 2013 12:05:30 +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 3289033DB52 for ; Wed, 23 Jan 2013 12:05:29 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 2CB30E4086 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: <1358803405.ffa22db238235c70dc4c7cd12434ec78d39ed01e.yamakuzure@gentoo> Subject: [gentoo-commits] proj/ufed:master commit in: / X-VCS-Repository: proj/ufed X-VCS-Files: ufed-curses-checklist.c ufed-curses-help.c ufed-curses.c ufed-curses.h X-VCS-Directories: / X-VCS-Committer: yamakuzure X-VCS-Committer-Name: Sven Eden X-VCS-Revision: ffa22db238235c70dc4c7cd12434ec78d39ed01e 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: 5c8e8fc2-d0f7-44da-8bbb-63a2d6730d1b X-Archives-Hash: b206f552c3bb64b447f97f102d7a0e58 commit: ffa22db238235c70dc4c7cd12434ec78d39ed01e Author: Sven Eden gmx de> AuthorDate: Mon Jan 21 21:23:25 2013 +0000 Commit: Sven Eden gmx de> CommitDate: Mon Jan 21 21:23:25 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/ufed.git;a=commit;h=ffa22db2 Rewrote the core displaying routines to use the static list of lines for the general organization, but determine the real display line number of each displayed flag in a flexible way. Variable line counts of flags with multiple descriptions are not scrolling correctly, yet. This has to be fixed. Once fully functional, the new drawing allows a much easier filtering of the displayed flags. It will no longer be neccessary to have the masked flags being at the front of the list. --- ufed-curses-checklist.c | 97 +++++++++++++------- ufed-curses-help.c | 10 +- ufed-curses.c | 229 ++++++++++++++++++++++++++++------------------- ufed-curses.h | 5 +- 4 files changed, 207 insertions(+), 134 deletions(-) diff --git a/ufed-curses-checklist.c b/ufed-curses-checklist.c index 11de724..ae2a3e3 100644 --- a/ufed-curses-checklist.c +++ b/ufed-curses-checklist.c @@ -55,8 +55,13 @@ static void free_flags(void); enum mask showMasked = show_unmasked; //!< Set whether to show masked, unmasked or both flags enum order pkgOrder = pkgs_left; //!< Set whether to display package lists left or right of the description enum scope showScope = show_all; //!< Set whether global, local or all flags are shown -int firstNormalY = -1; //!< y of first not masked flag -extern int topy, minwidth; +int lineCountGlobal; +int lineCountLocal; +int lineCountLocalInstalled; +int lineCountMasked; +int lineCountMaskedInstalled; +int lineCountMasked; +extern int minwidth; /* static functions */ static char *getline(FILE *fp) { @@ -99,14 +104,22 @@ static char *getline(FILE *fp) { } static void read_flags(void) { - FILE *input = fdopen(3, "r"); - int y = 0; - char *line = NULL; + FILE *input = fdopen(3, "r"); + int lineNum = 0; + char *line = NULL; if(input == NULL) ERROR_EXIT(-1, "fdopen failed with error %d\n", errno); atexit(&free_flags); + // Initialize line count per type: + lineCountGlobal = 0; + lineCountLocal = 0; + lineCountLocalInstalled = 0; + lineCountMasked = 0; + lineCountMaskedInstalled = 0; + lineCountMasked = 0; + for(;;) { struct { int start, end; @@ -144,7 +157,8 @@ static void read_flags(void) { ERROR_EXIT(-1, "Can not allocate %lu bytes for descr array\n", ndescr * sizeof(char*)); /* note position and name of the flag */ - flag->item.top = y; + flag->item.listline = lineNum; + flag->item.currline = 0; if(name.end - name.start + 11 > minwidth) minwidth = name.end - name.start + 11; @@ -167,7 +181,7 @@ static void read_flags(void) { strncpy(flag->state, &line[state.start], 4); /* check and set flag item height */ - flag->item.height = ndescr; + flag->item.ndescr = ndescr; /* read description(s) and determine flag status */ flag->item.isMasked = false; @@ -196,16 +210,26 @@ static void read_flags(void) { // Set general state of the flag flag->isInstalled[i] = false; - if ('g' == descState) + if ('g' == descState) { flag->item.isGlobal = true; - else if ('L' == descState) + ++lineCountGlobal; + } + else if ('l' == descState) { + ++lineCountLocal; + } + else if ('L' == descState) { flag->isInstalled[i] = true; + ++lineCountLocalInstalled; + } else if ('M' == descState) { flag->item.isMasked = true; flag->isInstalled[i] = true; + ++lineCountMaskedInstalled; } - else if ('m' == descState) + else if ('m' == descState) { flag->item.isMasked = true; + ++lineCountMasked; + } // Save packages if (pkgs.start > -1) { @@ -231,13 +255,10 @@ static void read_flags(void) { size_t fullWidth = 1 + strlen(flag->descr[i]) + (flag->pkgs[i] ? strlen(flag->pkgs[i] + 3) : 0); if (fullWidth > maxDescWidth) maxDescWidth = fullWidth; - } // loop through description lines - /* record first not masked y if not done, yet */ - if (firstNormalY < 0 && !flag->item.isMasked) - firstNormalY = flag->item.top; - - y += ndescr; + // Advance lineNum + ++lineNum; + } // loop through description lines /* Save flag in our linked list */ if(flags==NULL) { @@ -266,7 +287,7 @@ static void free_flags(void) { flag->item.prev->next = NULL; do { void *p = flag; - for (int i = 0; i < flag->item.height; ++i) { + for (int i = 0; i < flag->item.ndescr; ++i) { if (flag->pkgs[i]) free(flag->pkgs[i]); if (flag->descr[i]) free(flag->descr[i]); } @@ -290,12 +311,12 @@ static int drawflag(struct item *item, bool highlight) { struct flag *flag = (struct flag *) item; char buf[wWidth(List)+1]; char desc[maxDescWidth]; - int y = flag->item.top - topy; - int idx = 0; + int idx = 0; int usedY = 0; + int line = flag->item.currline; // Return early if there is nothing to display: - if (!isLegalItem(item)) + if (!isLegalItem(&flag->item)) return 0; /* Determine with which description to start. @@ -303,11 +324,16 @@ static int drawflag(struct item *item, bool highlight) { * and therefore must be scrolled instead of the flags * themselves. */ - if(y < 0 && (-y < flag->item.height)) { - idx = -y; - y = 0; + if (line < 0) { + if (-line < getItemHeight(&flag->item)) { + idx = -line; + line = 0; + } else + // Otherwise this item is out of the display area + return 0; } - wmove(win(List), y, 0); + + wmove(win(List), line, 0); /* print the selection, name and state of the flag */ sprintf(buf, " %c%c%c %s%s%s%-*s %-4.4s ", @@ -328,7 +354,7 @@ static int drawflag(struct item *item, bool highlight) { /* print descriptions according to filters * TODO: Implement installed/all filters */ - if(idx < flag->item.height) { + if(idx < flag->item.ndescr) { for(;;) { // Filter global description if it is not wanted: if (!idx && (show_local == showScope) && flag->item.isGlobal) { @@ -374,10 +400,10 @@ static int drawflag(struct item *item, bool highlight) { // Finally put the line on the screen waddstr(win(List), buf); - y++; - idx++; - usedY++; - if((idx < flag->item.height) && (y < wHeight(List)) ) { + ++line; + ++idx; + ++usedY; + if((idx < flag->item.ndescr) && (line < wHeight(List)) ) { char *p; for(p = buf; p != buf + minwidth; p++) *p = ' '; @@ -391,7 +417,7 @@ static int drawflag(struct item *item, bool highlight) { waddstr(win(List), buf); } if(highlight) - wmove(win(List), max(flag->item.top - topy, 0), 2); + wmove(win(List), max(flag->item.currline, 0), 2); wnoutrefresh(win(List)); return usedY; } @@ -472,7 +498,7 @@ static int callback(struct item **currentitem, int key) { mvwaddstr(win(Input), 0, 0, fayt); whline(win(Input), ' ', 2); if(n==0) { - wmove(win(List), (*currentitem)->top-topy, 2); + wmove(win(List), (*currentitem)->currline, 2); wnoutrefresh(win(Input)); wrefresh(win(List)); } else { @@ -508,7 +534,7 @@ static int callback(struct item **currentitem, int key) { } if (*currentitem != &flags->item) { drawflag(*currentitem, TRUE); - wmove(win(List), (*currentitem)->top-topy, 2); + wmove(win(List), (*currentitem)->currline, 2); wrefresh(win(List)); } else { drawitems(); @@ -519,13 +545,13 @@ static int callback(struct item **currentitem, int key) { if(descriptionleft>0) descriptionleft--; drawflag(*currentitem, TRUE); - wmove(win(List), (*currentitem)->top-topy, 2); + wmove(win(List), (*currentitem)->currline, 2); wrefresh(win(List)); break; case KEY_RIGHT: descriptionleft++; drawflag(*currentitem, TRUE); - wmove(win(List), (*currentitem)->top-topy, 2); + wmove(win(List), (*currentitem)->currline, 2); wrefresh(win(List)); break; #ifdef NCURSES_MOUSE_VERSION @@ -547,7 +573,7 @@ static int callback(struct item **currentitem, int key) { } if (*currentitem != &flags->item) { drawflag(*currentitem, TRUE); - wmove(win(List), (*currentitem)->top-topy, 2); + wmove(win(List), (*currentitem)->currline, 2); wrefresh(win(List)); } else { drawitems(); @@ -600,3 +626,4 @@ int main(void) { return result; } + diff --git a/ufed-curses-help.c b/ufed-curses-help.c index fff79f5..5a12712 100644 --- a/ufed-curses-help.c +++ b/ufed-curses-help.c @@ -11,7 +11,7 @@ #include #include -extern int topy; +extern int topline; static struct line { struct item item; @@ -123,8 +123,8 @@ static void init_lines(void) { lines->item.prev->next = (struct item *) line; lines->item.prev = (struct item *) line; } - line->item.top = y++; - line->item.height = 1; + line->item.listline = y++; + line->item.ndescr = 1; n = strlen(word); if(n > helpwidth-1) { for(n = helpwidth-1; word[n]!=' '; n--) { @@ -180,9 +180,9 @@ static int drawline(struct item *item, bool highlight) { wattrset(win(List), COLOR_PAIR(3)); else wattrset(win(List), COLOR_PAIR(3) | A_BOLD | A_REVERSE); - mvwaddstr(win(List), line->item.top-topy, 0, buf); + mvwaddstr(win(List), line->item.currline, 0, buf); if(highlight) - wmove(win(List), line->item.top-topy, 0); + wmove(win(List), line->item.currline, 0); wnoutrefresh(win(List)); return 1; } diff --git a/ufed-curses.c b/ufed-curses.c index 1e9b232..1bb26ca 100644 --- a/ufed-curses.c +++ b/ufed-curses.c @@ -25,21 +25,60 @@ static struct item *items, *currentitem; /* external members */ -int topy, minwidth; +int topline, minwidth; extern enum mask showMasked; extern enum order pkgOrder; extern enum scope showScope; -extern int firstNormalY; +extern int lineCountGlobal; +extern int lineCountLocal; +extern int lineCountLocalInstalled; +extern int lineCountMasked; +extern int lineCountMaskedInstalled; +extern int lineCountMasked; /* internal prototypes */ static void checktermsize(void); +int getListHeight(); void resetDisplay(); void setNextItem(int count, bool strict); void setPrevItem(int count, bool strict); /* internal functions */ +/** @brief return the number of lines the full item display needs +**/ +int getItemHeight(struct item *item) +{ + // TODO : Add filtering and possible line break + return item->ndescr; +} + + +/** @brief get the sum of lines the list holds respecting current filtering +**/ +int getListHeight() +{ + int result = 0; + + if (show_unmasked != showMasked) { + // TODO : add installed/not installed filter + result += lineCountMasked + lineCountMaskedInstalled; + } + if (show_masked != showMasked) { + if (show_global != showScope) { + // TODO : add installed/not installed filter + result += lineCountLocal + lineCountLocalInstalled; + } + if (show_local != showScope) { + result += lineCountGlobal; + } + } + + return result; +} + + void initcurses(void) { setlocale(LC_CTYPE, ""); initscr(); @@ -87,49 +126,63 @@ static void checktermsize(void) { static int (*drawitem)(struct item *, bool); void drawitems(void) { + /* sanitize currentitem first. + * This is needed, because the currently selected + * item may become invalid when a filter is + * toggled. + */ + if (!isLegalItem(currentitem)) { + while ((currentitem != items) && !isLegalItem(currentitem)) { + currentitem = currentitem->prev; + topline -= getItemHeight(currentitem); + } + while ((currentitem->next != items) && !isLegalItem(currentitem)) { + topline += getItemHeight(currentitem); + currentitem = currentitem->next; + } + } // End of sanitizing currentitem + struct item *item = currentitem; - int y = item->top - topy; + int line = item->listline - topline; /* move to the top of the displayed list */ - for ( ; (y > 0) && item; y = item->top - topy) + for ( ; (item != items) && ((line > 0) || !isLegalItem(item)); line = item->listline - topline) item = item->prev; - /* advance in the list if the top item would be a masked - * flag that is to be filtered out. - * This is needed in two situations. First at the very start - * of the program and second whenever the filtering is - * toggled. The latter resets the list position to guarantee - * a valid display. + /* If the above move ended up with item == items + * it must be checked whether to move forwards again. + * This can happen if the flag filter is toggled + * and the current item is the first not filtered item. */ - if ((show_unmasked == showMasked) && item->isMasked) { - while (item && item->isMasked) { + if ((item == items) && !isLegalItem(item)) { + item = currentitem; + while (!isLegalItem(item) && (item != items)) { if (currentitem == item) currentitem = item->next; - topy += item->height; - item = item->next; + item = item->next; + topline += getItemHeight(item); } } - for(;;) { - if(item!=currentitem) - y += (*drawitem)(item, FALSE); - else - y += item->height; + for( ; line < wHeight(List); ) { + item->currline = line; // drawitem() and maineventloop() need this + line += (*drawitem)(item, item == currentitem ? TRUE : FALSE); item = item->next; - if(y >= wHeight(List)) - break; - if(item==items) { + + /* Add blank lines if we reached the end of the + * flag list, but not the end of the display. + */ + if((line < wHeight(List)) && (item == items)) { char buf[wWidth(List)]; memset(buf, ' ', wWidth(List)); buf[wWidth(List)] = '\0'; - wmove(win(List), y, 0); + wmove(win(List), line, 0); wattrset(win(List), COLOR_PAIR(3)); - while(y++ < wHeight(List)) + while(line++ < wHeight(List)) waddstr(win(List), buf); break; } } - (*drawitem)(currentitem, TRUE); wnoutrefresh(win(List)); } @@ -142,25 +195,12 @@ static void drawscrollbar(void) { /* The scrollbar location differs related to the * current filtering of masked flags. */ - int bottomY = items->prev->top + items->prev->height; - // Case 1: Masked flags are not displayed (the default) - int listHeight = bottomY - firstNormalY; - int listTopY = topy - firstNormalY; - if (show_masked == showMasked) { - // Case 2: Only masked flags are displayed - listHeight = firstNormalY; - listTopY = topy; - } - else if (show_both == showMasked) { - // case 3: All flags are shown - listHeight = bottomY; - listTopY = topy; - } + int listHeight = getListHeight(); // 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 * listTopY / listHeight); + int barStart = 1 + (sbHeight / listHeight); int barEnd = barStart + (sbHeight * wHeight(List) / listHeight); for ( ; barStart <= barEnd; ++barStart) mvwaddch(w, barStart, 0, ACS_BLOCK); @@ -291,10 +331,10 @@ static void draw(void) { } void scrollcurrent(void) { - if(currentitem->top < topy) - topy = max(currentitem->top, currentitem->top + currentitem->height - wHeight(List)); - else if( (currentitem->top + currentitem->height) > (topy + wHeight(List))) - topy = min(currentitem->top + currentitem->height - wHeight(List), currentitem->top); + 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; drawitems(); @@ -327,7 +367,7 @@ bool yesno(const char *prompt) { window[w].win = newwin(wHeight(w), wWidth(w), wTop(w), wLeft(w)); } } /* this won't work for the help viewer, but it doesn't use yesno() */ - topy = 0; + topline = 0; scrollcurrent(); draw(); wattrset(win(Input), COLOR_PAIR(4) | A_BOLD | A_REVERSE); @@ -363,7 +403,7 @@ int maineventloop( _keys=temp; } currentitem = items; - topy = 0; + topline = 0; draw(); @@ -395,14 +435,14 @@ int maineventloop( if(wmouse_trafo(win(List), &event.y, &event.x, FALSE)) { if(event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED)) { struct item *item = currentitem; - if(currentitem->top-topy > event.y) { + if(currentitem->currline > event.y) { do item = item->prev; while((item==items ? item=NULL, 0 : 1) - && item->top-topy > event.y); - } else if(currentitem->top-topy+currentitem->height-1 < event.y) { + && item->currline > event.y); + } else if(currentitem->currline + getItemHeight(currentitem) - 1 < event.y) { do item = item->next; while((item->next==items ? item=NULL, 0 : 1) - && item->top-topy+item->height-1 < event.y); + && item->currline + getItemHeight(item) - 1 < event.y); } if(item==NULL) continue; @@ -417,10 +457,15 @@ int maineventloop( (*drawitem)(currentitem, TRUE); } } else if(wmouse_trafo(win(Scrollbar), &event.y, &event.x, FALSE)) { - if( (event.bstate & (BUTTON1_PRESSED | BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED)) + // Only do mouse events if there actually is a scrollbar + int listHeight = getListHeight(); + if( (listHeight > wHeight(List)) + && (event.bstate & (BUTTON1_PRESSED | BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED)) && (event.y < wHeight(Scrollbar)-1) ) { + int sbHeight = wHeight(Scrollbar) - 3; + int barStart = 1 + (sbHeight / listHeight); + int barEnd = barStart + (sbHeight * wHeight(List) / listHeight); halfdelay(1); - #define SIM(key) \ { \ c = KEY_ ## key; \ @@ -428,50 +473,48 @@ int maineventloop( mousekey = c; \ goto check_key; \ } - if(items->prev->top+items->prev->height > wHeight(List)) - {} - else if(event.y == 0) + if(event.y == 0) SIM(UP) else if(event.y == wHeight(Scrollbar)-2) SIM(DOWN) - else if(event.y-1 < (wHeight(Scrollbar)-3)*topy/(items->prev->top+items->prev->height-(wHeight(List)-1))) + else if( (event.y - 1) < barStart) SIM(PPAGE) - else if(event.y-1 > (wHeight(Scrollbar)-3)*topy/(items->prev->top+items->prev->height-(wHeight(List)-1))) + else if( (event.y - 1) > barEnd) SIM(NPAGE) #undef SIM - else - if(event.bstate & BUTTON1_PRESSED) { - for(;;) { - c = getch(); - switch(c) { - case ERR: - continue; - case KEY_MOUSE: - if(getmouse(&event)==OK) { - event.y -= wTop(Scrollbar)+1; - if(event.y>=0 && event.yprev->top+items->prev->height-(wHeight(List)-1))+(wHeight(Scrollbar)-4))/(wHeight(Scrollbar)-3); - while(currentitem!=items - && currentitem->prev->top >= topy) - currentitem = currentitem->prev; - while(currentitem->next!=items - && currentitem->top < topy) - currentitem = currentitem->next; - if(currentitem->top+currentitem->height > topy+wHeight(List)) - topy = currentitem->top+currentitem->height - wHeight(List); - drawitems(); - drawscrollbar(); - wrefresh(win(List)); - } + else if(event.bstate & BUTTON1_PRESSED) { + for(;;) { + c = getch(); + switch(c) { + case ERR: + continue; + case KEY_MOUSE: + if(getmouse(&event)==OK) { + event.y -= wTop(Scrollbar) + 1; + if( (event.y >= 0) && (event.y < sbHeight) ) { + topline = (event.y * (listHeight - sbHeight + 2) + sbHeight - 1) / sbHeight; + // was: topy = (event.y*(items->prev->top+items->prev->height-(wHeight(List)-1))+(wHeight(Scrollbar)-4))/(wHeight(Scrollbar)-3); + while( (currentitem != items) + && (currentitem->prev->listline >= topline) ) + currentitem = currentitem->prev; + while( (currentitem->next != items) + && (currentitem->listline < topline) ) + currentitem = currentitem->next; + if( (currentitem->listline + currentitem->ndescr) > (topline + wHeight(List)) ) + topline = currentitem->listline + currentitem->ndescr - wHeight(List); + drawitems(); + drawscrollbar(); + wrefresh(win(List)); } - break; - default: - goto check_key; } break; + default: + goto check_key; } + break; } - } + } // End of alternate scrollbar event + } // End of having a scrollbar } else if(wmouse_trafo(win(Bottom), &event.y, &event.x, FALSE)) { if( (event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED)) && (event.y == 1) ) { @@ -511,19 +554,19 @@ int maineventloop( switch(c) { case KEY_UP: - if(currentitem->top < topy ) { + if(currentitem->listline < topline ) { (*drawitem)(currentitem, FALSE); - topy--; + topline--; (*drawitem)(currentitem, TRUE); } else setPrevItem(1, true); break; case KEY_DOWN: - if( (currentitem->top + currentitem->height) > (topy + wHeight(List)) ) { + if( (currentitem->listline + currentitem->ndescr) > (topline + wHeight(List)) ) { // Scroll through descriptions if their list is longer than the window (*drawitem)(currentitem, FALSE); - topy++; + ++topline; (*drawitem)(currentitem, TRUE); } else setNextItem(1, true); @@ -584,7 +627,7 @@ int maineventloop( window[w].win = newwin(wHeight(w), wWidth(w), wTop(w), wLeft(w)); } } if(result==-1) { - topy = 0; + topline = 0; scrollcurrent(); } else items = currentitem; @@ -603,7 +646,7 @@ exit: if(items!=NULL) { currentitem = items; - topy = 0; + topline = 0; draw(); } @@ -619,7 +662,7 @@ void resetDisplay() currentitem = items; while (!isLegalItem(currentitem)) currentitem = currentitem->next; - topy = currentitem->top; + topline = currentitem->listline; draw(); } @@ -692,7 +735,7 @@ bool isLegalItem(struct item *item) ( ( item->isMasked && (show_unmasked != showMasked)) || (!item->isMasked && (show_masked != showMasked)) ) // 2: Global / Local filter - && ( ( item->isGlobal && ( (show_local != showScope) || (item->height > 1) ) ) + && ( ( item->isGlobal && ( (show_local != showScope) || (item->ndescr > 1) ) ) || (!item->isGlobal && ( show_global != showScope)) ) ) return true; return false; diff --git a/ufed-curses.h b/ufed-curses.h index 9633692..71a4b18 100644 --- a/ufed-curses.h +++ b/ufed-curses.h @@ -41,7 +41,9 @@ struct window { struct item { struct item *prev, *next; - int top, height; + int currline; //!< the current line on the screen this item starts. + int listline; //!< the fixed line within the full list this item starts + int ndescr; //!< number of description lines bool isMasked; bool isGlobal; }; @@ -55,6 +57,7 @@ struct key { /* global prototypes */ void cursesdone(void); +int getItemHeight(struct item *item); void initcurses(void); bool isLegalItem(struct item *item);