IDE: improve Path Editor's GUI

git-svn-id: trunk@35315 -
This commit is contained in:
juha 2012-02-11 20:19:29 +00:00
parent 5b0a8deab2
commit ce0d3e2bc4
3 changed files with 335 additions and 802 deletions

View File

@ -40,6 +40,10 @@ uses
Classes, SysUtils;
resourcestring
// Common strings that can be used around Lazarus:
lisAdd = 'Add';
// errors
lisErrInvalidOption = 'Invalid option at position %d: "%s"';
lisErrNoOptionAllowed = 'Option at position %d does not allow an argument: %s';
lisErrOptionNeeded = 'Option at position %d needs an argument : %s';
@ -52,13 +56,11 @@ resourcestring
// command line help
listhisHelpMessage = 'this help message';
lisprimaryConfigDirectoryWhereLazarusStoresItsConfig =
'primary config '+
lisprimaryConfigDirectoryWhereLazarusStoresItsConfig = 'primary config '+
'directory, where Lazarus stores its config files. Default is ';
lislazarusOptionsProjectFilename = 'lazarus [options] <project-filename>';
lisIDEOptions = 'IDE Options:';
lisCmdLineLCLInterfaceSpecificOptions =
'LCL Interface specific options:';
lisCmdLineLCLInterfaceSpecificOptions = 'LCL Interface specific options:';
lisDoNotShowSplashScreen = 'Do not show splash screen';
lisSkipLoadingLastProject = 'Skip loading last project';
lisOverrideLanguage = 'Override language. For example --language=de.'+
@ -3352,10 +3354,11 @@ resourcestring
lisPathEditSearchPaths = 'Search paths:';
lisPckSearchPathsForFpdocXmlFilesMultiplePathsMustBeSepa = 'Search paths for'
+' fpdoc xml files. Multiple paths must be separated by semicolon.';
lisPathEditMovePathDown = 'Move path down';
lisPathEditMovePathUp = 'Move path up';
lisPathEditMovePathDown = 'Move path down (Ctrl+Down)';
lisPathEditMovePathUp = 'Move path up (Ctrl+Up)';
lisPathEditBrowse = 'Browse';
lisPathEditPathTemplates = 'Path templates';
lisPathEditDeleteInvalidPaths = 'Delete Invalid Paths';
// new dialog
lisNewDlgNoItemSelected = 'No item selected';
@ -4438,12 +4441,10 @@ resourcestring
lisReplacingSelectionFailed = 'Replacing selection failed.';
lisUnableToFindInLFMStream = 'Unable to find %s in LFM Stream.';
lisErrorParsingLfmComponentStream = 'Error parsing lfm component stream.';
lisUnableToCreateTemporaryLfmBuffer =
'Unable to create temporary lfm buffer.';
lisUnableToCreateTemporaryLfmBuffer = 'Unable to create temporary lfm buffer.';
lisUnableToGetSourceForDesigner = 'Unable to get source for designer.';
lisUnableToGatherEditorChanges = 'Unable to gather editor changes.';
lisUnableToStreamSelectedComponents2 =
'Unable to stream selected components.';
lisUnableToStreamSelectedComponents2 = 'Unable to stream selected components.';
lisUnableToChangeClassOfTo = '%s%sUnable to change class of %s to %s';
lisCanOnlyChangeTheClassOfTComponents = 'Can only change the class of TComponents.';
lisOldClass = 'Old Class';
@ -4471,10 +4472,6 @@ resourcestring
lisCEProcedures = 'Procedures';
lisCEProperties = 'Properties';
lisCodeObserver = 'Code Observer';
dlgCOMoveLevelDown = 'Move level down';
dlgCOMoveLevelUp = 'Move level up';
dlgCOMoveDown = 'Move down';
dlgCOMoveUp = 'Move up';
lisCEOMode = 'Preferred exhibition mode';
lisCEOModeCategory = 'Category';
lisCEOModeSource = 'Source';

View File

@ -1,732 +1,188 @@
object PathEditorDialog: TPathEditorDialog
Left = 295
Height = 400
Top = 158
Width = 500
ActiveControl = PathEdit
Left = 420
Height = 446
Top = 156
Width = 553
AutoSize = True
Caption = 'PathEditorDialog'
ClientHeight = 400
ClientWidth = 500
ClientHeight = 446
ClientWidth = 553
Constraints.MinHeight = 400
Constraints.MinWidth = 500
OnCreate = FormCreate
OnResize = FormResize
Position = poScreenCenter
LCLVersion = '0.9.29'
LCLVersion = '0.9.31'
object PathGroupBox: TGroupBox
AnchorSideRight.Side = asrBottom
Left = 6
Height = 194
Height = 221
Top = 6
Width = 488
Width = 541
Align = alClient
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Around = 6
Caption = 'PathGroupBox'
ClientHeight = 175
ClientWidth = 484
ClientHeight = 202
ClientWidth = 535
Constraints.MinHeight = 194
Constraints.MinWidth = 488
TabOrder = 0
inline PathEdit: TSynEdit
AnchorSideLeft.Control = PathGroupBox
AnchorSideTop.Control = PathGroupBox
AnchorSideRight.Control = PathGroupBox
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = MoveUpButton
Left = 6
Height = 128
Top = 6
Width = 472
BorderSpacing.Around = 6
Anchors = [akTop, akLeft, akRight, akBottom]
Font.Height = -16
Font.Name = 'courier'
Font.Pitch = fpFixed
Font.Quality = fqNonAntialiased
ParentColor = False
ParentFont = False
TabOrder = 0
BookMarkOptions.Xoffset = -18
Gutter.Visible = False
Gutter.Width = 0
Gutter.MouseActions = <
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccAny
ClickDir = cdDown
Command = 13
MoveCaret = False
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbRight
ClickCount = ccSingle
ClickDir = cdUp
Command = 12
MoveCaret = False
Option = 0
Priority = 0
end>
Keystrokes = <
item
Command = ecUp
ShortCut = 38
end
item
Command = ecSelUp
ShortCut = 8230
end
item
Command = ecScrollUp
ShortCut = 16422
end
item
Command = ecDown
ShortCut = 40
end
item
Command = ecSelDown
ShortCut = 8232
end
item
Command = ecScrollDown
ShortCut = 16424
end
item
Command = ecLeft
ShortCut = 37
end
item
Command = ecSelLeft
ShortCut = 8229
end
item
Command = ecWordLeft
ShortCut = 16421
end
item
Command = ecSelWordLeft
ShortCut = 24613
end
item
Command = ecRight
ShortCut = 39
end
item
Command = ecSelRight
ShortCut = 8231
end
item
Command = ecWordRight
ShortCut = 16423
end
item
Command = ecSelWordRight
ShortCut = 24615
end
item
Command = ecPageDown
ShortCut = 34
end
item
Command = ecSelPageDown
ShortCut = 8226
end
item
Command = ecPageBottom
ShortCut = 16418
end
item
Command = ecSelPageBottom
ShortCut = 24610
end
item
Command = ecPageUp
ShortCut = 33
end
item
Command = ecSelPageUp
ShortCut = 8225
end
item
Command = ecPageTop
ShortCut = 16417
end
item
Command = ecSelPageTop
ShortCut = 24609
end
item
Command = ecLineStart
ShortCut = 36
end
item
Command = ecSelLineStart
ShortCut = 8228
end
item
Command = ecEditorTop
ShortCut = 16420
end
item
Command = ecSelEditorTop
ShortCut = 24612
end
item
Command = ecLineEnd
ShortCut = 35
end
item
Command = ecSelLineEnd
ShortCut = 8227
end
item
Command = ecEditorBottom
ShortCut = 16419
end
item
Command = ecSelEditorBottom
ShortCut = 24611
end
item
Command = ecToggleMode
ShortCut = 45
end
item
Command = ecCopy
ShortCut = 16429
end
item
Command = ecPaste
ShortCut = 8237
end
item
Command = ecDeleteChar
ShortCut = 46
end
item
Command = ecCut
ShortCut = 8238
end
item
Command = ecDeleteLastChar
ShortCut = 8
end
item
Command = ecDeleteLastChar
ShortCut = 8200
end
item
Command = ecDeleteLastWord
ShortCut = 16392
end
item
Command = ecUndo
ShortCut = 32776
end
item
Command = ecRedo
ShortCut = 40968
end
item
Command = ecLineBreak
ShortCut = 13
end
item
Command = ecSelectAll
ShortCut = 16449
end
item
Command = ecCopy
ShortCut = 16451
end
item
Command = ecBlockIndent
ShortCut = 24649
end
item
Command = ecLineBreak
ShortCut = 16461
end
item
Command = ecInsertLine
ShortCut = 16462
end
item
Command = ecDeleteWord
ShortCut = 16468
end
item
Command = ecBlockUnindent
ShortCut = 24661
end
item
Command = ecPaste
ShortCut = 16470
end
item
Command = ecCut
ShortCut = 16472
end
item
Command = ecDeleteLine
ShortCut = 16473
end
item
Command = ecDeleteEOL
ShortCut = 24665
end
item
Command = ecUndo
ShortCut = 16474
end
item
Command = ecRedo
ShortCut = 24666
end
item
Command = ecGotoMarker0
ShortCut = 16432
end
item
Command = ecGotoMarker1
ShortCut = 16433
end
item
Command = ecGotoMarker2
ShortCut = 16434
end
item
Command = ecGotoMarker3
ShortCut = 16435
end
item
Command = ecGotoMarker4
ShortCut = 16436
end
item
Command = ecGotoMarker5
ShortCut = 16437
end
item
Command = ecGotoMarker6
ShortCut = 16438
end
item
Command = ecGotoMarker7
ShortCut = 16439
end
item
Command = ecGotoMarker8
ShortCut = 16440
end
item
Command = ecGotoMarker9
ShortCut = 16441
end
item
Command = ecSetMarker0
ShortCut = 24624
end
item
Command = ecSetMarker1
ShortCut = 24625
end
item
Command = ecSetMarker2
ShortCut = 24626
end
item
Command = ecSetMarker3
ShortCut = 24627
end
item
Command = ecSetMarker4
ShortCut = 24628
end
item
Command = ecSetMarker5
ShortCut = 24629
end
item
Command = ecSetMarker6
ShortCut = 24630
end
item
Command = ecSetMarker7
ShortCut = 24631
end
item
Command = ecSetMarker8
ShortCut = 24632
end
item
Command = ecSetMarker9
ShortCut = 24633
end
item
Command = ecNormalSelect
ShortCut = 24654
end
item
Command = ecColumnSelect
ShortCut = 24643
end
item
Command = ecLineSelect
ShortCut = 24652
end
item
Command = ecTab
ShortCut = 9
end
item
Command = ecShiftTab
ShortCut = 8201
end
item
Command = ecMatchBracket
ShortCut = 24642
end>
MouseActions = <
item
Shift = []
ShiftMask = [ssShift, ssAlt]
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdDown
Command = 1
MoveCaret = True
Option = 0
Priority = 0
end
item
Shift = [ssShift]
ShiftMask = [ssShift, ssAlt]
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdDown
Command = 1
MoveCaret = True
Option = 1
Priority = 0
end
item
Shift = [ssAlt]
ShiftMask = [ssShift, ssAlt]
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdDown
Command = 3
MoveCaret = True
Option = 0
Priority = 0
end
item
Shift = [ssShift, ssAlt]
ShiftMask = [ssShift, ssAlt]
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdDown
Command = 3
MoveCaret = True
Option = 1
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbRight
ClickCount = ccSingle
ClickDir = cdUp
Command = 12
MoveCaret = False
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccDouble
ClickDir = cdDown
Command = 6
MoveCaret = True
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccTriple
ClickDir = cdDown
Command = 7
MoveCaret = True
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccQuad
ClickDir = cdDown
Command = 8
MoveCaret = True
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbMiddle
ClickCount = ccSingle
ClickDir = cdDown
Command = 10
MoveCaret = True
Option = 0
Priority = 0
end
item
Shift = [ssCtrl]
ShiftMask = [ssShift, ssAlt, ssCtrl]
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdUp
Command = 11
MoveCaret = False
Option = 0
Priority = 0
end>
MouseSelActions = <
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdDown
Command = 9
MoveCaret = False
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdDown
Command = 9
MoveCaret = False
Option = 0
Priority = 0
end>
Lines.Strings = (
'PathEdit'
)
Options = [eoDragDropEditing, eoHalfPageScroll, eoScrollByOneLess, eoScrollPastEol, eoSmartTabs, eoTabsToSpaces, eoTrimTrailingSpaces, eoBracketHighlight, eoHideRightMargin]
BracketHighlightStyle = sbhsBoth
inline TSynGutterPartList
object TSynGutterMarks
Width = 23
end
object TSynGutterLineNumber
Width = 25
MouseActions = <>
MarkupInfo.Background = clBtnFace
MarkupInfo.Foreground = clNone
DigitCount = 2
ShowOnlyLineNumbersMultiplesOf = 1
ZeroStart = False
LeadingZeros = False
end
object TSynGutterChanges
Width = 4
ModifiedColor = 59900
SavedColor = clGreen
end
object TSynGutterSeparator
Width = 2
end
object TSynGutterCodeFolding
MouseActions = <
item
Shift = []
ShiftMask = []
Button = mbRight
ClickCount = ccSingle
ClickDir = cdUp
Command = 16
MoveCaret = False
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = [ssShift]
Button = mbMiddle
ClickCount = ccAny
ClickDir = cdDown
Command = 14
MoveCaret = False
Option = 0
Priority = 0
end
item
Shift = [ssShift]
ShiftMask = [ssShift]
Button = mbMiddle
ClickCount = ccAny
ClickDir = cdDown
Command = 14
MoveCaret = False
Option = 1
Priority = 0
end
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccAny
ClickDir = cdDown
Command = 0
MoveCaret = False
Option = 0
Priority = 0
end>
MarkupInfo.Background = clNone
MarkupInfo.Foreground = clGray
MouseActionsExpanded = <
item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccAny
ClickDir = cdDown
Command = 14
MoveCaret = False
Option = 0
Priority = 0
end>
MouseActionsCollapsed = <
item
Shift = [ssCtrl]
ShiftMask = [ssCtrl]
Button = mbLeft
ClickCount = ccAny
ClickDir = cdDown
Command = 15
MoveCaret = False
Option = 0
Priority = 0
end
item
Shift = []
ShiftMask = [ssCtrl]
Button = mbLeft
ClickCount = ccAny
ClickDir = cdDown
Command = 15
MoveCaret = False
Option = 1
Priority = 0
end>
end
end
end
object MoveUpButton: TBitBtn
AnchorSideLeft.Control = PathGroupBox
AnchorSideRight.Control = PathGroupBox
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = PathGroupBox
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 29
Top = 140
Width = 110
Anchors = [akLeft, akBottom]
AutoSize = True
Left = 504
Height = 25
Top = 47
Width = 25
Anchors = [akRight]
BorderSpacing.Around = 6
Caption = 'MoveUpButton'
NumGlyphs = 0
OnClick = MoveUpButtonClick
ParentShowHint = False
ShowHint = True
TabOrder = 1
end
object MoveDownButton: TBitBtn
AnchorSideLeft.Control = MoveUpButton
AnchorSideLeft.Side = asrBottom
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = MoveUpButton
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = PathGroupBox
AnchorSideBottom.Side = asrBottom
Left = 122
Height = 29
Top = 140
Width = 127
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Around = 6
Left = 504
Height = 25
Top = 86
Width = 25
BorderSpacing.Around = 14
Caption = 'MoveDownButton'
NumGlyphs = 0
OnClick = MoveDownButtonClick
ParentShowHint = False
ShowHint = True
TabOrder = 2
end
object BrowseButton: TBitBtn
AnchorSideLeft.Control = MoveDownButton
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = MoveDownButton
AnchorSideBottom.Control = PathGroupBox
AnchorSideBottom.Side = asrBottom
Left = 255
Height = 29
Top = 140
Width = 104
Anchors = [akTop, akLeft, akBottom]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Right = 6
BorderSpacing.Bottom = 6
Caption = 'BrowseButton'
NumGlyphs = 0
OnClick = BrowseButtonClick
TabOrder = 3
end
object DeleteButton: TBitBtn
AnchorSideLeft.Control = BrowseButton
AnchorSideLeft.Control = AddButton
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = PathGroupBox
AnchorSideBottom.Side = asrBottom
Left = 365
Height = 29
Top = 140
Width = 100
Left = 185
Height = 24
Top = 172
Width = 86
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Around = 6
Caption = 'DeleteButton'
Enabled = False
NumGlyphs = 0
OnClick = DeleteButtonClick
TabOrder = 6
end
object PathListBox: TListBox
AnchorSideLeft.Control = PathGroupBox
AnchorSideTop.Control = PathGroupBox
AnchorSideRight.Control = MoveUpButton
AnchorSideBottom.Control = DirectoryEdit
Left = 6
Height = 132
Top = 6
Width = 492
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 6
ItemHeight = 0
OnKeyDown = PathListBoxKeyDown
OnSelectionChange = PathListBoxSelectionChange
TabOrder = 0
end
object DirectoryEdit: TDirectoryEdit
AnchorSideLeft.Control = ReplaceButton
AnchorSideRight.Control = PathListBox
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ReplaceButton
Left = 6
Height = 22
Top = 144
Width = 492
ShowHidden = False
ButtonWidth = 23
NumGlyphs = 0
Anchors = [akLeft, akRight, akBottom]
MaxLength = 0
TabOrder = 3
OnChange = DirectoryEditChange
end
object ReplaceButton: TBitBtn
AnchorSideLeft.Control = PathGroupBox
AnchorSideBottom.Control = PathGroupBox
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 24
Top = 172
Width = 95
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Around = 6
Caption = 'ReplaceButton'
Enabled = False
NumGlyphs = 0
OnClick = ReplaceButtonClick
TabOrder = 4
end
object AddButton: TBitBtn
AnchorSideLeft.Control = ReplaceButton
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = PathGroupBox
AnchorSideBottom.Side = asrBottom
Left = 107
Height = 24
Top = 172
Width = 72
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Around = 6
Caption = 'AddButton'
Enabled = False
NumGlyphs = 0
OnClick = AddButtonClick
TabOrder = 5
end
object DeleteInvalidPathsButton: TBitBtn
AnchorSideLeft.Control = DeleteButton
AnchorSideLeft.Side = asrBottom
AnchorSideBottom.Control = PathGroupBox
AnchorSideBottom.Side = asrBottom
Left = 277
Height = 24
Top = 172
Width = 154
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Around = 6
Caption = 'DeleteInvalidPathsButton'
Enabled = False
NumGlyphs = 0
OnClick = DeleteInvalidPathsButtonClick
TabOrder = 7
end
end
object TemplateGroupBox: TGroupBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 6
Height = 150
Top = 206
Width = 488
Height = 164
Top = 244
Width = 541
Align = alBottom
Anchors = [akTop, akLeft, akRight, akBottom]
Anchors = []
BorderSpacing.Around = 6
Caption = 'TemplateGroupBox'
ClientHeight = 131
ClientWidth = 484
ClientHeight = 145
ClientWidth = 535
TabOrder = 1
object TemplatesListBox: TListBox
AnchorSideLeft.Control = TemplateGroupBox
@ -735,25 +191,24 @@ object PathEditorDialog: TPathEditorDialog
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = AddTemplateButton
Left = 6
Height = 84
Height = 103
Top = 6
Width = 472
Width = 523
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 6
ItemHeight = 0
MultiSelect = True
OnDblClick = TemplatesListBoxDblClick
OnSelectionChange = TemplatesListBoxSelectionChange
TabOrder = 0
TopIndex = -1
end
object AddTemplateButton: TBitBtn
AnchorSideLeft.Control = TemplateGroupBox
AnchorSideBottom.Control = TemplateGroupBox
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 29
Top = 96
Width = 141
Height = 24
Top = 115
Width = 123
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Around = 6
@ -765,16 +220,33 @@ object PathEditorDialog: TPathEditorDialog
end
object ButtonPanel1: TButtonPanel
Left = 6
Height = 32
Top = 362
Width = 488
Height = 26
Top = 414
Width = 541
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True
HelpButton.Name = 'HelpButton'
HelpButton.DefaultCaption = True
CloseButton.Name = 'CloseButton'
CloseButton.DefaultCaption = True
CancelButton.Name = 'CancelButton'
CancelButton.DefaultCaption = True
TabOrder = 2
ShowButtons = [pbOK, pbCancel]
ShowBevel = False
end
object Splitter1: TSplitter
Cursor = crVSplit
Left = 0
Height = 5
Top = 233
Width = 553
Align = alBottom
ResizeAnchor = akBottom
end
object BrowseDialog: TSelectDirectoryDialog
Options = [ofFileMustExist, ofEnableSizing, ofViewDetail]
left = 355
top = 80
left = 504
top = 32
end
end

View File

@ -28,7 +28,7 @@ interface
uses
Classes, SysUtils, Forms, Controls, SynEdit, Buttons, StdCtrls, Dialogs,
FileUtil, ButtonPanel, MacroIntf,
FileUtil, ButtonPanel, ExtCtrls, EditBtn, MacroIntf, LCLType,
LazarusIDEStrConsts, EditorOptions;
type
@ -37,42 +37,55 @@ type
TPathEditorDialog = class(TForm)
AddTemplateButton: TBitBtn;
BrowseButton: TBitBtn;
ButtonPanel1: TButtonPanel;
ReplaceButton: TBitBtn;
AddButton: TBitBtn;
DeleteInvalidPathsButton: TBitBtn;
DirectoryEdit: TDirectoryEdit;
Splitter1: TSplitter;
DeleteButton: TBitBtn;
PathListBox: TListBox;
MoveDownButton: TBitBtn;
MoveUpButton: TBitBtn;
TemplatesListBox: TListBox;
TemplateGroupBox: TGroupBox;
PathGroupBox: TGroupBox;
PathEdit: TSynEdit;
BrowseDialog: TSelectDirectoryDialog;
procedure AddButtonClick(Sender: TObject);
procedure AddTemplateButtonClick(Sender: TObject);
procedure BrowseButtonClick(Sender: TObject);
procedure DeleteInvalidPathsButtonClick(Sender: TObject);
procedure DeleteButtonClick(Sender: TObject);
procedure DirectoryEditChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure MoveDownButtonClick(Sender: TObject);
procedure MoveUpButtonClick(Sender: TObject);
procedure PathListBoxKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure PathListBoxSelectionChange(Sender: TObject; User: boolean);
procedure ReplaceButtonClick(Sender: TObject);
procedure TemplatesListBoxDblClick(Sender: TObject);
procedure TemplatesListBoxSelectionChange(Sender: TObject; User: boolean);
private
FBaseDirectory: string;
FEffectiveBaseDirectory: string;
function GetPath: string;
function GetTemplates: string;
function PathToText(const APath: string): string;
procedure SelectCurrentPath;
function RelativePathHelper: String;
function AbsolutePathHelper: String;
procedure SetBaseDirectory(const AValue: string);
procedure SetPath(const AValue: string);
procedure SetTemplates(const AValue: string);
function TextToPath(const AText: string): string;
procedure UpdateButtons;
public
property BaseDirectory: string read FBaseDirectory write SetBaseDirectory;
property EffectiveBaseDirectory: string read FEffectiveBaseDirectory;
property Path: string read GetPath write SetPath;
property Templates: string read GetTemplates write SetTemplates;
end;
TOnPathEditorExecuted = TNotifyEvent;
TPathEditorButton = class(TButton)
@ -102,128 +115,188 @@ var PathEditor: TPathEditorDialog;
function PathEditorDialog: TPathEditorDialog;
begin
if PathEditor=nil then PathEditor:=TPathEditorDialog.Create(Application);
if PathEditor=nil then
PathEditor:=TPathEditorDialog.Create(Application);
Result:=PathEditor;
end;
{ TPathEditorDialog }
procedure TPathEditorDialog.AddTemplateButtonClick(Sender: TObject);
var i, y: integer;
function TPathEditorDialog.RelativePathHelper: String;
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;
Result:=DirectoryEdit.Text;
if (FEffectiveBaseDirectory<>'') and FilenameIsAbsolute(FEffectiveBaseDirectory) then
Result:=CreateRelativePath(Result, FEffectiveBaseDirectory);
end;
procedure TPathEditorDialog.BrowseButtonClick(Sender: TObject);
var y: integer;
NewPath: String;
function TPathEditorDialog.AbsolutePathHelper: String;
begin
with BrowseDialog do begin
Title:=lisPathEditSelectDirectory;
if (not Execute) then exit;
y:=PathEdit.CaretY;
if y>PathEdit.Lines.Count then y:=PathEdit.Lines.Count;
NewPath:=Filename;
if (FEffectiveBaseDirectory<>'')
and FilenameIsAbsolute(FEffectiveBaseDirectory) then
NewPath:=CreateRelativePath(NewPath,FEffectiveBaseDirectory);
PathEdit.Lines.Insert(y,Trim(NewPath));
PathEdit.CaretY:=y+1;
Result:=PathListBox.Items[PathListBox.ItemIndex];
if (FEffectiveBaseDirectory<>'') and FilenameIsAbsolute(FEffectiveBaseDirectory) then
Result:=CreateAbsolutePath(Result, FEffectiveBaseDirectory);
end;
procedure TPathEditorDialog.AddButtonClick(Sender: TObject);
var
y: integer;
begin
y:=PathListBox.ItemIndex+1;
if y=0 then
y:=PathListBox.Count;
PathListBox.Items.Insert(y,Trim(RelativePathHelper));
PathListBox.ItemIndex:=y;
UpdateButtons;
end;
procedure TPathEditorDialog.ReplaceButtonClick(Sender: TObject);
begin
if PathListBox.ItemIndex>-1 then begin
PathListBox.Items[PathListBox.ItemIndex]:=Trim(RelativePathHelper);
UpdateButtons;
end;
SelectCurrentPath;
end;
procedure TPathEditorDialog.DeleteButtonClick(Sender: TObject);
var y: integer;
var
y: integer;
begin
y:=PathEdit.CaretY-1;
if (y>=0) and (y<PathEdit.Lines.Count) then begin
PathEdit.Lines.Delete(y);
SelectCurrentPath;
y:=PathListBox.ItemIndex;
if (y>=0) and (y<PathListBox.Count) then begin
PathListBox.Items.Delete(y);
UpdateButtons;
end;
end;
procedure TPathEditorDialog.DeleteInvalidPathsButtonClick(Sender: TObject);
begin
;
end;
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]
and (PathListBox.Items.IndexOf(TemplatesListBox.Items[i])=-1) then begin
PathListBox.Items.Add(TemplatesListBox.Items[i]);
y:=PathListBox.Count-1;
end;
end;
if y>=1 then
PathListBox.ItemIndex:=y;
UpdateButtons;
end;
procedure TPathEditorDialog.DirectoryEditChange(Sender: TObject);
begin
UpdateButtons;
end;
procedure TPathEditorDialog.FormCreate(Sender: TObject);
begin
Caption:=dlgDebugOptionsPathEditorDlgCaption;
PathGroupBox.Caption:=lisPathEditSearchPaths;
MoveUpButton.Caption:=lisPathEditMovePathUp;
MoveDownButton.Caption:=lisPathEditMovePathDown;
BrowseButton.Caption:=lisPathEditBrowse;
MoveUpButton.Hint:=lisPathEditMovePathUp;
MoveDownButton.Hint:=lisPathEditMovePathDown;
ReplaceButton.Caption:=lisMenuReplace;
AddButton.Caption:=lisAdd;
DeleteButton.Caption:=dlgEdDelete;
DeleteInvalidPathsButton.Caption:=lisPathEditDeleteInvalidPaths;
TemplateGroupBox.Caption:=lisPathEditPathTemplates;
AddTemplateButton.Caption:=lisCodeTemplAdd;
AddTemplateButton.LoadGlyphFromLazarusResource('laz_add');
MoveUpButton.LoadGlyphFromLazarusResource('arrow_up');
MoveDownButton.LoadGlyphFromLazarusResource('arrow_down');
ReplaceButton.LoadGlyphFromLazarusResource('menu_reportingbug');
AddButton.LoadGlyphFromLazarusResource('laz_add');
DeleteButton.LoadGlyphFromLazarusResource('laz_delete');
DeleteInvalidPathsButton.LoadGlyphFromLazarusResource('menu_clean');
AddTemplateButton.LoadGlyphFromLazarusResource('laz_add');
PathEdit.Font.BeginUpdate;
PathEdit.Font.Pitch := SynDefaultFontPitch;
EditorOpts.ApplyFontSettingsTo(PathEdit);
PathEdit.Font.EndUpdate;
PathEdit.ExtraCharSpacing := EditorOpts.ExtraCharSpacing;
PathEdit.ExtraLineSpacing := EditorOpts.ExtraLineSpacing;
PathListBox.ItemIndex:=-1;
TemplatesListBox.ItemIndex:=-1;
end;
procedure TPathEditorDialog.FormResize(Sender: TObject);
var PathGroupBoxHeight: integer;
var
PathGroupBoxHeight: integer;
begin
PathGroupBoxHeight:=((ClientHeight-70)*2) div 3;
if PathGroupBoxHeight<10 then PathGroupBoxHeight:=10;
if PathGroupBoxHeight<10 then
PathGroupBoxHeight:=10;
PathGroupBox.Height:=PathGroupBoxHeight;
SelectCurrentPath;
UpdateButtons;
end;
procedure TPathEditorDialog.MoveDownButtonClick(Sender: TObject);
var y: integer;
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;
y:=PathListBox.ItemIndex;
if (y>-1) and (y<PathListBox.Count-1) then begin
PathListBox.Items.Move(y,y+1);
PathListBox.ItemIndex:=y+1;
UpdateButtons;
end;
end;
procedure TPathEditorDialog.MoveUpButtonClick(Sender: TObject);
var y: integer;
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;
y:=PathListBox.ItemIndex;
if (y>0) and (y<PathListBox.Count) then begin
PathListBox.Items.Move(y,y-1);
PathListBox.ItemIndex:=y-1;
UpdateButtons;
end;
end;
procedure TPathEditorDialog.PathListBoxKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (ssCtrl in shift ) and ((Key = VK_UP) or (Key = VK_DOWN)) then begin
if Key = VK_UP then
MoveUpButtonClick(Nil)
else
MoveDownButtonClick(Nil);
Key:=VK_UNKNOWN;
end;
end;
procedure TPathEditorDialog.PathListBoxSelectionChange(Sender: TObject; User: boolean);
begin
if PathListBox.ItemIndex>-1 then begin
DirectoryEdit.Text:=AbsolutePathHelper;
UpdateButtons;
end;
end;
procedure TPathEditorDialog.TemplatesListBoxSelectionChange(Sender: TObject; User: boolean);
begin
UpdateButtons;
end;
procedure TPathEditorDialog.TemplatesListBoxDblClick(Sender: TObject);
var i: integer;
var
i: integer;
begin
i := TemplatesListBox.ItemIndex;
if i>=0 then begin
PathEdit.Lines.Add(TemplatesListBox.Items[i]);
PathEdit.CaretY:=PathEdit.Lines.Count;
SelectCurrentPath;
PathListBox.Items.Add(TemplatesListBox.Items[i]);
PathListBox.ItemIndex:=PathListBox.Count-1;
UpdateButtons;
end;
end;
function TPathEditorDialog.GetPath: string;
begin
Result:=TextToPath(PathEdit.Text);
Result:=TextToPath(PathListBox.Items.Text);
end;
function TPathEditorDialog.GetTemplates: string;
@ -233,38 +306,18 @@ end;
procedure TPathEditorDialog.SetPath(const AValue: string);
begin
PathEdit.Text:=PathToText(AValue);
PathListBox.Items.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;
TemplateGroupBox.Visible:=TemplatesListBox.Items.Count>0;
TemplatesListBox.Items.Text:=PathToText(AValue);
TemplateGroupBox.Visible:=TemplatesListBox.Count>0;
end;
function TPathEditorDialog.TextToPath(const AText: string): string;
var i, j: integer;
var
i, j: integer;
PathAsText: string;
begin
PathAsText:=AText;
@ -309,22 +362,33 @@ begin
end;
function TPathEditorDialog.PathToText(const APath: string): string;
var i: integer;
var
i: integer;
NewPath: string;
begin
NewPath:=APath;
for i:=1 to length(NewPath) do
if NewPath[i]=';' then NewPath[i]:=#13;
if NewPath[i]=';' then
NewPath[i]:=#13;
Result:=NewPath;
end;
procedure TPathEditorDialog.SelectCurrentPath;
var y: integer;
procedure TPathEditorDialog.UpdateButtons;
var
i: 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);
// Replace / add / delete / Delete Invalid Paths
ReplaceButton.Enabled:=(DirectoryEdit.Text<>'') and (DirectoryEdit.Text<>FEffectiveBaseDirectory)
and (PathListBox.Items.IndexOf(RelativePathHelper)=-1);
AddButton.Enabled:=ReplaceButton.Enabled;
DeleteButton.Enabled:=PathListBox.ItemIndex>-1;
DeleteInvalidPathsButton.Enabled:=False;
AddTemplateButton.Enabled:=(TemplatesListBox.SelCount>1) or ((TemplatesListBox.ItemIndex>-1)
and (PathListBox.Items.IndexOf(TemplatesListBox.Items[TemplatesListBox.ItemIndex])=-1));
// Move up / down buttons
i := PathListBox.ItemIndex;
MoveUpButton.Enabled := i > 0;
MoveDownButton.Enabled := (i > -1) and (i < PathListBox.Count-1);
end;
procedure TPathEditorDialog.SetBaseDirectory(const AValue: string);
@ -333,7 +397,7 @@ begin
FBaseDirectory:=AValue;
FEffectiveBaseDirectory:=FBaseDirectory;
IDEMacros.SubstituteMacros(FEffectiveBaseDirectory);
BrowseDialog.InitialDir:=FEffectiveBaseDirectory;
DirectoryEdit.Directory:=FEffectiveBaseDirectory;
end;
{ TPathEditorButton }