mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-21 00:41:22 +01:00
Added more code for the find function.
Shane git-svn-id: trunk@25 -
This commit is contained in:
parent
109626d9c4
commit
04bd08aab8
@ -27,12 +27,12 @@ interface
|
||||
|
||||
uses
|
||||
classes,LclLinux, stdctrls,forms,buttons,comctrls,
|
||||
Controls,graphics,extctrls;
|
||||
Controls,graphics,extctrls,Dialogs,VCLGlobals,LMessages;
|
||||
|
||||
|
||||
type
|
||||
|
||||
TFind = class(TFORM)
|
||||
TFindDialog = class(TCustomForm)
|
||||
lblTexttofind : TLabel;
|
||||
edtTexttoFind: TEdit;
|
||||
btnOK : TButton;
|
||||
@ -45,31 +45,29 @@ type
|
||||
cbRegularExpressions : TCheckBox;
|
||||
|
||||
rgForwardBack : TRadioGroup;
|
||||
|
||||
{ event handlers }
|
||||
procedure btnOKClicked(Sender : TObject);
|
||||
procedure btnCancelClicked(Sender : TObject);
|
||||
procedure btnHelpClicked(Sender : TObject);
|
||||
private
|
||||
FFindText : String;
|
||||
FOnFind : TNotifyEvent;
|
||||
protected
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
property OnFind : TNotifyEvent read FonFind write FOnFind;
|
||||
property FIndText : String read FFindText write FFindText;
|
||||
end;
|
||||
|
||||
var
|
||||
dlgFind1 : TFind;
|
||||
|
||||
implementation
|
||||
|
||||
constructor TFind.Create(AOwner: TComponent);
|
||||
constructor TFindDialog.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
fCompStyle := csForm;
|
||||
|
||||
Caption := 'Find';
|
||||
Left := 0;
|
||||
Top := 0;
|
||||
Width := 450;
|
||||
height := 395;
|
||||
Setbounds(0,0,450,250);
|
||||
Position:= poScreenCenter;
|
||||
|
||||
lblTextToFind := TLabel.Create(self);
|
||||
@ -87,6 +85,7 @@ begin
|
||||
Begin
|
||||
parent := Self;
|
||||
Left := lblTextToFind.LEft+lblTextToFind.Width+5;
|
||||
Width := Self.Width - Left - 5;
|
||||
Top := 5;
|
||||
Visible := True;
|
||||
end;
|
||||
@ -99,7 +98,7 @@ begin
|
||||
Left := 10;
|
||||
Top := 35;
|
||||
Width :=(Self.Width div 2) - 10;
|
||||
Height := (Self.Height div 3) -35;
|
||||
Height := (Self.Height div 2) -35;
|
||||
Caption := 'Options';
|
||||
Visible := True;
|
||||
end;
|
||||
@ -141,7 +140,7 @@ begin
|
||||
parent := self;
|
||||
left := (Self.Width div 2) +5;
|
||||
top := 35;
|
||||
Height := (Self.Height div 3) -35;
|
||||
Height := (Self.Height div 2) -35;
|
||||
width := (Self.Width div 2) -10;
|
||||
Caption := 'Direction';
|
||||
Items.Add('Forward');
|
||||
@ -149,18 +148,60 @@ begin
|
||||
visible := True;
|
||||
end;
|
||||
|
||||
btnOK := TButton.create(self);
|
||||
with btnOK do
|
||||
begin
|
||||
parent := self;
|
||||
left := (Self.Width div 2);
|
||||
top := Self.Height -30;
|
||||
Height := 25;
|
||||
Caption := 'OK';
|
||||
ModalResult := mrOK;
|
||||
visible := True;
|
||||
OnCLick := @BTnOKClicked;
|
||||
end;
|
||||
|
||||
procedure TFind.btnOKClicked(Sender : TObject);
|
||||
Begin
|
||||
btnCancel := TButton.create(self);
|
||||
with btnCancel do
|
||||
begin
|
||||
parent := self;
|
||||
left := (Self.Width div 2) + ((Self.Width div 2) div 3);
|
||||
top := Self.Height -30;
|
||||
Height := 25;
|
||||
Caption := 'Cancel';
|
||||
ModalResult := mrCancel;
|
||||
visible := True;
|
||||
OnCLick := @BTnCancelClicked;
|
||||
end;
|
||||
|
||||
procedure TFind.btnCancelClicked(Sender : TObject);
|
||||
btnHelp := TButton.create(self);
|
||||
with btnHelp do
|
||||
begin
|
||||
parent := self;
|
||||
left := (Self.Width div 2) + (2*((Self.Width div 2) div 3));
|
||||
top := Self.Height -30;
|
||||
Height := 25;
|
||||
Caption := 'Help';
|
||||
// ModalResult := mrHelp;
|
||||
visible := True;
|
||||
OnCLick := @BTnHelpClicked;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TFindDialog.btnOKClicked(Sender : TObject);
|
||||
Begin
|
||||
FFIndText := edtTexttoFind.Text;
|
||||
if Assigned(FOnFind) then FOnFind(self);
|
||||
end;
|
||||
|
||||
procedure TFindDialog.btnCancelClicked(Sender : TObject);
|
||||
Begin
|
||||
FFIndText := '';
|
||||
End;
|
||||
|
||||
procedure TFInd.btnHelpClicked(Sender : TObject);
|
||||
procedure TFindDialog.btnHelpClicked(Sender : TObject);
|
||||
Begin
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
|
||||
@ -36,7 +36,15 @@ type
|
||||
private
|
||||
FEmpty : Boolean;
|
||||
FHighlighter: TmwPasSyn;
|
||||
FCurrentSource : TStrings;
|
||||
FCurrentCursorXLine : Integer;
|
||||
FCurrentCursorYLine : Integer;
|
||||
function CreateNewEditor(const AParent: TWinControl): TmwCustomEdit;
|
||||
Function GetCurrentSource : TStrings;
|
||||
Function GetCurrentCursorXLine : Integer;
|
||||
Procedure SetCurrentCursorXLine(num : Integer);
|
||||
Function GetCurrentCursorYLine : Integer;
|
||||
Procedure SetCurrentCursorYLine(num : Integer);
|
||||
protected
|
||||
Procedure IDEEditorPaint(Sender : TObject);
|
||||
public
|
||||
@ -45,6 +53,10 @@ type
|
||||
Function AddPage(title: String; Lines : TStringList) : TmwCustomEdit;
|
||||
Procedure DeletePage(Value : Integer);
|
||||
Function GetEditorfromPage(Value : Integer) : TmwCustomEdit;
|
||||
Procedure SelectText(SelStart,SelEnd : Integer);
|
||||
property CurrentSource : TStrings read GetCurrentSource;
|
||||
property CurrentCursorXLine : Integer read GetCurrentCursorXLine write SetCurrentCursorXLine;
|
||||
property CurrentCursorYLine : Integer read GetCurrentCursorYLine write SetCurrentCursorYLine;
|
||||
property Empty : Boolean read FEmpty write FEmpty;
|
||||
end;
|
||||
|
||||
@ -224,4 +236,78 @@ with Notebook1.Page[Value] do
|
||||
|
||||
end;
|
||||
|
||||
Function TIdeEditor.GetCurrentSource : TStrings;
|
||||
var
|
||||
temp : TmwCustomEdit;
|
||||
begin
|
||||
Temp := GetEditorFromPage(Notebook1.PageIndex);
|
||||
if Temp <> nil then
|
||||
Result := Temp.Lines
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
Function TIdeEditor.GetCurrentCursorYLine : Integer;
|
||||
var
|
||||
temp : TmwCustomEdit;
|
||||
begin
|
||||
Temp := GetEditorFromPage(Notebook1.PageIndex);
|
||||
if Temp <> nil then
|
||||
Result := Temp.CaretY
|
||||
else
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
Procedure TIdeEditor.SetCurrentCursorYLine(num : Integer);
|
||||
var
|
||||
temp : TmwCustomEdit;
|
||||
begin
|
||||
FCurrentCursorYLine := Num;
|
||||
|
||||
Temp := GetEditorFromPage(Notebook1.PageIndex);
|
||||
if Temp <> nil then
|
||||
Temp.CaretY := Num;
|
||||
|
||||
end;
|
||||
|
||||
Function TIdeEditor.GetCurrentCursorXLine : Integer;
|
||||
var
|
||||
temp : TmwCustomEdit;
|
||||
begin
|
||||
Temp := GetEditorFromPage(Notebook1.PageIndex);
|
||||
if Temp <> nil then
|
||||
Result := Temp.CaretX
|
||||
else
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
Procedure TIdeEditor.SetCurrentCursorXLine(num : Integer);
|
||||
var
|
||||
temp : TmwCustomEdit;
|
||||
begin
|
||||
FCurrentCursorXLine := Num;
|
||||
|
||||
Temp := GetEditorFromPage(Notebook1.PageIndex);
|
||||
if Temp <> nil then
|
||||
Temp.CaretX := Num;
|
||||
|
||||
end;
|
||||
|
||||
Procedure TideEditor.SelectText(SelStart,SelEnd : Integer);
|
||||
var
|
||||
temp : TmwCustomEdit;
|
||||
begin
|
||||
Temp := GetEditorFromPage(Notebook1.PageIndex);
|
||||
Writeln('In SelectText');
|
||||
Writeln(Format('SelStart and SelEnd are %d,%d',[SelStart,SelEnd]));
|
||||
if Temp <> nil then
|
||||
Begin
|
||||
Temp.SetSelStart(SelStart);
|
||||
Temp.SetSelEnd(SelEnd);
|
||||
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
|
||||
@ -35,8 +35,8 @@ uses
|
||||
compileroptions,
|
||||
IdeEditor,
|
||||
viewunit_dlg, //dialog used to list the units in a project
|
||||
viewform_dlg, //dialog to display the forms in the project
|
||||
Find_dlg;
|
||||
viewform_dlg; //dialog to display the forms in the project
|
||||
|
||||
|
||||
var
|
||||
SplashForm: TSplashForm;
|
||||
@ -58,7 +58,6 @@ begin
|
||||
Application.CreateForm(TIDEEditor, IdeEditor1);
|
||||
Application.CreateForm(TViewUnits1, ViewUnits1);
|
||||
Application.CreateForm(TViewForms1, ViewForms1);
|
||||
Application.CreateForm(TFind, dlgFind1);
|
||||
|
||||
SplashForm.StartTimer;
|
||||
Application.Run;
|
||||
@ -67,6 +66,10 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.3 2000/08/09 18:32:10 lazarus
|
||||
Added more code for the find function.
|
||||
Shane
|
||||
|
||||
Revision 1.2 2000/08/08 18:52:14 lazarus
|
||||
Started a FIND dialog box.
|
||||
Shane
|
||||
|
||||
62
ide/main.pp
62
ide/main.pp
@ -31,7 +31,7 @@ uses
|
||||
classes,LclLinux,compiler, stdctrls,forms,buttons,menus,comctrls,
|
||||
Spin, project,sysutils, global,
|
||||
compileroptions,Controls,graphics,extctrls, Dialogs,dlgMEssage,
|
||||
designerform,process,idecomp;
|
||||
designerform,process,idecomp,Find_dlg;
|
||||
|
||||
const
|
||||
STANDARDBTNCOUNT = 50;
|
||||
@ -43,6 +43,7 @@ type
|
||||
Savedialog1 : TSaveDialog;
|
||||
FontDialog1 : TFontDialog;
|
||||
ColorDialog1 : TColorDialog;
|
||||
FindDialog1 : TFindDialog;
|
||||
ToolBar1 : TToolBar;
|
||||
Toolbutton1 : TToolButton;
|
||||
Toolbutton2 : TToolButton;
|
||||
@ -151,6 +152,8 @@ private
|
||||
Procedure ReAssignEditorLines(SList : TUnitInfo);
|
||||
Procedure ReAssignSourcefromEditor(var SList : TUnitInfo);
|
||||
protected
|
||||
procedure DoFind(Sender : TObject);
|
||||
|
||||
procedure FormShow(Sender : TObject);
|
||||
procedure ButtonCLick(Sender : TObject);
|
||||
procedure ToolButtonCLick(Sender : TObject);
|
||||
@ -183,7 +186,7 @@ Form1 : TForm1;
|
||||
Taginc : Integer;
|
||||
implementation
|
||||
uses
|
||||
TestForm, IDEEditor,mwCustomEdit,gtk,ViewUnit_dlg,ViewForm_dlg,Find_dlg;
|
||||
TestForm, IDEEditor,mwCustomEdit,gtk,ViewUnit_dlg,ViewForm_dlg;
|
||||
|
||||
constructor TForm1.Create(AOwner: TComponent);
|
||||
var
|
||||
@ -592,6 +595,8 @@ begin
|
||||
SaveDialog1 := TSaveDialog.Create(self);
|
||||
FontDialog1 := TFontDialog.Create(self);
|
||||
ColorDialog1 := TColorDialog.Create(self);
|
||||
FindDialog1 := TFindDialog.Create(self);
|
||||
FindDialog1.OnFind := @DoFind;
|
||||
|
||||
//?? dont need these handlers.
|
||||
// Form will kill itself
|
||||
@ -1778,9 +1783,56 @@ Begin
|
||||
Messagedlg.Show;
|
||||
End;
|
||||
|
||||
Procedure TForm1.DoFind(Sender : TObject);
|
||||
var
|
||||
Source : TStrings;
|
||||
Str : String;
|
||||
CaseSensitive : Boolean;
|
||||
I : Integer;
|
||||
Findtext : String;
|
||||
CharCount : Integer;
|
||||
Found : Boolean;
|
||||
Begin
|
||||
Found := False;
|
||||
if (IDeEditor1.Visible) then
|
||||
begin
|
||||
IDEEditor1.BringToFront;
|
||||
CaseSensitive := TFindDialog(Sender).cbCaseSensitive.Checked;
|
||||
FindText := TFindDialog(Sender).FindText;
|
||||
if CaseSensitive then
|
||||
FindText := Uppercase(FindText);
|
||||
Source := IDEEditor1.CurrentSource;
|
||||
if Source <> nil then
|
||||
begin
|
||||
CharCount := 0;
|
||||
for I := 0 to Source.Count -1 do
|
||||
Begin
|
||||
Str := Source.Strings[i];
|
||||
//check to see if you should be checking CASE
|
||||
if CaseSensitive then Str := UpperCase(str);
|
||||
if pos(FindText,Str) <> 0 then
|
||||
begin
|
||||
IDEEditor1.CurrentCursorYLine := I+1;
|
||||
IDEEditor1.CurrentCursorXLine := pos(FindText,Str);
|
||||
|
||||
IdeEditor1.SelectText(CharCount+1,CharCount +length(FindText));
|
||||
Found := True;
|
||||
Break;
|
||||
end;
|
||||
CharCount := CharCount + Length(Str);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
end;
|
||||
if not found then
|
||||
Application.Messagebox('Text not found','Error',MB_OK);
|
||||
|
||||
end;
|
||||
|
||||
Procedure TForm1.mnuSearchFindClicked(Sender : TObject);
|
||||
Begin
|
||||
dlgFind1.Show;
|
||||
FindDialog1.ShowModal;
|
||||
End;
|
||||
|
||||
|
||||
@ -2188,8 +2240,8 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.3 2000/08/08 18:52:14 lazarus
|
||||
Started a FIND dialog box.
|
||||
Revision 1.4 2000/08/09 18:32:10 lazarus
|
||||
Added more code for the find function.
|
||||
Shane
|
||||
|
||||
Revision 1.2 2000/08/07 19:15:05 lazarus
|
||||
|
||||
@ -47,7 +47,9 @@ const
|
||||
|
||||
|
||||
type
|
||||
TCustomDialog = class(TComponent)
|
||||
// TCustomDialog = class(TComponent)
|
||||
// TCustomDialog = class(TWinControl)
|
||||
TCustomDialog = class(TCustomForm)
|
||||
private
|
||||
FHandle : integer;
|
||||
FOnShow, FOnClose : TNotifyEvent;
|
||||
@ -55,7 +57,7 @@ type
|
||||
FUserChoice: integer;
|
||||
protected
|
||||
public
|
||||
FCompStyle : LongInt;
|
||||
// FCompStyle : LongInt;
|
||||
constructor Create (AOwner : TComponent); override;
|
||||
function DoExecute : boolean; virtual;
|
||||
function Execute : boolean; virtual;
|
||||
@ -120,6 +122,10 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.2 2000/08/09 18:32:10 lazarus
|
||||
Added more code for the find function.
|
||||
Shane
|
||||
|
||||
Revision 1.1 2000/07/13 10:28:23 michael
|
||||
+ Initial import
|
||||
|
||||
|
||||
@ -459,8 +459,6 @@ begin
|
||||
gtk_window_set_position(PGtkWindow(handle), GTK_WIN_POS_CENTER);
|
||||
gtk_widget_show(PGtkWidget(handle));
|
||||
gtk_window_set_modal(PGtkWindow(handle), true);
|
||||
{ Don't grab anything - this is done by gtk_window_set_modal }
|
||||
//gtk_grab_add(PgtkWidget(Handle));
|
||||
end;
|
||||
|
||||
//SH: think of TCanvas.handle!!!!
|
||||
@ -2621,6 +2619,10 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.6 2000/08/09 18:32:10 lazarus
|
||||
Added more code for the find function.
|
||||
Shane
|
||||
|
||||
Revision 1.5 2000/07/30 21:48:33 lazarus
|
||||
MWE:
|
||||
= Moved ObjectToGTKObject to GTKProc unit
|
||||
|
||||
Loading…
Reference in New Issue
Block a user