MG: added path editor for compiler options

git-svn-id: trunk@1612 -
This commit is contained in:
lazarus 2002-04-16 08:55:06 +00:00
parent 625ac9a73c
commit dd37880074
7 changed files with 631 additions and 36 deletions

1
.gitattributes vendored
View File

@ -166,6 +166,7 @@ ide/miscoptions.pas svneol=native#text/pascal
ide/msgview.pp svneol=native#text/pascal
ide/newprojectdlg.pp svneol=native#text/pascal
ide/outputfilter.pas svneol=native#text/pascal
ide/patheditordlg.pas svneol=native#text/pascal
ide/project.pp svneol=native#text/pascal
ide/projectdefs.pas svneol=native#text/pascal
ide/projectopts.lrs svneol=native#text/pascal

View File

@ -43,7 +43,7 @@ interface
{$I codetools.inc}
{$DEFINE CTDEBUG}
{ $DEFINE CTDEBUG}
uses
{$IFDEF MEM_CHECK}

View File

@ -47,12 +47,12 @@ interface
// activate for debug:
{$DEFINE CTDEBUG}
{ $DEFINE CTDEBUG}
{ $DEFINE ShowSearchPaths}
{ $DEFINE ShowTriedFiles}
{ $DEFINE ShowTriedContexts}
{ $DEFINE ShowTriedIdentifiers}
{$DEFINE ShowExprEval}
{ $DEFINE ShowExprEval}
{ $DEFINE ShowFoundIdentifier}
{ $DEFINE ShowInterfaceCache}
{ $DEFINE ShowNodeCache}

View File

@ -32,7 +32,7 @@ interface
uses
Forms, Classes, SysUtils, ComCtrls, Buttons, StdCtrls, ExtCtrls, LazConf,
XMLCfg, FileCtrl, Dialogs, Controls;
XMLCfg, FileCtrl, Dialogs, Controls, PathEditorDlg;
type
{ Compiler Options object used to hold the compiler options }
@ -204,22 +204,25 @@ type
{ Compiler options form }
TfrmCompilerOptions = class(TForm)
private
nbMain: TNotebook;
//bvlButtonBar: TBevel;
{ Search Paths Controls }
grpOtherUnits: TGroupBox;
edtOtherUnits: TEdit;
OtherUnitsPathEditBtn: TPathEditorButton;
grpIncludeFiles: TGroupBox;
edtIncludeFiles: TEdit;
IncludeFilesPathEditBtn: TPathEditorButton;
grpOtherSources: TGroupBox;
edtOtherSources: TEdit;
OtherSourcesPathEditBtn: TPathEditorButton;
grpLibraries: TGroupBox;
edtLibraries: TEdit;
LibrariesPathEditBtn: TPathEditorButton;
grpCompiler: TGroupBox;
edtCompiler: TEdit;
@ -334,14 +337,17 @@ type
// fPath: String;
{ Procedures }
procedure CreateForm(Sender: TObject);
procedure SetupParsingTab(Sender: TObject; Page: integer);
procedure SetupCodeGenerationTab(Sender: TObject; Page: integer);
procedure SetupLinkingTab(Sender: TObject; Page: integer);
procedure SetupOtherTab(Sender: TObject; Page: integer);
procedure SetupSearchPathsTab(Sender: TObject; Page: integer);
procedure SetupButtonBar(Sender: TObject);
procedure chkAdditionalConfigFileClick(Sender: TObject);
procedure CreateForm(Sender: TObject);
procedure PathEditBtnClick(Sender: TObject);
procedure PathEditBtnExecuted(Sender: TObject);
private
procedure SetupSearchPathsTab(Page: integer);
procedure SetupParsingTab(Page: integer);
procedure SetupCodeGenerationTab(Page: integer);
procedure SetupLinkingTab(Page: integer);
procedure SetupOtherTab(Page: integer);
procedure SetupButtonBar;
private
function GetOtherSourcePath: string;
procedure SetOtherSourcePath(const AValue: string);
@ -1363,27 +1369,27 @@ begin
Page:=0;
{ Search Paths Tab }
SetupSearchPathsTab(Self,Page);
SetupSearchPathsTab(Page);
inc(Page);
{ Parsing Tab }
SetupParsingTab(Self,Page);
SetupParsingTab(Page);
inc(Page);
{ Code Generation Tab }
SetupCodeGenerationTab(Self,Page);
SetupCodeGenerationTab(Page);
inc(Page);
{ Linking Tab }
SetupLinkingTab(Self,Page);
SetupLinkingTab(Page);
inc(Page);
{ Other Tab }
SetupOtherTab(Self,Page);
SetupOtherTab(Page);
inc(Page);
{ Bottom Buttons }
SetupButtonBar(Self);
SetupButtonBar;
{ Show everything }
nbMain.Show;
@ -1709,7 +1715,7 @@ end;
{------------------------------------------------------------------------------}
{ TfrmCompilerOptions SetupParsingTab }
{------------------------------------------------------------------------------}
procedure TfrmCompilerOptions.SetupParsingTab(Sender: TObject; Page: integer);
procedure TfrmCompilerOptions.SetupParsingTab(Page: integer);
begin
// Setup the Parsing Tab
Assert(False, 'Trace:Setting up compiler options parsing tab');
@ -1923,8 +1929,7 @@ end;
{------------------------------------------------------------------------------}
{ TfrmCompilerOptions SetupCodeGenerationTab }
{------------------------------------------------------------------------------}
procedure TfrmCompilerOptions.SetupCodeGenerationTab(Sender: TObject;
Page: integer);
procedure TfrmCompilerOptions.SetupCodeGenerationTab(Page: integer);
begin
// Setup the Code Generation Tab
Assert(False, 'Trace:Setting up compiler options code generation tab');
@ -2216,7 +2221,7 @@ end;
{------------------------------------------------------------------------------}
{ TfrmCompilerOptions SetupLinkingTab }
{------------------------------------------------------------------------------}
procedure TfrmCompilerOptions.SetupLinkingTab(Sender: TObject; Page: integer);
procedure TfrmCompilerOptions.SetupLinkingTab(Page: integer);
begin
// Setup the Linking Tab
Assert(False, 'Trace:Setting up compiler options linking tab');
@ -2385,7 +2390,7 @@ end;
{------------------------------------------------------------------------------}
{ TfrmCompilerOptions SetupOtherTab }
{------------------------------------------------------------------------------}
procedure TfrmCompilerOptions.SetupOtherTab(Sender: TObject; Page: integer);
procedure TfrmCompilerOptions.SetupOtherTab(Page: integer);
begin
// Setup the Other Tab
Assert(False, 'Trace:Setting up compiler options other tab');
@ -2686,8 +2691,7 @@ end;
{------------------------------------------------------------------------------}
{ TfrmCompilerOptions SetupSearchPathsTab }
{------------------------------------------------------------------------------}
procedure TfrmCompilerOptions.SetupSearchPathsTab(Sender: TObject;
Page: integer);
procedure TfrmCompilerOptions.SetupSearchPathsTab(Page: integer);
begin
// Setup the Search Paths Tab
@ -2709,11 +2713,25 @@ begin
Parent := grpOtherUnits;
Left := 8;
Top := 5;
Width := Parent.ClientWidth-2*Left;
Width := Parent.ClientWidth-Left-37;
Height := 23;
Text := '';
Visible := True;
end;
OtherUnitsPathEditBtn:=TPathEditorButton.Create(Self);
with OtherUnitsPathEditBtn do begin
Name:='OtherUnitsPathEditBtn';
Parent:=grpOtherUnits;
Left:=edtOtherUnits.Left+edtOtherUnits.Width+3;
Top:=edtOtherUnits.Top;
Width:=25;
Height:=edtOtherUnits.Height;
Caption:='...';
OnClick:=@PathEditBtnClick;
OnExecuted:=@PathEditBtnExecuted;
Visible:=true;
end;
{------------------------------------------------------------}
@ -2735,12 +2753,26 @@ begin
Parent := grpIncludeFiles;
Top := 5;
Left := 8;
Width := Parent.ClientWidth-2*Left;
Width := Parent.ClientWidth-Left-37;
Height := 23;
Text := '';
Visible := True;
end;
IncludeFilesPathEditBtn:=TPathEditorButton.Create(Self);
with IncludeFilesPathEditBtn do begin
Name:='IncludeFilesPathEditBtn';
Parent:=grpIncludeFiles;
Left:=edtIncludeFiles.Left+edtIncludeFiles.Width+3;
Top:=edtIncludeFiles.Top;
Width:=25;
Height:=edtIncludeFiles.Height;
Caption:='...';
OnClick:=@PathEditBtnClick;
OnExecuted:=@PathEditBtnExecuted;
Visible:=true;
end;
{------------------------------------------------------------}
grpOtherSources := TGroupBox.Create(Self);
@ -2762,11 +2794,25 @@ begin
Top := 5;
Left := 8;
Height := 23;
Width := Parent.ClientWidth-2*Left;
Width := Parent.ClientWidth-Left-37;
Text := '';
Visible := True;
end;
OtherSourcesPathEditBtn:=TPathEditorButton.Create(Self);
with OtherSourcesPathEditBtn do begin
Name:='OtherSourcesPathEditBtn';
Parent:=grpOtherSources;
Left:=edtOtherSources.Left+edtOtherSources.Width+3;
Top:=edtOtherSources.Top;
Width:=25;
Height:=edtOtherSources.Height;
Caption:='...';
OnClick:=@PathEditBtnClick;
OnExecuted:=@PathEditBtnExecuted;
Visible:=true;
end;
{------------------------------------------------------------}
grpLibraries := TGroupBox.Create(Self);
@ -2788,11 +2834,25 @@ begin
Top := 5;
Left := 8;
Height := 23;
Width := Parent.ClientWidth-2*Left;
Width := Parent.ClientWidth-Left-37;
Text := '';
Visible := True;
end;
LibrariesPathEditBtn:=TPathEditorButton.Create(Self);
with LibrariesPathEditBtn do begin
Name:='LibrariesPathEditBtn';
Parent:=grpLibraries;
Left:=edtLibraries.Left+edtLibraries.Width+3;
Top:=edtLibraries.Top;
Width:=25;
Height:=edtLibraries.Height;
Caption:='...';
OnClick:=@PathEditBtnClick;
OnExecuted:=@PathEditBtnExecuted;
Visible:=true;
end;
{------------------------------------------------------------}
grpCompiler := TGroupBox.Create(Self);
@ -2870,7 +2930,7 @@ end;
{------------------------------------------------------------------------------}
{ TfrmCompilerOptions SetupButtonBar }
{------------------------------------------------------------------------------}
procedure TfrmCompilerOptions.SetupButtonBar(Sender: TObject);
procedure TfrmCompilerOptions.SetupButtonBar;
begin
// Setup the Button Bar
Assert(False, 'Trace:Setting up compiler options button bar');
@ -2933,6 +2993,60 @@ begin
edtConfigPath.Enabled:=chkAdditionalConfigFile.Checked;
end;
procedure TfrmCompilerOptions.PathEditBtnClick(Sender: TObject);
var AButton: TPathEditorButton;
OldPath, Templates: string;
begin
if Sender is TPathEditorButton then begin
AButton:=TPathEditorButton(Sender);
if AButton=OtherUnitsPathEditBtn then begin
OldPath:=edtOtherUnits.Text;
Templates:=
'$(LazarusDir)/lcl/units'
+';$(LazarusDir)/lcl/$(LCLWidgetType)';
end else
if AButton=IncludeFilesPathEditBtn then begin
OldPath:=edtIncludeFiles.Text;
Templates:='include';
end else
if AButton=OtherSourcesPathEditBtn then begin
OldPath:=edtOtherSources.Text;
Templates:=
'$(LazarusDir)/lcl'
+';$(LazarusDir)/lcl/interfaces/$(LCLWidgetType)';
end else
if AButton=LibrariesPathEditBtn then begin
OldPath:=edtLibraries.Text;
Templates:='';
end;
AButton.CurrentPathEditor.Path:=OldPath;
AButton.CurrentPathEditor.Templates:=SetDirSeparators(Templates);
end;
end;
procedure TfrmCompilerOptions.PathEditBtnExecuted(Sender: TObject);
var AButton: TPathEditorButton;
NewPath: string;
begin
if Sender is TPathEditorButton then begin
AButton:=TPathEditorButton(Sender);
if AButton.CurrentPathEditor.ModalResult<>mrOk then exit;
NewPath:=AButton.CurrentPathEditor.Path;
if AButton=OtherUnitsPathEditBtn then begin
edtOtherUnits.Text:=NewPath;
end else
if AButton=IncludeFilesPathEditBtn then begin
edtIncludeFiles.Text:=NewPath;
end else
if AButton=OtherSourcesPathEditBtn then begin
edtOtherSources.Text:=NewPath;
end else
if AButton=LibrariesPathEditBtn then begin
edtLibraries.Text:=NewPath;
end;
end;
end;
function TfrmCompilerOptions.GetOtherSourcePath: string;
begin
Result:=edtOtherSources.Text;

View File

@ -36,6 +36,7 @@ type
// FPC unitlinks
FLastFPCUnitLinks: string;
FLastFPCPath: string;
FLastFPCSearchPath: string;
FLastFPCAge: longint;
procedure SetFilename(const AValue: string);
@ -55,8 +56,8 @@ type
procedure AddToReplaceHistory(const AReplaceStr: String);
function LastFPCUnitLinksValid: boolean;
function LastFPCUnitLinksNeedsUpdate: boolean;
procedure SetLastFPCUnitLinks(const FPCPath, UnitLinks: string);
function LastFPCUnitLinksNeedsUpdate(const SearchPath: string): boolean;
procedure SetLastFPCUnitLinks(const FPCPath, SearchPath, UnitLinks: string);
public
// Find- and replace-history
property FindHistory: TStringList read FFindHistory write FFindHistory;
@ -67,6 +68,7 @@ type
// FPC unitlinks
property LastFPCUnitLinks: string read FLastFPCUnitLinks;
property LastFPCPath: string read FLastFPCPath write SetLastFPCPath;
property LastFPCSearchPath: string read FLastFPCSearchPath;
property LastFPCAge: longint read FLastFPCAge;
end;
@ -203,16 +205,20 @@ begin
Result:=(LastFPCPath<>'') and (FLastFPCAge>=0);
end;
function TInputHistories.LastFPCUnitLinksNeedsUpdate: boolean;
function TInputHistories.LastFPCUnitLinksNeedsUpdate(
const SearchPath: string): boolean;
begin
Result:=(not LastFPCUnitLinksValid)
or (SearchPath<>LastFPCSearchPath)
or (FileAge(LastFPCPath)<>LastFPCAge);
end;
procedure TInputHistories.SetLastFPCUnitLinks(const FPCPath, UnitLinks: string);
procedure TInputHistories.SetLastFPCUnitLinks(const FPCPath, SearchPath,
UnitLinks: string);
begin
FLastFPCPath:=FPCPath;
FLastFPCUnitLinks:=UnitLinks;
FLastFPCSearchPath:=SearchPath;
FLastFPCAge:=FileAge(FPCPath);
end;

View File

@ -5264,7 +5264,8 @@ begin
// create compiler macros to simulate the Makefiles of the FPC sources
CompilerUnitLinks:=InputHistories.LastFPCUnitLinks;
UnitLinksChanged:=InputHistories.LastFPCUnitLinksNeedsUpdate;
UnitLinksChanged:=InputHistories.LastFPCUnitLinksNeedsUpdate(
CompilerUnitSearchPath);
ADefTempl:=CreateFPCSrcTemplate(
CodeToolBoss.GlobalValues.Variables[ExternalMacroStart+'FPCSrcDir'],
CompilerUnitSearchPath,
@ -5275,7 +5276,7 @@ begin
or (InputHistories.LastFPCUnitLinks<>InputHistories.LastFPCUnitLinks)
then begin
InputHistories.SetLastFPCUnitLinks(EnvironmentOptions.CompilerFilename,
CompilerUnitLinks);
CompilerUnitSearchPath,CompilerUnitLinks);
InputHistories.Save;
end;
AddTemplate(ADefTempl,false,
@ -6221,6 +6222,9 @@ end.
{ =============================================================================
$Log$
Revision 1.279 2002/04/16 08:55:04 lazarus
MG: added path editor for compiler options
Revision 1.278 2002/04/15 10:56:05 lazarus
MG: fixes for open lpi files and improved jump points

470
ide/patheditordlg.pas Normal file
View File

@ -0,0 +1,470 @@
{ $Id$ }
{
/***************************************************************************
patheditordlg.pp
----------------
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
Abstract:
Defines the TPathEditorDialog, which is a form to edit search paths
}
unit PathEditorDlg;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, SynEdit, Buttons, StdCtrls, ExtCtrls,
Dialogs;
type
TPathEditorDialog = class(TForm)
PathGroupBox: TGroupBox;
PathEdit: TSynEdit;
MoveUpButton: TButton;
MoveDownButton: TButton;
BrowseButton: TButton;
DeleteButton: TButton;
TemplateGroupBox: TGroupBox;
TemplatesListBox: TListBox;
AddTemplateButton: TButton;
OkButton: TButton;
CancelButton: TButton;
OpenDialog: TOpenDialog;
procedure AddTemplateButtonClick(Sender: TObject);
procedure BrowseButtonClick(Sender: TObject);
procedure CancelButtonClick(Sender: TObject);
procedure DeleteButtonClick(Sender: TObject);
procedure MoveDownButtonClick(Sender: TObject);
procedure MoveUpButtonClick(Sender: TObject);
procedure OkButtonClick(Sender: TObject);
procedure PathEditorDialogResize(Sender: TObject);
private
function GetPath: string;
function GetTemplates: string;
function PathToText(const APath: string): string;
procedure SelectCurrentPath;
procedure SetPath(const AValue: string);
procedure SetTemplates(const AValue: string);
procedure SetupComponents;
function TextToPath(const AText: string): string;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
public
property Path: string read GetPath write SetPath;
property Templates: string read GetTemplates write SetTemplates;
end;
TOnPathEditorExecuted = TNotifyEvent;
TPathEditorButton = class(TButton)
private
FCurrentPathEditor: TPathEditorDialog;
FOnExecuted: TOnPathEditorExecuted;
protected
procedure Click; override;
procedure DoOnPathEditorExecuted;
public
property CurrentPathEditor: TPathEditorDialog read FCurrentPathEditor;
property OnExecuted: TOnPathEditorExecuted
read FOnExecuted write FOnExecuted;
end;
function PathEditorDialog: TPathEditorDialog;
implementation
uses Math, IDEProcs, LResources;
var PathEditor: TPathEditorDialog;
function PathEditorDialog: TPathEditorDialog;
begin
if PathEditor=nil then PathEditor:=TPathEditorDialog.Create(Application);
Result:=PathEditor;
end;
{ TPathEditorDialog }
procedure TPathEditorDialog.AddTemplateButtonClick(Sender: TObject);
var i, y: integer;
begin
y:=-1;
for i:=0 to TemplatesListBox.Items.Count-1 do begin
if TemplatesListBox.Selected[i] then begin
PathEdit.Lines.Add(TemplatesListBox.Items[i]);
y:=PathEdit.Lines.Count;
end;
end;
if y>=1 then PathEdit.CaretY:=y;
SelectCurrentPath;
end;
procedure TPathEditorDialog.BrowseButtonClick(Sender: TObject);
var y: integer;
NewPath: string;
begin
if OpenDialog=nil then OpenDialog:=TOpenDialog.Create(Self);
with OpenDialog do begin
Title:='Select directory';
if (not Execute) then exit;
NewPath:=ExtractFilePath(Trim(Filename));
if (not DirectoryExists(NewPath)) then exit;
y:=PathEdit.CaretY;
if y>PathEdit.Lines.Count then y:=PathEdit.Lines.Count;
PathEdit.Lines.Insert(y,NewPath);
PathEdit.CaretY:=y+1;
end;
SelectCurrentPath;
end;
procedure TPathEditorDialog.CancelButtonClick(Sender: TObject);
begin
ModalResult:=mrCancel;
end;
procedure TPathEditorDialog.DeleteButtonClick(Sender: TObject);
var y: integer;
begin
y:=PathEdit.CaretY-1;
if (y>=0) and (y<PathEdit.Lines.Count) then begin
PathEdit.Lines.Delete(y);
SelectCurrentPath;
end;
end;
procedure TPathEditorDialog.MoveDownButtonClick(Sender: TObject);
var y: integer;
begin
y:=PathEdit.CaretY-1;
if (y>=0) and (y<PathEdit.Lines.Count-1) then begin
PathEdit.Lines.Move(y,y+1);
PathEdit.CaretY:=y+2;
SelectCurrentPath;
end;
end;
procedure TPathEditorDialog.MoveUpButtonClick(Sender: TObject);
var y: integer;
begin
y:=PathEdit.CaretY-1;
if (y>0) and (y<PathEdit.Lines.Count) then begin
PathEdit.Lines.Move(y,y-1);
PathEdit.CaretY:=y;
SelectCurrentPath;
end;
end;
procedure TPathEditorDialog.OkButtonClick(Sender: TObject);
begin
ModalResult:=mrOk;
end;
procedure TPathEditorDialog.PathEditorDialogResize(Sender: TObject);
var MaxX, MaxY, PathGroupBoxHeight: integer;
begin
MaxX:=ClientWidth;
MaxY:=ClientHeight;
PathGroupBoxHeight:=((MaxY-70)*2) div 3;
if PathGroupBoxHeight<10 then PathGroupBoxHeight:=10;
// path groupbox
PathGroupBox.SetBounds(6,6,MaxX-2*6,PathGroupBoxHeight);
PathEdit.SetBounds(2,2,
PathGroupBox.Width-10,Max(0,PathGroupBox.Height-57));
MoveUpButton.SetBounds(8,PathEdit.Top+PathEdit.Height+8,
120,MoveUpButton.Height);
MoveDownButton.SetBounds(MoveUpButton.Left+MoveUpButton.Width+8,
MoveUpButton.Top,
MoveUpButton.Width,MoveUpButton.Height);
BrowseButton.SetBounds(MoveDownButton.Left+MoveDownButton.Width+8,
MoveDownButton.Top,
90,MoveDownButton.Height);
DeleteButton.SetBounds(BrowseButton.Left+BrowseButton.Width+8,
BrowseButton.Top,
BrowseButton.Width,BrowseButton.Height);
// template groupbox
with TemplateGroupBox do begin
Left:=PathGroupBox.Left;
Top:=PathGroupBox.Top+PathGroupBox.Height+8;
Width:=PathGroupBox.Width;
Height:=Max(0,MaxY-50-Top);
end;
TemplatesListBox.SetBounds(2,2,Max(0,TemplateGroupBox.Width-10),
Max(0,TemplateGroupBox.Height-57));
AddTemplateButton.SetBounds(8,TemplatesListBox.Top+TemplatesListBox.Height+8,
100,AddTemplateButton.Height);
// buttons at bottom
OkButton.SetBounds(20,Max(0,MaxY-35),100,OkButton.Height);
CancelButton.SetBounds(OkButton.Left+OkButton.Width+10,OkButton.Top,
OkButton.Width,OkButton.Height);
SelectCurrentPath;
end;
function TPathEditorDialog.GetPath: string;
begin
Result:=TextToPath(PathEdit.Text);
end;
function TPathEditorDialog.GetTemplates: string;
begin
Result:=TextToPath(TemplatesListBox.Items.Text);
end;
procedure TPathEditorDialog.SetPath(const AValue: string);
begin
PathEdit.Text:=PathToText(AValue);
end;
procedure TPathEditorDialog.SetTemplates(const AValue: string);
var sl: TStringList;
i: integer;
begin
sl:=TStringList.Create;
try
sl.Text:=PathToText(AValue);
with TemplatesListBox do begin
Items.BeginUpdate;
i:=0;
while i<sl.Count do begin
if Items.Count<=i then
Items.Add(sl[i])
else
Items[i]:=sl[i];
inc(i);
end;
while Items.Count>sl.Count do
Items.Delete(Items.Count-1);
Items.EndUpdate;
end;
finally
sl.Free;
end;
end;
procedure TPathEditorDialog.SetupComponents;
begin
PathGroupBox:=TGroupBox.Create(Self);
with PathGroupBox do begin
Name:='PathGroupBox';
Parent:=Self;
Caption:='Search paths:';
Visible:=true;
end;
PathEdit:=TSynEdit.Create(Self);
with PathEdit do begin
Name:='PathEdit';
Parent:=PathGroupBox;
Options:=[eoBracketHighlight, eoHideRightMargin, eoDragDropEditing,
eoHalfPageScroll, eoScrollByOneLess, eoScrollPastEol,
eoSmartTabs, eoTabsToSpaces, eoTrimTrailingSpaces];
Gutter.Visible:=false;
Visible:=true;
end;
MoveUpButton:=TButton.Create(Self);
with MoveUpButton do begin
Name:='MoveUpButton';
Parent:=PathGroupBox;
Caption:='Move path up';
OnClick:=@MoveUpButtonClick;
Visible:=true;
end;
MoveDownButton:=TButton.Create(Self);
with MoveDownButton do begin
Name:='MoveDownButton';
Parent:=PathGroupBox;
Caption:='Move path down';
OnClick:=@MoveDownButtonClick;
Visible:=true;
end;
BrowseButton:=TButton.Create(Self);
with BrowseButton do begin
Name:='BrowseButton';
Parent:=PathGroupBox;
Caption:='Browse';
OnClick:=@BrowseButtonClick;
Visible:=true;
end;
DeleteButton:=TButton.Create(Self);
with DeleteButton do begin
Name:='DeleteButton';
Parent:=PathGroupBox;
Caption:='Delete';
OnClick:=@DeleteButtonClick;
Visible:=true;
end;
TemplateGroupBox:=TGroupBox.Create(Self);
with TemplateGroupBox do begin
Name:='TemplateGroupBox';
Parent:=Self;
Caption:='Path templates';
Visible:=true;
end;
TemplatesListBox:=TListBox.Create(Self);
with TemplatesListBox do begin
Name:='TemplatesListBox';
Parent:=TemplateGroupBox;
MultiSelect:=true;
Visible:=true;
end;
AddTemplateButton:=TButton.Create(Self);
with AddTemplateButton do begin
Name:='AddTemplateButton';
Parent:=TemplateGroupBox;
Caption:='Add';
OnClick:=@AddTemplateButtonClick;
Visible:=true;
end;
OkButton:=TButton.Create(Self);
with OkButton do begin
Name:='OkButton';
Parent:=Self;
Caption:='Ok';
OnClick:=@OkButtonClick;
Visible:=true;
end;
CancelButton:=TButton.Create(Self);
with CancelButton do begin
Name:='CancelButton';
Parent:=Self;
Caption:='Cancel';
OnClick:=@CancelButtonClick;
Visible:=true;
end;
end;
function TPathEditorDialog.TextToPath(const AText: string): string;
var i, j: integer;
PathAsText: string;
begin
PathAsText:=AText;
Result:=PathAsText;
// convert all line ends to semicolons, remove empty paths and trailing spaces
i:=1;
j:=1;
while i<=length(PathAsText) do begin
if PathAsText[i] in [#10,#13] then begin
// new line -> new path
inc(i);
if (i<=length(PathAsText)) and (PathAsText[i] in [#10,#13])
and (PathAsText[i]<>PathAsText[i-1]) then
inc(i);
// skip spaces at end of path
while (j>1) and (Result[j-1]=' ') do
dec(j);
// skip empty paths
if (j=1) or (Result[j-1]<>';') then begin
Result[j]:=';';
inc(j);
end;
end else if ord(PathAsText[i])<32 then begin
// skip trailing spaces
inc(i)
end else if PathAsText[i]=' ' then begin
// space -> skip spaces at beginning of path
if (j>1) and (Result[j-1]<>';') then begin
Result[j]:=PathAsText[i];
inc(j);
end;
inc(i);
end else begin
// path char -> just copy
Result[j]:=PathAsText[i];
inc(j);
inc(i);
end;
end;
if (j>1) and (Result[j-1]=';') then dec(j);
SetLength(Result,j-1);
end;
function TPathEditorDialog.PathToText(const APath: string): string;
var i: integer;
NewPath: string;
begin
NewPath:=APath;
for i:=1 to length(NewPath) do
if NewPath[i]=';' then NewPath[i]:=#13;
Result:=NewPath;
end;
procedure TPathEditorDialog.SelectCurrentPath;
var y: integer;
begin
y:=PathEdit.CaretY;
if y>PathEdit.Lines.Count then exit;
PathEdit.BlockBegin:=Point(0,y);
PathEdit.BlockEnd:=Point(length(PathEdit.Lines[y-1])+1,y);
end;
constructor TPathEditorDialog.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
if LazarusResources.Find(ClassName)=nil then begin
Width:=500;
Height:=400;
Position:=poScreenCenter;
OnResize:=@PathEditorDialogResize;
SetupComponents;
end;
PathEditorDialogResize(nil);
end;
destructor TPathEditorDialog.Destroy;
begin
inherited Destroy;
end;
{ TPathEditorButton }
procedure TPathEditorButton.Click;
begin
FCurrentPathEditor:=PathEditorDialog;
try
inherited Click;
FCurrentPathEditor.ShowModal;
DoOnPathEditorExecuted;
finally
FCurrentPathEditor:=nil;
end;
end;
procedure TPathEditorButton.DoOnPathEditorExecuted;
begin
if Assigned(OnExecuted) then OnExecuted(Self);
end;
//------------------------------------------------------------------------------
finalization
FreeAndNil(PathEditor);
end.