From c69b9f7f923729e1663d75d9ab3378c4ec67e5ad Mon Sep 17 00:00:00 2001 From: Sven Eden Date: Thu, 19 Sep 2013 19:36:16 +0200 Subject: calculateDescWrap(): Take later pre-/postfixing of brackets of the package list into account when setting the next wrap part. --- ufed-curses-types.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/ufed-curses-types.c b/ufed-curses-types.c index fad7b2d..1a30392 100644 --- a/ufed-curses-types.c +++ b/ufed-curses-types.c @@ -570,7 +570,25 @@ static void calculateDescWrap(sDesc* desc) while (left) { // Step 1: Set current wrap part end - end = start + width + (curr == desc->wrap ? 2 : 0); + end = start + width; + + // First line has two more spaces: + if (curr == desc->wrap) + end += 2; + + // Package lists have one space less in their first line, + // because an opening bracket is prefixed by drawflag(), + // and two spaces less in their last line, because another + // bracked is postfixed and the leading whitespace is + // skipped below. + if (pch == pPkg) { + if (!start || (start == oLen)) + --end; + else if (end >= (wLen - 1)) + end -= 2; + } + + // Don't shoot over the target! if (end >= wLen) end = wLen - 1; @@ -584,7 +602,7 @@ static void calculateDescWrap(sDesc* desc) // Step 3: Note values and increase start curr->pos = start + oLen; - curr->len = end - start + (' ' == pch[end] ? 0 : 1); + curr->len = end - start + (end == (wLen - 1) ? 1 : 0); start += curr->len; left -= curr->len; ++desc->wrapCount; -- cgit v1.2.3-65-gdbad