mirror of
				https://gitlab.com/freepascal.org/lazarus/lazarus.git
				synced 2025-11-04 15:09:36 +01:00 
			
		
		
		
	IDE,IDEIntf: added TSourceEditorManagerInterface.ReIndent, added parameter Beautify to TLazProjectFile.SetSourceText
git-svn-id: trunk@40813 -
This commit is contained in:
		
							parent
							
								
									53774998ef
								
							
						
					
					
						commit
						fd4d0497fc
					
				@ -377,7 +377,7 @@ type
 | 
				
			|||||||
    procedure UpdateUsageCount(TheUsage: TUnitUsage; const Factor: TDateTime);
 | 
					    procedure UpdateUsageCount(TheUsage: TUnitUsage; const Factor: TDateTime);
 | 
				
			||||||
    procedure UpdateSourceDirectoryReference;
 | 
					    procedure UpdateSourceDirectoryReference;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    procedure SetSourceText(const SourceText: string); override;
 | 
					    procedure SetSourceText(const SourceText: string; Beautify: boolean = false); override;
 | 
				
			||||||
    function GetSourceText: string; override;
 | 
					    function GetSourceText: string; override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // component dependencies
 | 
					    // component dependencies
 | 
				
			||||||
@ -2125,9 +2125,14 @@ begin
 | 
				
			|||||||
  end;
 | 
					  end;
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
procedure TUnitInfo.SetSourceText(const SourceText: string);
 | 
					procedure TUnitInfo.SetSourceText(const SourceText: string; Beautify: boolean);
 | 
				
			||||||
 | 
					var
 | 
				
			||||||
 | 
					  Src: String;
 | 
				
			||||||
begin
 | 
					begin
 | 
				
			||||||
  Source.Source:=SourceText;
 | 
					  Src:=SourceText;
 | 
				
			||||||
 | 
					  if Beautify then
 | 
				
			||||||
 | 
					    Src:=SourceEditorManagerIntf.ReIndent(Src);
 | 
				
			||||||
 | 
					  Source.Source:=Src;
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function TUnitInfo.GetSourceText: string;
 | 
					function TUnitInfo.GetSourceText: string;
 | 
				
			||||||
 | 
				
			|||||||
@ -1309,7 +1309,7 @@ begin
 | 
				
			|||||||
    +'  Application.Run;'+LineEnding
 | 
					    +'  Application.Run;'+LineEnding
 | 
				
			||||||
    +'end.'+LineEnding
 | 
					    +'end.'+LineEnding
 | 
				
			||||||
    +LineEnding;
 | 
					    +LineEnding;
 | 
				
			||||||
  AProject.MainFile.SetSourceText(NewSource);
 | 
					  AProject.MainFile.SetSourceText(NewSource,true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // add lcl pp/pas dirs to source search path
 | 
					  // add lcl pp/pas dirs to source search path
 | 
				
			||||||
  AProject.AddPackageDependency('LCL');
 | 
					  AProject.AddPackageDependency('LCL');
 | 
				
			||||||
@ -1363,7 +1363,7 @@ begin
 | 
				
			|||||||
    +'begin'+LineEnding
 | 
					    +'begin'+LineEnding
 | 
				
			||||||
    +'end.'+LineEnding
 | 
					    +'end.'+LineEnding
 | 
				
			||||||
    +LineEnding;
 | 
					    +LineEnding;
 | 
				
			||||||
  AProject.MainFile.SetSourceText(NewSource);
 | 
					  AProject.MainFile.SetSourceText(NewSource,true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  AProject.LazCompilerOptions.UnitOutputDirectory:='lib'+PathDelim+'$(TargetCPU)-$(TargetOS)';
 | 
					  AProject.LazCompilerOptions.UnitOutputDirectory:='lib'+PathDelim+'$(TargetCPU)-$(TargetOS)';
 | 
				
			||||||
  AProject.LazCompilerOptions.TargetFilename:='project1';
 | 
					  AProject.LazCompilerOptions.TargetFilename:='project1';
 | 
				
			||||||
@ -1422,7 +1422,7 @@ begin
 | 
				
			|||||||
    +'begin'+LineEnding
 | 
					    +'begin'+LineEnding
 | 
				
			||||||
    +'end.'+LineEnding
 | 
					    +'end.'+LineEnding
 | 
				
			||||||
    +LineEnding;
 | 
					    +LineEnding;
 | 
				
			||||||
  AProject.MainFile.SetSourceText(NewSource);
 | 
					  AProject.MainFile.SetSourceText(NewSource,true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  AProject.LazCompilerOptions.UnitOutputDirectory:='lib'+PathDelim+'$(TargetCPU)-$(TargetOS)';
 | 
					  AProject.LazCompilerOptions.UnitOutputDirectory:='lib'+PathDelim+'$(TargetCPU)-$(TargetOS)';
 | 
				
			||||||
  AProject.LazCompilerOptions.TargetFilename:='project1';
 | 
					  AProject.LazCompilerOptions.TargetFilename:='project1';
 | 
				
			||||||
@ -1484,7 +1484,7 @@ begin
 | 
				
			|||||||
      +'begin'+LineEnding
 | 
					      +'begin'+LineEnding
 | 
				
			||||||
      +'end.'+LineEnding
 | 
					      +'end.'+LineEnding
 | 
				
			||||||
      +LineEnding;
 | 
					      +LineEnding;
 | 
				
			||||||
    AProject.MainFile.SetSourceText(NewSource);
 | 
					    AProject.MainFile.SetSourceText(NewSource,true);
 | 
				
			||||||
    AProject.LazCompilerOptions.Win32GraphicApp:=false;
 | 
					    AProject.LazCompilerOptions.Win32GraphicApp:=false;
 | 
				
			||||||
  end;
 | 
					  end;
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
@ -1664,7 +1664,7 @@ begin
 | 
				
			|||||||
  NewSource.Add('  Application.Free;');
 | 
					  NewSource.Add('  Application.Free;');
 | 
				
			||||||
  NewSource.Add('end.');
 | 
					  NewSource.Add('end.');
 | 
				
			||||||
  NewSource.Add('');
 | 
					  NewSource.Add('');
 | 
				
			||||||
  AProject.MainFile.SetSourceText(NewSource.Text);
 | 
					  AProject.MainFile.SetSourceText(NewSource.Text,true);
 | 
				
			||||||
  NewSource.Free;
 | 
					  NewSource.Free;
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1720,7 +1720,7 @@ begin
 | 
				
			|||||||
    +'begin'+LineEnding
 | 
					    +'begin'+LineEnding
 | 
				
			||||||
    +'end.'+LineEnding
 | 
					    +'end.'+LineEnding
 | 
				
			||||||
    +LineEnding;
 | 
					    +LineEnding;
 | 
				
			||||||
  AProject.MainFile.SetSourceText(NewSource);
 | 
					  AProject.MainFile.SetSourceText(NewSource,true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  AProject.LazCompilerOptions.UnitOutputDirectory:='lib'+PathDelim+'$(TargetCPU)-$(TargetOS)';
 | 
					  AProject.LazCompilerOptions.UnitOutputDirectory:='lib'+PathDelim+'$(TargetCPU)-$(TargetOS)';
 | 
				
			||||||
  AProject.LazCompilerOptions.TargetFilename:='project1';
 | 
					  AProject.LazCompilerOptions.TargetFilename:='project1';
 | 
				
			||||||
 | 
				
			|||||||
@ -1015,6 +1015,8 @@ type
 | 
				
			|||||||
    procedure ClearExecutionMarks;
 | 
					    procedure ClearExecutionMarks;
 | 
				
			||||||
    procedure FillExecutionMarks;
 | 
					    procedure FillExecutionMarks;
 | 
				
			||||||
    procedure ReloadEditorOptions;
 | 
					    procedure ReloadEditorOptions;
 | 
				
			||||||
 | 
					    function ReIndent(const Src: string; OldIndent: integer=0;
 | 
				
			||||||
 | 
					      OldTabWidth: integer=4): string; override;
 | 
				
			||||||
    // find / replace text
 | 
					    // find / replace text
 | 
				
			||||||
    procedure FindClicked(Sender: TObject);
 | 
					    procedure FindClicked(Sender: TObject);
 | 
				
			||||||
    procedure FindNextClicked(Sender: TObject);
 | 
					    procedure FindNextClicked(Sender: TObject);
 | 
				
			||||||
@ -5463,7 +5465,7 @@ begin
 | 
				
			|||||||
  Manager.DeactivateCompletionForm;
 | 
					  Manager.DeactivateCompletionForm;
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Procedure TSourceNotebook.CreateNotebook;
 | 
					procedure TSourceNotebook.CreateNotebook;
 | 
				
			||||||
var
 | 
					var
 | 
				
			||||||
  APage: TTabSheet;
 | 
					  APage: TTabSheet;
 | 
				
			||||||
Begin
 | 
					Begin
 | 
				
			||||||
@ -6026,7 +6028,7 @@ begin
 | 
				
			|||||||
  Result:=TSourceEditorInterface(FSourceEditorList[Index]);
 | 
					  Result:=TSourceEditorInterface(FSourceEditorList[Index]);
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Procedure TSourceNotebook.BuildPopupMenu;
 | 
					procedure TSourceNotebook.BuildPopupMenu;
 | 
				
			||||||
begin
 | 
					begin
 | 
				
			||||||
  //debugln('TSourceNotebook.BuildPopupMenu');
 | 
					  //debugln('TSourceNotebook.BuildPopupMenu');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -6308,7 +6310,7 @@ end;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  Called whenever an editor status changes. Sender is normally a TSynEdit.
 | 
					  Called whenever an editor status changes. Sender is normally a TSynEdit.
 | 
				
			||||||
-------------------------------------------------------------------------------}
 | 
					-------------------------------------------------------------------------------}
 | 
				
			||||||
Procedure TSourceNotebook.EditorChanged(Sender: TObject);
 | 
					procedure TSourceNotebook.EditorChanged(Sender: TObject);
 | 
				
			||||||
var SenderDeleted: boolean;
 | 
					var SenderDeleted: boolean;
 | 
				
			||||||
Begin
 | 
					Begin
 | 
				
			||||||
  SenderDeleted:=(Sender as TControl).Parent=nil;
 | 
					  SenderDeleted:=(Sender as TControl).Parent=nil;
 | 
				
			||||||
@ -6398,8 +6400,8 @@ begin
 | 
				
			|||||||
  Result := SourceEditorManager.CompletionPlugins[Index];
 | 
					  Result := SourceEditorManager.CompletionPlugins[Index];
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function TSourceNotebook.NewSE(PageNum: Integer; NewPageNum: Integer = -1;
 | 
					function TSourceNotebook.NewSE(Pagenum: Integer; NewPagenum: Integer;
 | 
				
			||||||
  ASharedEditor: TSourceEditor = nil; ATabCaption: String = ''): TSourceEditor;
 | 
					  ASharedEditor: TSourceEditor; ATabCaption: String): TSourceEditor;
 | 
				
			||||||
begin
 | 
					begin
 | 
				
			||||||
  {$IFDEF IDE_DEBUG}
 | 
					  {$IFDEF IDE_DEBUG}
 | 
				
			||||||
  debugln('TSourceNotebook.NewSE A ');
 | 
					  debugln('TSourceNotebook.NewSE A ');
 | 
				
			||||||
@ -6477,7 +6479,7 @@ begin
 | 
				
			|||||||
  Result := TSourceEditor(FSourceEditorList[i]);
 | 
					  Result := TSourceEditor(FSourceEditorList[i]);
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Function TSourceNotebook.GetActiveSE: TSourceEditor;
 | 
					function TSourceNotebook.GetActiveSE: TSourceEditor;
 | 
				
			||||||
Begin
 | 
					Begin
 | 
				
			||||||
  Result := nil;
 | 
					  Result := nil;
 | 
				
			||||||
  if (FSourceEditorList=nil) or (FSourceEditorList.Count=0) or (PageIndex<0) then
 | 
					  if (FSourceEditorList=nil) or (FSourceEditorList.Count=0) or (PageIndex<0) then
 | 
				
			||||||
@ -6713,7 +6715,7 @@ begin
 | 
				
			|||||||
  UpdateStatusBar;
 | 
					  UpdateStatusBar;
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Procedure TSourceNotebook.NextEditor;
 | 
					procedure TSourceNotebook.NextEditor;
 | 
				
			||||||
Begin
 | 
					Begin
 | 
				
			||||||
  if PageIndex < PageCount-1 then
 | 
					  if PageIndex < PageCount-1 then
 | 
				
			||||||
    PageIndex := PageIndex+1
 | 
					    PageIndex := PageIndex+1
 | 
				
			||||||
@ -6721,7 +6723,7 @@ Begin
 | 
				
			|||||||
    PageIndex := 0;
 | 
					    PageIndex := 0;
 | 
				
			||||||
End;
 | 
					End;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Procedure TSourceNotebook.PrevEditor;
 | 
					procedure TSourceNotebook.PrevEditor;
 | 
				
			||||||
Begin
 | 
					Begin
 | 
				
			||||||
  if PageIndex > 0 then
 | 
					  if PageIndex > 0 then
 | 
				
			||||||
    PageIndex := PageIndex-1
 | 
					    PageIndex := PageIndex-1
 | 
				
			||||||
@ -7091,13 +7093,13 @@ begin
 | 
				
			|||||||
  MainIDEInterface.DoShowProjectInspector(True);
 | 
					  MainIDEInterface.DoShowProjectInspector(True);
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Procedure TSourceNotebook.OpenAtCursorClicked(Sender: TObject);
 | 
					procedure TSourceNotebook.OpenAtCursorClicked(Sender: TObject);
 | 
				
			||||||
begin
 | 
					begin
 | 
				
			||||||
  if assigned(Manager) and Assigned(Manager.OnOpenFileAtCursorClicked) then
 | 
					  if assigned(Manager) and Assigned(Manager.OnOpenFileAtCursorClicked) then
 | 
				
			||||||
    Manager.OnOpenFileAtCursorClicked(Sender);
 | 
					    Manager.OnOpenFileAtCursorClicked(Sender);
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Procedure TSourceNotebook.CutClicked(Sender: TObject);
 | 
					procedure TSourceNotebook.CutClicked(Sender: TObject);
 | 
				
			||||||
var ActSE: TSourceEditor;
 | 
					var ActSE: TSourceEditor;
 | 
				
			||||||
begin
 | 
					begin
 | 
				
			||||||
  ActSE := GetActiveSE;
 | 
					  ActSE := GetActiveSE;
 | 
				
			||||||
@ -7105,7 +7107,7 @@ begin
 | 
				
			|||||||
    ActSE.DoEditorExecuteCommand(ecCut);
 | 
					    ActSE.DoEditorExecuteCommand(ecCut);
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Procedure TSourceNotebook.CopyClicked(Sender: TObject);
 | 
					procedure TSourceNotebook.CopyClicked(Sender: TObject);
 | 
				
			||||||
var ActSE: TSourceEditor;
 | 
					var ActSE: TSourceEditor;
 | 
				
			||||||
begin
 | 
					begin
 | 
				
			||||||
  ActSE := GetActiveSE;
 | 
					  ActSE := GetActiveSE;
 | 
				
			||||||
@ -7113,7 +7115,7 @@ begin
 | 
				
			|||||||
    ActSE.DoEditorExecuteCommand(ecCopy);
 | 
					    ActSE.DoEditorExecuteCommand(ecCopy);
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Procedure TSourceNotebook.PasteClicked(Sender: TObject);
 | 
					procedure TSourceNotebook.PasteClicked(Sender: TObject);
 | 
				
			||||||
var ActSE: TSourceEditor;
 | 
					var ActSE: TSourceEditor;
 | 
				
			||||||
begin
 | 
					begin
 | 
				
			||||||
  ActSE := GetActiveSE;
 | 
					  ActSE := GetActiveSE;
 | 
				
			||||||
@ -7374,7 +7376,7 @@ begin
 | 
				
			|||||||
  Result:=FSourceEditorList.Count;
 | 
					  Result:=FSourceEditorList.Count;
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Procedure TSourceNotebook.CloseClicked(Sender: TObject; CloseOthers: Boolean = False);
 | 
					procedure TSourceNotebook.CloseClicked(Sender: TObject; CloseOthers: Boolean);
 | 
				
			||||||
Begin
 | 
					Begin
 | 
				
			||||||
  if assigned(Manager) and Assigned(Manager.OnCloseClicked) then
 | 
					  if assigned(Manager) and Assigned(Manager.OnCloseClicked) then
 | 
				
			||||||
    Manager.OnCloseClicked(Sender, CloseOthers);
 | 
					    Manager.OnCloseClicked(Sender, CloseOthers);
 | 
				
			||||||
@ -7472,7 +7474,7 @@ begin
 | 
				
			|||||||
  GetActiveSE.IsLocked := not GetActiveSE.IsLocked;
 | 
					  GetActiveSE.IsLocked := not GetActiveSE.IsLocked;
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Procedure TSourceNotebook.UpdateStatusBar;
 | 
					procedure TSourceNotebook.UpdateStatusBar;
 | 
				
			||||||
var
 | 
					var
 | 
				
			||||||
  tempEditor: TSourceEditor;
 | 
					  tempEditor: TSourceEditor;
 | 
				
			||||||
  PanelFilename: String;
 | 
					  PanelFilename: String;
 | 
				
			||||||
@ -7685,7 +7687,7 @@ begin
 | 
				
			|||||||
  FUpdateTabAndPageTimer.Enabled := True;
 | 
					  FUpdateTabAndPageTimer.Enabled := True;
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Procedure TSourceNotebook.NotebookPageChanged(Sender: TObject);
 | 
					procedure TSourceNotebook.NotebookPageChanged(Sender: TObject);
 | 
				
			||||||
var
 | 
					var
 | 
				
			||||||
  TempEditor:TSourceEditor;
 | 
					  TempEditor:TSourceEditor;
 | 
				
			||||||
  CaretXY: TPoint;
 | 
					  CaretXY: TPoint;
 | 
				
			||||||
@ -7745,7 +7747,7 @@ Begin
 | 
				
			|||||||
  DebugLnExit(SRCED_PAGES, ['<< TSourceNotebook.NotebookPageChanged ']);
 | 
					  DebugLnExit(SRCED_PAGES, ['<< TSourceNotebook.NotebookPageChanged ']);
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Procedure TSourceNotebook.ProcessParentCommand(Sender: TObject;
 | 
					procedure TSourceNotebook.ProcessParentCommand(Sender: TObject;
 | 
				
			||||||
  var Command: TSynEditorCommand; var AChar: TUTF8Char; Data: pointer;
 | 
					  var Command: TSynEditorCommand; var AChar: TUTF8Char; Data: pointer;
 | 
				
			||||||
  var Handled: boolean);
 | 
					  var Handled: boolean);
 | 
				
			||||||
var
 | 
					var
 | 
				
			||||||
@ -7858,7 +7860,7 @@ begin
 | 
				
			|||||||
  FProcessingCommand:=false;
 | 
					  FProcessingCommand:=false;
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Procedure TSourceNotebook.ParentCommandProcessed(Sender: TObject;
 | 
					procedure TSourceNotebook.ParentCommandProcessed(Sender: TObject;
 | 
				
			||||||
  var Command: TSynEditorCommand; var AChar: TUTF8Char; Data: pointer;
 | 
					  var Command: TSynEditorCommand; var AChar: TUTF8Char; Data: pointer;
 | 
				
			||||||
  var Handled: boolean);
 | 
					  var Handled: boolean);
 | 
				
			||||||
begin
 | 
					begin
 | 
				
			||||||
@ -7873,7 +7875,7 @@ begin
 | 
				
			|||||||
  if Handled then Command:=ecNone;
 | 
					  if Handled then Command:=ecNone;
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Procedure TSourceNotebook.ReloadEditorOptions;
 | 
					procedure TSourceNotebook.ReloadEditorOptions;
 | 
				
			||||||
var
 | 
					var
 | 
				
			||||||
  I: integer;
 | 
					  I: integer;
 | 
				
			||||||
Begin
 | 
					Begin
 | 
				
			||||||
@ -7935,8 +7937,8 @@ begin
 | 
				
			|||||||
  dec(fAutoFocusLock);
 | 
					  dec(fAutoFocusLock);
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Procedure TSourceNotebook.EditorMouseMove(Sender: TObject; Shift: TShiftstate;
 | 
					procedure TSourceNotebook.EditorMouseMove(Sender: TObject; Shift: TShiftstate;
 | 
				
			||||||
  X,Y: Integer);
 | 
					  X, Y: Integer);
 | 
				
			||||||
begin
 | 
					begin
 | 
				
			||||||
  MaybeHideHint;
 | 
					  MaybeHideHint;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -8021,7 +8023,7 @@ begin
 | 
				
			|||||||
  SrcEdit.CursorScreenXY:=Point(Indent+1,SrcEdit.CursorScreenXY.Y);
 | 
					  SrcEdit.CursorScreenXY:=Point(Indent+1,SrcEdit.CursorScreenXY.Y);
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Procedure TSourceNotebook.HintTimer(sender: TObject);
 | 
					procedure TSourceNotebook.HintTimer(Sender: TObject);
 | 
				
			||||||
var
 | 
					var
 | 
				
			||||||
  MousePos: TPoint;
 | 
					  MousePos: TPoint;
 | 
				
			||||||
  AControl: TControl;
 | 
					  AControl: TControl;
 | 
				
			||||||
@ -9272,6 +9274,24 @@ begin
 | 
				
			|||||||
  end;
 | 
					  end;
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function TSourceEditorManager.ReIndent(const Src: string; OldIndent: integer;
 | 
				
			||||||
 | 
					  OldTabWidth: integer): string;
 | 
				
			||||||
 | 
					var
 | 
				
			||||||
 | 
					  NewTabWidth: Integer;
 | 
				
			||||||
 | 
					  NewIndent: Integer;
 | 
				
			||||||
 | 
					begin
 | 
				
			||||||
 | 
					  if OldIndent=0 then
 | 
				
			||||||
 | 
					    GuessIndentSize(Src,OldIndent,EditorOpts.TabWidth);
 | 
				
			||||||
 | 
					  if (eoTabsToSpaces in EditorOpts.SynEditOptions)
 | 
				
			||||||
 | 
					  or (EditorOpts.BlockTabIndent=0) then
 | 
				
			||||||
 | 
					    NewTabWidth:=0
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    NewTabWidth:=EditorOpts.TabWidth;
 | 
				
			||||||
 | 
					  NewIndent:=EditorOpts.BlockTabIndent*EditorOpts.TabWidth+EditorOpts.BlockIndent;
 | 
				
			||||||
 | 
					  //debugln(['TSourceEditorManager.ReIndent OldIndent=',OldIndent,' OldTabWidth=',OldTabWidth,' NewIndent=',NewIndent,' NewTabWidth=',NewTabWidth]);
 | 
				
			||||||
 | 
					  Result:=BasicCodeTools.ReIndent(Src,OldIndent,OldTabWidth,NewIndent,NewTabWidth);
 | 
				
			||||||
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
procedure TSourceEditorManager.FindClicked(Sender: TObject);
 | 
					procedure TSourceEditorManager.FindClicked(Sender: TObject);
 | 
				
			||||||
begin
 | 
					begin
 | 
				
			||||||
  if ActiveEditor <> nil then ActiveEditor.StartFindAndReplace(false);
 | 
					  if ActiveEditor <> nil then ActiveEditor.StartFindAndReplace(false);
 | 
				
			||||||
@ -9708,7 +9728,8 @@ begin
 | 
				
			|||||||
  end;
 | 
					  end;
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
procedure TSourceEditorManager.OnFilesDroping(Sender: TObject; const FileNames: Array of String);
 | 
					procedure TSourceEditorManager.OnFilesDroping(Sender: TObject;
 | 
				
			||||||
 | 
					  const FileNames: array of String);
 | 
				
			||||||
begin
 | 
					begin
 | 
				
			||||||
  if Sender is TSourceNotebook then
 | 
					  if Sender is TSourceNotebook then
 | 
				
			||||||
    ActiveSourceWindow := TSourceNotebook(Sender);
 | 
					    ActiveSourceWindow := TSourceNotebook(Sender);
 | 
				
			||||||
 | 
				
			|||||||
@ -107,7 +107,6 @@ type
 | 
				
			|||||||
        AncestorType: TPersistentClass; ResourceCode: TCodeBuffer;
 | 
					        AncestorType: TPersistentClass; ResourceCode: TCodeBuffer;
 | 
				
			||||||
        UseCreateFormStatements, DisableAutoSize: Boolean): TModalResult;
 | 
					        UseCreateFormStatements, DisableAutoSize: Boolean): TModalResult;
 | 
				
			||||||
    function NewUniqueComponentName(Prefix: string): string;
 | 
					    function NewUniqueComponentName(Prefix: string): string;
 | 
				
			||||||
    function ReIndent(const Src: string; OldIndent: integer = 0; OldTabWidth: integer = 4): string;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // methods for 'save unit'
 | 
					    // methods for 'save unit'
 | 
				
			||||||
    function ShowSaveFileAsDialog(var AFilename: string; AnUnitInfo: TUnitInfo;
 | 
					    function ShowSaveFileAsDialog(var AFilename: string; AnUnitInfo: TUnitInfo;
 | 
				
			||||||
@ -536,7 +535,7 @@ begin
 | 
				
			|||||||
      NewUnitInfo.ComponentResourceName:='';
 | 
					      NewUnitInfo.ComponentResourceName:='';
 | 
				
			||||||
    end;
 | 
					    end;
 | 
				
			||||||
    Src:=NewFileDescriptor.CreateSource(NewUnitInfo.Filename,NewUnitName,NewUnitInfo.ComponentName);
 | 
					    Src:=NewFileDescriptor.CreateSource(NewUnitInfo.Filename,NewUnitName,NewUnitInfo.ComponentName);
 | 
				
			||||||
    Src:=ReIndent(Src);
 | 
					    Src:=SourceEditorManager.ReIndent(Src);
 | 
				
			||||||
    //debugln(['TLazSourceFileManager.NewFile ',dbgtext(Src)]);
 | 
					    //debugln(['TLazSourceFileManager.NewFile ',dbgtext(Src)]);
 | 
				
			||||||
    Src:=CodeToolBoss.SourceChangeCache.BeautifyCodeOptions.BeautifyStatement(Src,0);
 | 
					    Src:=CodeToolBoss.SourceChangeCache.BeautifyCodeOptions.BeautifyStatement(Src,0);
 | 
				
			||||||
    NewUnitInfo.Source.Source:=Src;
 | 
					    NewUnitInfo.Source.Source:=Src;
 | 
				
			||||||
@ -2542,24 +2541,6 @@ begin
 | 
				
			|||||||
  until IdentifierIsOk(Result);
 | 
					  until IdentifierIsOk(Result);
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function TLazSourceFileManager.ReIndent(const Src: string; OldIndent: integer;
 | 
					 | 
				
			||||||
  OldTabWidth: integer): string;
 | 
					 | 
				
			||||||
var
 | 
					 | 
				
			||||||
  NewTabWidth: Integer;
 | 
					 | 
				
			||||||
  NewIndent: Integer;
 | 
					 | 
				
			||||||
begin
 | 
					 | 
				
			||||||
  if OldIndent=0 then
 | 
					 | 
				
			||||||
    GuessIndentSize(Src,OldIndent,EditorOpts.TabWidth);
 | 
					 | 
				
			||||||
  if (eoTabsToSpaces in EditorOpts.SynEditOptions)
 | 
					 | 
				
			||||||
  or (EditorOpts.BlockTabIndent=0) then
 | 
					 | 
				
			||||||
    NewTabWidth:=0
 | 
					 | 
				
			||||||
  else
 | 
					 | 
				
			||||||
    NewTabWidth:=EditorOpts.TabWidth;
 | 
					 | 
				
			||||||
  NewIndent:=EditorOpts.BlockTabIndent*EditorOpts.TabWidth+EditorOpts.BlockIndent;
 | 
					 | 
				
			||||||
  //debugln(['TLazSourceFileManager.ReIndent OldIndent=',OldIndent,' OldTabWidth=',OldTabWidth,' NewIndent=',NewIndent,' NewTabWidth=',NewTabWidth]);
 | 
					 | 
				
			||||||
  Result:=BasicCodeTools.ReIndent(Src,OldIndent,OldTabWidth,NewIndent,NewTabWidth);
 | 
					 | 
				
			||||||
end;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function TLazSourceFileManager.ShowSaveFileAsDialog(var AFilename: string;
 | 
					function TLazSourceFileManager.ShowSaveFileAsDialog(var AFilename: string;
 | 
				
			||||||
  AnUnitInfo: TUnitInfo; var LFMCode, LRSCode: TCodeBuffer; CanAbort: boolean): TModalResult;
 | 
					  AnUnitInfo: TUnitInfo; var LFMCode, LRSCode: TCodeBuffer; CanAbort: boolean): TModalResult;
 | 
				
			||||||
var
 | 
					var
 | 
				
			||||||
 | 
				
			|||||||
@ -65,7 +65,7 @@ type
 | 
				
			|||||||
  public
 | 
					  public
 | 
				
			||||||
    constructor Create;
 | 
					    constructor Create;
 | 
				
			||||||
    destructor Destroy; override;
 | 
					    destructor Destroy; override;
 | 
				
			||||||
    procedure SetSourceText(const SourceText: string); virtual; abstract;
 | 
					    procedure SetSourceText(const SourceText: string; Beautify: boolean = false); virtual; abstract;
 | 
				
			||||||
    function GetSourceText: string; virtual; abstract;
 | 
					    function GetSourceText: string; virtual; abstract;
 | 
				
			||||||
    procedure ClearModifieds; virtual; abstract;
 | 
					    procedure ClearModifieds; virtual; abstract;
 | 
				
			||||||
  public
 | 
					  public
 | 
				
			||||||
 | 
				
			|||||||
@ -312,7 +312,10 @@ type
 | 
				
			|||||||
    // Editor Preferences
 | 
					    // Editor Preferences
 | 
				
			||||||
    function GetEditorControlSettings(EditControl: TControl): boolean; virtual; abstract;
 | 
					    function GetEditorControlSettings(EditControl: TControl): boolean; virtual; abstract;
 | 
				
			||||||
    function GetHighlighterSettings(Highlighter: TObject): boolean; virtual; abstract;
 | 
					    function GetHighlighterSettings(Highlighter: TObject): boolean; virtual; abstract;
 | 
				
			||||||
 | 
					    // Messages
 | 
				
			||||||
    procedure ClearErrorLines; virtual; abstract;
 | 
					    procedure ClearErrorLines; virtual; abstract;
 | 
				
			||||||
 | 
					    // General source functions
 | 
				
			||||||
 | 
					    function ReIndent(const Src: string; OldIndent: integer = 0; OldTabWidth: integer = 4): string; virtual; abstract;
 | 
				
			||||||
  protected
 | 
					  protected
 | 
				
			||||||
    // Completion Plugins
 | 
					    // Completion Plugins
 | 
				
			||||||
    function GetActiveCompletionPlugin: TSourceEditorCompletionPlugin; virtual; abstract;
 | 
					    function GetActiveCompletionPlugin: TSourceEditorCompletionPlugin; virtual; abstract;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user