diff options
author | 2013-09-19 19:36:16 +0200 | |
---|---|---|
committer | 2013-09-19 19:36:16 +0200 | |
commit | c69b9f7f923729e1663d75d9ab3378c4ec67e5ad (patch) | |
tree | 10df3d64b82d966930d3caaacd21fd794a3111e3 | |
parent | Really add wrapped/long description state to the status line. The space calcu... (diff) | |
download | ufed-c69b9f7f923729e1663d75d9ab3378c4ec67e5ad.tar.gz ufed-c69b9f7f923729e1663d75d9ab3378c4ec67e5ad.tar.bz2 ufed-c69b9f7f923729e1663d75d9ab3378c4ec67e5ad.zip |
calculateDescWrap(): Take later pre-/postfixing of brackets of the package list into account when setting the next wrap part.
-rw-r--r-- | ufed-curses-types.c | 22 |
1 files 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; |