ide: When going from LayDes to text, cursor is put on current layout

git-svn-id: svn://ultimatepp.org/upp/trunk@15965 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2021-05-27 06:47:56 +00:00
parent 95aad22691
commit 2cb907542e
3 changed files with 19 additions and 0 deletions

View file

@ -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()); }
};

View file

@ -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;

View file

@ -711,11 +711,22 @@ void Ide::EditAsText()
return;
// if(!FileExists(path))
// return;
String layout;
if(auto *l = dynamic_cast<LayDesigner *>(~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()