From d4592db146c6de626212caf808c3a4c8297f0af4 Mon Sep 17 00:00:00 2001 From: Mirek Fidler Date: Thu, 27 Oct 2022 11:55:51 +0200 Subject: [PATCH] ide: Fixed creating new codereferenced topic --- examples/AddressBook/AddressBook.lay | 42 ++++++++++++++-------------- uppsrc/ide/Annotations.cpp | 8 +++--- uppsrc/ide/Assist.h | 2 +- uppsrc/ide/Browser/Browser.h | 4 +-- uppsrc/ide/Browser/CodeRef.cpp | 6 ++-- uppsrc/ide/Browser/TopicWin.cpp | 8 +++--- uppsrc/ide/idetool.cpp | 4 +-- 7 files changed, 37 insertions(+), 37 deletions(-) diff --git a/examples/AddressBook/AddressBook.lay b/examples/AddressBook/AddressBook.lay index 7f5748d9b..d73dee42b 100644 --- a/examples/AddressBook/AddressBook.lay +++ b/examples/AddressBook/AddressBook.lay @@ -1,31 +1,31 @@ LAYOUT(AddressBookLayout, 512, 456) ITEM(MenuBar, menu, LeftPosZ(0, 216).TopPosZ(0, 20)) - ITEM(TabCtrl, tab, LeftPosZ(8, 496).TopPosZ(32, 84)) - ITEM(ArrayCtrl, array, LeftPosZ(8, 496).TopPosZ(124, 324)) + ITEM(Upp::TabCtrl, tab, LeftPosZ(8, 496).TopPosZ(32, 84)) + ITEM(Upp::ArrayCtrl, array, LeftPosZ(8, 496).TopPosZ(124, 324)) END_LAYOUT LAYOUT(ModifyLayout, 480, 52) - ITEM(Label, dv___0, SetLabel(t_("&Name")).LeftPosZ(8, 48).TopPosZ(8, 15)) - ITEM(EditField, name, LeftPosZ(8, 96).TopPosZ(28, 19)) - ITEM(Label, dv___2, SetLabel(t_("&Surname")).LeftPosZ(108, 48).TopPosZ(8, 15)) - ITEM(EditField, surname, LeftPosZ(108, 96).TopPosZ(28, 19)) - ITEM(Label, dv___4, SetLabel(t_("&Address")).LeftPosZ(208, 48).TopPosZ(8, 15)) - ITEM(EditField, address, LeftPosZ(208, 96).TopPosZ(28, 19)) - ITEM(Label, dv___6, SetLabel(t_("&Email")).LeftPosZ(308, 48).TopPosZ(8, 15)) - ITEM(EditField, email, LeftPosZ(308, 96).TopPosZ(28, 19)) - ITEM(Button, add, SetLabel(t_("Ad&d")).LeftPosZ(416, 56).TopPosZ(4, 20)) - ITEM(Button, change, SetLabel(t_("&Change")).LeftPosZ(416, 56).TopPosZ(28, 20)) + ITEM(Upp::Label, dv___0, SetLabel(t_("&Name")).LeftPosZ(8, 48).TopPosZ(8, 15)) + ITEM(Upp::EditField, name, LeftPosZ(8, 96).TopPosZ(28, 19)) + ITEM(Upp::Label, dv___2, SetLabel(t_("&Surname")).LeftPosZ(108, 48).TopPosZ(8, 15)) + ITEM(Upp::EditField, surname, LeftPosZ(108, 96).TopPosZ(28, 19)) + ITEM(Upp::Label, dv___4, SetLabel(t_("&Address")).LeftPosZ(208, 48).TopPosZ(8, 15)) + ITEM(Upp::EditField, address, LeftPosZ(208, 96).TopPosZ(28, 19)) + ITEM(Upp::Label, dv___6, SetLabel(t_("&Email")).LeftPosZ(308, 48).TopPosZ(8, 15)) + ITEM(Upp::EditField, email, LeftPosZ(308, 96).TopPosZ(28, 19)) + ITEM(Upp::Button, add, SetLabel(t_("Ad&d")).LeftPosZ(416, 56).TopPosZ(4, 20)) + ITEM(Upp::Button, change, SetLabel(t_("&Change")).LeftPosZ(416, 56).TopPosZ(28, 20)) END_LAYOUT LAYOUT(SearchLayout, 480, 56) - ITEM(Option, oname, SetLabel(t_("&Name")).LeftPosZ(8, 56).TopPosZ(8, 18)) - ITEM(EditField, name, LeftPosZ(8, 96).TopPosZ(28, 19)) - ITEM(Option, osurname, SetLabel(t_("&Surname")).LeftPosZ(108, 64).TopPosZ(8, 18)) - ITEM(EditField, surname, LeftPosZ(108, 96).TopPosZ(28, 19)) - ITEM(Option, oaddress, SetLabel(t_("&Address")).LeftPosZ(208, 64).TopPosZ(8, 18)) - ITEM(EditField, address, LeftPosZ(208, 96).TopPosZ(28, 19)) - ITEM(Option, oemail, SetLabel(t_("&Email")).LeftPosZ(308, 52).TopPosZ(8, 18)) - ITEM(EditField, email, LeftPosZ(308, 96).TopPosZ(28, 19)) - ITEM(Button, search, SetLabel(t_("&Search")).LeftPosZ(416, 56).TopPosZ(28, 20)) + ITEM(Upp::Option, oname, SetLabel(t_("&Name")).LeftPosZ(8, 56).TopPosZ(8, 18)) + ITEM(Upp::EditField, name, LeftPosZ(8, 96).TopPosZ(28, 19)) + ITEM(Upp::Option, osurname, SetLabel(t_("&Surname")).LeftPosZ(108, 64).TopPosZ(8, 18)) + ITEM(Upp::EditField, surname, LeftPosZ(108, 96).TopPosZ(28, 19)) + ITEM(Upp::Option, oaddress, SetLabel(t_("&Address")).LeftPosZ(208, 64).TopPosZ(8, 18)) + ITEM(Upp::EditField, address, LeftPosZ(208, 96).TopPosZ(28, 19)) + ITEM(Upp::Option, oemail, SetLabel(t_("&Email")).LeftPosZ(308, 52).TopPosZ(8, 18)) + ITEM(Upp::EditField, email, LeftPosZ(308, 96).TopPosZ(28, 19)) + ITEM(Upp::Button, search, SetLabel(t_("&Search")).LeftPosZ(416, 56).TopPosZ(28, 20)) END_LAYOUT diff --git a/uppsrc/ide/Annotations.cpp b/uppsrc/ide/Annotations.cpp index 27712ecea..542f8d744 100644 --- a/uppsrc/ide/Annotations.cpp +++ b/uppsrc/ide/Annotations.cpp @@ -141,12 +141,12 @@ void AssistEditor::OpenTopic(String topic, String create, bool before) theide->OpenTopic(topic, create, before); } -const AnnotationItem *AssistEditor::GetAnnotationPtr(const String& id) +AnnotationItem AssistEditor::GetCodeAnnotation(const String& id) { for(const AnnotationItem& h : annotations) if(h.id == id) - return &h; - return nullptr; + return h; + return AnnotationItem(); } void SplitCodeRef(const String& s, String& scope, String& item) @@ -177,7 +177,7 @@ void AssistEditor::NewTopic(String group, String coderef) return; String scope, item; SplitCodeRef(coderef, scope, item); - if(!te->NewTopicEx(IsNull(scope) ? n : Join(Split(scope, ':'), "_"), GetAnnotationPtr(coderef))) + if(!te->NewTopicEx(IsNull(scope) ? n : Join(Split(scope, ':'), "_"), GetCodeAnnotation(coderef))) theide->EditFile(ef); } diff --git a/uppsrc/ide/Assist.h b/uppsrc/ide/Assist.h index bd9ab1c72..b16d68364 100644 --- a/uppsrc/ide/Assist.h +++ b/uppsrc/ide/Assist.h @@ -190,7 +190,7 @@ struct AssistEditor : CodeEditor, Navigator { bool WaitCurrentFile(); - const AnnotationItem *GetAnnotationPtr(const String& id); + AnnotationItem GetCodeAnnotation(const String& id); bool GetAnnotationRefs(Vector& tl, String& coderef, int q = -1); bool GetAnnotationRef(String& t, String& coderef, int q = -1); diff --git a/uppsrc/ide/Browser/Browser.h b/uppsrc/ide/Browser/Browser.h index 03248ab90..957e0d5e0 100644 --- a/uppsrc/ide/Browser/Browser.h +++ b/uppsrc/ide/Browser/Browser.h @@ -207,10 +207,10 @@ public: typedef TopicEditor CLASSNAME; void ShowEditor(bool b) { editor.Show(b); } - bool NewTopicEx(const String& name, const AnnotationItem *create); + bool NewTopicEx(const String& iname, const AnnotationItem& create); void Open(const String& grouppath); void OpenFile(const String& path); - void GoTo(const String& _topic, const String& link, const AnnotationItem *create, bool before); + void GoTo(const String& _topic, const String& link, const AnnotationItem& create, bool before); void GoToPart(int ii); void PersistentFindReplace(bool b) { editor.PersistentFindReplace(b); } diff --git a/uppsrc/ide/Browser/CodeRef.cpp b/uppsrc/ide/Browser/CodeRef.cpp index f26018b19..49694a2bf 100644 --- a/uppsrc/ide/Browser/CodeRef.cpp +++ b/uppsrc/ide/Browser/CodeRef.cpp @@ -314,14 +314,14 @@ void TopicEditor::GoTo(const String& _topic, const String& link, const String& c -void TopicEditor::GoTo(const String& _topic, const String& link, const AnnotationItem *create, bool before) +void TopicEditor::GoTo(const String& _topic, const String& link, const AnnotationItem& create, bool before) { if(topics_list.FindSetCursor(_topic) && !IsNull(link)) { editor.Select(editor.GetLength(), 0); for(String cr : AnnotationCandidates(link)) if(editor.GotoLabel([&](const WString& id) { return cr == CleanupTppId(id.ToString()); })) break; - if(create) { + if(create.id.GetCount()) { if(!before) for(int pass = 0; pass < 2; pass++) for(;;) { @@ -333,7 +333,7 @@ void TopicEditor::GoTo(const String& _topic, const String& link, const Annotatio if(editor.GetCursor() == c) break; } - InsertNew(*create); + InsertNew(create); } } } diff --git a/uppsrc/ide/Browser/TopicWin.cpp b/uppsrc/ide/Browser/TopicWin.cpp index c1640d2b4..c9b547b4d 100644 --- a/uppsrc/ide/Browser/TopicWin.cpp +++ b/uppsrc/ide/Browser/TopicWin.cpp @@ -278,7 +278,7 @@ void CreateTopic(const char *fn, int lang, const String& ss) SaveFile(fn, WriteTopic("", ParseQTF(ss + "[{_}%" + LNGAsText(lang) + " "))); } -bool TopicEditor::NewTopicEx(const String& iname, const AnnotationItem *create) +bool TopicEditor::NewTopicEx(const String& iname, const AnnotationItem& create) { TopicDlg > d("New topic"); d.lang <<= lastlang; @@ -326,14 +326,14 @@ bool TopicEditor::NewTopicEx(const String& iname, const AnnotationItem *create) topics_list.FindSetCursor(GetFileTitle(fn)); editor.SetFocus(); serial++; - if(create) - InsertNew(*create); + if(create.id.GetCount()) + InsertNew(create); return true; } void TopicEditor::NewTopic() { - NewTopicEx(Null, nullptr); + NewTopicEx(Null, AnnotationItem()); } void TopicEditor::RemoveTopic() diff --git a/uppsrc/ide/idetool.cpp b/uppsrc/ide/idetool.cpp index 5b185f6c6..6d3960227 100644 --- a/uppsrc/ide/idetool.cpp +++ b/uppsrc/ide/idetool.cpp @@ -88,7 +88,7 @@ void Ide::OpenTopic(const String& topic, const String& create_id, bool before) if(designer) { TopicEditor *te = dynamic_cast(&designer->DesignerCtrl()); if(te) - te->GoTo(tl.topic, tl.label, editor.GetAnnotationPtr(create_id), before); + te->GoTo(tl.topic, tl.label, editor.GetCodeAnnotation(create_id), before); } } } @@ -117,7 +117,7 @@ void Ide::IdeOpenTopicFile(const String& file) if(designer) { TopicEditor *te = dynamic_cast(&designer->DesignerCtrl()); if(te) - te->GoTo(GetFileTitle(file), "", nullptr, false); + te->GoTo(GetFileTitle(file), "", AnnotationItem(), false); } }