mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-06 10:00:34 +02:00
IDE: Set cursor position inside begin..end for new programs. Issue #32089, based on n7800's patch.
This commit is contained in:
parent
f468a36dd0
commit
26de2f9330
@ -15,7 +15,8 @@ uses
|
|||||||
// IdeIntf
|
// IdeIntf
|
||||||
CompOptsIntf, ProjectIntf, LazIDEIntf,
|
CompOptsIntf, ProjectIntf, LazIDEIntf,
|
||||||
// IDE
|
// IDE
|
||||||
frmCustomApplicationOptions, LazarusIDEStrConsts, Project, W32Manifest;
|
frmCustomApplicationOptions, LazarusIDEStrConsts, Project, W32Manifest,
|
||||||
|
SourceEditor;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -87,6 +88,7 @@ type
|
|||||||
function GetLocalizedDescription: string; override;
|
function GetLocalizedDescription: string; override;
|
||||||
function InitProject(AProject: TLazProject): TModalResult; override;
|
function InitProject(AProject: TLazProject): TModalResult; override;
|
||||||
function CreateStartFiles(AProject: TLazProject): TModalResult; override;
|
function CreateStartFiles(AProject: TLazProject): TModalResult; override;
|
||||||
|
public
|
||||||
property AddMainSource: boolean read FAddMainSource write FAddMainSource;
|
property AddMainSource: boolean read FAddMainSource write FAddMainSource;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -209,8 +211,8 @@ begin
|
|||||||
|
|
||||||
// create program source
|
// create program source
|
||||||
NewSource:='program Project1;'+LineEnding
|
NewSource:='program Project1;'+LineEnding
|
||||||
+LineEnding
|
|
||||||
+'begin'+LineEnding
|
+'begin'+LineEnding
|
||||||
|
+LineEnding
|
||||||
+'end.'+LineEnding
|
+'end.'+LineEnding
|
||||||
+LineEnding;
|
+LineEnding;
|
||||||
AProject.MainFile.SetSourceText(NewSource,true);
|
AProject.MainFile.SetSourceText(NewSource,true);
|
||||||
@ -223,6 +225,9 @@ function TProjectSimpleProgramDescriptor.CreateStartFiles(AProject: TLazProject)
|
|||||||
begin
|
begin
|
||||||
Result:=LazarusIDE.DoOpenEditorFile(AProject.MainFile.Filename,-1,-1,
|
Result:=LazarusIDE.DoOpenEditorFile(AProject.MainFile.Filename,-1,-1,
|
||||||
[ofProjectLoading,ofRegularFile]);
|
[ofProjectLoading,ofRegularFile]);
|
||||||
|
// set caret position
|
||||||
|
if Assigned(SourceEditorManager.ActiveEditor) then
|
||||||
|
SourceEditorManager.ActiveEditor.EditorComponent.LogicalCaretXY:=Point(3,3);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TProjectProgramDescriptor }
|
{ TProjectProgramDescriptor }
|
||||||
@ -270,6 +275,7 @@ begin
|
|||||||
+' { you can add units after this };'+LineEnding
|
+' { you can add units after this };'+LineEnding
|
||||||
+LineEnding
|
+LineEnding
|
||||||
+'begin'+LineEnding
|
+'begin'+LineEnding
|
||||||
|
+LineEnding
|
||||||
+'end.'+LineEnding
|
+'end.'+LineEnding
|
||||||
+LineEnding;
|
+LineEnding;
|
||||||
AProject.MainFile.SetSourceText(NewSource,true);
|
AProject.MainFile.SetSourceText(NewSource,true);
|
||||||
@ -282,6 +288,9 @@ function TProjectProgramDescriptor.CreateStartFiles(AProject: TLazProject): TMod
|
|||||||
begin
|
begin
|
||||||
Result:=LazarusIDE.DoOpenEditorFile(AProject.MainFile.Filename,-1,-1,
|
Result:=LazarusIDE.DoOpenEditorFile(AProject.MainFile.Filename,-1,-1,
|
||||||
[ofProjectLoading,ofRegularFile]);
|
[ofProjectLoading,ofRegularFile]);
|
||||||
|
// set caret position
|
||||||
|
if Assigned(SourceEditorManager.ActiveEditor) then
|
||||||
|
SourceEditorManager.ActiveEditor.EditorComponent.LogicalCaretXY:=Point(3,13);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TProjectManualProgramDescriptor }
|
{ TProjectManualProgramDescriptor }
|
||||||
@ -332,6 +341,7 @@ begin
|
|||||||
+' { you can add units after this };'+LineEnding
|
+' { you can add units after this };'+LineEnding
|
||||||
+LineEnding
|
+LineEnding
|
||||||
+'begin'+LineEnding
|
+'begin'+LineEnding
|
||||||
|
+LineEnding
|
||||||
+'end.'+LineEnding
|
+'end.'+LineEnding
|
||||||
+LineEnding;
|
+LineEnding;
|
||||||
AProject.MainFile.SetSourceText(NewSource,true);
|
AProject.MainFile.SetSourceText(NewSource,true);
|
||||||
@ -343,8 +353,13 @@ function TProjectManualProgramDescriptor.CreateStartFiles(AProject: TLazProject
|
|||||||
): TModalResult;
|
): TModalResult;
|
||||||
begin
|
begin
|
||||||
if AProject.MainFile<>nil then
|
if AProject.MainFile<>nil then
|
||||||
|
begin
|
||||||
Result:=LazarusIDE.DoOpenEditorFile(AProject.MainFile.Filename,-1,-1,
|
Result:=LazarusIDE.DoOpenEditorFile(AProject.MainFile.Filename,-1,-1,
|
||||||
[ofProjectLoading,ofRegularFile])
|
[ofProjectLoading,ofRegularFile]);
|
||||||
|
// set caret position
|
||||||
|
if Assigned(SourceEditorManager.ActiveEditor) then
|
||||||
|
SourceEditorManager.ActiveEditor.EditorComponent.LogicalCaretXY:=Point(3,10);
|
||||||
|
end
|
||||||
else
|
else
|
||||||
Result:=mrCancel;
|
Result:=mrCancel;
|
||||||
end;
|
end;
|
||||||
@ -570,6 +585,7 @@ begin
|
|||||||
+' { you can add units after this };'+LineEnding
|
+' { you can add units after this };'+LineEnding
|
||||||
+LineEnding
|
+LineEnding
|
||||||
+'begin'+LineEnding
|
+'begin'+LineEnding
|
||||||
|
+LineEnding
|
||||||
+'end.'+LineEnding
|
+'end.'+LineEnding
|
||||||
+LineEnding;
|
+LineEnding;
|
||||||
AProject.MainFile.SetSourceText(NewSource,true);
|
AProject.MainFile.SetSourceText(NewSource,true);
|
||||||
@ -584,6 +600,9 @@ function TProjectLibraryDescriptor.CreateStartFiles(AProject: TLazProject): TMod
|
|||||||
begin
|
begin
|
||||||
Result:=LazarusIDE.DoOpenEditorFile(AProject.MainFile.Filename,-1,-1,
|
Result:=LazarusIDE.DoOpenEditorFile(AProject.MainFile.Filename,-1,-1,
|
||||||
[ofProjectLoading,ofRegularFile]);
|
[ofProjectLoading,ofRegularFile]);
|
||||||
|
// set caret position
|
||||||
|
if Assigned(SourceEditorManager.ActiveEditor) then
|
||||||
|
SourceEditorManager.ActiveEditor.EditorComponent.LogicalCaretXY:=Point(3,10);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user