summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Eden <yamakuzure@gmx.net>2013-09-17 08:50:54 +0200
committerSven Eden <yamakuzure@gmx.net>2013-09-17 08:50:54 +0200
commitdd3865c8e95cf5ee10fef1c6a0c4ad1b0fbf02cc (patch)
tree5d506f1f869064dd50c6a7575a32f59c27ce9ffc
parenttypes: Added calculation of wrapped description parameters. (diff)
downloadufed-dd3865c8e95cf5ee10fef1c6a0c4ad1b0fbf02cc.tar.gz
ufed-dd3865c8e95cf5ee10fef1c6a0c4ad1b0fbf02cc.tar.bz2
ufed-dd3865c8e95cf5ee10fef1c6a0c4ad1b0fbf02cc.zip
drawFlag(): Added skipping of individual wrapped description parts when searching the start of a flag with enabled description wrapping.
-rw-r--r--ufed-curses-checklist.c53
1 files changed, 43 insertions, 10 deletions
diff --git a/ufed-curses-checklist.c b/ufed-curses-checklist.c
index f55cf66..9aaf35f 100644
--- a/ufed-curses-checklist.c
+++ b/ufed-curses-checklist.c
@@ -202,11 +202,12 @@ static void free_flags(void)
static int drawflag(sFlag* flag, bool highlight)
{
- int idx = 0;
- int usedY = 0;
- int line = flag->currline;
- char buf[wWidth(List)+1];
- char desc[maxDescWidth];
+ int idx = 0;
+ int usedY = 0;
+ int line = flag->currline;
+ char buf[wWidth(List)+1];
+ char desc[maxDescWidth];
+ sWrap* wrapPart = NULL;
// Return early if there is nothing to display:
if (!isFlagLegal(flag))
@@ -216,15 +217,47 @@ static int drawflag(sFlag* flag, bool highlight)
* 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++)) {
- ++line;
- ++usedY;
- }
- }
+ 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;
+ }
+ } 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;