mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-04 22:37:26 +01:00
extern help: added button to select from editor files
git-svn-id: trunk@24891 -
This commit is contained in:
parent
638f1c3e07
commit
785ebd8f90
@ -1,8 +1,8 @@
|
||||
inherited ExternHelpGeneralOptsFrame: TExternHelpGeneralOptsFrame
|
||||
Height = 384
|
||||
Width = 551
|
||||
Width = 581
|
||||
ClientHeight = 384
|
||||
ClientWidth = 551
|
||||
ClientWidth = 581
|
||||
TabOrder = 0
|
||||
DesignLeft = 358
|
||||
DesignTop = 166
|
||||
@ -83,7 +83,7 @@ inherited ExternHelpGeneralOptsFrame: TExternHelpGeneralOptsFrame
|
||||
Left = 235
|
||||
Height = 27
|
||||
Top = 38
|
||||
Width = 310
|
||||
Width = 340
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Right = 6
|
||||
OnChange = NameEditChange
|
||||
@ -112,7 +112,7 @@ inherited ExternHelpGeneralOptsFrame: TExternHelpGeneralOptsFrame
|
||||
Left = 235
|
||||
Height = 27
|
||||
Top = 98
|
||||
Width = 316
|
||||
Width = 346
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
OnChange = FilenameEditChange
|
||||
OnEditingDone = FilenameEditEditingDone
|
||||
@ -136,7 +136,7 @@ inherited ExternHelpGeneralOptsFrame: TExternHelpGeneralOptsFrame
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 462
|
||||
Left = 492
|
||||
Height = 29
|
||||
Top = 349
|
||||
Width = 83
|
||||
@ -224,7 +224,7 @@ inherited ExternHelpGeneralOptsFrame: TExternHelpGeneralOptsFrame
|
||||
Left = 235
|
||||
Height = 63
|
||||
Top = 209
|
||||
Width = 316
|
||||
Width = 346
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
Lines.Strings = (
|
||||
'URLMemo'
|
||||
@ -244,4 +244,18 @@ inherited ExternHelpGeneralOptsFrame: TExternHelpGeneralOptsFrame
|
||||
OnEditingDone = WithSubDirsCheckBoxEditingDone
|
||||
TabOrder = 9
|
||||
end
|
||||
object SelEditorFileButton: TButton[16]
|
||||
AnchorSideLeft.Control = FileMacrofyButton
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = FileMacrofyButton
|
||||
Left = 430
|
||||
Height = 29
|
||||
Top = 125
|
||||
Width = 132
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 6
|
||||
Caption = 'SelEditorFileButton'
|
||||
OnClick = SelEditorFileButtonClick
|
||||
TabOrder = 10
|
||||
end
|
||||
end
|
||||
|
||||
@ -36,9 +36,9 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLProc, FileUtil, LResources, Forms, Controls, Graphics,
|
||||
Dialogs, LazConfigStorage, ComCtrls, Buttons, StdCtrls, ExtCtrls, LazHelpIntf,
|
||||
PackageIntf, MacroIntf, IDEOptionsIntf, LazIDEIntf, BaseIDEIntf, IDEDialogs,
|
||||
HelpIntfs, IDEImagesIntf;
|
||||
Dialogs, LazConfigStorage, ComCtrls, Buttons, StdCtrls, ExtCtrls, ButtonPanel,
|
||||
LazHelpIntf, PackageIntf, MacroIntf, IDEOptionsIntf, LazIDEIntf, BaseIDEIntf,
|
||||
IDEDialogs, HelpIntfs, IDEImagesIntf, SrcEditorIntf;
|
||||
|
||||
const
|
||||
ExternHelpConfigVersion = 1;
|
||||
@ -56,13 +56,16 @@ resourcestring
|
||||
ehrsDeleteItem = 'Delete item';
|
||||
ehrsBrowseForPath = 'Browse for path';
|
||||
ehrsGeneral = 'General';
|
||||
ehrsBrowse = 'Browse';
|
||||
ehrsBrowse = 'Browse ...';
|
||||
ehrsMacrofy = 'Macrofy';
|
||||
ehrsReplaceCommonDirectoriesWithMacros = 'Replace common directories with '
|
||||
+'macros';
|
||||
ehrsEditorFile = 'Editor file ...';
|
||||
ehrsStoreThisURLIn = 'Store this URL in';
|
||||
ehrsIncludeSubDirectories = 'Include sub directories';
|
||||
ehrsSelectAFileFromTheSourceEditor = 'Select a file from the source editor';
|
||||
ehrsChooseAPascalUnit = 'Choose a pascal unit';
|
||||
ehrsSelectFile = 'Select file';
|
||||
ehrsDirectoryNotFound = 'Directory not found: %s';
|
||||
ehrsFileNotFound = 'File not found: %s';
|
||||
ehrsWarning = 'Warning';
|
||||
@ -71,6 +74,17 @@ resourcestring
|
||||
|
||||
type
|
||||
|
||||
{ TExternHelpFileSelector }
|
||||
|
||||
TExternHelpFileSelector = class(TForm)
|
||||
published
|
||||
FileListBox: TListBox;
|
||||
ButtonPanel1: TButtonPanel;
|
||||
procedure ButtonPanel1OKButtonClick(Sender: TObject);
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
end;
|
||||
|
||||
{ TExternHelpItem }
|
||||
|
||||
TExternHelpItem = class
|
||||
@ -184,6 +198,7 @@ type
|
||||
|
||||
TExternHelpGeneralOptsFrame = class(TAbstractIDEOptionsEditor)
|
||||
AddSpeedButton: TSpeedButton;
|
||||
SelEditorFileButton: TButton;
|
||||
WithSubDirsCheckBox: TCheckBox;
|
||||
FileMacrofyButton: TButton;
|
||||
DeleteSpeedButton: TSpeedButton;
|
||||
@ -219,6 +234,7 @@ type
|
||||
var DragObject: TDragObject);
|
||||
procedure NameEditChange(Sender: TObject);
|
||||
procedure NameEditEditingDone(Sender: TObject);
|
||||
procedure SelEditorFileButtonClick(Sender: TObject);
|
||||
procedure StoreComboBoxEditingDone(Sender: TObject);
|
||||
procedure URLMemoEditingDone(Sender: TObject);
|
||||
procedure WithSubDirsCheckBoxEditingDone(Sender: TObject);
|
||||
@ -846,6 +862,74 @@ begin
|
||||
NameChanged(ItemsTreeView.Selected,S,true,true);
|
||||
end;
|
||||
|
||||
procedure TExternHelpGeneralOptsFrame.SelEditorFileButtonClick(Sender: TObject);
|
||||
var
|
||||
Selector: TExternHelpFileSelector;
|
||||
i: Integer;
|
||||
Filename: String;
|
||||
Files: TStringList;
|
||||
j: Integer;
|
||||
Filename2: String;
|
||||
SelTVNode: TTreeNode;
|
||||
Item: TExternHelpItem;
|
||||
begin
|
||||
if SourceEditorManagerIntf=nil then exit;
|
||||
Files:=TStringList.Create;
|
||||
Selector:=TExternHelpFileSelector.Create(GetParentForm(Self));
|
||||
try
|
||||
// collect open editor files
|
||||
for i:=0 to SourceEditorManagerIntf.SourceEditorCount-1 do begin
|
||||
Filename:=SourceEditorManagerIntf.SourceEditors[i].FileName;
|
||||
j:=Files.Count-1;
|
||||
while (j>=0) and (CompareFilenames(Files[j],Filename)<>0) do dec(j);
|
||||
if j>=0 then continue;
|
||||
Files.Add(Filename);
|
||||
end;
|
||||
// shorten file names
|
||||
for i:=0 to Files.Count-1 do begin
|
||||
Filename:=ExtractFileName(Files[i]);
|
||||
j:=Files.Count-1;
|
||||
while (j>=0)
|
||||
and ((i=j) or (CompareFilenames(ExtractFileName(Files[j]),Filename)<>0)) do
|
||||
dec(j);
|
||||
if (j<0) then begin
|
||||
// short file is unique => use short file
|
||||
Files[i]:=Filename;
|
||||
end;
|
||||
end;
|
||||
Selector.FileListBox.Items:=Files;
|
||||
Selector.Position:=poOwnerFormCenter;
|
||||
Selector.Caption:=ehrsSelectFile;
|
||||
if Files.Count>0 then
|
||||
Selector.FileListBox.ItemIndex:=0;
|
||||
if (Selector.ShowModal=mrOK) then begin
|
||||
i:=Selector.FileListBox.ItemIndex;
|
||||
if i>=0 then begin
|
||||
Filename2:=Selector.FileListBox.Items[i];
|
||||
for i:=0 to SourceEditorManagerIntf.SourceEditorCount-1 do begin
|
||||
Filename:=SourceEditorManagerIntf.SourceEditors[i].FileName;
|
||||
if (CompareFilenames(Filename2,Filename)=0)
|
||||
or (CompareFilenames(Filename2,ExtractFileName(Filename))=0) then
|
||||
begin
|
||||
Filename:=Macrofy(FileName);
|
||||
FilenameEdit.Text:=Filename;
|
||||
SelTVNode:=ItemsTreeView.Selected;
|
||||
if (SelTVNode<>nil) and (TObject(SelTVNode.Data) is TExternHelpItem)
|
||||
then begin
|
||||
Item:=TExternHelpItem(SelTVNode.Data);
|
||||
Item.Filename:=Filename;
|
||||
end;
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
Selector.Free;
|
||||
Files.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TExternHelpGeneralOptsFrame.StoreComboBoxEditingDone(Sender: TObject);
|
||||
var
|
||||
S: String;
|
||||
@ -1087,6 +1171,8 @@ begin
|
||||
FileBrowseButton.Hint:=ehrsBrowseForPath;
|
||||
FileMacrofyButton.Caption:=ehrsMacrofy;
|
||||
FileMacrofyButton.Hint:=ehrsReplaceCommonDirectoriesWithMacros;
|
||||
SelEditorFileButton.Caption:=ehrsEditorFile;
|
||||
SelEditorFileButton.Hint:=ehrsSelectAFileFromTheSourceEditor;
|
||||
WithSubDirsCheckBox.Caption:=ehrsIncludeSubDirectories;
|
||||
StoreLabel.Caption:=ehrsStoreThisURLIn;
|
||||
FMySettingsCaption:=ehrsMySettings;
|
||||
@ -1396,6 +1482,35 @@ begin
|
||||
Result:=inherited ShowHelp(Query, BaseNode, NewNode, QueryItem, ErrMsg);
|
||||
end;
|
||||
|
||||
{ TExternHelpFileSelector }
|
||||
|
||||
procedure TExternHelpFileSelector.ButtonPanel1OKButtonClick(Sender: TObject);
|
||||
begin
|
||||
ModalResult:=mrOk;
|
||||
end;
|
||||
|
||||
constructor TExternHelpFileSelector.Create(TheOwner: TComponent);
|
||||
begin
|
||||
inherited Create(TheOwner);
|
||||
|
||||
FileListBox:=TListBox.Create(Self);
|
||||
with FileListBox do begin
|
||||
Name:='FileListBox';
|
||||
Align:=alClient;
|
||||
Parent:=Self;
|
||||
end;
|
||||
|
||||
ButtonPanel1:=TButtonPanel.Create(Self);
|
||||
with ButtonPanel1 do begin
|
||||
Name:='ButtonPanel1';
|
||||
Align:=alBottom;
|
||||
ShowButtons:=[pbOK,pbCancel];
|
||||
OKButton.OnClick:=@ButtonPanel1OKButtonClick;
|
||||
OKButton.ModalResult:=mrNone;
|
||||
Parent:=Self;
|
||||
end;
|
||||
end;
|
||||
|
||||
finalization
|
||||
FreeAndNil(ExternHelpOptions);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user