From 838b25429b54e6a4f1903a3576716666d0977078 Mon Sep 17 00:00:00 2001 From: Mirek Fidler Date: Fri, 3 May 2024 12:33:31 +0200 Subject: [PATCH] ide: Improved Assist in layout files in text mode --- uppsrc/ide/ContextGoto.cpp | 4 ++++ uppsrc/ide/Swaps.cpp | 4 ++++ uppsrc/ide/Usage.cpp | 12 ++++++++++++ uppsrc/ide/ide.h | 2 ++ uppsrc/ide/idefile.cpp | 27 ++++++++++++++++----------- 5 files changed, 38 insertions(+), 11 deletions(-) diff --git a/uppsrc/ide/ContextGoto.cpp b/uppsrc/ide/ContextGoto.cpp index d0ad93af5..766fc2326 100644 --- a/uppsrc/ide/ContextGoto.cpp +++ b/uppsrc/ide/ContextGoto.cpp @@ -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()) { diff --git a/uppsrc/ide/Swaps.cpp b/uppsrc/ide/Swaps.cpp index f8e48ac32..fb7ecefde 100644 --- a/uppsrc/ide/Swaps.cpp +++ b/uppsrc/ide/Swaps.cpp @@ -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); diff --git a/uppsrc/ide/Usage.cpp b/uppsrc/ide/Usage.cpp index 413dec650..819a2c00f 100644 --- a/uppsrc/ide/Usage.cpp +++ b/uppsrc/ide/Usage.cpp @@ -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; diff --git a/uppsrc/ide/ide.h b/uppsrc/ide/ide.h index 2df981b79..1753468f9 100644 --- a/uppsrc/ide/ide.h +++ b/uppsrc/ide/ide.h @@ -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(); diff --git a/uppsrc/ide/idefile.cpp b/uppsrc/ide/idefile.cpp index 5618fa423..17c48e9f2 100644 --- a/uppsrc/ide/idefile.cpp +++ b/uppsrc/ide/idefile.cpp @@ -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()) {