mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
ide: Fixed problem with highlighting annotation in help window
This commit is contained in:
parent
a1c3e984bb
commit
66dc3536d2
4 changed files with 27 additions and 21 deletions
|
|
@ -15,28 +15,30 @@ void HelpWindow::FinishText(RichText& text)
|
|||
|
||||
bool HelpWindow::GoTo0(const String& link)
|
||||
{
|
||||
if(IsNull(link) || current_link == link)
|
||||
if(IsNull(link) || doing_goto)
|
||||
return true;
|
||||
Topic t = AcquireTopic(link);
|
||||
SetBar();
|
||||
if(!IsNull(t.text)) {
|
||||
if(current_link != link) {
|
||||
Topic t = AcquireTopic(link);
|
||||
SetBar();
|
||||
if(IsNull(t.text))
|
||||
return false;
|
||||
label = t.label;
|
||||
topic = t.link;
|
||||
doing_goto++; // suppress recursive GoTo
|
||||
if(~tree != topic)
|
||||
tree.FindSetCursor(topic);
|
||||
doing_goto--;
|
||||
Title(ToUtf32(t.title));
|
||||
RichText txt = ParseQTF(t.text);
|
||||
FinishText(txt);
|
||||
view.Pick(pick(txt), zoom);
|
||||
current_link = link;
|
||||
if(WhenMatchLabel) {
|
||||
WString lw = label.ToWString();
|
||||
return view.GotoLabel([=](const WString& data) { return WhenMatchLabel(data, lw); }, true);
|
||||
}
|
||||
else
|
||||
return view.GotoLabel(label, true);
|
||||
}
|
||||
return false;
|
||||
if(WhenMatchLabel) {
|
||||
WString lw = label.ToWString();
|
||||
return view.GotoLabel([=](const WString& data) { return WhenMatchLabel(data, lw); }, true, true);
|
||||
}
|
||||
return view.GotoLabel(label, true, true);
|
||||
}
|
||||
|
||||
HelpWindow::Pos HelpWindow::GetPos()
|
||||
|
|
@ -49,7 +51,7 @@ HelpWindow::Pos HelpWindow::GetPos()
|
|||
|
||||
bool HelpWindow::GoTo(const String& link)
|
||||
{
|
||||
if(IsNull(link) || current_link == link)
|
||||
if(IsNull(link))
|
||||
return false;
|
||||
Pos p = GetPos();
|
||||
if(GoTo0(link)) {
|
||||
|
|
|
|||
|
|
@ -75,8 +75,8 @@ public:
|
|||
Zoom GetZoom() const;
|
||||
Rect GetPage() const;
|
||||
|
||||
bool GotoLabel(Gate<const WString&> match, bool dohighlight = false);
|
||||
bool GotoLabel(const String& lbl, bool highlight = false);
|
||||
bool GotoLabel(Gate<const WString&> match, bool dohighlight = false, bool match_last = false);
|
||||
bool GotoLabel(const String& lbl, bool highlight = false, bool match_last = false);
|
||||
void ClearHighlight() { highlight = Null; Refresh(); }
|
||||
|
||||
int GetLength() const { return text.GetLength(); }
|
||||
|
|
@ -300,6 +300,7 @@ private:
|
|||
String topic;
|
||||
String label;
|
||||
String current_link;
|
||||
int doing_goto = 0;
|
||||
|
||||
bool GoTo0(const String& link);
|
||||
void Back();
|
||||
|
|
|
|||
|
|
@ -317,26 +317,29 @@ void RichTextView::Scroll()
|
|||
scroller.Scroll(*this, Rect(GetSize()).Deflated(margin), sb * GetZoom());
|
||||
}
|
||||
|
||||
bool RichTextView::GotoLabel(Gate<const WString&> match, bool dohighlight)
|
||||
bool RichTextView::GotoLabel(Gate<const WString&> match, bool dohighlight, bool find_last)
|
||||
{
|
||||
Vector<RichValPos> f = text.GetValPos(GetPage(), RichText::LABELS);
|
||||
highlight = Null;
|
||||
bool ret = false;
|
||||
for(int i = 0; i < f.GetCount(); i++) {
|
||||
if(match(f[i].data)) {
|
||||
sb = f[i].py.y;
|
||||
if(dohighlight)
|
||||
highlight = f[i].pos;
|
||||
Refresh();
|
||||
return true;
|
||||
if(!find_last)
|
||||
return true;
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool RichTextView::GotoLabel(const String& lbl, bool dohighlight)
|
||||
bool RichTextView::GotoLabel(const String& lbl, bool dohighlight, bool find_last)
|
||||
{
|
||||
WString lw = lbl.ToWString();
|
||||
return GotoLabel([&](const WString& data) { return data == lw; }, dohighlight);
|
||||
return GotoLabel([&](const WString& data) { return data == lw; }, dohighlight, find_last);
|
||||
}
|
||||
|
||||
void RichTextView::Clear()
|
||||
|
|
|
|||
|
|
@ -218,11 +218,11 @@ void AssistEditor::EditAnnotation(bool leftclick)
|
|||
if(!GetAnnotationRefs(tl, coderef))
|
||||
return;
|
||||
SetCursor(GetPos64(GetActiveAnnotationLine()));
|
||||
if(leftclick) {
|
||||
if(leftclick) { // show documentation in help widget
|
||||
auto GoToTopic = [&] (int i) {
|
||||
if(theide) {
|
||||
theide->doc.WhenMatchLabel = [](const WString& lbl, const WString& ref) {
|
||||
return CleanupTppId(lbl.ToString()) == ref.ToString();
|
||||
return ref.ToString() == CleanupTppId(lbl.ToString());
|
||||
};
|
||||
theide->ShowTopics();
|
||||
for(String cr : AnnotationCandidates(coderef))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue