diff --git a/uppsrc/CtrlLib/Help.cpp b/uppsrc/CtrlLib/Help.cpp index b897ca312..45f040e3e 100644 --- a/uppsrc/CtrlLib/Help.cpp +++ b/uppsrc/CtrlLib/Help.cpp @@ -192,7 +192,7 @@ HelpWindow::HelpWindow() view.SetZoom(Zoom(1, 1)); zoom.m = 160; SetZoom(); - view.Margins(2); + view.Margins(Rect(12, 12, 2, 2)); SetRect(Ctrl::GetWorkArea().Deflated(80)); tree <<= THISBACK(TreeCursor); tree.NoRoot(); diff --git a/uppsrc/ide/Browser/TopicBase.cpp b/uppsrc/ide/Browser/TopicBase.cpp index 4c988de73..9214aab5c 100644 --- a/uppsrc/ide/Browser/TopicBase.cpp +++ b/uppsrc/ide/Browser/TopicBase.cpp @@ -152,38 +152,42 @@ void SyncTopicFile(const String& link, const String& path) SyncTopicFile(ParseQTF(tp.text), link, path, tp.title); } +void SyncRefsDir(const char *dir, const String& rel, Progress& pi) +{ + for(FindFile pff(AppendFileName(dir, "*.*")); pff; pff.Next()) { + if(pff.IsFolder() && *pff.GetName() != '.') { + pi.Step(); + TopicLink tl; + tl.package = rel + pff.GetName(); + String pdir = AppendFileName(dir, pff.GetName()); + for(FindFile ff(AppendFileName(pdir, "*.tpp")); ff; ff.Next()) { + if(ff.IsFolder()) { + String group = GetFileTitle(ff.GetName()); + tl.group = group; + String dir = AppendFileName(pdir, ff.GetName()); + for(FindFile ft(AppendFileName(dir, "*.tpp")); ft; ft.Next()) { + if(ft.IsFile()) { + String path = AppendFileName(dir, ft.GetName()); + tl.topic = GetFileTitle(ft.GetName()); + String link = TopicLinkString(tl); + pi.SetText("Indexing topic " + tl.topic); + SyncTopicFile(link, path); + } + } + } + } + SyncRefsDir(pdir, tl.package + '/', pi); + } + } +} + void SyncRefs() { Progress pi; pi.AlignText(ALIGN_LEFT); Vector upp = GetUppDirs(); - for(int i = 0; i < upp.GetCount(); i++) { - for(FindFile pff(AppendFileName(upp[i], "*.*")); pff; pff.Next()) { - if(pff.IsFolder()) { - pi.Step(); - String package = pff.GetName(); - String pdir = PackageDirectory(package); - TopicLink tl; - tl.package = package; - for(FindFile ff(AppendFileName(pdir, "*.tpp")); ff; ff.Next()) { - if(ff.IsFolder()) { - String group = GetFileTitle(ff.GetName()); - tl.group = group; - String dir = AppendFileName(pdir, ff.GetName()); - for(FindFile ft(AppendFileName(dir, "*.tpp")); ft; ft.Next()) { - if(ft.IsFile()) { - String path = AppendFileName(dir, ft.GetName()); - tl.topic = GetFileTitle(ft.GetName()); - String link = TopicLinkString(tl); - pi.SetText("Indexing topic " + tl.topic); - SyncTopicFile(link, path); - } - } - } - } - } - } - } + for(int i = 0; i < upp.GetCount(); i++) + SyncRefsDir(upp[i], String(), pi); } Vector GetRefLinks(const String& ref) diff --git a/uppsrc/ide/Help.cpp b/uppsrc/ide/Help.cpp index aab1d8071..16b6f0e14 100644 --- a/uppsrc/ide/Help.cpp +++ b/uppsrc/ide/Help.cpp @@ -128,6 +128,43 @@ void GatherLinks(Index& link, const char *topic) } } +Index TopicCtrl::idelink; + +void TopicCtrl::ScanDirForTpp(const char *dir, Index& li, Vector& sdx, + const String& lng, + VectorMap > >& map, + const String& rel) +{ + TopicLink tl; + for(FindFile pff(AppendFileName(dir, "*.*")); pff; pff.Next()) { + if(pff.IsFolder() && *pff.GetName() != '.') { + String pdir = AppendFileName(dir, pff.GetName()); + tl.package = rel + pff.GetName(); + for(FindFile ff(AppendFileName(pdir, "*.tpp")); ff; ff.Next()) + if(ff.IsFolder()) { + tl.group = GetFileTitle(ff.GetName()); + String dir = AppendFileName(pdir, ff.GetName()); + for(FindFile ft(AppendFileName(dir, "*.tpp")); ft; ft.Next()) + if(ft.IsFile()) { + tl.topic = GetFileTitle(ft.GetName()); + int q = tl.topic.ReverseFind('$'); + String l; + if(q >= 0) { + l = ToUpper(tl.topic.Mid(q + 1)); + li.FindAdd(l); + } + String link = TopicLinkString(tl); + if(idelink.Find(link) < 0 && MatchTopicLink(link, sdx) && + (lng == "All" || lng == l)) { + map.GetAdd(tl.package).GetAdd(tl.group).Add(tl.topic); + } + } + } + ScanDirForTpp(pdir, li, sdx, lng, map, tl.package + '/'); + } + } +} + void TopicCtrl::SyncDocTree() { Vector ss = Split((String)~search, ' '); @@ -137,7 +174,6 @@ void TopicCtrl::SyncDocTree() ClearTree(); - static Index idelink; String hdx = "topic://ide/app/index$en-us"; if(idelink.GetCount() == 0) GatherLinks(idelink, hdx); @@ -157,34 +193,8 @@ void TopicCtrl::SyncDocTree() lang.Clear(); lang.Add("All"); Index li; - for(int i = 0; i < upp.GetCount(); i++) { - TopicLink tl; - for(FindFile pff(AppendFileName(upp[i], "*.*")); pff; pff.Next()) { - if(pff.IsFolder()) { - String pdir = AppendFileName(upp[i], pff.GetName()); - tl.package = pff.GetName(); - for(FindFile ff(AppendFileName(pdir, "*.tpp")); ff; ff.Next()) - if(ff.IsFolder()) { - tl.group = GetFileTitle(ff.GetName()); - String dir = AppendFileName(pdir, ff.GetName()); - for(FindFile ft(AppendFileName(dir, "*.tpp")); ft; ft.Next()) - if(ft.IsFile()) { - tl.topic = GetFileTitle(ft.GetName()); - int q = tl.topic.ReverseFind('$'); - String l; - if(q >= 0) { - l = ToUpper(tl.topic.Mid(q + 1)); - li.FindAdd(l); - } - String link = TopicLinkString(tl); - if(idelink.Find(link) < 0 && MatchTopicLink(link, sdx) && - (lng == "All" || lng == l)) - map.GetAdd(tl.package).GetAdd(tl.group).Add(tl.topic); - } - } - } - } - } + for(int i = 0; i < upp.GetCount(); i++) + ScanDirForTpp(upp[i], li, sdx, lng, map, String()); Vector sli = li.PickKeys(); Sort(sli); for(int i = 0; i < sli.GetCount(); i++) @@ -199,7 +209,7 @@ void TopicCtrl::SyncDocTree() TopicLink tl; tl.package = map.GetKey(i); int pid = AddTree(used.Find(tl.package) >= 0 ? usid : otid, - TopicImg::Package(), Null, tl.package); + TopicImg::Package(), Null, tl.package); VectorMap >& package = map[i]; for(int i = 0; i < package.GetCount(); i++) { tl.group = package.GetKey(i); diff --git a/uppsrc/ide/ide.h b/uppsrc/ide/ide.h index 981cfdcae..82aa0689f 100644 --- a/uppsrc/ide/ide.h +++ b/uppsrc/ide/ide.h @@ -268,12 +268,16 @@ private: void All(); void Lang(); void SShow(); + void ScanDirForTpp(const char *dir, Index& li, Vector& sdx, const String& lng, + VectorMap > >& map, + const String& rel); Label search_label; WithDropChoice search; DropList lang; bool internal; bool showwords, issearch, all; + static Index idelink; public: