Skip to content

Commit 406c5dd

Browse files
committed
bk/2024-05-22-1701
1 parent d26f054 commit 406c5dd

File tree

6 files changed

+47
-226
lines changed

6 files changed

+47
-226
lines changed

Src/Consts/C4D.Wizard.Consts.pas

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ TC4DConsts = class
109109
MENU_IDE_VSCODE_INTEGRATION_OPEN_CAPTION = 'Open In VS Code';
110110
MENU_IDE_VSCODE_INTEGRATION_INSTALL_DELPHILSP_NAME = 'C4DWizarVsCodeIntegrationInstallDelphiLSP1';
111111
MENU_IDE_VSCODE_INTEGRATION_INSTALL_DELPHILSP_CAPTION = 'Install DelphiLSP extension in VS Code';
112+
MENU_IDE_VSCODE_INTEGRATION_INSTALL_GithubCopilot_NAME = 'C4DWizarVsCodeIntegrationInstallGithubCopilot1';
113+
MENU_IDE_VSCODE_INTEGRATION_INSTALL_GithubCopilot_CAPTION = 'Install GitHub Copilot extension in VS Code';
112114

113115
//FILE .INI REOPEN
114116
REOPEN_INI_Favorite = 'Favorite';

Src/IDE/MainMenu/C4D.Wizard.IDE.MainMenu.Clicks.pas

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ TC4DWizardIDEMainMenuClicks = class
2222
class procedure ReplaceClick(Sender: TObject);
2323
class procedure NotesClick(Sender: TObject);
2424
class procedure VsCodeIntegrationOpenInVsCodeClick(Sender: TObject);
25+
class procedure VsCodeIntegrationInstallGithubCopilotClick(Sender: TObject);
2526
class procedure VsCodeIntegrationInstallDelphiLSPClick(Sender: TObject);
2627
class procedure DefaultFilesInOpeningProjectClick(Sender: TObject);
2728
class procedure BackupExportClick(Sender: TObject);
@@ -140,6 +141,11 @@ class procedure TC4DWizardIDEMainMenuClicks.VsCodeIntegrationOpenInVsCodeClick(S
140141
TC4DWizardVsCodeIntegration.Open;
141142
end;
142143

144+
class procedure TC4DWizardIDEMainMenuClicks.VsCodeIntegrationInstallGithubCopilotClick(Sender: TObject);
145+
begin
146+
TC4DWizardVsCodeIntegration.InstallGithubCopilot;
147+
end;
148+
143149
class procedure TC4DWizardIDEMainMenuClicks.VsCodeIntegrationInstallDelphiLSPClick(Sender: TObject);
144150
begin
145151
TC4DWizardVsCodeIntegration.InstallDelphiLSP;

Src/IDE/MainMenu/C4D.Wizard.IDE.MainMenu.VsCodeIntegration.pas

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ TC4DWizardIDEMainMenuVsCodeIntegration = class(TInterfacedObject, IC4DWizardID
1919
FMenuItemVsCodeIntegration: TMenuItem;
2020
procedure AddMenuVsCodeIntegration;
2121
procedure AddSubMenuItemOpen;
22-
procedure AddSubMenuInstallDelphiLSP;
2322
procedure AddSeparator(AName: string);
23+
procedure AddSubMenuInstallGithubCopilot;
24+
procedure AddSubMenuInstallDelphiLSP;
2425
function GetShortcutOpenInVsCode: string;
2526
protected
2627
function Process: IC4DWizardIDEMainMenuVsCodeIntegration;
@@ -53,6 +54,7 @@ function TC4DWizardIDEMainMenuVsCodeIntegration.Process: IC4DWizardIDEMainMenuVs
5354
Self.AddMenuVsCodeIntegration;
5455
Self.AddSubMenuItemOpen;
5556
Self.AddSeparator('C4DVsCodeIntegrationSeparator01');
57+
Self.AddSubMenuInstallGithubCopilot;
5658
Self.AddSubMenuInstallDelphiLSP;
5759
end;
5860

@@ -90,6 +92,18 @@ procedure TC4DWizardIDEMainMenuVsCodeIntegration.AddSubMenuItemOpen;
9092
FMenuItemVsCodeIntegration.Add(LMenuItem);
9193
end;
9294

95+
procedure TC4DWizardIDEMainMenuVsCodeIntegration.AddSubMenuInstallGithubCopilot;
96+
var
97+
LMenuItem: TMenuItem;
98+
begin
99+
LMenuItem := TMenuItem.Create(FMenuItemVsCodeIntegration);
100+
LMenuItem.Name := TC4DConsts.MENU_IDE_VSCODE_INTEGRATION_INSTALL_GithubCopilot_NAME;
101+
LMenuItem.Caption := TC4DConsts.MENU_IDE_VSCODE_INTEGRATION_INSTALL_GithubCopilot_CAPTION;
102+
LMenuItem.ImageIndex := TC4DWizardIDEImageListMain.GetInstance.ImgIndexImport;
103+
LMenuItem.OnClick := TC4DWizardIDEMainMenuClicks.VsCodeIntegrationInstallGithubCopilotClick;
104+
FMenuItemVsCodeIntegration.Add(LMenuItem);
105+
end;
106+
93107
procedure TC4DWizardIDEMainMenuVsCodeIntegration.AddSubMenuInstallDelphiLSP;
94108
var
95109
LMenuItem: TMenuItem;

Src/View/C4D.Wizard.View.About.dfm

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,6 +2092,7 @@ object C4DWizardViewAbout: TC4DWizardViewAbout
20922092
Padding.Right = 2
20932093
Padding.Bottom = 2
20942094
TabOrder = 1
2095+
ExplicitTop = 265
20952096
object btnOK: TButton
20962097
Left = 522
20972098
Top = 2
@@ -2113,32 +2114,5 @@ object C4DWizardViewAbout: TC4DWizardViewAbout
21132114
TabOrder = 1
21142115
OnClick = btnTesteClick
21152116
end
2116-
object Button1: TButton
2117-
Left = 112
2118-
Top = 3
2119-
Width = 75
2120-
Height = 25
2121-
Caption = 'Button1'
2122-
TabOrder = 2
2123-
OnClick = Button1Click
2124-
end
2125-
object Button2: TButton
2126-
Left = 193
2127-
Top = 6
2128-
Width = 75
2129-
Height = 25
2130-
Caption = 'Button2'
2131-
TabOrder = 3
2132-
OnClick = Button2Click
2133-
end
2134-
object Button3: TButton
2135-
Left = 288
2136-
Top = -1
2137-
Width = 75
2138-
Height = 25
2139-
Caption = 'Button3'
2140-
TabOrder = 4
2141-
OnClick = Button3Click
2142-
end
21432117
end
21442118
end

Src/View/C4D.Wizard.View.About.pas

Lines changed: 1 addition & 195 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ TC4DWizardViewAbout = class(TForm)
3636
Panel1: TPanel;
3737
lbDonateToCode4Delphi: TLabel;
3838
imgDonate: TImage;
39-
Button1: TButton;
40-
Button2: TButton;
41-
Button3: TButton;
4239
procedure FormShow(Sender: TObject);
4340
procedure btnOKClick(Sender: TObject);
4441
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
@@ -49,9 +46,6 @@ TC4DWizardViewAbout = class(TForm)
4946
procedure FormCreate(Sender: TObject);
5047
procedure btnTesteClick(Sender: TObject);
5148
procedure lbDonateToCode4DelphiClick(Sender: TObject);
52-
procedure Button1Click(Sender: TObject);
53-
procedure Button2Click(Sender: TObject);
54-
procedure Button3Click(Sender: TObject);
5549
private
5650

5751
public
@@ -129,196 +123,8 @@ procedure TC4DWizardViewAbout.lbSiteCode4DelphiMouseMove(Sender: TObject; Shift:
129123
end;
130124

131125
procedure TC4DWizardViewAbout.btnTesteClick(Sender: TObject);
132-
var
133-
LIOTAModuleServices: IOTAModuleServices;
134-
LIOTASourceEditor: IOTASourceEditor;
135-
LFileName: string;
136-
i: integer;
137-
138-
LIOTAModule: IOTAModule;
139-
begin
140-
LIOTAModule := TC4DWizardUtilsOTA.GetCurrentModule;
141-
LFileName := '';
142-
LIOTASourceEditor := TC4DWizardUtilsOTA.GetIOTASourceEditor(LIOTAModule);
143-
if LIOTASourceEditor <> nil then
144-
LFileName := LIOTASourceEditor.FileName;
145-
146-
TC4DWizardUtils.ShowMsg('Atual: ' + LFileName);
147-
//**
148-
149-
LIOTAModuleServices := TC4DWizardUtilsOTA.GetIOTAModuleServices;
150-
if(not Assigned(LIOTAModuleServices))then
151-
raise Exception.Create('No Units Opened was found');
152-
153-
mmMensagem.Lines.Clear;
154-
for i := 0 to pred(LIOTAModuleServices.ModuleCount) do
155-
begin
156-
LIOTAModule := LIOTAModuleServices.GetModule(i);
157-
158-
LIOTASourceEditor := TC4DWizardUtilsOTA.GetIOTASourceEditor(LIOTAModule);
159-
if LIOTASourceEditor <> nil then
160-
if LIOTASourceEditor.CreateReader <> nil then
161-
mmMensagem.Lines.Add(LIOTAModule.FileName);
162-
163-
164-
165-
{for LContFile := 0 to pred(LIOTAModule.GetModuleFileCount)do
166-
begin
167-
//LIOTAEditor := LIOTAModule.GetModuleFileEditor(LContFile);
168-
//if(Supports(LIOTAEditor, IOTASourceEditor, LIOTASourceEditor))then
169-
//begin
170-
// Self.ListFilesAdd(LIOTAEditor.FileName);
171-
// Break;
172-
//end;
173-
end;}
174-
end;
175-
end;
176-
177-
function CnOtaGetFileEditorForModule(Module: IOTAModule; Index: Integer): IOTAEditor;
178-
begin
179-
Result := nil;
180-
if not Assigned(Module) then
181-
Exit;
182-
183-
try
184-
{$IFDEF BCB5}
185-
if IsCpp(Module.FileName) and (Module.GetModuleFileCount = 2) and (Index = 1) then
186-
Index := 2;
187-
{$ENDIF}
188-
Result := Module.GetModuleFileEditor(Index);
189-
except
190-
Result := nil;
191-
end;
192-
end;
193-
194-
function CnOtaIsFileOpen(const FileName: string): Boolean;
195-
var
196-
ModuleServices: IOTAModuleServices;
197-
Module: IOTAModule;
198-
FileEditor: IOTAEditor;
199-
I: Integer;
200-
begin
201-
Result := False;
202-
203-
ModuleServices := BorlandIDEServices as IOTAModuleServices;
204-
if ModuleServices = nil then
205-
Exit;
206-
207-
Module := ModuleServices.FindModule(FileName);
208-
if Assigned(Module) then
209-
begin
210-
for I := 0 to Module.GetModuleFileCount-1 do
211-
begin
212-
FileEditor := CnOtaGetFileEditorForModule(Module, I);
213-
Assert(Assigned(FileEditor));
214-
215-
Result := CompareText(FileName, FileEditor.FileName) = 0;
216-
if Result then
217-
Exit;
218-
end;
219-
end;
220-
end;
221-
222-
procedure TC4DWizardViewAbout.Button1Click(Sender: TObject);
223-
var
224-
LIOTAModuleServices: IOTAModuleServices;
225-
I: Integer;
226-
LIOTAModule: IOTAModule;
227-
LIOTAEditor: IOTAEditor;
228-
begin
229-
mmMensagem.Lines.Clear;
230-
231-
LIOTAModuleServices := BorlandIDEServices as IOTAModuleServices;
232-
for I := 0 to LIOTAModuleServices.ModuleCount - 1 do
233-
begin
234-
LIOTAModule := LIOTAModuleServices.Modules[I];
235-
LIOTAEditor := LIOTAModule.CurrentEditor;
236-
if LIOTAEditor = nil then
237-
Continue;
238-
239-
if not CnOtaIsFileOpen(LIOTAModule.FileName) then
240-
Continue;
241-
242-
if not TC4DWizardUtilsOTA.FileIsOpenInIDE(LIOTAModule.FileName) then
243-
Continue;
244-
245-
mmMensagem.Lines.Add(LIOTAModule.FileName);
246-
end;
247-
end;
248-
249-
procedure TC4DWizardViewAbout.Button2Click(Sender: TObject);
250-
var
251-
LIOTAModuleServices: IOTAModuleServices;
252-
LIOTAModule: IOTAModule;
253-
LIOTAEditor: IOTAEditor;
254-
i: Integer;
255-
LIOTASourceEditor: IOTASourceEditor;
256-
LIOTAEditView: IOTAEditView;
257-
begin
258-
mmMensagem.Lines.Clear;
259-
260-
LIOTAModuleServices := BorlandIDEServices as IOTAModuleServices;
261-
262-
for i := 0 to Pred(LIOTAModuleServices.ModuleCount) do
263-
begin
264-
LIOTAModule := LIOTAModuleServices.Modules[i];
265-
266-
mmMensagem.Lines.Add(LIOTAModule.FileName +
267-
' / ' + LIOTAModule.OwnerCount.ToString + ' / ' + LIOTAModule.OwnerModuleCount.ToString +
268-
' / ' + LIOTAModule.HasCoClasses.ToString(TUseBoolStrs.True) +
269-
' / ' + LIOTAModule.ModuleFileCount.ToString +
270-
' / ' + LIOTAModule.FileSystem);
271-
272-
273-
LIOTAEditor := LIOTAModule.CurrentEditor;
274-
275-
LIOTASourceEditor := TC4DWizardUtilsOTA.GetIOTASourceEditor(LIOTAModule);
276-
if(LIOTASourceEditor <> nil)then
277-
begin
278-
mmMensagem.Lines.Add(' - LIOTASourceEditor: ' + LIOTASourceEditor.GetSubViewCount.ToString +
279-
' / A: ' + LIOTASourceEditor.GetSubViewIndex.ToString +
280-
' / B: ' + LIOTASourceEditor.GetLinesInBuffer.ToString +
281-
' / C: ' + LIOTASourceEditor.EditViewCount.ToString);
282-
283-
284-
LIOTAEditView := TC4DWizardUtilsOTA.GetIOTAEditView(LIOTASourceEditor);
285-
end;
286-
287-
288-
289-
290-
{if LIOTAModule.OwnerCount > 0 then
291-
mmMensagem.Lines.Add(' - Owners: ' + LIOTAModule.Owners[0].FileName);
292-
293-
if LIOTAModule.OwnerModuleCount > 0 then
294-
mmMensagem.Lines.Add(' - Owners: ' + LIOTAModule.OwnerModules[0].FileName);}
295-
296-
end;
297-
end;
298-
299-
procedure TC4DWizardViewAbout.Button3Click(Sender: TObject);
300-
var
301-
LIOTAModuleServices: IOTAModuleServices;
302-
LIOTAModule: IOTAModule;
303-
LIOTASourceEditor: IOTASourceEditor;
304-
i: Integer;
305126
begin
306-
mmMensagem.Lines.Clear;
307-
308-
LIOTAModuleServices := BorlandIDEServices as IOTAModuleServices;
309-
for i := 0 to Pred(LIOTAModuleServices.ModuleCount) do
310-
begin
311-
LIOTAModule := LIOTAModuleServices.Modules[i];
312-
313-
LIOTASourceEditor := TC4DWizardUtilsOTA.GetIOTASourceEditor(LIOTAModule);
314-
if(LIOTASourceEditor = nil)then
315-
Continue;
316-
317-
if LIOTASourceEditor.EditViewCount <= 0 then
318-
Continue;
319-
320-
mmMensagem.Lines.Add(LIOTAModule.FileName + ' / C: ' + LIOTASourceEditor.EditViewCount.ToString);
321-
end;
127+
//
322128
end;
323129

324130
end.

Src/VsCodeIntegration/C4D.Wizard.VsCodeIntegration.pas

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ interface
99
type
1010
TC4DWizardVsCodeIntegration = class
1111
private
12+
class procedure RunCommandInstallExtension(const AIdentifierExtension: string);
1213
public
1314
class procedure Open;
15+
class procedure InstallGithubCopilot;
1416
class procedure InstallDelphiLSP;
1517
end;
1618

@@ -46,8 +48,8 @@ class procedure TC4DWizardVsCodeIntegration.Open;
4648
if LIOTAEditView = nil then
4749
TC4DWizardUtils.ShowMsgAndAbort('Editor view cannot be located');
4850

49-
LFileNameModule := LIOTAModule.FileName;
5051

52+
LFileNameModule := LIOTAModule.FileName;
5153
LIOTAProject := LIOTAModuleServices.GetActiveProject;
5254
if LIOTAProject = nil then
5355
TC4DWizardUtils.ShowMsgAndAbort('No active projects were found');
@@ -58,16 +60,33 @@ class procedure TC4DWizardVsCodeIntegration.Open;
5860
LCursorPos := LIOTAEditView.CursorPos;
5961

6062
//REFERENCE: https://code.visualstudio.com/docs/editor/command-line
61-
LComand := Format('"code -r %s -g %s:%d:%d"', [LFilePathProject, LFileNameModule, LCursorPos.Line, LCursorPos.Col]);
63+
LComand := Format('"code -n %s -g %s:%d:%d"', [LFilePathProject, LFileNameModule, LCursorPos.Line, LCursorPos.Col]);
64+
TC4DWizardUtils.ShowMsg(LComand);
65+
Exit;
6266
TC4DWizardProcessDelphi.RunCommand([LComand]);
6367
end;
6468

69+
class procedure TC4DWizardVsCodeIntegration.InstallGithubCopilot;
70+
begin
71+
Self.RunCommandInstallExtension('github.copilot');
72+
end;
73+
6574
class procedure TC4DWizardVsCodeIntegration.InstallDelphiLSP;
75+
begin
76+
Self.RunCommandInstallExtension('embarcaderotechnologies.delphilsp');
77+
end;
78+
79+
class procedure TC4DWizardVsCodeIntegration.RunCommandInstallExtension(const AIdentifierExtension: string);
6680
var
6781
LComand: string;
6882
begin
69-
LComand := Format('"code --install-extension %s --force"', ['embarcaderotechnologies.delphilsp']);
83+
if AIdentifierExtension.Trim.IsEmpty then
84+
Exit;
85+
86+
LComand := Format('"code --install-extension %s --force"', [AIdentifierExtension]);
7087
TC4DWizardProcessDelphi.RunCommand([LComand]);
88+
89+
TC4DWizardUtils.ShowMsg('Extension installation pushed to VS Code!');
7190
end;
7291

7392
end.

0 commit comments

Comments
 (0)