Recent

Author Topic: [CLOSED] Automate IDE  (Read 3041 times)

pcurtis

  • Hero Member
  • *****
  • Posts: 939
[CLOSED] Automate IDE
« on: December 21, 2021, 11:33:02 am »
After executing

Code: Pascal  [Select][+][-]
  1.   LazarusIDE.DoOpenProjectFile('SomeProjectName.lpr',
  2.     [ofProjectLoading,ofOnlyIfExists,ofConvertMacros,ofDoLoadResource]);
  3.  

How can I show the project inspector and code editor ?
« Last Edit: January 10, 2022, 04:02:20 pm by pcurtis »
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

pcurtis

  • Hero Member
  • *****
  • Posts: 939
Re: Automate IDE
« Reply #1 on: January 07, 2022, 11:50:10 am »
500+ Hits.
Is it even possible?
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

GetMem

  • Hero Member
  • *****
  • Posts: 3752
Re: Automate IDE
« Reply #2 on: January 07, 2022, 12:09:27 pm »
After executing

Code: Pascal  [Select][+][-]
  1.   LazarusIDE.DoOpenProjectFile('SomeProjectName.lpr',
  2.     [ofProjectLoading,ofOnlyIfExists,ofConvertMacros,ofDoLoadResource]);
  3.  

How can I show the project inspector and code editor ?

What exactly are you trying to achieve? It looks like you are trying to open a project from a package via the IDE and package interface. In that case the OI and CodeEditor should be already visible.
I did not checked, but I'm almost certain that accessing the OI via the IDEInterface is not possible, though the interface can be extended if there is a good reason for it.

pcurtis

  • Hero Member
  • *****
  • Posts: 939
Re: Automate IDE
« Reply #3 on: January 07, 2022, 12:56:27 pm »
OK. Simply open the source editor and bring it to the front. Like clicking View -> Source Editor
and then toggle the form view.
« Last Edit: January 07, 2022, 01:07:03 pm by pcurtis »
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

GetMem

  • Hero Member
  • *****
  • Posts: 3752
Re: Automate IDE
« Reply #4 on: January 07, 2022, 02:31:56 pm »
OK. Simply open the source editor and bring it to the front. Like clicking View -> Source Editor
and then toggle the form view.

You still did not tell us what are you trying to achieve.
Code: Pascal  [Select][+][-]
  1. uses SrcEditorIntf;
  2.  
  3. if SourceEditorManagerIntf.ActiveEditor <> nil then
  4. begin
  5.   SourceEditorManagerIntf.ActiveSourceWindow.Show;
  6.   SourceEditorManagerIntf.ActiveSourceWindow.BringToFront;
  7. end;

pcurtis

  • Hero Member
  • *****
  • Posts: 939
Re: Automate IDE
« Reply #5 on: January 07, 2022, 02:52:35 pm »
Show the form designer from after using project templates.
« Last Edit: January 07, 2022, 03:09:55 pm by pcurtis »
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

GetMem

  • Hero Member
  • *****
  • Posts: 3752
Re: Automate IDE
« Reply #6 on: January 07, 2022, 03:25:51 pm »
@pcurtis

I'm not gonna play this game, this is the last one:
Code: Pascal  [Select][+][-]
  1. uses SrcEditorIntf, LazIDEIntf;
  2. //..
  3. var
  4.   EditorForm: TCustomForm;
  5. begin
  6.   if SourceEditorManagerIntf.ActiveEditor <> nil then
  7.   begin
  8.     SourceEditorManagerIntf.ActiveSourceWindow.Show;
  9.     SourceEditorManagerIntf.ActiveSourceWindow.BringToFront;
  10.  
  11.     LazarusIDE.DoShowDesignerFormOfSrc(SourceEditorManagerIntf.ActiveEditor, EditorForm);
  12.     if EditorForm <> nil then
  13.     begin
  14.       EditorForm.Show;
  15.       EditorForm.BringToFront;
  16.     end;
  17.   end;
  18. end;

pcurtis

  • Hero Member
  • *****
  • Posts: 939
Re: Automate IDE
« Reply #7 on: January 07, 2022, 03:38:03 pm »
What game?

Anyway that doesn't work.

I tried in idetemplateproject.pp

Code: Pascal  [Select][+][-]
  1. Procedure DoProject(Sender : TObject);
  2.  
  3. Var
  4.   I : Integer;
  5.   Desc : TTemplateProjectDescriptor;
  6.   fn: string;
  7.   EditorForm: TCustomForm;  
  8.  
  9. begin
  10.   I:=MenuList.count-1;
  11.   Desc:=Nil;
  12.   While (Desc=Nil) and (I>=0) do
  13.     begin
  14.     With TIDEObject(MenuList[i]) do
  15.       if FProjMenu=Sender then
  16.         Desc:=FProjDesc;
  17.     Dec(i);
  18.     end;
  19.   If Desc=Nil then
  20.     exit;
  21.  
  22.   If Desc.ShowOptionsDialog<>mrOk then
  23.     exit;
  24.   Desc.Template.CreateProject(Desc.FProjectDirectory,Desc.FVariables);
  25.   fn:=Desc.FProjectDirectory+Desc.FProjectName;
  26.  // FileReplaceText(fn+'.lpi',Desc.FTemplate.ProjectFile,Desc.FProjectName);
  27.   FileReplaceText(fn+'.lpr',Desc.FTemplate.ProjectFile,Desc.FProjectName);
  28.   FileReplaceText(fn+'.lps',Desc.FTemplate.ProjectFile,Desc.FProjectName);
  29.   LazarusIDE.DoOpenProjectFile(Desc.FProjectDirectory+Desc.FProjectName+'.lpr',
  30.     [ofProjectLoading,ofOnlyIfExists,ofConvertMacros,ofDoLoadResource]);
  31.  
  32.  
  33.   if SourceEditorManagerIntf.ActiveEditor <> nil then
  34.     begin
  35.       SourceEditorManagerIntf.ActiveSourceWindow.Show;
  36.       SourceEditorManagerIntf.ActiveSourceWindow.BringToFront;
  37.     LazarusIDE.DoShowDesignerFormOfSrc(SourceEditorManagerIntf.ActiveEditor, EditorForm);
  38.     if EditorForm <> nil then
  39.     begin
  40.       EditorForm.Show;
  41.       EditorForm.BringToFront;
  42.     end;                 
  43.     end;               
  44. end;
  45.  

SourceEditorManagerIntf.ActiveEditor is sometimes nil.
« Last Edit: January 07, 2022, 07:34:20 pm by pcurtis »
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

 

TinyPortal © 2005-2018