ide: Improved Assist in layout files in text mode

This commit is contained in:
Mirek Fidler 2024-05-03 12:33:31 +02:00
parent 20e5b5fafd
commit 838b25429b
5 changed files with 38 additions and 11 deletions

View file

@ -92,6 +92,10 @@ void Ide::ContextGoto0(int pos)
String l = editor.GetUtf8Line(li);
if(OpenLink(l, lp))
return;
if(editfile.EndsWith(".lay")) {
EditUsingDesigner();
return;
}
if(IsPif(l) || IsPelse(l)) {
int lvl = 0;
while(li + 1 < editor.GetLineCount()) {

View file

@ -8,6 +8,10 @@ void Ide::SwapS()
return;
if(!editor.WaitCurrentFile())
return;
if(editfile.EndsWith(".lay")) {
EditUsingDesigner();
return;
}
AnnotationItem cm = editor.FindCurrentAnnotation();
PutAssist("Swap: " + cm.id);
Cycle(cm, cm.pos.y, false);

View file

@ -261,6 +261,18 @@ void Ide::Usage()
void Ide::IdUsage()
{
if(designer)
return;
if(editfile.EndsWith(".lay")) {
String layout, item;
if(GetLayoutItem(layout, item)) {
if(item.GetCount())
FindDesignerItemReferences("With" + layout + "::" + item, item);
else
FindDesignerItemReferences("With" + layout, layout);
}
return;
}
String name;
Point ref_pos;
String ref_id;

View file

@ -796,6 +796,8 @@ public:
void GotoPos(String path, int line);
void GotoPos(String path, Point pos);
bool GetLayoutItem(String& layout, String& item);
void LoadAbbr();
void SaveAbbr();

View file

@ -757,16 +757,8 @@ void Ide::EditAsText()
}
}
void Ide::EditUsingDesigner()
bool Ide::GetLayoutItem(String& layout, String& item)
{
String path = editfile;
if(editastext.Find(editfile) < 0 && editashex.Find(editfile) < 0)
return;
editashex.RemoveKey(editfile);
editastext.RemoveKey(editfile);
byte cs = editor.GetCharset();
int sc = editor.GetSpellcheckComments();
String layout, item;
if(ToLower(GetFileExt(editfile)) == ".lay") {
int i = editor.GetLine(editor.GetCursor());
item = GetLayItemId(editor.GetUtf8Line(i));
@ -777,13 +769,26 @@ void Ide::EditUsingDesigner()
if(p.Id("LAYOUT")) {
p.Char('(');
layout = p.ReadId();
break;
return true;
}
}
catch(CParser::Error) {}
}
}
return false;
}
void Ide::EditUsingDesigner()
{
String path = editfile;
if(editastext.Find(editfile) < 0 && editashex.Find(editfile) < 0)
return;
editashex.RemoveKey(editfile);
editastext.RemoveKey(editfile);
byte cs = editor.GetCharset();
int sc = editor.GetSpellcheckComments();
String layout, item;
GetLayoutItem(layout, item);
FlushFile();
EditFile0(path, cs, sc);
if(layout.GetCount()) {