diff options
author | dimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7> | 2012-03-17 20:32:54 (GMT) |
---|---|---|
committer | dimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7> | 2012-03-17 20:32:54 (GMT) |
commit | 6cbcbc787daeae62ce59c04bbc35597986bcca7d (patch) | |
tree | 5c9d2280ca0cb07840bfa26ca4dbed5b3225d21f /src/dot.cpp | |
parent | c3a03d5cb1f856d2b3a7bff8ddf74416a1281f66 (diff) | |
download | Doxygen-6cbcbc787daeae62ce59c04bbc35597986bcca7d.zip Doxygen-6cbcbc787daeae62ce59c04bbc35597986bcca7d.tar.gz Doxygen-6cbcbc787daeae62ce59c04bbc35597986bcca7d.tar.bz2 |
Release-1.8.0
Diffstat (limited to 'src/dot.cpp')
-rw-r--r-- | src/dot.cpp | 63 |
1 files changed, 54 insertions, 9 deletions
diff --git a/src/dot.cpp b/src/dot.cpp index b952ce2..e178ef1 100644 --- a/src/dot.cpp +++ b/src/dot.cpp @@ -1484,23 +1484,68 @@ void DotNode::setDistance(int distance) static QCString convertLabel(const QCString &l) { QCString result; + QCString bBefore("\\_/<({[: =-+@%#~?$"); + QCString bAfter(">]),;|"); const char *p=l.data(); if (p==0) return result; char c; + char cs[2]; + cs[1]=0; + int len=l.length(); + int charsLeft=len; + int sinceLast=0; + int foldLen=17; // ideal text length while ((c=*p++)) { + QCString replacement; switch(c) { - case '\\': result+="\\\\"; break; - case '\n': result+="\\n"; break; - case '<': result+="\\<"; break; - case '>': result+="\\>"; break; - case '|': result+="\\|"; break; - case '{': result+="\\{"; break; - case '}': result+="\\}"; break; - case '"': result+="\\\""; break; - default: result+=c; break; + case '\\': replacement="\\\\"; break; + case '\n': replacement="\\n"; break; + case '<': replacement="\\<"; break; + case '>': replacement="\\>"; break; + case '|': replacement="\\|"; break; + case '{': replacement="\\{"; break; + case '}': replacement="\\}"; break; + case '"': replacement="\\\""; break; + default: cs[0]=c; replacement=cs; break; } + // Some heuristics to insert newlines to prevent too long + // boxes and at the same time prevent ugly breaks + if (c=='\n') + { + result+=replacement; + foldLen = (3*foldLen+sinceLast+2)/4; + sinceLast=1; + } + else if (charsLeft>foldLen/3 && sinceLast>foldLen && bBefore.contains(c)) + { + result+="\\n"; + result+=replacement; + foldLen = (foldLen+sinceLast+1)/2; + sinceLast=1; + } + else if (charsLeft>1+foldLen/4 && sinceLast>foldLen+foldLen/3 && + !isupper(c) && isupper(*p)) + { + result+=replacement; + result+="\\n"; + foldLen = (foldLen+sinceLast+1)/2; + sinceLast=0; + } + else if (charsLeft>foldLen/3 && sinceLast>foldLen && bAfter.contains(c)) + { + result+=replacement; + result+="\\n"; + foldLen = (foldLen+sinceLast+1)/2; + sinceLast=0; + } + else + { + result+=replacement; + sinceLast++; + } + charsLeft--; } return result; } |