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:38 +0000 (UTC)	[thread overview]
Message-ID: <1379486916.c1c2d4e2581a150a267a8d9851d4492bae8c4f34.yamakuzure@gentoo> (raw)

commit:     c1c2d4e2581a150a267a8d9851d4492bae8c4f34
Author:     Sven Eden <yamakuzure <AT> gmx <DOT> net>
AuthorDate: Wed Sep 18 06:48:36 2013 +0000
Commit:     Sven Eden <sven.eden <AT> gmx <DOT> de>
CommitDate: Wed Sep 18 06:48:36 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/ufed.git;a=commit;h=c1c2d4e2

drawFlag(): Moved finding the starting description / wrapped line out of the function into the new static function findFlagStart()

---
 ufed-curses-checklist.c | 143 ++++++++++++++++++++++++++++--------------------
 1 file changed, 83 insertions(+), 60 deletions(-)

diff --git a/ufed-curses-checklist.c b/ufed-curses-checklist.c
index ee11b10..8425997 100644
--- a/ufed-curses-checklist.c
+++ b/ufed-curses-checklist.c
@@ -19,6 +19,7 @@ static char*   lineBuf         = NULL;
 static sFlag*  flags           = NULL;
 
 /* internal prototypes */
+static int  findFlagStart(sFlag* flag, int* index, sWrap** wrap, int* line, bool* isFirstWrap);
 static void free_flags(void);
 
 
@@ -202,71 +203,26 @@ static void free_flags(void)
 
 static int drawflag(sFlag* flag, bool highlight)
 {
-	int    idx       = 0;
-	int    usedY     = 0;
+	// Return early if there is nothing to display:
+	if (!isFlagLegal(flag))
+		return 0;
+
+	// Get the starting description/wrapped line of the flag
+	int    idx       = 0;    // The description index to start with
 	int    line      = flag->currline;
-	char   buf[wWidth(List)+1];
-	char   desc[maxDescWidth];
-	sWrap* wrapPart  = NULL;
+	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
 
-	// Return early if there is nothing to display:
-	if (!isFlagLegal(flag))
+	if ((line < 0)
+	  && (0 == (usedY = findFlagStart(flag, &idx, &wrapPart, &line, &wrapFirst))) )
 		return 0;
 
-	/* Determine with which description to start.
-	 * Overly long description lists might not fit on one screen,
-	 * and therefore must be scrolled instead of the flags
-	 * themselves.
-	 * If descriptions are wrapped, any description must be held
-	 * until wrapPart is either NULL, or a part on the screen is
-	 * reached.
-	 */
-	if (line < 0) {
-		if (-line < getFlagHeight(flag)) {
-			while (line < 0) {
-				if (isDescLegal(flag, idx)) {
-					if (eWrap_normal == e_wrap) {
-						++line;
-						++usedY;
-						++idx;
-					} else {
-						/* With wrapped descriptions there are two possible
-						 * situations:
-						 * a) The list of wrapped lines is shorter than the
-						 *    lines to be skipped to get this description on
-						 *    the screen. In this case the full description
-						 *    can be fast forwareded.
-						 * b) The number of lines above the screen is less
-						 *    than the number of wrapped parts. In this case
-						 *    the first on screen part must be found.
-						 */
-						int wrapCount = flag->desc[idx].wrapCount;
-						wrapPart = flag->desc[idx].wrap;
-						if (wrapPart && wrapCount && (-line < wrapCount)) {
-							// Situation b) This description enters screen
-							while (wrapPart && (line < 0)) {
-								++line;
-								++usedY;
-								wrapPart = wrapPart->next;
-								if (wrapPart && !wrapPart->pos)
-									wrapFirst = false;
-								// Note: The wrap parts are already calculated
-								//       to resemble the current order.
-							}
-						} else {
-							// Situation a) Fast forward
-							line += wrapCount;
-							usedY += wrapCount;
-							++idx;
-						}
-					} // End of handling wrapped lines
-				} // End of having a legal flag
-			} // end of moving to line 0
-		} else
-			// Otherwise this item is out of the display area
-			return 0;
-	}
+
+	char   buf[wWidth(List)+1];
+	char   desc[maxDescWidth];
+
+
 
 	memset(buf, 0, sizeof(char) * (wWidth(List)+1));
 
@@ -715,6 +671,73 @@ static int callback(sFlag** curr, int key)
 	return -1;
 }
 
+/** @brief find the first description/wrapped part drawn on line 0.
+  *
+  * Determine with which description to start.
+  * Overly long description lists might not fit on one screen,
+  * and therefore must be scrolled instead of the flags
+  * themselves.
+  * If descriptions are wrapped, any description must be held
+  * 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)
+{
+	int    usedLines  = 0;
+	int    flagHeight = getFlagHeight(flag); // Will recalculate wrap parts if needed
+	sWrap* wrapPart = NULL;
+
+	if ( (*line < 0) && (-(*line) < flagHeight) ){
+
+		while (*line < 0) {
+			if (isDescLegal(flag, *index)) {
+				if (eWrap_normal == e_wrap) {
+					++(*line);
+					++usedLines;
+					++(*index);
+				} else {
+					/* With wrapped descriptions there are two possible
+					 * situations:
+					 * a) The list of wrapped lines is shorter than the
+					 *    lines to be skipped to get this description on
+					 *    the screen. In this case the full description
+					 *    can be fast forwareded.
+					 * b) The number of lines above the screen is less
+					 *    than the number of wrapped parts. In this case
+					 *    the first on screen part must be found.
+					 */
+					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
+						*line     += wrapCount;
+						usedLines += wrapCount;
+						++(*index);
+					}
+				} // End of handling wrapped lines
+			} // End of having a legal flag
+		} // end of moving to line 0
+
+		// Write back wrapPart:
+		*wrap = wrapPart;
+	}
+
+	return usedLines;
+}
+
+
 int main(void)
 {
 	int result = EXIT_SUCCESS;


             reply	other threads:[~2013-09-20  8:30 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=1379486916.c1c2d4e2581a150a267a8d9851d4492bae8c4f34.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