public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Sven Eden" <sven.eden@gmx.de>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/ufed:master commit in: /
Date: Fri, 20 Sep 2013 08:30:41 +0000 (UTC)	[thread overview]
Message-ID: <1379598169.be5a88cd3986f81fe3be6fd3381ab7e0449cff7b.yamakuzure@gentoo> (raw)

commit:     be5a88cd3986f81fe3be6fd3381ab7e0449cff7b
Author:     Sven Eden <yamakuzure <AT> gmx <DOT> net>
AuthorDate: Thu Sep 19 13:42:49 2013 +0000
Commit:     Sven Eden <sven.eden <AT> gmx <DOT> de>
CommitDate: Thu Sep 19 13:42:49 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/ufed.git;a=commit;h=be5a88cd

drawing a flag witrh wrapped descriptions does no longer add an offset for the second part. The calculation does this now, which simplifies things alot.

---
 ufed-curses-checklist.c | 57 +++++++++++++++++--------------------------------
 ufed-curses-types.c     |  8 ++++---
 2 files changed, 24 insertions(+), 41 deletions(-)

diff --git a/ufed-curses-checklist.c b/ufed-curses-checklist.c
index e5506c4..b82e9f0 100644
--- a/ufed-curses-checklist.c
+++ b/ufed-curses-checklist.c
@@ -19,11 +19,11 @@ static char*   lineBuf         = NULL;
 static sFlag*  flags           = NULL;
 
 /* internal prototypes */
-static int  findFlagStart(sFlag* flag, int* index, sWrap** wrap, int* line, bool* isFirstWrap);
+static int  findFlagStart(sFlag* flag, int* index, sWrap** wrap, int* line);
 static void free_flags(void);
 static char getFlagSpecialChar(sFlag* flag, int index);
 static void printFlagInfo(char* buf, sFlag* flag, int index, bool printFlagName, bool printFlagState);
-static void setFlagWrapDraw(sFlag* flag, int index, sWrap** wrap, size_t* pos, size_t* len, bool* isFirstWrap);
+static void setFlagWrapDraw(sFlag* flag, int index, sWrap** wrap, size_t* pos, size_t* len);
 
 
 /* static functions */
@@ -197,10 +197,9 @@ static int drawflag(sFlag* flag, bool highlight)
 	int    line      = flag->currline;
 	int    usedY     = 0;    // Counts how many lines this flag really needs to display
 	sWrap* wrapPart  = NULL; // Wrap part to begin with/draw
-	bool   wrapFirst = true; // The first part, pkg or desc
 
 	// Get the starting description/wrapped line of the flag
-	usedY = findFlagStart(flag, &idx, &wrapPart, &line, &wrapFirst);
+	usedY = findFlagStart(flag, &idx, &wrapPart, &line);
 
 	// findFlagStart returns -1 if the flag is out of the screen
 	if (0 > usedY)
@@ -289,12 +288,8 @@ static int drawflag(sFlag* flag, bool highlight)
 
 		// For normal descriptions, pos and length are already set, but
 		// not so for wrapped lines, these must be set for each line:
-		if (eWrap_wrap == e_wrap) {
-			setFlagWrapDraw(flag, idx, &wrapPart, &pos, &length, &wrapFirst);
-			wrapPart = wrapPart->next;
-			if (newDesc && wrapPart)
-				newDesc = false;
-		}
+		if (eWrap_wrap == e_wrap)
+			setFlagWrapDraw(flag, idx, &wrapPart, &pos, &length);
 
 		// The right side of buf can be added now:
 		leftover = rightwidth - (int)length;
@@ -367,7 +362,8 @@ static int drawflag(sFlag* flag, bool highlight)
 		if (NULL == wrapPart) {
 			++idx;
 			newDesc = true;
-		}
+		} else
+			newDesc = false;
 	} // end of looping flag descriptions
 
 	if(highlight)
@@ -644,7 +640,7 @@ static int callback(sFlag** curr, int key)
   * until wrapPart is either NULL, or a part on the screen is
   * reached.
 **/
-static int findFlagStart(sFlag* flag, int* index, sWrap** wrap, int* line, bool* isFirstWrap)
+static int findFlagStart(sFlag* flag, int* index, sWrap** wrap, int* line)
 {
 	int    usedLines  = 0;
 	int    flagHeight = getFlagHeight(flag); // Will recalculate wrap parts if needed
@@ -676,17 +672,12 @@ static int findFlagStart(sFlag* flag, int* index, sWrap** wrap, int* line, bool*
 					 */
 					int wrapCount = flag->desc[*index].wrapCount;
 					wrapPart      = flag->desc[*index].wrap;
-					*isFirstWrap  = true;
 					if (wrapPart && wrapCount && (-(*line) < wrapCount)) {
 						// Situation b) This description enters screen
 						while (wrapPart && (*line < 0)) {
 							++(*line);
 							++usedLines;
 							wrapPart = wrapPart->next;
-							if (wrapPart && !wrapPart->pos)
-								*isFirstWrap = false;
-							// Note: The wrap parts are already calculated
-							//       to resemble the current order.
 						}
 					} else {
 						// Situation a) Fast forward
@@ -775,32 +766,22 @@ static void printFlagInfo(char* buf, sFlag* flag, int index, bool printFlagName,
 	}
 }
 
-static void setFlagWrapDraw(sFlag* flag, int index, sWrap** wrap, size_t* pos, size_t* len, bool* isFirstWrap)
+static void setFlagWrapDraw(sFlag* flag, int index, sWrap** wrap, size_t* pos, size_t* len)
 {
 	sWrap* wrapPart = *wrap;
 
-	if (NULL == wrapPart) {
-		wrapPart     = flag->desc[index].wrap;
-		*isFirstWrap = true;
-	} else if (*isFirstWrap
-			&& (flag->desc[index].wrap != wrapPart)
-			&& !wrapPart->pos)
-		*isFirstWrap = false;
+	if (NULL == wrapPart)
+		wrapPart = flag->desc[index].wrap;
+	else
+		wrapPart = wrapPart->next;
 
 	// The length and position can be written back already
-	*pos = wrapPart->pos;
-	*len = wrapPart->len;
-
-	// If this is the second part, the length of the first
-	// must be added to the position, or drawflag() will
-	// start all over again.
-	if (false == *isFirstWrap) {
-		if (eOrder_left == e_order)
-			*pos += sizeof(flag->desc[index].pkg);
-		else
-			*pos += eDesc_ori == e_desc
-				  ? sizeof(flag->desc[index].desc)
-				  : sizeof(flag->desc[index].desc_alt);
+	if (wrapPart) {
+		*pos = wrapPart->pos;
+		*len = wrapPart->len;
+	} else {
+		*pos = 0;
+		*len = 0;
 	}
 
 	// Write back wrap part pointer

diff --git a/ufed-curses-types.c b/ufed-curses-types.c
index e6b1139..4a5445f 100644
--- a/ufed-curses-types.c
+++ b/ufed-curses-types.c
@@ -533,6 +533,8 @@ static void calculateDescWrap(sDesc* desc)
 		size_t pLen  = pPkg ? strlen(pPkg) : 0;
 		size_t left  = dLen + pLen;
 		size_t wLen  = eOrder_left == desc->wrapOrder ? pLen : dLen;
+		size_t oLen  = 0; // Set to the first part to be added to pos on the second
+		// part, so drawflag knows from where to start taking in the unified desc.
 
 		/* A valid curr is needed first */
 		if (NULL == curr) {
@@ -581,7 +583,7 @@ static void calculateDescWrap(sDesc* desc)
 			}
 
 			// Step 3: Note values and increase start
-			curr->pos = start;
+			curr->pos = start + oLen;
 			curr->len = end - start + (' ' == pch[end] ? 0 : 1);
 			start += curr->len;
 			left  -= curr->len;
@@ -600,12 +602,12 @@ static void calculateDescWrap(sDesc* desc)
 					// Switch from pkg to desc
 					pch  = pDesc;
 					wLen = dLen;
-					left = dLen;
+					oLen = pLen + 2;
 				} else {
 					// Switch from desc to pkg
 					pch  = pPkg;
 					wLen = pLen;
-					left = pLen;
+					oLen = dLen + 2;
 				}
 				start = 0;
 			} // End of having to swap pkg/desc


             reply	other threads:[~2013-09-20  8:31 UTC|newest]

Thread overview: 238+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-20  8:30 Sven Eden [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-11-07 14:25 [gentoo-commits] proj/ufed:master commit in: / Sven Eden
2020-05-02  8:38 Ulrich Müller
2019-09-27  6:42 Sven Eden
2019-09-27  6:39 Sven Eden
2019-09-24 17:57 Sven Eden
2019-09-24 17:56 Sven Eden
2019-04-07 15:17 David Seifert
2019-04-07 13:56 David Seifert
2019-04-07 13:19 David Seifert
2019-04-07 13:19 David Seifert
2019-04-07 13:19 David Seifert
2019-04-07 13:19 David Seifert
2019-04-07 13:19 David Seifert
2015-02-12 15:47 Sven Eden
2015-02-11  9:03 Sven Eden
2014-11-10  9:59 Sven Eden
2014-10-28 11:43 Sven Eden
2014-02-26 10:26 Sven Eden
2014-02-26 10:26 Sven Eden
2014-02-26 10:26 Sven Eden
2014-02-26 10:26 Sven Eden
2014-02-26 10:26 Sven Eden
2014-02-26 10:26 Sven Eden
2014-02-25  8:18 Sven Eden
2014-02-25  8:18 Sven Eden
2014-02-25  8:18 Sven Eden
2014-02-25  8:18 Sven Eden
2013-11-25 21:43 Sven Eden
2013-11-25 21:43 Sven Eden
2013-11-25 21:43 Sven Eden
2013-11-25 21:43 Sven Eden
2013-11-25 21:43 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-11  7:09 Sven Eden
2013-09-11  6:31 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-10 12:37 Sven Eden
2013-09-10  6:36 Sven Eden
2013-09-10  6:36 Sven Eden
2013-09-10  6:36 Sven Eden
2013-09-10  6:36 Sven Eden
2013-09-10  6:36 Sven Eden
2013-09-10  6:36 Sven Eden
2013-09-10  6:36 Sven Eden
2013-07-22  9:34 Sven Eden
2013-07-22  6:09 Sven Eden
2013-07-22  6:09 Sven Eden
2013-04-09  7:22 Sven Eden
2013-04-09  7:22 Sven Eden
2013-04-09  7:22 Sven Eden
2013-04-08  7:18 Sven Eden
2013-04-03 13:39 Sven Eden
2013-03-05 16:53 Sven Eden
2013-03-05 16:49 Sven Eden
2013-03-05 16:49 Sven Eden
2013-03-05 16:49 Sven Eden
2013-03-05 16:49 Sven Eden
2013-03-05 16:49 Sven Eden
2013-02-21 10:02 Sven Eden
2013-02-19 15:16 Sven Eden
2013-02-19 13:34 Sven Eden
2013-02-18  7:22 Sven Eden
2013-02-15  8:36 Sven Eden
2013-02-15  8:36 Sven Eden
2013-02-15  8:36 Sven Eden
2013-02-14  8:35 Sven Eden
2013-02-14  8:35 Sven Eden
2013-02-14  8:35 Sven Eden
2013-02-13  9:23 Sven Eden
2013-02-13  9:23 Sven Eden
2013-02-13  9:23 Sven Eden
2013-02-13  9:23 Sven Eden
2013-02-13  9:23 Sven Eden
2013-02-12 10:51 Sven Eden
2013-02-12 10:51 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-06  9:09 Sven Eden
2013-02-06  9:09 Sven Eden
2013-02-05 18:06 Paul Varner
2013-02-05 13:53 Sven Eden
2013-02-05 13:53 Sven Eden
2013-02-05 11:24 Sven Eden
2013-02-03 14:32 Sven Eden
2013-02-03 14:32 Sven Eden
2013-02-03 14:32 Sven Eden
2013-02-03 14:32 Sven Eden
2013-02-03 14:32 Sven Eden
2013-02-02 20:49 Sven Eden
2013-02-02 10:11 Sven Eden
2013-02-02  9:47 Sven Eden
2013-02-02  9:47 Sven Eden
2013-02-02  9:47 Sven Eden
2013-02-01 21:12 Sven Eden
2013-02-01 21:12 Sven Eden
2013-02-01 21:12 Sven Eden
2013-02-01 16:04 Sven Eden
2013-02-01 15:55 Sven Eden
2013-02-01 15:26 Sven Eden
2013-02-01 14:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-01-24 10:15 Sven Eden
2013-01-24 10:15 Sven Eden
2013-01-24 10:15 Sven Eden
2013-01-24 10:15 Sven Eden
2013-01-24 10:15 Sven Eden
2013-01-23 14:44 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-16 13:43 Sven Eden
2013-01-16 12:56 Sven Eden
2013-01-16 12:56 Sven Eden
2013-01-16 12:56 Sven Eden
2013-01-16 12:56 Sven Eden
2013-01-16 12:56 Sven Eden
2013-01-16 12:56 Sven Eden
2013-01-08 11:02 Sven Eden
2013-01-02  8:47 Sven Eden
2013-01-02  8:01 Sven Eden
2013-01-02  8:01 Sven Eden
2012-11-20 17:31 Paul Varner
2012-11-20 17:25 Paul Varner
2012-10-23 16:13 Paul Varner
2012-10-23 16:13 Paul Varner
2012-10-23 16:13 Paul Varner
2012-10-23 16:01 Paul Varner
2012-10-22 20:42 Paul Varner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1379598169.be5a88cd3986f81fe3be6fd3381ab7e0449cff7b.yamakuzure@gentoo \
    --to=sven.eden@gmx.de \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox