Mailinglist Archive: zypp-devel (24 mails)
| < Previous | Next > |
[zypp-devel] Re: [zypp-commit] <zypper> master : Fixed enless loop in word-longer-than-screen case.
- From: Michael Matz <matz@xxxxxxx>
- Date: Mon, 6 Apr 2009 13:14:38 +0200 (CEST)
- Message-id: <Pine.LNX.4.64.0904061309370.29566@xxxxxxxxxxxxx>
Hi Jano,
On Wed, 25 Mar 2009, Ján Kupec wrote:
It's usually better to _not_ mangle the output string in case it's
overlong. It only creates problems with copy&paste, and still isn't more
readable, especially for the words that usually are overlong, namely URLs
and the like (lets ignore finnish or gaelic location names). Just leave
out the hyphen if you don't find any good place to split. Also (and
that's important) don't add an eol explicitely if you overflow the
screenwidth, let it overflow by the normal terminal wrap-around. The
visual effect is the same but again for copy&paste it makes a difference
(when you explicitely output an eol the terminal has no way of knowing
that the thing starting at the next line actually is a continuation).
Ciao,
Michael.
On Wed, 25 Mar 2009, Ján Kupec wrote:
Fixed enless loop in word-longer-than-screen case.
---
src/utils/text.cc | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/src/utils/text.cc b/src/utils/text.cc
+ bool wanthyphen = false;
+ // A single word is longer than the wrap width. Split the word and
+ // append a hyphen at the end of the line. This won't normally
happen,
+ // but it can eventually happen e.g. with paths or too low screen
widths.
It's usually better to _not_ mangle the output string in case it's
overlong. It only creates problems with copy&paste, and still isn't more
readable, especially for the words that usually are overlong, namely URLs
and the like (lets ignore finnish or gaelic location names). Just leave
out the hyphen if you don't find any good place to split. Also (and
that's important) don't add an eol explicitely if you overflow the
screenwidth, let it overflow by the normal terminal wrap-around. The
visual effect is the same but again for copy&paste it makes a difference
(when you explicitely output an eol the terminal has no way of knowing
that the thing starting at the next line actually is a continuation).
+ //! \todo make word-splitting more intelligent, e.g. if the word
already
+ //! contains a hyphen, split there; do not split because
+ //! of a non-alphabet character; do not leave orphans, etc...
+ if (linep == prevwp)
+ {
+ prevwp = s - 2;
+ wanthyphen = true;
+ }
+
// update the size of the string to read
s_bytes -= (prevwp - linep);
// print the line, leave linep point to the start of the last word.
for (; linep < prevwp; ++linep)
out << *linep;
+ if (wanthyphen)
+ out << "-";
out << endl;
Ciao,
Michael.
| < Previous | Next > |