Skip to content

Commit 5111e92

Browse files
committed
Fix for section selection range offset in page outline panel
Also fixes problem interpreting page titles with \<tag\> as <tag> in the navigation panel
1 parent def79ca commit 5111e92

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

src/ftvhelp.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ void FTVHelp::Private::generateLink(TextStream &t,const FTVNodePtr &n)
284284
//printf("FTVHelp::generateLink(ref=%s,file=%s,anchor=%s\n",
285285
// qPrint(n->ref),qPrint(n->file),qPrint(n->anchor));
286286
bool setTarget = FALSE;
287-
QCString text = n->nameAsHtml.isEmpty() ? convertToHtml(n->name) : n->nameAsHtml;
287+
bool nameAsHtml = !n->nameAsHtml.isEmpty();
288+
QCString text = nameAsHtml ? n->nameAsHtml : convertToHtml(n->name);
288289
if (n->file.isEmpty()) // no link
289290
{
290291
t << "<b>" << text << "</b>";
@@ -546,15 +547,17 @@ static bool dupOfParent(const FTVNodePtr &n)
546547

547548
static void generateJSLink(TextStream &t,const FTVNodePtr &n)
548549
{
549-
QCString result = n->nameAsHtml.isEmpty() ? n->name : n->nameAsHtml;
550+
bool nameAsHtml = !n->nameAsHtml.isEmpty();
551+
QCString result = nameAsHtml ? n->nameAsHtml : n->name;
552+
QCString link = convertToJSString(result,nameAsHtml);
550553
if (n->file.isEmpty()) // no link
551554
{
552-
t << "\"" << convertToJSString(result) << "\", null, ";
555+
t << "\"" << link << "\", null, ";
553556
}
554557
else // link into other page
555558
{
556559
if (Config_getBool(HIDE_SCOPE_NAMES)) result=stripScope(result);
557-
t << "\"" << convertToJSString(result) << "\", \"";
560+
t << "\"" << link << "\", \"";
558561
t << externalRef("",n->ref,TRUE);
559562
t << node2URL(n);
560563
t << "\", ";

src/util.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4537,7 +4537,7 @@ QCString convertToHtml(const QCString &s,bool keepEntities)
45374537
return growBuf.get();
45384538
}
45394539

4540-
QCString convertToJSString(const QCString &s)
4540+
QCString convertToJSString(const QCString &s,bool keepEntities)
45414541
{
45424542
if (s.isEmpty()) return s;
45434543
GrowBuf growBuf;
@@ -4555,7 +4555,7 @@ QCString convertToJSString(const QCString &s)
45554555
}
45564556
}
45574557
growBuf.addChar(0);
4558-
return convertCharEntitiesToUTF8(growBuf.get());
4558+
return keepEntities ? growBuf.get() : convertCharEntitiesToUTF8(growBuf.get());
45594559
}
45604560

45614561
QCString convertCharEntitiesToUTF8(const QCString &str)

src/util.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,11 @@ QCString stripScope(const QCString &name);
273273
QCString convertToId(const QCString &s);
274274
QCString correctId(const QCString &s);
275275

276-
QCString convertToHtml(const QCString &s,bool keepEntities=TRUE);
276+
QCString convertToHtml(const QCString &s,bool keepEntities=true);
277277

278-
QCString convertToXML(const QCString &s, bool keepEntities=FALSE);
278+
QCString convertToXML(const QCString &s, bool keepEntities=false);
279279

280-
QCString convertToJSString(const QCString &s);
280+
QCString convertToJSString(const QCString &s,bool keepEntities=false);
281281

282282
QCString getOverloadDocs();
283283

templates/html/navtree.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,11 @@ function initNavTree(toroot,relpath,allMembersFile) {
846846
let offsets = []
847847
for (let i=0;i<topMapping.length;i++) {
848848
const heading = $('#'+topMapping[i]);
849-
offsets.push({id:topMapping[i],y:heading.offset().top-yc});
849+
if (heading.parent().hasClass('doxsection')) {
850+
offsets.push({id:topMapping[i],y:heading.parent().offset().top-yc});
851+
} else {
852+
offsets.push({id:topMapping[i],y:heading.offset().top-yc});
853+
}
850854
}
851855
offsets.push({id:'',y:1e10});
852856
let scrollTarget = undefined, numItems=0;
@@ -855,7 +859,8 @@ function initNavTree(toroot,relpath,allMembersFile) {
855859
const ye = offsets[i+1].y;
856860
const id = offsets[i].id;
857861
const nav = $('#nav-'+id);
858-
if ((ys>2 || ye>2) && (ys<height-2 || ye<height-2)) {
862+
const margin = 10; // #pixels before content show as visible
863+
if ((ys>margin || ye>margin) && (ys<height-margin || ye<height-margin)) {
859864
if (!scrollTarget) scrollTarget=nav;
860865
nav.addClass('vis'); // mark navigation entry as visible within content area
861866
numItems+=1;

0 commit comments

Comments
 (0)