mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-06 20:00:17 +02:00
MG: started find/replace history
git-svn-id: trunk@519 -
This commit is contained in:
parent
040a6ad2a6
commit
daad2096a2
@ -101,6 +101,7 @@ const
|
||||
ctnFileType = 81;
|
||||
ctnPointerType = 82;
|
||||
ctnClassOfType = 83;
|
||||
|
||||
|
||||
|
||||
// combined values
|
||||
@ -123,6 +124,7 @@ type
|
||||
SubDesc: TCodeTreeNodeSubDesc;
|
||||
Parent, NextBrother, PriorBrother, FirstChild, LastChild: TCodeTreeNode;
|
||||
StartPos, EndPos: integer;
|
||||
Cache: TObject;
|
||||
function Next: TCodeTreeNode;
|
||||
function Prior: TCodeTreeNode;
|
||||
procedure Clear;
|
||||
@ -307,6 +309,8 @@ begin
|
||||
LastChild:=nil;
|
||||
StartPos:=-1;
|
||||
EndPos:=-1;
|
||||
Cache.Free;
|
||||
Cache:=nil;
|
||||
end;
|
||||
|
||||
function TCodeTreeNode.Next: TCodeTreeNode;
|
||||
|
@ -46,6 +46,7 @@ uses
|
||||
type
|
||||
TFindDeclarationTool = class(TPascalParserTool)
|
||||
public
|
||||
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
@ -26,7 +26,7 @@ interface
|
||||
uses
|
||||
LCLLinux,
|
||||
Forms, Classes, SysUtils, ComCtrls, Buttons, StdCtrls, ExtCtrls, LazConf,
|
||||
FileCtrl, Graphics, Controls, Dialogs, LResources,
|
||||
FileCtrl, Graphics, Controls, Dialogs, LResources, IDEProcs,
|
||||
{$ifdef NEW_EDITOR_SYNEDIT}
|
||||
SynEdit, SynEditHighlighter, SynEditAutoComplete, SynEditKeyCmds,
|
||||
SynHighlighterPas, SynHighlighterHTML, SynHighlighterCPP, SynHighlighterXML,
|
||||
@ -150,19 +150,24 @@ type
|
||||
// Color options
|
||||
fHighlighterList: TEditOptLangList;
|
||||
|
||||
// Code tools options
|
||||
// Code tools options (MG: these will move to an unit of their own)
|
||||
fAutoCodeCompletion:boolean;
|
||||
fAutoCodeParameters:boolean;
|
||||
fAutoToolTipExprEval:boolean;
|
||||
fAutoToolTipSymbTools:boolean;
|
||||
fAutoDelayInMSec:integer;
|
||||
fCodeTemplateFileName:Ansistring;
|
||||
private
|
||||
|
||||
// Find- and replace-history
|
||||
FFindHistory: TStringList;
|
||||
FReplaceHistory: TStringList;
|
||||
FMaxFindHistory: Integer;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure Load;
|
||||
procedure Save;
|
||||
|
||||
procedure GetHighlighterSettings(Syn: TCustomSyn);// read highlight settings from config file
|
||||
procedure SetHighlighterSettings(Syn: TCustomSyn);// write highlight settings to config file
|
||||
procedure GetSynEditSettings(ASynEdit:TSynEdit); // read synedit settings from config file
|
||||
@ -183,6 +188,9 @@ type
|
||||
procedure WriteHighlighterSettings(Syn: TCustomSyn; SynColorScheme: string);
|
||||
procedure GetSpecialLineColors(Syn: TCustomSyn;
|
||||
AddHilightAttr: TAdditionalHilightAttribute; var FG, BG: TColor);
|
||||
|
||||
procedure AddToFindHistory(const AFindStr: string);
|
||||
procedure AddToReplaceHistory(const AReplaceStr: String);
|
||||
|
||||
published
|
||||
// general options
|
||||
@ -240,6 +248,11 @@ type
|
||||
read fAutoDelayInMSec write fAutoDelayInMSec default 1000;
|
||||
property CodeTemplateFileName:Ansistring
|
||||
read fCodeTemplateFileName write fCodeTemplateFileName;
|
||||
|
||||
// Find- and replace-history
|
||||
property FindHistory: TStringList read FFindHistory write FFindHistory;
|
||||
property ReplaceHistory: TStringList read FReplaceHistory write FReplaceHistory;
|
||||
property MaxFindHistory: Integer read FMaxFindHistory write FMaxFindHistory;
|
||||
end;
|
||||
|
||||
{ color button }
|
||||
@ -975,10 +988,17 @@ begin
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
// Find- and replace-history
|
||||
FFindHistory:=TStringList.Create;
|
||||
FReplaceHistory:=TStringList.Create;
|
||||
FMaxFindHistory:=20;
|
||||
end;
|
||||
|
||||
destructor TEditorOptions.Destroy;
|
||||
begin
|
||||
FFindHistory.Free;
|
||||
FReplaceHistory.Free;
|
||||
fHighlighterList.Free;
|
||||
fKeyMap.Free;
|
||||
XMLConfig.Free;
|
||||
@ -1091,6 +1111,14 @@ begin
|
||||
fCodeTemplateFileName:=
|
||||
XMLConfig.GetValue('EditorOptions/CodeTools/CodeTemplateFileName'
|
||||
,SetDirSeparators(GetPrimaryConfigPath+'/lazarus.dci'));
|
||||
|
||||
// Find- and replace-history
|
||||
fMaxFindHistory:=XMLConfig.GetValue(
|
||||
'EditorOptions/Find/History/Max',FMaxFindHistory);
|
||||
LoadRecentList(XMLConfig,FFindHistory,'EditorOptions/Find/History/Find/');
|
||||
LoadRecentList(XMLConfig,FReplaceHistory,
|
||||
'EditorOptions/Find/History/Replace/');
|
||||
|
||||
except
|
||||
on E: Exception do
|
||||
writeln('[TEditorOptions.Load] ERROR: ',e.Message);
|
||||
@ -1191,6 +1219,13 @@ begin
|
||||
XMLConfig.SetValue('EditorOptions/CodeTools/CodeTemplateFileName'
|
||||
,fCodeTemplateFileName);
|
||||
|
||||
// Find- and replace-history
|
||||
XMLConfig.SetValue('EditorOptions/Find/History/Max',FMaxFindHistory);
|
||||
SaveRecentList(XMLConfig,FFindHistory,'EditorOptions/Find/History/Find/');
|
||||
SaveRecentList(XMLConfig,FReplaceHistory,
|
||||
'EditorOptions/Find/History/Replace/');
|
||||
|
||||
|
||||
XMLConfig.Flush;
|
||||
except
|
||||
on E: Exception do
|
||||
@ -1676,6 +1711,17 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TEditorOptions.AddToFindHistory(const AFindStr: string);
|
||||
begin
|
||||
AddToRecentList(AFindStr,FFindHistory,FMaxFindHistory);
|
||||
end;
|
||||
|
||||
procedure TEditorOptions.AddToReplaceHistory(const AReplaceStr: String);
|
||||
begin
|
||||
AddToRecentList(AReplaceStr,FReplaceHistory,FMaxFindHistory);
|
||||
end;
|
||||
|
||||
|
||||
{ TColorButton }
|
||||
|
||||
constructor TColorButton.Create(AnOwner: TComponent);
|
||||
|
@ -120,8 +120,6 @@ type
|
||||
fPascalFileExtension: TPascalExtType;
|
||||
|
||||
procedure SetFileName(const NewFilename: string);
|
||||
procedure AddToRecentList(const AFilename: string; RecentList: TStringList;
|
||||
Max: integer);
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
@ -457,14 +455,6 @@ procedure TEnvironmentOptions.Load(OnlyDesktop:boolean);
|
||||
var XMLConfig: TXMLConfig;
|
||||
FileVersion: integer;
|
||||
|
||||
procedure LoadRect(AKey:string; var ARect:TRect);
|
||||
begin
|
||||
ARect.Left:=XMLConfig.GetValue(AKey+'/Left',ARect.Left);
|
||||
ARect.Top:=XMLConfig.GetValue(AKey+'/Top',ARect.Top);
|
||||
ARect.Right:=XMLConfig.GetValue(AKey+'/Right',ARect.Right);
|
||||
ARect.Bottom:=XMLConfig.GetValue(AKey+'/Bottom',ARect.Bottom);
|
||||
end;
|
||||
|
||||
procedure LoadBackupInfo(var BackupInfo: TBackupInfo; const Path:string);
|
||||
var i:integer;
|
||||
begin
|
||||
@ -488,18 +478,6 @@ var XMLConfig: TXMLConfig;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure LoadRecentList(List: TStringList; const Path: string);
|
||||
var i,Count: integer;
|
||||
s: string;
|
||||
begin
|
||||
Count:=XMLConfig.GetValue(Path+'Count',0);
|
||||
List.Clear;
|
||||
for i:=1 to Count do begin
|
||||
s:=XMLConfig.GetValue(Path+'Item'+IntToStr(i)+'/Value','');
|
||||
if s<>'' then List.Add(s);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure LoadDebuggerType(var ADebuggerType: TDebuggerType;
|
||||
const Path: string);
|
||||
var i:integer;
|
||||
@ -544,15 +522,16 @@ begin
|
||||
FWindowPositionsValid:=XMLConfig.GetValue(
|
||||
'EnvironmentOptions/Desktop/WindowPositionsValid',false);
|
||||
if FWindowPositionsValid then begin
|
||||
LoadRect('EnvironmentOptions/Desktop/MainWindowBounds',FMainWindowBounds);
|
||||
LoadRect('EnvironmentOptions/Desktop/SourceEditorBounds'
|
||||
LoadRect(XMLConfig,'EnvironmentOptions/Desktop/MainWindowBounds/',
|
||||
FMainWindowBounds);
|
||||
LoadRect(XMLConfig,'EnvironmentOptions/Desktop/SourceEditorBounds/'
|
||||
,FSourceEditorBounds);
|
||||
end;
|
||||
if FileVersion>=100 then begin
|
||||
FMessagesViewBoundsValid:=XMLConfig.GetValue(
|
||||
'EnvironmentOptions/Desktop/MessagesViewBoundsValid',false);
|
||||
if FMessagesViewBoundsValid then
|
||||
LoadRect('EnvironmentOptions/Desktop/MessagesViewBounds'
|
||||
LoadRect(XMLConfig,'EnvironmentOptions/Desktop/MessagesViewBounds/'
|
||||
,FMessagesViewBounds);
|
||||
end;
|
||||
|
||||
@ -595,11 +574,13 @@ begin
|
||||
|
||||
// recent files and directories
|
||||
FMaxRecentOpenFiles:=XMLConfig.GetValue(
|
||||
'EnvironmentOptions/Recent/OpenFiles/Max',FMaxRecentOpenFiles);
|
||||
LoadRecentList(FRecentOpenFiles,'EnvironmentOptions/Recent/OpenFiles/');
|
||||
'EnvironmentOptions/Recent/OpenFiles/Max',FMaxRecentOpenFiles);
|
||||
LoadRecentList(XMLConfig,FRecentOpenFiles,
|
||||
'EnvironmentOptions/Recent/OpenFiles/');
|
||||
FMaxRecentProjectFiles:=XMLConfig.GetValue(
|
||||
'EnvironmentOptions/Recent/ProjectFiles/Max',FMaxRecentProjectFiles);
|
||||
LoadRecentList(FRecentProjectFiles,'EnvironmentOptions/Recent/ProjectFiles/');
|
||||
'EnvironmentOptions/Recent/ProjectFiles/Max',FMaxRecentProjectFiles);
|
||||
LoadRecentList(XMLConfig,FRecentProjectFiles,
|
||||
'EnvironmentOptions/Recent/ProjectFiles/');
|
||||
FLastOpenDialogDir:=XMLConfig.GetValue(
|
||||
'EnvironmentOptions/Recent/LastOpenDialogDir/Value',FLastOpenDialogDir);
|
||||
|
||||
@ -623,14 +604,6 @@ end;
|
||||
procedure TEnvironmentOptions.Save(OnlyDesktop: boolean);
|
||||
var XMLConfig: TXMLConfig;
|
||||
|
||||
procedure SaveRect(AKey:string; var ARect:TRect);
|
||||
begin
|
||||
XMLConfig.SetValue(AKey+'/Left',ARect.Left);
|
||||
XMLConfig.SetValue(AKey+'/Top',ARect.Top);
|
||||
XMLConfig.SetValue(AKey+'/Right',ARect.Right);
|
||||
XMLConfig.SetValue(AKey+'/Bottom',ARect.Bottom);
|
||||
end;
|
||||
|
||||
procedure SaveBackupInfo(var BackupInfo: TBackupInfo; Path:string);
|
||||
var i:integer;
|
||||
begin
|
||||
@ -651,14 +624,6 @@ var XMLConfig: TXMLConfig;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure SaveRecentList(List: TStringList; Path: string);
|
||||
var i: integer;
|
||||
begin
|
||||
XMLConfig.SetValue(Path+'Count',List.Count);
|
||||
for i:=0 to List.Count-1 do
|
||||
XMLConfig.SetValue(Path+'Item'+IntToStr(i+1)+'/Value',List[i]);
|
||||
end;
|
||||
|
||||
procedure SaveDebuggerType(ADebuggerType: TDebuggerType; Path:string);
|
||||
var i:integer;
|
||||
begin
|
||||
@ -693,14 +658,15 @@ begin
|
||||
XMLConfig.SetValue('EnvironmentOptions/Desktop/WindowPositionsValid'
|
||||
,FWindowPositionsValid);
|
||||
if FWindowPositionsValid then begin
|
||||
SaveRect('EnvironmentOptions/Desktop/MainWindowBounds',FMainWindowBounds);
|
||||
SaveRect('EnvironmentOptions/Desktop/SourceEditorBounds'
|
||||
SaveRect(XMLConfig,'EnvironmentOptions/Desktop/MainWindowBounds/',
|
||||
FMainWindowBounds);
|
||||
SaveRect(XMLConfig,'EnvironmentOptions/Desktop/SourceEditorBounds/'
|
||||
,FSourceEditorBounds);
|
||||
end;
|
||||
XMLConfig.SetValue('EnvironmentOptions/Desktop/MessagesViewBoundsValid'
|
||||
,FMessagesViewBoundsValid);
|
||||
if FMessagesViewBoundsValid then
|
||||
SaveRect('EnvironmentOptions/Desktop/MessagesViewBounds'
|
||||
SaveRect(XMLConfig,'EnvironmentOptions/Desktop/MessagesViewBounds/'
|
||||
,FMessagesViewBounds);
|
||||
|
||||
// form editor
|
||||
@ -738,11 +704,13 @@ begin
|
||||
|
||||
// recent files and directories
|
||||
XMLConfig.SetValue(
|
||||
'EnvironmentOptions/Recent/OpenFiles/Max',FMaxRecentOpenFiles);
|
||||
SaveRecentList(FRecentOpenFiles,'EnvironmentOptions/Recent/OpenFiles/');
|
||||
'EnvironmentOptions/Recent/OpenFiles/Max',FMaxRecentOpenFiles);
|
||||
SaveRecentList(XMLConfig,FRecentOpenFiles,
|
||||
'EnvironmentOptions/Recent/OpenFiles/');
|
||||
XMLConfig.SetValue(
|
||||
'EnvironmentOptions/Recent/ProjectFiles/Max',FMaxRecentProjectFiles);
|
||||
SaveRecentList(FRecentProjectFiles,'EnvironmentOptions/Recent/ProjectFiles/');
|
||||
'EnvironmentOptions/Recent/ProjectFiles/Max',FMaxRecentProjectFiles);
|
||||
SaveRecentList(XMLConfig,FRecentProjectFiles,
|
||||
'EnvironmentOptions/Recent/ProjectFiles/');
|
||||
XMLConfig.SetValue('EnvironmentOptions/Recent/LastOpenDialogDir/Value'
|
||||
,FLastOpenDialogDir);
|
||||
|
||||
@ -768,21 +736,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TEnvironmentOptions.AddToRecentList(const AFilename: string;
|
||||
RecentList: TStringList; Max: integer);
|
||||
var i: integer;
|
||||
begin
|
||||
i:=RecentList.Count-1;
|
||||
while i>=0 do begin
|
||||
if RecentList[i]=AFilename then RecentList.Delete(i);
|
||||
dec(i);
|
||||
end;
|
||||
RecentList.Insert(0,AFilename);
|
||||
if Max>0 then
|
||||
while RecentList.Count>Max do
|
||||
RecentList.Delete(RecentList.Count-1);
|
||||
end;
|
||||
|
||||
procedure TEnvironmentOptions.AddToRecentOpenFiles(const AFilename: string);
|
||||
begin
|
||||
AddToRecentList(AFilename,FRecentOpenFiles,FMaxRecentOpenFiles);
|
||||
|
@ -20,11 +20,13 @@ unit FindReplaceDialog;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
{$Define DeleteMeWhenComboBoxFocusIsFixed}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLLinux, Controls, StdCtrls, Forms, Buttons, ExtCtrls,
|
||||
LResources, SynEdit;
|
||||
LResources, SynEdit, IDEProcs;
|
||||
|
||||
type
|
||||
TLazFindReplaceDialog = class(TFORM)
|
||||
@ -36,11 +38,17 @@ type
|
||||
procedure SetFindText(NewFindText:AnsiString);
|
||||
function GetReplaceText:AnsiString;
|
||||
procedure SetReplaceText(NewReplaceText:AnsiString);
|
||||
procedure SetComboBoxText(AComboBox:TComboBox;const AText:AnsiString);
|
||||
published
|
||||
TextToFindLabel:TLabel;
|
||||
ReplaceWithLabel:TLabel;
|
||||
TextToFindEdit:TEdit;
|
||||
ReplaceTextEdit:TEdit;
|
||||
{$IFDEF DeleteMeWhenComboBoxFocusIsFixed}
|
||||
TextToFindComboBox:TEdit;
|
||||
ReplaceTextComboBox:TEdit;
|
||||
{$ELSE}
|
||||
TextToFindComboBox:TComboBox;
|
||||
ReplaceTextComboBox:TComboBox;
|
||||
{$ENDIF}
|
||||
OptionsGroupBox:TGroupBox;
|
||||
CaseSensitiveCheckBox:TCheckBox;
|
||||
WholeWordsOnlyCheckBox:TCheckBox;
|
||||
@ -52,7 +60,7 @@ type
|
||||
OkButton:TButton;
|
||||
ReplaceAllButton:TButton;
|
||||
CancelButton:TButton;
|
||||
procedure TextToFindEditKeyDown(Sender: TObject; var Key:Word;
|
||||
procedure TextToFindComboboxKeyDown(Sender: TObject; var Key:Word;
|
||||
Shift:TShiftState);
|
||||
procedure OkButtonClick(Sender:TObject);
|
||||
procedure ReplaceAllButtonClick(Sender:TObject);
|
||||
@ -80,6 +88,23 @@ begin
|
||||
Width:=317;
|
||||
Height:=285;
|
||||
|
||||
{$IFDEF DeleteMeWhenComboBoxFocusIsFixed}
|
||||
TextToFindComboBox:=TEdit.Create(Self);
|
||||
{$ELSE}
|
||||
TextToFindComboBox:=TComboBox.Create(Self);
|
||||
{$ENDIF}
|
||||
with TextToFindComboBox do begin
|
||||
Name:='TextToFindComboBox';
|
||||
Parent:=Self;
|
||||
Left:=90;
|
||||
Top:=4;
|
||||
Width:=220;
|
||||
Height:=21;
|
||||
Text:='';
|
||||
OnKeyDown:=@TextToFindComboBoxKeyDown;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
TextToFindLabel:=TLabel.Create(Self);
|
||||
with TextToFindLabel do begin
|
||||
Name:='TextToFindLabel';
|
||||
@ -89,9 +114,26 @@ begin
|
||||
Width:=80;
|
||||
Height:=15;
|
||||
Caption:='Text to Find';
|
||||
Show;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
{$IFDEF DeleteMeWhenComboBoxFocusIsFixed}
|
||||
ReplaceTextComboBox:=TEdit.Create(Self);
|
||||
{$ELSE}
|
||||
ReplaceTextComboBox:=TComboBox.Create(Self);
|
||||
{$ENDIF}
|
||||
with ReplaceTextComboBox do begin
|
||||
Name:='ReplaceTextComboBox';
|
||||
Parent:=Self;
|
||||
Left:=90;
|
||||
Top:=28;
|
||||
Width:=220;
|
||||
Height:=21;
|
||||
Text:='';
|
||||
OnKeyDown:=@TextToFindComboBoxKeyDown;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
ReplaceWithLabel:=TLabel.Create(Self);
|
||||
with ReplaceWithLabel do begin
|
||||
Name:='ReplaceWithLabel';
|
||||
@ -101,35 +143,9 @@ begin
|
||||
Width:=80;
|
||||
Height:=15;
|
||||
Caption:='Replace With';
|
||||
Show;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
TextToFindEdit:=TEdit.Create(Self);
|
||||
with TextToFindEdit do begin
|
||||
Name:='TextToFindEdit';
|
||||
Parent:=Self;
|
||||
Left:=90;
|
||||
Top:=4;
|
||||
Width:=220;
|
||||
Height:=21;
|
||||
Text:='';
|
||||
OnKeyDown:=@TextToFindEditKeyDown;
|
||||
Show;
|
||||
end;
|
||||
|
||||
ReplaceTextEdit:=Tedit.Create(Self);
|
||||
with ReplaceTextEdit do begin
|
||||
Name:='ReplaceTextEdit';
|
||||
Parent:=Self;
|
||||
Left:=90;
|
||||
Top:=28;
|
||||
Width:=220;
|
||||
Height:=21;
|
||||
Text:='';
|
||||
OnKeyDown:=@TextToFindeditKeyDown;
|
||||
Show;
|
||||
end;
|
||||
|
||||
OptionsGroupBox:=TGroupBox.Create(Self);
|
||||
with OptionsGroupBox do begin
|
||||
Name:='OptionsGroupBox';
|
||||
@ -139,7 +155,7 @@ begin
|
||||
Width:=150;
|
||||
Height:=105;
|
||||
Caption:='Options';
|
||||
Show;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
CaseSensitiveCheckBox:=TCheckBox.Create(Self);
|
||||
@ -151,7 +167,7 @@ begin
|
||||
Width:=135;
|
||||
Height:=17;
|
||||
Caption:='Case Sensitive';
|
||||
Show;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
WholeWordsOnlyCheckBox:=TCheckBox.Create(Self);
|
||||
@ -163,7 +179,7 @@ begin
|
||||
Width:=135;
|
||||
Height:=17;
|
||||
Caption:='Whole Words Only';
|
||||
Show;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
RegularExpressionsCheckBox:=TCheckBox.Create(Self);
|
||||
@ -175,7 +191,7 @@ begin
|
||||
Width:=135;
|
||||
Height:=17;
|
||||
Caption:='Regular Expressions';
|
||||
Show;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
PromptOnReplaceCheckBox:=TCheckBox.Create(Self);
|
||||
@ -188,7 +204,7 @@ begin
|
||||
Height:=17;
|
||||
Caption:='Prompt On Replace';
|
||||
Checked:=true;
|
||||
Show;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
OriginRadioGroup:=TRadioGroup.Create(Self);
|
||||
@ -208,7 +224,7 @@ begin
|
||||
EndUpdate;
|
||||
end;
|
||||
ItemIndex:=0;
|
||||
Show;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
ScopeRadioGroup:=TRadioGroup.Create(Self);
|
||||
@ -228,7 +244,7 @@ begin
|
||||
EndUpdate;
|
||||
end;
|
||||
ItemIndex:=0;
|
||||
Show;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
DirectionRadioGroup:=TRadioGroup.Create(Self);
|
||||
@ -248,7 +264,7 @@ begin
|
||||
EndUpdate;
|
||||
end;
|
||||
ItemIndex:=1;
|
||||
Show;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
OkButton:=TButton.Create(Self);
|
||||
@ -261,7 +277,7 @@ begin
|
||||
Height:=25;
|
||||
Caption:='Ok';
|
||||
OnClick:=@OkButtonClick;
|
||||
Show;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
ReplaceAllButton:=TButton.Create(Self);
|
||||
@ -274,7 +290,7 @@ begin
|
||||
Height:=25;
|
||||
Caption:='Replace All';
|
||||
OnClick:=@ReplaceAllButtonClick;
|
||||
Show;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
CancelButton:=TButton.Create(Self);
|
||||
@ -287,43 +303,43 @@ begin
|
||||
Height:=25;
|
||||
Caption:='Cancel';
|
||||
OnClick:=@CancelButtonClick;
|
||||
Show;
|
||||
Visible:=true;
|
||||
end;
|
||||
end;
|
||||
fReplaceAllClickedLast:=false;
|
||||
TextToFindedit.SetFocus;
|
||||
TextToFindComboBox.SetFocus;
|
||||
end;
|
||||
|
||||
procedure TLazFindReplaceDialog.TextToFindeditKeyDown(
|
||||
procedure TLazFindReplaceDialog.TextToFindComboBoxKeyDown(
|
||||
Sender: TObject; var Key:Word; Shift:TShiftState);
|
||||
begin
|
||||
if (Key=VK_RETURN) then OkButtonClick(Sender);
|
||||
if (Key=VK_ESCAPE) then CancelButtonClick(Sender);
|
||||
if Key=VK_TAB then begin
|
||||
if Sender=TextToFindEdit then
|
||||
ReplaceTextEdit.SetFocus;
|
||||
if Sender=ReplaceTextEdit then
|
||||
TextToFindEdit.SetFocus;
|
||||
if (Sender=TextToFindComboBox) and (ReplaceTextComboBox.Enabled) then
|
||||
ReplaceTextComboBox.SetFocus;
|
||||
if Sender=ReplaceTextComboBox then
|
||||
TextToFindComboBox.SetFocus;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLazFindReplaceDialog.OkButtonClick(Sender:TObject);
|
||||
begin
|
||||
fReplaceAllClickedLast:=false;
|
||||
TextToFindedit.SetFocus;
|
||||
TextToFindComboBox.SetFocus;
|
||||
ModalResult:=mrOk;
|
||||
end;
|
||||
|
||||
procedure TLazFindReplaceDialog.ReplaceAllButtonClick(Sender:TObject);
|
||||
begin
|
||||
fReplaceAllClickedLast:=true;
|
||||
TextToFindedit.SetFocus;
|
||||
TextToFindComboBox.SetFocus;
|
||||
ModalResult:=mrAll;
|
||||
end;
|
||||
|
||||
procedure TLazFindReplaceDialog.CancelButtonClick(Sender:TObject);
|
||||
begin
|
||||
TextToFindedit.SetFocus;
|
||||
TextToFindComboBox.SetFocus;
|
||||
ModalResult:=mrCancel;
|
||||
end;
|
||||
|
||||
@ -343,7 +359,7 @@ begin
|
||||
then DirectionRadioGroup.ItemIndex:=0
|
||||
else DirectionRadioGroup.ItemIndex:=1;
|
||||
ReplaceAllButton.Enabled:=ssoReplace in NewOptions;
|
||||
ReplaceTextEdit.Enabled:=ReplaceAllButton.Enabled;
|
||||
ReplaceTextComboBox.Enabled:=ReplaceAllButton.Enabled;
|
||||
ReplaceWithLabel.Enabled:=ReplaceAllButton.Enabled;
|
||||
PromptOnReplaceCheckBox.Enabled:=ReplaceAllButton.Enabled;
|
||||
if ssoReplace in NewOptions then begin
|
||||
@ -371,22 +387,43 @@ end;
|
||||
|
||||
function TLazFindReplaceDialog.GetFindText:AnsiString;
|
||||
begin
|
||||
Result:=TextToFindedit.Text;
|
||||
Result:=TextToFindComboBox.Text;
|
||||
end;
|
||||
|
||||
procedure TLazFindReplaceDialog.SetFindText(NewFindText:AnsiString);
|
||||
begin
|
||||
TextToFindedit.Text:=NewFindText;
|
||||
{$IFDEF DeleteMeWhenComboBoxFocusIsFixed}
|
||||
TextToFindComboBox.Text:=NewFindText;
|
||||
{$ELSE}
|
||||
SetComboBoxText(TextToFindComboBox,NewFindText);
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
function TLazFindReplaceDialog.GetReplaceText:AnsiString;
|
||||
begin
|
||||
Result:=ReplaceTextEdit.Text;
|
||||
Result:=ReplaceTextComboBox.Text;
|
||||
end;
|
||||
|
||||
procedure TLazFindReplaceDialog.SetReplaceText(NewReplaceText:AnsiString);
|
||||
begin
|
||||
ReplaceTextEdit.Text:=NewReplaceText;
|
||||
{$IFDEF DeleteMeWhenComboBoxFocusIsFixed}
|
||||
ReplaceTextComboBox.Text:=NewReplaceText;
|
||||
{$ELSE}
|
||||
SetComboBoxText(ReplaceTextComboBox,NewReplaceText);
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TLazFindReplaceDialog.SetComboBoxText(AComboBox:TComboBox;
|
||||
const AText:AnsiString);
|
||||
var a:integer;
|
||||
begin
|
||||
a:=AComboBox.Items.IndexOf(AText);
|
||||
if a>=0 then
|
||||
AComboBox.ItemIndex:=a
|
||||
else begin
|
||||
AComboBox.Items.Add(AText);
|
||||
AComboBox.ItemIndex:=AComboBox.Items.IndexOf(AText);
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -8,12 +8,14 @@ unit IDEProcs;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils;
|
||||
Classes, SysUtils, XMLCfg;
|
||||
|
||||
//
|
||||
const
|
||||
// ToDo: find the constant in the fpc units.
|
||||
EndOfLine:shortstring={$IFDEF win32}#13+{$ENDIF}#10;
|
||||
|
||||
// files
|
||||
function FilenameIsAbsolute(TheFilename: string):boolean;
|
||||
function DirectoryExists(DirectoryName: string): boolean;
|
||||
function ForceDirectory(DirectoryName: string): boolean;
|
||||
@ -22,6 +24,19 @@ procedure CheckIfFileIsExecutable(const AFilename: string);
|
||||
function FileIsExecutable(const AFilename: string): boolean;
|
||||
function CompareFilenames(const Filename1, Filename2: string): integer;
|
||||
|
||||
// XMLConfig
|
||||
procedure LoadRecentList(XMLConfig: TXMLConfig; List: TStringList;
|
||||
const Path: string);
|
||||
procedure SaveRecentList(XMLConfig: TXMLConfig; List: TStringList;
|
||||
const Path: string);
|
||||
procedure LoadRect(XMLConfig: TXMLConfig; const Path:string; var ARect:TRect);
|
||||
procedure SaveRect(XMLConfig: TXMLConfig; const Path:string; var ARect:TRect);
|
||||
|
||||
// various
|
||||
procedure AddToRecentList(const s: string; RecentList: TStringList;
|
||||
Max: integer);
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
// to get more detailed error messages consider the os
|
||||
@ -35,6 +50,59 @@ uses
|
||||
;
|
||||
{$ENDIF}
|
||||
|
||||
procedure AddToRecentList(const s: string; RecentList: TStringList;
|
||||
Max: integer);
|
||||
var i: integer;
|
||||
begin
|
||||
i:=RecentList.Count-1;
|
||||
while i>=0 do begin
|
||||
if RecentList[i]=s then RecentList.Delete(i);
|
||||
dec(i);
|
||||
end;
|
||||
RecentList.Insert(0,s);
|
||||
if Max>0 then
|
||||
while RecentList.Count>Max do
|
||||
RecentList.Delete(RecentList.Count-1);
|
||||
end;
|
||||
|
||||
procedure SaveRecentList(XMLConfig: TXMLConfig; List: TStringList;
|
||||
const Path: string);
|
||||
var i: integer;
|
||||
begin
|
||||
XMLConfig.SetValue(Path+'Count',List.Count);
|
||||
for i:=0 to List.Count-1 do
|
||||
XMLConfig.SetValue(Path+'Item'+IntToStr(i+1)+'/Value',List[i]);
|
||||
end;
|
||||
|
||||
procedure LoadRecentList(XMLConfig: TXMLConfig; List: TStringList;
|
||||
const Path: string);
|
||||
var i,Count: integer;
|
||||
s: string;
|
||||
begin
|
||||
Count:=XMLConfig.GetValue(Path+'Count',0);
|
||||
List.Clear;
|
||||
for i:=1 to Count do begin
|
||||
s:=XMLConfig.GetValue(Path+'Item'+IntToStr(i)+'/Value','');
|
||||
if s<>'' then List.Add(s);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure LoadRect(XMLConfig: TXMLConfig; const Path:string; var ARect:TRect);
|
||||
begin
|
||||
ARect.Left:=XMLConfig.GetValue(Path+'Left',ARect.Left);
|
||||
ARect.Top:=XMLConfig.GetValue(Path+'Top',ARect.Top);
|
||||
ARect.Right:=XMLConfig.GetValue(Path+'Right',ARect.Right);
|
||||
ARect.Bottom:=XMLConfig.GetValue(Path+'Bottom',ARect.Bottom);
|
||||
end;
|
||||
|
||||
procedure SaveRect(XMLConfig: TXMLConfig; const Path:string; var ARect:TRect);
|
||||
begin
|
||||
XMLConfig.SetValue(Path+'Left',ARect.Left);
|
||||
XMLConfig.SetValue(Path+'Top',ARect.Top);
|
||||
XMLConfig.SetValue(Path+'Right',ARect.Right);
|
||||
XMLConfig.SetValue(Path+'Bottom',ARect.Bottom);
|
||||
end;
|
||||
|
||||
function CompareFilenames(const Filename1, Filename2: string): integer;
|
||||
begin
|
||||
{$IFDEF WIN32}
|
||||
|
Loading…
Reference in New Issue
Block a user