diff --git a/uppsrc/ide/LayDes/LayDes.h b/uppsrc/ide/LayDes/LayDes.h index 8deee82a2..aad1e80f1 100644 --- a/uppsrc/ide/LayDes/LayDes.h +++ b/uppsrc/ide/LayDes/LayDes.h @@ -467,6 +467,7 @@ private: void RestoreEditPos(); void FindLayout(const String& name, const String& item_name); + String GetLayoutName() const; bool Load(const char *filename, byte charset); @@ -496,6 +497,7 @@ public: bool Load(const char *filename, byte cs) { return designer.Load(filename, cs); } void FindLayout(const String& name, const String& item) { designer.FindLayout(name, item); } + String GetCurrentLayout() const { return designer.GetLayoutName(); } LayDesigner() { parent.Add(designer.DesignerCtrl().SizePos()); } }; diff --git a/uppsrc/ide/LayDes/layfile.cpp b/uppsrc/ide/LayDes/layfile.cpp index ea19641e9..12826f1a2 100644 --- a/uppsrc/ide/LayDes/layfile.cpp +++ b/uppsrc/ide/LayDes/layfile.cpp @@ -94,6 +94,12 @@ void LayDes::FindLayout(const String& name, const String& item_name) } } +String LayDes::GetLayoutName() const +{ + return currentlayout >= 0 && currentlayout < layout.GetCount() ? layout[currentlayout].name + : String(); +} + bool LayDes::Load(const char *file, byte _charset) { charset = _charset; diff --git a/uppsrc/ide/idefile.cpp b/uppsrc/ide/idefile.cpp index f4420adf9..2638789a1 100644 --- a/uppsrc/ide/idefile.cpp +++ b/uppsrc/ide/idefile.cpp @@ -711,11 +711,22 @@ void Ide::EditAsText() return; // if(!FileExists(path)) // return; + String layout; + if(auto *l = dynamic_cast(~designer)) + layout = l->GetCurrentLayout(); DoEditAsText(path); byte cs = editor.GetCharset(); int sc = editor.GetSpellcheckComments(); FlushFile(); EditFile0(path, cs, sc); + if(layout.GetCount()) { + layout = "LAYOUT(" + layout + ","; + for(int i = 0; i < editor.GetLineCount(); i++) + if(editor.GetUtf8Line(i).StartsWith(layout)) { + editor.GotoLine(i); + break; + } + } } void Ide::EditUsingDesigner()