mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-24 06:09:15 +02:00
MG: added find previous to source editor
git-svn-id: trunk@355 -
This commit is contained in:
parent
1ecb6200d7
commit
96a5cb3237
@ -14,11 +14,11 @@
|
||||
- mrCancel for Cancel
|
||||
|
||||
ToDo:
|
||||
-regular expression checkbox
|
||||
|
||||
}
|
||||
unit findreplacedialog;
|
||||
|
||||
{$mode objfpc}
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
@ -52,7 +52,7 @@ type
|
||||
OkButton:TButton;
|
||||
ReplaceAllButton:TButton;
|
||||
CancelButton:TButton;
|
||||
procedure TextToFindeditKeyDown(Sender: TObject; var Key:Word;
|
||||
procedure TextToFindEditKeyDown(Sender: TObject; var Key:Word;
|
||||
Shift:TShiftState);
|
||||
procedure OkButtonClick(Sender:TObject);
|
||||
procedure ReplaceAllButtonClick(Sender:TObject);
|
||||
@ -117,9 +117,9 @@ begin
|
||||
Show;
|
||||
end;
|
||||
|
||||
ReplaceTextedit:=Tedit.Create(Self);
|
||||
with ReplaceTextedit do begin
|
||||
Name:='ReplaceTextedit';
|
||||
ReplaceTextEdit:=Tedit.Create(Self);
|
||||
with ReplaceTextEdit do begin
|
||||
Name:='ReplaceTextEdit';
|
||||
Parent:=Self;
|
||||
Left:=90;
|
||||
Top:=28;
|
||||
@ -299,6 +299,10 @@ procedure TLazFindReplaceDialog.TextToFindeditKeyDown(
|
||||
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;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLazFindReplaceDialog.OkButtonClick(Sender:TObject);
|
||||
@ -334,7 +338,7 @@ begin
|
||||
then DirectionRadioGroup.ItemIndex:=0
|
||||
else DirectionRadioGroup.ItemIndex:=1;
|
||||
ReplaceAllButton.Enabled:=ssoReplace in NewOptions;
|
||||
ReplaceTextedit.Enabled:=ReplaceAllButton.Enabled;
|
||||
ReplaceTextEdit.Enabled:=ReplaceAllButton.Enabled;
|
||||
ReplaceWithLabel.Enabled:=ReplaceAllButton.Enabled;
|
||||
PromptOnReplaceCheckBox.Enabled:=ReplaceAllButton.Enabled;
|
||||
if ssoReplace in NewOptions then begin
|
||||
@ -372,12 +376,12 @@ end;
|
||||
|
||||
function TLazFindReplaceDialog.GetReplaceText:AnsiString;
|
||||
begin
|
||||
Result:=ReplaceTextedit.Text;
|
||||
Result:=ReplaceTextEdit.Text;
|
||||
end;
|
||||
|
||||
procedure TLazFindReplaceDialog.SetReplaceText(NewReplaceText:AnsiString);
|
||||
begin
|
||||
ReplaceTextedit.Text:=NewReplaceText;
|
||||
ReplaceTextEdit.Text:=NewReplaceText;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -21,8 +21,9 @@ uses
|
||||
|
||||
const
|
||||
// editor commands constants. see syneditkeycmds.pp for more
|
||||
ecFind = ecUserFirst + 1;
|
||||
ecFind = ecUserFirst + 1;
|
||||
ecFindAgain = ecUserFirst + 2;
|
||||
ecFindNext = ecFindAgain;
|
||||
ecReplace = ecUserFirst + 3;
|
||||
ecFindProcedureDefinition = ecUserFirst + 4;
|
||||
ecFindProcedureMethod = ecUserFirst + 5;
|
||||
@ -31,7 +32,10 @@ const
|
||||
ecNextEditor = ecUserFirst + 7;
|
||||
ecPrevEditor = ecUserFirst + 8;
|
||||
|
||||
ecPeriod = ecUserFirst + 9;
|
||||
ecPeriod = ecUserFirst + 9;
|
||||
|
||||
ecFindPrevious = ecUserFirst + 10;
|
||||
ecFindInFiles = ecUserFirst + 11;
|
||||
|
||||
ecWordCompletion = ecUserFirst + 100;
|
||||
ecCompleteCode = ecUserFirst + 101;
|
||||
@ -287,7 +291,9 @@ begin
|
||||
ecSetMarker9: Result:= 'SetMarker9';
|
||||
|
||||
ecFind: Result:= 'Find text';
|
||||
ecFindAgain: Result:= 'Find again';
|
||||
ecFindNext: Result:= 'Find next';
|
||||
ecFindPrevious: Result:= 'Find previous';
|
||||
ecFindInFiles: Result:= 'Find in files';
|
||||
ecReplace: Result:= 'Replace text';
|
||||
ecFindProcedureDefinition: Result:= 'find procedure definition';
|
||||
ecFindProcedureMethod: Result:= 'find procedure method';
|
||||
@ -704,10 +710,7 @@ begin
|
||||
ACaption:='No No No';
|
||||
AText:=' The key "'+KeyAndShiftStateToStr(NewKey2,NewShiftState2)+'"'
|
||||
+' is already connected to "'+DummyRelation.Name+'".';
|
||||
|
||||
// Application.MessageBox(PChar(AText),PChar(ACaption),0);
|
||||
MessageDlg(ACaption,AText,mterror,[mbok],0);
|
||||
|
||||
exit;
|
||||
end;
|
||||
if NewKey1=VK_UNKNOWN then begin
|
||||
@ -877,7 +880,9 @@ begin
|
||||
Add('Identifier completion',ecIdentCompletion,VK_SPACE,[ssCtrl],VK_UNKNOWN,[]);
|
||||
|
||||
Add('Find text',ecFind,VK_F,[SSCtrl],VK_UNKNOWN,[]);
|
||||
Add('Find text again',ecFindAgain,VK_F3,[],VK_UNKNOWN,[]);
|
||||
Add('Find next',ecFindNext,VK_F3,[],VK_UNKNOWN,[]);
|
||||
Add('Find previous',ecFindPrevious,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
Add('Find in files',ecFindInFiles,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
Add('Replace text',ecReplace,VK_R,[SSCtrl],VK_UNKNOWN,[]);
|
||||
Add('Find procedure definiton',ecFindProcedureDefinition,
|
||||
VK_UP,[ssShift,SSCtrl],VK_UNKNOWN,[]);
|
||||
|
33
ide/main.pp
33
ide/main.pp
@ -109,7 +109,9 @@ type
|
||||
itmEditPaste: TMenuItem;
|
||||
|
||||
itmSearchFind: TMenuItem;
|
||||
itmSearchFindAgain: TMenuItem;
|
||||
itmSearchFindNext: TMenuItem;
|
||||
itmSearchFindPrevious: TMenuItem;
|
||||
itmSearchFindInFiles: TMenuItem;
|
||||
itmSearchReplace: TMenuItem;
|
||||
itmGotoLineNumber: TMenuItem;
|
||||
|
||||
@ -527,7 +529,9 @@ begin
|
||||
|
||||
// find / replace dialog
|
||||
itmSearchFind.OnClick := @SourceNotebook.FindClicked;
|
||||
itmSearchFindAgain.OnClick := @SourceNotebook.FindAgainClicked;
|
||||
itmSearchFindNext.OnClick := @SourceNotebook.FindNextClicked;
|
||||
itmSearchFindPrevious.OnClick := @SourceNotebook.FindPreviousClicked;
|
||||
itmSearchFindInFiles.OnClick := @SourceNotebook.FindInFilesClicked;
|
||||
itmSearchReplace.OnClick := @SourceNotebook.ReplaceClicked;
|
||||
|
||||
// message view
|
||||
@ -924,11 +928,23 @@ begin
|
||||
itmSearchFind.Caption := 'Find';
|
||||
mnuSearch.add(itmSearchFind);
|
||||
|
||||
itmSearchFindAgain := TMenuItem.Create(nil);
|
||||
itmSearchFindAgain.Name:='itmSearchFindAgain';
|
||||
itmSearchFindAgain.caption := 'Find &Again';
|
||||
itmSearchFindAgain.Enabled := False;
|
||||
mnuSearch.add(itmSearchFindAgain);
|
||||
itmSearchFindNext := TMenuItem.Create(nil);
|
||||
itmSearchFindNext.Name:='itmSearchFindNext';
|
||||
itmSearchFindNext.Caption := 'Find &Next';
|
||||
itmSearchFindNext.Enabled := False;
|
||||
mnuSearch.add(itmSearchFindNext);
|
||||
|
||||
itmSearchFindPrevious := TMenuItem.Create(nil);
|
||||
itmSearchFindPrevious.Name:='itmSearchFindPrevious';
|
||||
itmSearchFindPrevious.Caption := 'Find &Previous';
|
||||
itmSearchFindPrevious.Enabled := False;
|
||||
mnuSearch.add(itmSearchFindPrevious);
|
||||
|
||||
itmSearchFindInFiles := TMenuItem.Create(nil);
|
||||
itmSearchFindInFiles.Name:='itmSearchFindInFiles';
|
||||
itmSearchFindInFiles.Caption := 'Find &in files';
|
||||
itmSearchFindInFiles.Enabled := False;
|
||||
mnuSearch.add(itmSearchFindInFiles);
|
||||
|
||||
itmSearchReplace := TMenuItem.Create(nil);
|
||||
itmSearchReplace.Name:='itmSearchReplace';
|
||||
@ -4004,6 +4020,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.123 2001/10/17 13:43:15 lazarus
|
||||
MG: added find previous to source editor
|
||||
|
||||
Revision 1.122 2001/10/16 14:19:10 lazarus
|
||||
MG: added nvidia opengl support and a new opengl example from satan
|
||||
|
||||
|
@ -162,7 +162,8 @@ type
|
||||
procedure OnReplace(Sender: TObject; const ASearch, AReplace:
|
||||
string; Line, Column: integer; var Action: TSynReplaceAction);
|
||||
procedure DoFindAndReplace;
|
||||
procedure FindAgain;
|
||||
procedure FindNext;
|
||||
procedure FindPrevious;
|
||||
procedure GetDialogPosition(Width, Height:integer; var Left,Top:integer);
|
||||
|
||||
property CodeBuffer: TCodeBuffer read FCodeBuffer write SetCodeBuffer;
|
||||
@ -299,8 +300,10 @@ type
|
||||
procedure ToggleFormUnitClicked(Sender: TObject);
|
||||
|
||||
procedure FindClicked(Sender : TObject);
|
||||
procedure FindNextClicked(Sender : TObject);
|
||||
procedure FindPreviousClicked(Sender : TObject);
|
||||
procedure FindInFilesClicked(Sender : TObject);
|
||||
procedure ReplaceClicked(Sender : TObject);
|
||||
procedure FindAgainClicked(Sender : TObject);
|
||||
|
||||
Procedure NewFile(const NewShortName: String; ASource : TCodeBuffer);
|
||||
Procedure CloseFile(PageIndex:integer);
|
||||
@ -647,7 +650,7 @@ Begin
|
||||
End;
|
||||
|
||||
{------------------------------F I N D A G A I N ----------------------------}
|
||||
procedure TSourceEditor.FindAgain;
|
||||
procedure TSourceEditor.FindNext;
|
||||
var OldOptions: TSynSearchOptions;
|
||||
Begin
|
||||
OldOptions:=FindReplaceDlg.Options;
|
||||
@ -656,23 +659,40 @@ Begin
|
||||
FindReplaceDlg.Options:=OldOptions;
|
||||
End;
|
||||
|
||||
{---------------------------F I N D P R E V I O U S ------------------------}
|
||||
procedure TSourceEditor.FindPrevious;
|
||||
var OldOptions: TSynSearchOptions;
|
||||
Begin
|
||||
OldOptions:=FindReplaceDlg.Options;
|
||||
FindReplaceDlg.Options:=FindReplaceDlg.Options-[ssoEntireScope];
|
||||
if ssoBackwards in FindReplaceDlg.Options then
|
||||
FindReplaceDlg.Options:=FindReplaceDlg.Options-[ssoBackwards]
|
||||
else
|
||||
FindReplaceDlg.Options:=FindReplaceDlg.Options+[ssoBackwards];
|
||||
DoFindAndReplace;
|
||||
FindReplaceDlg.Options:=OldOptions;
|
||||
End;
|
||||
|
||||
procedure TSourceEditor.DoFindAndReplace;
|
||||
var OldCaretXY:TPoint;
|
||||
AText,ACaption:AnsiString;
|
||||
TopLine: integer;
|
||||
begin
|
||||
OldCaretXY:=EditorComponent.CaretXY;
|
||||
if EditorComponent.SelAvail then begin
|
||||
if ssoBackwards in FindReplaceDlg.Options then
|
||||
EditorComponent.CaretXY:=EditorComponent.BlockBegin
|
||||
else
|
||||
EditorComponent.CaretXY:=EditorComponent.BlockEnd
|
||||
end;
|
||||
EditorComponent.SearchReplace(
|
||||
FindReplaceDlg.FindText,FindReplaceDlg.ReplaceText,FindReplaceDlg.Options);
|
||||
if (OldCaretXY.X=EditorComponent.CaretX)
|
||||
and (OldCaretXY.Y=EditorComponent.CaretY)
|
||||
and not (ssoReplaceAll in FindReplaceDlg.Options) then begin
|
||||
ACaption:='Message';
|
||||
ACaption:='Not found';
|
||||
AText:='Search string '''+FindReplaceDlg.FindText+''' not found!';
|
||||
|
||||
// Application.MessageBox(PChar(AText),PChar(ACaption),MB_OK);
|
||||
MessageDlg(ACaption,AText,mtinformation,[mbok],0);
|
||||
|
||||
MessageDlg(ACaption,AText,mtInformation,[mbOk],0);
|
||||
end else begin
|
||||
TopLine := EditorComponent.CaretY - (EditorComponent.LinesInWindow div 2);
|
||||
if TopLine < 1 then TopLine:=1;
|
||||
@ -762,11 +782,18 @@ Begin
|
||||
aCompletion.Execute(TextS2,P.X,P.Y);
|
||||
end;
|
||||
|
||||
ecFind :
|
||||
ecFind:
|
||||
StartFindAndReplace(false);
|
||||
|
||||
ecFindAgain :
|
||||
FindAgain;
|
||||
ecFindNext:
|
||||
FindNext;
|
||||
|
||||
ecFindPrevious:
|
||||
FindPrevious;
|
||||
|
||||
ecFindInFiles:
|
||||
// ToDo
|
||||
;
|
||||
|
||||
ecReplace:
|
||||
StartFindAndReplace(true);
|
||||
@ -2322,11 +2349,25 @@ Begin
|
||||
if TempEditor <> nil then TempEditor.StartFindAndReplace(true);
|
||||
End;
|
||||
|
||||
Procedure TSourceNotebook.FindAgainClicked(Sender : TObject);
|
||||
Procedure TSourceNotebook.FindNextClicked(Sender : TObject);
|
||||
var TempEditor:TSourceEditor;
|
||||
Begin
|
||||
TempEditor:=GetActiveSe;
|
||||
if TempEditor <> nil then TempEditor.FindAgain;
|
||||
if TempEditor <> nil then TempEditor.FindNext;
|
||||
End;
|
||||
|
||||
Procedure TSourceNotebook.FindPreviousClicked(Sender : TObject);
|
||||
var TempEditor:TSourceEditor;
|
||||
Begin
|
||||
TempEditor:=GetActiveSe;
|
||||
if TempEditor <> nil then TempEditor.FindPrevious;
|
||||
End;
|
||||
|
||||
Procedure TSourceNotebook.FindInFilesClicked(Sender : TObject);
|
||||
Begin
|
||||
MessageDlg('Not implemented yet',
|
||||
'If you can help us to implement this feature, mail to'#13
|
||||
+'lazarus@miraclec.com', mtInformation,[mbCancel],0);
|
||||
End;
|
||||
|
||||
Procedure TSourceNotebook.BookMarkClicked(Sender : TObject);
|
||||
|
Loading…
Reference in New Issue
Block a user