prepared IDE units for split

git-svn-id: trunk@4822 -
This commit is contained in:
mattias 2003-11-22 15:14:12 +00:00
parent 0fe15bc95c
commit 2d193b48c1
15 changed files with 600 additions and 280 deletions

View File

@ -37,8 +37,8 @@ interface
{ $DEFINE VerboseDesigner}
uses
Classes, LCLIntf, LCLType, Controls, Forms, GraphType, Graphics, SysUtils,
Menus, EnvironmentOpts, PropEdits, DesignerProcs;
Classes, SysUtils, Math, LCLIntf, LCLType, Controls, Forms, GraphType,
Graphics, Menus, EnvironmentOpts, PropEdits, DesignerProcs;
type
TControlSelection = class;
@ -459,9 +459,6 @@ var TheControlSelection: TControlSelection;
implementation
uses
Math;
const
GRAB_CURSOR: array[TGrabIndex] of TCursor = (
crSizeNWSE, crSizeNS, crSizeNESW,

View File

@ -36,8 +36,8 @@ interface
{ $DEFINE VerboseDesignerDraw}
uses
Classes, LCLType, LCLIntf, Forms, Controls, LMessages, GraphType, Graphics,
Dialogs, ExtCtrls, Menus, ClipBrd, IDEProcs,
Classes, SysUtils, Math, LCLType, LCLIntf, Forms, Controls, LMessages,
GraphType, Graphics, Dialogs, ExtCtrls, Menus, ClipBrd, IDEProcs,
LazarusIDEStrConsts, EnvironmentOpts, KeyMapping, ComponentReg,
NonControlForms, AlignCompsDlg, SizeCompsDlg, ScaleCompsDlg, TabOrderDlg,
DesignerProcs, PropEdits, ComponentEditors, CustomFormEditor,
@ -302,9 +302,6 @@ type
implementation
uses
SysUtils, Math;
const
mk_lbutton = 1;
mk_rbutton = 2;

View File

@ -35,8 +35,8 @@ unit AddToProjectDlg;
interface
uses
Classes, SysUtils, LCLProc, LResources, Forms, Controls, Buttons, ComCtrls,
StdCtrls, ExtCtrls, Menus, Dialogs, Graphics, FileCtrl, AVL_Tree,
Classes, SysUtils, Math, LCLProc, LResources, Forms, Controls, Buttons,
ComCtrls, StdCtrls, ExtCtrls, Menus, Dialogs, Graphics, FileCtrl, AVL_Tree,
LazarusIDEStrConsts, IDEProcs, IDEOptionDefs, EnvironmentOpts,
Project, PackageDefs, PackageSystem;
@ -101,9 +101,6 @@ function CheckAddingDependency(LazProject: TProject;
implementation
uses
Math;
function ShowAddToProjectDlg(AProject: TProject;
var AddResult: TAddToProjectResult): TModalResult;
var

View File

@ -34,10 +34,10 @@ unit BuildLazDialog;
interface
uses
Classes, SysUtils, Forms, Controls, LCLType, LCLIntf, Graphics, GraphType,
StdCtrls, ExtCtrls, Buttons, FileCtrl, Dialogs, LResources, Laz_XMLCfg,
LazarusIDEStrConsts, TransferMacros, LazConf, IDEProcs, InputHistory,
ExtToolDialog, ExtToolEditDlg;
Classes, SysUtils, Math, Forms, Controls, LCLType, LCLIntf, Graphics,
GraphType, StdCtrls, ExtCtrls, Buttons, FileCtrl, Dialogs, LResources,
Laz_XMLCfg, LazarusIDEStrConsts, TransferMacros, LazConf, IDEProcs,
InputHistory, ExtToolDialog, ExtToolEditDlg;
type
{ TBuildLazarusItem }
@ -222,9 +222,6 @@ function GetTranslatedMakeModes(MakeMode: TMakeMode): string;
implementation
uses
Math;
const
DefaultIDEMakeOptionFilename = 'idemake.cfg';

View File

@ -38,7 +38,7 @@ uses
{$IFDEF IDE_MEM_CHECK}
MemCheck,
{$ENDIF}
Classes, SysUtils, AbstractFormeditor, Controls, PropEdits, TypInfo,
Classes, SysUtils, Math, AbstractFormeditor, Controls, PropEdits, TypInfo,
Forms, Menus, Dialogs, AVL_Tree, ObjectInspector, JITForms, NonControlForms,
ComponentReg, IDEProcs, ComponentEditors, KeyMapping, EditorOptions,
Designerprocs;
@ -188,9 +188,6 @@ function CompareComponentAndInterface(Key, Data: Pointer): integer;
implementation
uses
Math;
function CompareComponentInterfaces(Data1, Data2: Pointer): integer;
var
CompIntf1: TComponentInterface;

View File

@ -39,9 +39,9 @@ unit DiffDialog;
interface
uses
Classes, SysUtils, Forms, Controls, Buttons, ExtCtrls, StdCtrls, SynEdit,
LResources, LazarusIDEStrConsts, EditorOptions, IDEOptionDefs, InputHistory,
DiffPatch;
Classes, SysUtils, Math, Forms, Controls, Buttons, ExtCtrls, StdCtrls,
SynEdit, LResources, LazarusIDEStrConsts, EditorOptions, IDEOptionDefs,
InputHistory, DiffPatch;
type
TOnGetDiffFile = procedure(TextID: integer; OnlySelection: boolean;
@ -148,9 +148,6 @@ function ShowDiffDialog(Files: TDiffFiles; Text1Index: integer;
implementation
uses
Math;
function ShowDiffDialog(Files: TDiffFiles; Text1Index: integer;
OnGetDiffFile: TOnGetDiffFile;

View File

@ -38,8 +38,8 @@ unit EditorOptions;
interface
uses
LCLIntf, LCLType,
Forms, Classes, SysUtils, ComCtrls, Buttons, StdCtrls, ExtCtrls, LazConf,
Classes, SysUtils, Math, LCLIntf, LCLType,
Forms, ComCtrls, Buttons, StdCtrls, ExtCtrls, LazConf,
FileCtrl, GraphType, Graphics, Controls, Dialogs, LResources, IDEProcs,
SynEdit, SynEditHighlighter, SynEditAutoComplete, SynEditKeyCmds,
SynHighlighterPas, SynHighlighterHTML, SynHighlighterCPP, SynHighlighterXML,
@ -531,8 +531,6 @@ function ExtensionToLazSyntaxHighlighter(Ext:string): TLazSyntaxHighlighter;
implementation
uses Math;
const
ValidAttribChars = ['a'..'z','A'..'Z','_','0'..'9'];

View File

@ -24,7 +24,7 @@ interface
uses
Classes, SysUtils, LCLIntf, Controls, StdCtrls, Forms, Buttons, ExtCtrls,
LResources, LazarusIDEStrConsts, DirSel, Dialogs, SynEditTypes;
LResources, FileCtrl, LazarusIDEStrConsts, DirSel, Dialogs, SynEditTypes;
type
TLazFindInFileSearchOption = (fifMatchCase, fifWholeWord, fifRegExpr,
@ -78,9 +78,6 @@ var FindInFilesDialog: TLazFindInFilesDialog;
implementation
uses
filectrl;
{ TLazFindInFilesDialog }
constructor TLazFindInFilesDialog.Create(AOwner: TComponent);

View File

@ -31,8 +31,14 @@ unit frmSearch;
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls,
StdCtrls, Buttons, FindInFilesDlg;
// LCL
Classes, SysUtils, LResources, LCLType, LCLIntf, Forms, Controls, Graphics,
Dialogs, ExtCtrls, StdCtrls, Buttons, FileCtrl,
// synedit
SynRegExpr,
// ide
LazarusIDEStrConsts, FindInFilesDlg, SearchResultView;
type
TSearchForm = class(TForm)
@ -68,6 +74,7 @@ type
fSearchFileList: TStringList;
fSearchFiles: boolean;
fResultsList: TStrings;
fResultsWindow: integer;
fPad: string;
procedure SearchFile(TheFileName: string);
procedure DoFindInFiles(TheFileName: string);
@ -89,6 +96,7 @@ type
property ResultsList: TStrings read fResultsList write fResultsList;
property SearchMask: string read fMask write fMask;
property Pad: string read fPad write fPad;
property ResultsWindow: integer read fResultsWindow write fResultsWindow;
end;
var
@ -96,9 +104,6 @@ var
implementation
uses
SynRegExpr, FileCtrl, LCLType, LCLIntf, LazarusIDEStrConsts;
const
{$IFDEF Win32}
FindMask = '*.*';
@ -201,6 +206,8 @@ procedure TSearchForm.SearchFile(TheFileName: string);
EndWord: boolean; //Does the word end with a seperator charater?
TheLine: string; //Temp Storage for the current line in the file.
TempSearch: string; //Temp Storage for the search string.
TheHeader: string;
MatchLen: integer;
const
WordBreakChars = ['.', ',', ';', ':', '"', '''', '!', '?', '[', ']', '(',
@ -208,6 +215,7 @@ procedure TSearchForm.SearchFile(TheFileName: string);
begin
try
ThisFile:= TStringList.Create;
MatchLen:= Length(fSearchFor);
//if this is not a regular expression search
if (Not fCaseSensitive) then
TempSearch:= UpperCase(fSearchFor)
@ -217,7 +225,7 @@ procedure TSearchForm.SearchFile(TheFileName: string);
for Lines:= 0 to ThisFile.Count -1 do
begin
Application.ProcessMessages;
TheLine:= ThisFile.Strings[Lines];
TheLine:= Trim(ThisFile.Strings[Lines]);
if not fCaseSensitive then
TheLine:= UpperCase(TheLine);
Match:= pos(TempSearch,TheLine);
@ -239,17 +247,23 @@ procedure TSearchForm.SearchFile(TheFileName: string);
end;//if
if StartWord And EndWord then
begin
fResultsList.Add(TheFileName +'('+IntToStr(lines+1)+ ',' +
IntToStr(match) + ')' + ' ' +
copy(ThisFile.Strings[Lines],Match,60));
TheHeader:= TheFileName +'('+IntToStr(lines+1)+ ','+ IntToStr(match)
+')' + ' ';
SearchResultsView.AddMatch(fResultsWindow,
TheHeader + Trim(ThisFile.Strings[Lines]),
match + Length(TheHeader),
MatchLen);
UpdateMatches;
end;//if
end;//if
if not fWholeWord and (Match > 0) then
begin
fResultsList.Add(TheFileName +'('+IntToStr(lines+1)+ ','+
IntToStr(match) +')' + ' ' +
copy(ThisFile.Strings[Lines],Match,60));
TheHeader:= TheFileName +'('+IntToStr(lines+1)+ ','+ IntToStr(match)
+')' + ' ';
SearchResultsView.AddMatch(fResultsWindow,
TheHeader + Trim(ThisFile.Strings[Lines]),
match + Length(TheHeader),
MatchLen);
UpdateMatches;
end;//if
if fAbort and not fAborting then
@ -271,10 +285,12 @@ procedure TSearchForm.SearchFile(TheFileName: string);
{DoRegExpSearch is called if the search is a regular expression}
procedure DoRegExpSearch;
var
ThisFile: TStringList;
ThisFile: TStringList;
Lines: integer; //Loop Counter
Match: integer; //Position of match in line.
MatchLen: integer;
TheLine: string; //Temp Storage for the current line in the file.
TheHeader: string;
RE: TRegExpr; //Regular expression search engin
begin
try
@ -291,13 +307,17 @@ procedure TSearchForm.SearchFile(TheFileName: string);
for Lines:= 0 to ThisFile.Count - 1 do
begin
Application.ProcessMessages;
TheLine:= ThisFile[Lines];
TheLine:= Trim(ThisFile[Lines]);
if RE.Exec(TheLine) then
begin
Match:= RE.MatchPos[0];
fResultsList.Add(TheFileName +'('+IntToStr(lines+1) +
','+ IntToStr(Match) + ')' +
copy(TheLine,Match,60));
MatchLen:= Re.MatchLen[0];
TheHeader:= TheFileName +'('+IntToStr(lines+1)+ ','+ IntToStr(match)
+')' + ' ';
SearchResultsView.AddMatch(fResultsWindow,TheHeader + TheLine,
match + Length(TheHeader),
MatchLen);
UpdateMatches;
end;//if
if fAbort and not fAborting then

View File

@ -28,8 +28,11 @@ unit InputFileDialog;
interface
uses
Classes, SysUtils, Forms, Controls, Dialogs, Buttons, StdCtrls, IDEProcs,
LResources, TransferMacros, InputHistory, FileCtrl;
// LCL
Classes, SysUtils, Math, Forms, Controls, Dialogs, Buttons, StdCtrls,
FileCtrl, LResources,
// IDE
IDEProcs, TransferMacros, InputHistory;
type
TInputFileFlag = (iftDirectory, iftFilename, iftCmdLine,
@ -113,9 +116,6 @@ function GetInputFileDialog: TInputFileDialog;
implementation
uses
Math;
var InputFileDlg: TInputFileDialog;
function GetInputFileDialog: TInputFileDialog;

View File

@ -925,7 +925,13 @@ procedure TMainIDE.CreateSearchResultWindow;
begin
if SearchResultsView<>nil then exit;
Application.CreateForm(TSearchResultsView, SearchResultsView);
SearchResultsView.OnSelectionChanged:= @SearchResultsViewSelectionChanged;
with SearchResultsView do
begin
// ListBoxFont.Name:= EditorOpts.EditorFont;
// ListBoxFont.Size:= EditorOpts.EditorFontHeight;
// ListBoxFont.Style:=[];
OnSelectionChanged:= @SearchResultsViewSelectionChanged;
end;//with
end;
procedure TMainIDE.OIOnSelectComponents(Sender: TObject);
@ -10100,6 +10106,9 @@ end.
{ =============================================================================
$Log$
Revision 1.671 2003/11/22 15:14:12 mattias
prepared IDE units for split
Revision 1.670 2003/11/16 19:28:33 mattias
build lazarus now uses custom compiler path

View File

@ -1,21 +1,21 @@
object SearchResultsView: TSearchResultsView
CAPTION = 'SearchResultsView'
CLIENTHEIGHT = 225
CLIENTHEIGHT = 229
CLIENTWIDTH = 799
ONCREATE = Form1Create
ONDESTROY = SearchResultsViewDestroy
HORZSCROLLBAR.PAGE = 800
VERTSCROLLBAR.PAGE = 226
LEFT = 280
HEIGHT = 225
TOP = 389
VERTSCROLLBAR.PAGE = 230
LEFT = 151
HEIGHT = 229
TOP = 481
WIDTH = 799
object ResultsNoteBook: TNOTEBOOK
ALIGN = albottom
ANCHORS = [aktop, akleft]
ONCLOSETABCLICKED = ResultsNoteBookClosetabclicked
OPTIONS = [nboshowclosebuttons, nbomultiline]
HEIGHT = 185
HEIGHT = 189
TOP = 40
WIDTH = 799
end

View File

@ -2,13 +2,13 @@
LazarusResources.Add('TSearchResultsView','FORMDATA',[
'TPF0'#18'TSearchResultsView'#17'SearchResultsView'#7'CAPTION'#6#17'SearchRes'
+'ultsView'#12'CLIENTHEIGHT'#3#225#0#11'CLIENTWIDTH'#3#31#3#8'ONCREATE'#7#11
+'ultsView'#12'CLIENTHEIGHT'#3#229#0#11'CLIENTWIDTH'#3#31#3#8'ONCREATE'#7#11
+'Form1Create'#9'ONDESTROY'#7#24'SearchResultsViewDestroy'#18'HORZSCROLLBAR.P'
+'AGE'#3' '#3#18'VERTSCROLLBAR.PAGE'#3#226#0#4'LEFT'#3#24#1#6'HEIGHT'#3#225#0
+#3'TOP'#3#133#1#5'WIDTH'#3#31#3#0#9'TNOTEBOOK'#15'ResultsNoteBook'#5'ALIGN'#7
+'AGE'#3' '#3#18'VERTSCROLLBAR.PAGE'#3#230#0#4'LEFT'#3#151#0#6'HEIGHT'#3#229#0
+#3'TOP'#3#225#1#5'WIDTH'#3#31#3#0#9'TNOTEBOOK'#15'ResultsNoteBook'#5'ALIGN'#7
+#8'albottom'#7'ANCHORS'#11#5'aktop'#6'akleft'#0#17'ONCLOSETABCLICKED'#7#30'R'
+'esultsNoteBookClosetabclicked'#7'OPTIONS'#11#19'nboshowclosebuttons'#12'nbo'
+'multiline'#0#6'HEIGHT'#3#185#0#3'TOP'#2'('#5'WIDTH'#3#31#3#0#0#7'TBUTTON'#14
+'multiline'#0#6'HEIGHT'#3#189#0#3'TOP'#2'('#5'WIDTH'#3#31#3#0#0#7'TBUTTON'#14
+'btnSearchAgain'#7'ANCHORS'#11#5'aktop'#6'akleft'#0#7'CAPTION'#6#12'Search A'
+'gain'#7'TABSTOP'#9#8'TABORDER'#2#1#7'ONCLICK'#7#19'btnSearchAgainClick'#4'L'
+'EFT'#2#8#6'HEIGHT'#2#25#3'TOP'#2#8#5'WIDTH'#2's'#0#0#0

View File

@ -39,8 +39,56 @@ interface
uses
Classes, SysUtils, Math, LResources, Forms, Controls, Graphics, Dialogs,
ComCtrls, ExtCtrls, StdCtrls, Buttons, LCLType,
IDEOptionDefs, LazarusIDEStrConsts, EnvironmentOpts;
IDEOptionDefs, LazarusIDEStrConsts, EnvironmentOpts, FindInFilesDlg, Project;
{TLazSearchMatchPos}
type
TLazSearchMatchPos = class(TObject)
private
fMatchStart: integer;
fMatchLen: integer;
public
property MatchStart: integer read fMatchStart write fMatchStart;
property MatchLen: integer read fMatchLen write fMatchLen;
end;//TLazSearchMatchPos
{TLazSearch}
type
TLazSearch = Class(TObject)
private
fSearchString: string;
fSearchOptions: TLazFindInFileSearchOptions;
fSearchDirectory: string;
fSearchMask: string;
public
property SearchString: string read fSearchString write fSearchString;
property SearchOptions: TLazFindInFileSearchOptions read fSearchOptions
write fSearchOptions;
property SearchDirectory: string read fSearchDirectory
write fSearchDirectory;
property SearchMask: string read fSearchMask write fSearchMask;
end;//TLazSearch
{TLazSearchResultLB}
type
TLazSearchResultLB = Class(TCustomListBox)
private
fSearchObject: TLazSearch;
fUpdateStrings: TStrings;
fUpdating: boolean;
fUpdateCount: integer;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property SearchObject: TLazSearch read fSearchObject write fSearchObject;
procedure BeginUpdate;
procedure EndUpdate;
property UpdateItems: TStrings read fUpdateStrings write fUpdateStrings;
property UpdateState: boolean read fUpdating;
end;
{TSearchResultsView}
type
TSearchResultsView = class(TForm)
btnSearchAgain: TBUTTON;
@ -52,42 +100,51 @@ type
procedure btnSearchAgainClick(Sender: TObject);
procedure ListboxDrawitem(Control: TWinControl; Index: Integer;
ARect: TRect; State: TOwnerDrawState);
procedure LazLBShowHint(Sender: TObject; HintInfo: Pointer);
procedure LazLBMousemove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
Procedure LazLBMouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
private
{ private declarations }
fUpdating: boolean;
fSearchObjectList: TStringList;
function PageExists(APageName: string): boolean;
function PageExists(const APageName: string): boolean;
function GetPageIndex(APageName: string): integer;
function GetListBox(APageIndex: integer): TListBox;
function GetListBox(APageIndex: integer): TLazSearchResultLB;
procedure ListBoxClicked(Sender: TObject);
procedure ListBoxDoubleClicked(Sender: TObject);
procedure SetItems(Index: Integer; Value: TStrings);
function GetItems(Index: integer): TStrings;
fOnSelectionChanged: TNotifyEvent;
fListBoxFont: TFont;
fMouseOverIndex: integer;
public
{ public declarations }
function AddResult(const ResultsName: string; SearchText: string): TStrings;
function AddResult(const ResultsName: string;
const SearchText: string;
const ADirectory: string;
const AMask: string;
const TheOptions: TLazFindInFileSearchOptions): integer;
function GetSourcePositon: TPoint;
function GetSourceFileName: string;
function GetSelectedText: string;
procedure BringResultsToFront(APageName: string);
procedure BeginUpdate;
procedure EndUpdate;
procedure BringResultsToFront(const APageName: string);
procedure AddMatch(const AIndex: integer; const TheText: string;
const MatchStart: integer; const MatchLen: integer);
procedure BeginUpdate(AIndex: integer);
procedure EndUpdate(AIndex: integer);
property ListBoxFont: TFont read fListBoxFont write fListBoxFont;
property OnSelectionChanged: TNotifyEvent read fOnSelectionChanged
write fOnSelectionChanged;
property Items[Index: integer]: TStrings read GetItems write SetItems;
end;
type
TLazSearch = Class(TObject)
private
fSearchString: string;
public
property SearchString: string read fSearchString write fSearchString;
end;
var
SearchResultsView: TSearchResultsView;
implementation
uses
MainBar;
{ TSearchResultsView }
const
@ -108,8 +165,13 @@ begin
ItemByEnum(nmiwSearchResultsViewName);
ALayout.Form:=TForm(Self);
ALayout.Apply;
fSearchObjectList:= TStringList.Create;
fListBoxFont:= TFont.Create;
fListBoxFont.Name:= 'courier';
fListBoxFont.Height:= 12;
fListBoxFont.Style:= [];
fOnSelectionChanged:= nil;
self.ShowHint:= True;
fMouseOverIndex:= -1;
end;//Create
procedure TSearchResultsView.ResultsNoteBookChangebounds(Sender: TObject);
@ -117,41 +179,89 @@ begin
end;
procedure TSearchResultsView.SearchResultsViewDestroy(Sender: TObject);
var
i: integer;
TheObject: TObject;
{Keeps track of the Index of the Item the mouse is over, Sets ShowHint to true
if the Item length is longer than the Listbox client width.}
procedure TSearchResultsView.LazLBMousemove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
begin
try
if not Assigned(fSearchObjectList) then
Writeln('fSearchObject is not assigned');
for i:= 0 to fSearchObjectList.Count - 1 do
if Sender is TLazSearchResultLB then
begin
with Sender as TLazSearchResultLB do
begin
if Assigned(fSearchObjectList.Objects[i]) then
fMouseOverIndex:= GetIndexAtY(Y);
if (fMouseOverIndex > -1) and (fMouseOverIndex < Items.Count) then
begin
TheObject:= fSearchObjectList.Objects[i];
FreeAndNil(TheObject);
if (Canvas.TextWidth(Items[fMouseOverIndex]) > Width) then
ShowHint:= True
else
ShowHint:= False;
end;//if
end;//for
except
writeln('Exception in form destroy!');
end;//except
FreeAndNil(fSearchObjectList);
end;//with
end;//
end;//LazLBMousemove
{Keep track of the mouse position over the list box when the wheel is used}
procedure TSearchResultsView.LazLBMouseWheel(Sender: TObject;
Shift: TShiftState;
WheelDelta: Integer;
MousePos: TPoint;
var Handled: Boolean);
begin
LazLBMouseMove(Sender,Shift,MousePos.X, MousePos.Y);
Handled:= false;
end;//LazLBMouseWheel
procedure TSearchResultsView.AddMatch(const AIndex: integer;
const TheText: string;
const MatchStart: integer;
const MatchLen: integer);
var
CurrentLB: TLazSearchResultLB;
SearchPos: TLazSearchMatchPos;
begin
CurrentLB:= GetListBox(AIndex);
if Assigned(CurrentLB) then
begin
SearchPos:= TLazSearchMatchPos.Create;
SearchPos.MatchStart:= MatchStart;
SearchPos.MatchLen:= MatchLen;
if CurrentLB.UpdateState then
CurrentLB.UpdateItems.AddObject(TheText, SearchPos)
else
CurrentLB.Items.AddObject(TheText, SearchPos);
end;//if
end;//AddMatch
procedure TSearchResultsView.SearchResultsViewDestroy(Sender: TObject);
begin
fListBoxFont.free;
end;//SearchResulstViewDestroy
Procedure TSearchResultsView.BeginUpdate;
Procedure TSearchResultsView.BeginUpdate(AIndex: integer);
var
CurrentLB: TLazSearchResultLB;
begin
fUpDating:= true;
CurrentLB:= GetListBox(AIndex);
if Assigned(CurrentLB) then
CurrentLB.BeginUpdate;
end;//BeginUpdate
procedure TSearchResultsView.EndUpdate;
procedure TSearchResultsView.EndUpdate(AIndex: integer);
var
CurrentLB: TLazSearchResultLB;
begin
fUpdating:= false;
CurrentLB:= GetListBox(AIndex);
if Assigned(CurrentLB) then
begin
CurrentLB.EndUpdate;
CurrentLB.ItemIndex:= 0;
CurrentLB.TopIndex:= 0;
end;//if
end;//EndUpdate
{Brings the results tab named APageName to front.
If APageName does not exist, does nothing}
procedure TSearchResultsView.BringResultsToFront(APageName: string);
procedure TSearchResultsView.BringResultsToFront(const APageName: string);
begin
if PageExists(APageName) then
begin
@ -159,19 +269,46 @@ begin
end;//if
end;//BringResultsToFront
procedure TSearchResultsView.ResultsNoteBookClosetabclicked(Sender: TObject);
{Sets the Items from the list box on the currently selected page in the
TNoteBook}
procedure TSearchResultsView.SetItems(Index: integer; Value: TStrings);
var
TheObject: TObject;
i: integer;
CurrentLB: TLazSearchResultLB;
begin
if Index > -1 then
begin
CurrentLB:= GetListBox(Index);
if Assigned(CurrentLB) then
begin
if CurrentLB.UpdateState then
CurrentLB.UpdateItems.Assign(Value)
else
CurrentLB.Items.Assign(Value);
end;//if
end//if
end;//SetItems
function TSearchResultsView.GetItems(Index: integer): TStrings;
var
CurrentLB: TLazSearchResultLB;
begin
result:= nil;
CurrentLB:= GetListBox(Index);
if Assigned(CurrentLB) then
begin
if CurrentLB.UpdateState then
result:= CurrentLB.UpdateItems
else
result:= CurrentLB.Items;
end;//if
end;//GetItems
procedure TSearchResultsView.ResultsNoteBookClosetabclicked(Sender: TObject);
begin
if (Sender is TPage) then
begin
with sender as TPage do
begin
i:= fSearchObjectList.IndexOf(Caption);
TheObject:= fSearchObjectList.Objects[i];
FreeAndNil(TheObject);
fSearchObjectList.Delete(i);
ResultsNoteBook.Pages.Delete(PageIndex);
end;//with
end;//if
@ -180,13 +317,29 @@ begin
end;//ResultsNoteBookClosetabclicked
procedure TSearchResultsView.btnSearchAgainClick(Sender: TObject);
var
CurrentLB: TLazSearchResultLB;
SearchObj: TLazSearch;
begin
MessageDlg('Working On it!', mtInformation,[mbOk],0);
CurrentLB:= GetListBox(ResultsNoteBook.PageIndex);
if not Assigned(CurrentLB) then exit;
SearchObj:= CurrentLB.SearchObject;
if Assigned(FindInFilesDialog) then
begin
with FindInFilesDialog do
begin
DirectoryComboBox.Text:= SearchObj.SearchDirectory;
FindText:= SearchObj.SearchString;
Options:= SearchObj.SearchOptions;
FileMaskComboBox.Text:= SearchObj.SearchMask;
end;//with
SourceNotebook.FindInFiles(Project1);
end;//if
end;
{Searched the notebook control for a page with APageName name, returns true if
found}
function TSearchResultsView.PageExists(APageName: string): boolean;
function TSearchResultsView.PageExists(const APageName: string): boolean;
var
i: integer;
begin
@ -202,17 +355,18 @@ begin
end;//PageExists
{Add Result will create a tab in the Results view window with an new
list box and return the Items from the new listbox to be filled in
by the search routine.}
list box or focus an existing listbox and update it's searchoptions.}
function TSearchResultsView.AddResult(const ResultsName: string;
SearchText: string ): TStrings;
const SearchText: string;
const ADirectory: string;
const AMask: string;
const TheOptions: TLazFindInFileSearchOptions): integer;
var
NewListBox: TListBox;
NewListBox: TLazSearchResultLB;
NewPage: LongInt;
i: integer;
SearchObj: TLazSearch;
begin
Result:= nil;
result:= -1;
if Assigned(ResultsNoteBook) then
begin
With ResultsNoteBook do
@ -226,29 +380,56 @@ begin
else
begin
NewPage:= Pages.Add(ResultsName + SPACE);
SearchObj:= TLazSearch.Create;
SearchObj.SearchString:= SearchText;
fSearchObjectList.AddObject(ResultsName + SPACE, SearchObj);
ResultsNoteBook.PageIndex:= NewPage;
if NewPage > -1 then
begin
NewListBox:= TListBox.Create(Page[NewPage]);
NewListBox.Parent:= Page[NewPage];
NewListBox.Align:= alClient;
NewListBox.OnClick:= @ListBoxClicked;
NewListBox.OnDblClick:= @ListBoxDoubleClicked;
//NewListBox.Style:= lbOwnerDrawFixed;
//NewListBox.OnDrawItem:= @ListBoxDrawItem;
//NewListBox.Font.Name:= 'courier';
//NewListBox.Font.Height:= 12;
//NewListBox.ItemHeight:= 2 * NewListBox.Canvas.TextHeight('0');
NewListBox:= TLazSearchResultLB.Create(Page[NewPage]);
with NewListBox do
begin
Parent:= Page[NewPage];
Align:= alClient;
OnClick:= @ListBoxClicked;
OnDblClick:= @ListBoxDoubleClicked;
Style:= lbOwnerDrawFixed;
OnDrawItem:= @ListBoxDrawItem;
Font.Name:= fListBoxFont.Name;
Font.Height:= fListBoxFont.Height;
OnShowHint:= @LazLBShowHint;
OnMouseMove:= @LazLBMousemove;
OnMouseWheel:= @LazLBMouseWheel;
ShowHint:= true;
NewLIstBox.Canvas.Color:= clWhite;
end;//with
end;//if
end;//else
end;//
end;//with
with NewListBox.SearchObject do
begin
SearchString:= SearchText;
SearchDirectory:= ADirectory;
SearchMask:= AMask;
SearchOptions:= TheOptions;
end;//with
result:= ResultsNoteBook.PageIndex;
end;//if
if NewListBox<>nil then
Result:= NewListBox.Items;
end;//AddResult
procedure TSearchResultsView.LazLBShowHint(Sender: TObject; HintInfo: Pointer);
begin
if Sender is TLazSearchResultLB then
begin
With Sender as TLazSearchResultLB do
begin
if (fMouseOverIndex >= 0) and (fMouseOverIndex < Items.Count) then
begin
Hint:= Items[fMouseOverIndex];
end;//if
end;//with
end;//if
end;//LazLBShowHint
procedure TSearchResultsView.ListboxDrawitem(Control: TWinControl;
Index: Integer; ARect: TRect;
State: TOwnerDrawState);
@ -256,56 +437,42 @@ var
FirstPart: string;
BoldPart: string;
LastPart: string;
i: integer;
BoldLen: integer;
SearchObj: TLazSearch;
TheText: string;
SearchText: string;
TheTop: integer;
MatchPos: TLazSearchMatchPos;
begin
//if not fUpdating then
//begin
With Control as TListBox do
With Control as TLazSearchResultLB do
begin
Canvas.FillRect(ARect);
TheText:= Items[Index];
if Items.Objects[Index] is TLazSearchMatchPos then
MatchPos:= TLazSearchMatchPos(Items.Objects[Index])
else
MatchPos:= nil;
if Assigned(MatchPos) then
begin
Canvas.FillRect(ARect);
TheText:= Items[Index];
if Items.Count > 0 then
begin
i:= fSearchObjectList.IndexOf(ResultsNoteBook.ActivePage);
SearchObj:= TLazSearch(fSearchObjectList.Objects[i]);
end;
if Assigned(SearchObj) then
begin
SearchText:= SearchObj.SearchString;
TheText:= Items[Index];
i:= pos(SearchText,TheText);
if i > 0 then
begin
TheTop:= ARect.Top + 1;
BoldLen:= Length(SearchText);
FirstPart:= copy(TheText,1,i-1);
BoldPart:= copy(TheText,i,BoldLen + 1);
LastPart:= copy(TheText, i + BoldLen +1, Length(TheText) -
(i + BoldLen));
Canvas.TextOut(ARect.Left, TheTop, FirstPart);
Canvas.Font.Style:= Canvas.Font.Style + [fsBold];
Canvas.TextOut(ARect.Left + Canvas.TextWidth(FirstPart),
TheTop, BoldPart);
Canvas.Font.Style:= Canvas.Font.Style - [fsBold];
Canvas.TextOut(ARect.Left + Canvas.TextWidth(FirstPart + BoldPart),
TheTop, LastPart);
end//if
else
begin
Canvas.TextOut(ARect.Left, ARect.Top + 1, TheText);
end;//else
end
else
begin
Canvas.TextOut(ARect.Left, ARect.Top + 1, TheText);
end;//else
end;//with
//end;//if
TheTop:= ARect.Top;
BoldLen:= MatchPos.MatchLen;
FirstPart:= copy(TheText,1,MatchPos.MatchStart - 1);
BoldPart:= copy(TheText,MatchPos.MatchStart ,BoldLen);
LastPart:= copy(TheText, MatchPos.MatchStart + BoldLen,
Length(TheText) - (MatchPos.MatchStart + BoldLen) + 2);
Canvas.TextOut(ARect.Left, TheTop, FirstPart);
Canvas.Font.Style:= Canvas.Font.Style + [fsBold];
{TODO: Find out why bold is 1 pixel off}
Canvas.TextOut(ARect.Left + Canvas.TextWidth(FirstPart),
TheTop - 1, BoldPart);
Canvas.Font.Style:= Canvas.Font.Style - [fsBold];
Canvas.TextOut(ARect.Left + Canvas.TextWidth(FirstPart + BoldPart),
TheTop, LastPart);
end//if
else
begin
Canvas.TextOut(ARect.Left, ARect.Top + 1, TheText);
end;//else
end;//with
end;//ListBoxDrawItem
procedure TSearchResultsView.ListBoxClicked(Sender: TObject);
@ -381,7 +548,7 @@ end;//GetSourceFileName
function TSearchResultsView.GetSelectedText: string;
var
ThePage: TPage;
TheListBox: TListBox;
TheListBox: TLazSearchResultLB;
i: integer;
begin
result:= '';
@ -419,7 +586,7 @@ end;//GetPageIndex
{Returns a the listbox control from a Tab if both the page and the listbox
exist else returns nil}
function TSearchResultsView.GetListBox(APageIndex: integer): TListBox;
function TSearchResultsView.GetListBox(APageIndex: integer): TLazSearchResultLB;
var
i: integer;
ThePage: TPage;
@ -432,9 +599,9 @@ begin
begin
for i:= 0 to ThePage.ComponentCount - 1 do
begin
if ThePage.Components[i] is TListBox then
if ThePage.Components[i] is TLazSearchResultLB then
begin
result:= TListBox(ThePage.Components[i]);
result:= TLazSearchResultLB(ThePage.Components[i]);
break;
end;//if
end;//for
@ -442,6 +609,76 @@ begin
end;//if
end;//GetListBox
{******************************************************************************
TLazSearchResultLB
******************************************************************************}
Constructor TLazSearchResultLB.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
fSearchObject:= TLazSearch.Create;
fUpdating:= false;
fUpdateCount:= 0;
fUpdateStrings:= TStringList.Create;
end;//Create
Destructor TLazSearchResultLB.Destroy;
var
i: integer;
begin
if Assigned(fSearchObject) then
FreeAndNil(fSearchObject);
if Assigned(fUpdateStrings) then
begin
for i:= 0 to fUpdateStrings.Count -1 do
begin
if Assigned(fUpdateStrings.Objects[i]) then
fUpdateStrings.Objects[i].free;
end;//for
FreeAndNil(fUpdateStrings);
end;//if
inherited Destroy;
end;//Destroy
procedure TLazSearchResultLB.BeginUpdate;
begin
inc(fUpdateCount);
if (fUpdateCount = 1) then
begin
if Assigned(Items) then
fUpdateStrings.Assign(Items);
fUpdating:= true;
end;//if
end;//BeginUpdate
procedure TLazSearchResultLB.EndUpdate;
var
i: integer;
begin
dec(fUpdateCount);
if (fUpdateCount < 0) then
fUpdateCount:= 0;
if (fUpdateCount = 0) then
begin
fUpdating:= false;
for i:= 0 to Items.Count -1 do
begin
try
if Assigned(Items.Objects[i]) then
begin
Items.Objects[i].free;
end;//if
except
writeln('Exception in TLazSearchResultLB.EndUpdate,' +
' Pointer assigned free failed');
end;//except
end;//for
Items.Assign(fUpdateStrings);
end;//if
end;//EndUpdate
initialization
{$I searchresultview.lrs}

View File

@ -55,7 +55,7 @@ uses
MsgView, SearchResultView, InputHistory, LazarusIDEStrConsts, BaseDebugManager, Debugger,
TypInfo, LResources, LazConf, EnvironmentOpts, Compiler,
SortSelectionDlg, EncloseSelectionDlg, ClipBoardHistory, DiffDialog,
SourceEditProcs, SourceMarks, CharacterMapDlg;
SourceEditProcs, SourceMarks, CharacterMapDlg, frmSearch;
type
TSourceNoteBook = class;
@ -566,6 +566,17 @@ type
procedure EndIncrementalFind;
property IncrementalSearchStr: string
read FIncrementalSearchStr write SetIncrementalSearchStr;
//FindInFiles
function CreateFindInFilesDialog: TLazFindInFilesDialog;
procedure LoadFindInFilesHistory(ADialog: TLazFindInFilesDialog);
procedure SaveFindInFilesHistory(ADialog: TLazFindInFilesDialog);
procedure FIFSearchProject(AProject: TProject;
ADialog: TLazFindInFilesDialog);
procedure FIFSearchOpenFiles(ADialog: TLazFindInFilesDialog);
procedure FIFSearchDir(ADialog: TLazFindInFilesDialog);
function FIFCreateSearchForm(ADialog:TLazFindInFilesDialog): TSearchForm;
procedure DoFindInFiles(ASearchForm: TSearchForm);
published
property OnAddJumpPoint: TOnAddJumpPoint
read FOnAddJumpPoint write FOnAddJumpPoint;
@ -638,9 +649,6 @@ type
implementation
uses
frmSearch;
var
Highlighters: array[TLazSyntaxHighlighter] of TSynCustomHighlighter;
// aCompletion:
@ -3353,98 +3361,167 @@ Begin
if TempEditor <> nil then TempEditor.FindPrevious;
End;
Procedure TSourceNotebook.FindInFiles(AProject: TProject);
var
TheFileList: TStringList; //List of Files to be searched.
i: integer; //loop counter
AnUnitInfo: TUnitInfo;
LocalFindText: String; //Text to search for
SearchForm: TSearchForm; //
Begin
if FindInFilesDialog=nil then
FindInFilesDialog:=TLazFindInFilesDialog.Create(Application);
with FindInFilesDialog do
//FindInFiles
function TSourceNotebook.CreateFindInFilesDialog: TLazFindInFilesDialog;
begin
Result:=TLazFindInFilesDialog.Create(Application);
LoadFindInFilesHistory(Result);
end;//CreateFindInFilesDialog
procedure TSourceNotebook.LoadFindInFilesHistory(ADialog: TLazFindInFilesDialog);
begin
if Assigned(ADialog) then
begin
TextToFindComboBox.Items.Assign(InputHistories.FindHistory);
DirectoryComboBox.Items.Assign(InputHistories.FindInFilesPathHistory);
FileMaskComboBox.Items.Assign(InputHistories.FindInFilesMaskHistory);
end;//With
if FindInFilesDialog.ShowModal=mrOk then
with ADialog do
begin
TextToFindComboBox.Items.Assign(InputHistories.FindHistory);
DirectoryComboBox.Items.Assign(InputHistories.FindInFilesPathHistory);
FileMaskComboBox.Items.Assign(InputHistories.FindInFilesMaskHistory);
end;//With
end;//if
end;//LoadFindInFilesHistory
procedure TSourceNoteBook.SaveFindInFilesHistory(ADialog: TLazFindInFilesDialog);
begin
if Assigned(ADialog) then
begin
LocalFindText:=FindInFilesDialog.FindText;
with FindInFilesDialog do
with ADialog do
begin
InputHistories.AddToFindHistory(FindText);
InputHistories.AddToFindInFilesPathHistory(DirectoryComboBox.Text);
InputHistories.AddToFindInFilesMaskHistory(FileMaskComboBox.Text);
end;//with
InputHistories.Save;
if LocalFindText<>'' then
end;//if
end;//SaveFindInFilesHistory
{Search All the files in a project and add the results to the SearchResultsView
Dialog}
procedure TSourceNoteBook.FIFSearchProject(AProject: TProject;
ADialog: TLazFindInFilesDialog);
var
AnUnitInfo: TUnitInfo;
TheFileList: TStringList;
SearchForm: TSearchForm;
begin
try
TheFileList:= TStringList.Create;
AnUnitInfo:=AProject.FirstPartOfProject;
while AnUnitInfo<>nil do begin
//Only if file exists on disk.
if FilenameIsAbsolute(AnUnitInfo.FileName) and
FileExists(AnUnitInfo.FileName) then
TheFileList.Add(AnUnitInfo.FileName);
AnUnitInfo:=AnUnitInfo.NextPartOfProject;
end;//while
SearchForm:= FIFCreateSearchForm(ADialog);
SearchForm.SearchFileList:= TheFileList;
DoFindInFiles(SearchForm);
finally
FreeAndNil(TheFileList);
FreeAndNil(SearchForm);
end;//finally
end;//FIFSearchProject
procedure TSourceNoteBook.FIFSearchDir(ADialog: TLazFindInFilesDialog);
var
SearchForm: TSearchForm;
begin
try
SearchForm:= FIFCreateSearchForm(ADialog);
SearchForm.SearchFileList:= Nil;
DoFindInFiles(SearchForm);
finally
FreeAndNil(SearchForm);
end;
end;//FIFSearchDir;
Procedure TSourceNoteBook.DoFindInFiles(ASearchForm: TSearchForm);
var
ListIndex: integer;
begin
ShowSearchResultsView;
ListIndex:=SearchResultsView.AddResult('Search For '+ASearchForm.SearchText,
ASearchForm.SearchText,
ASearchForm.SearchDirectory,
ASearchForm.SearchMask,
ASearchForm.SearchOptions);
try
SearchResultsView.BeginUpdate(ListIndex);
ASearchForm.ResultsList:= SearchResultsView.Items[ListIndex];
SearchResultsView.Items[ListIndex].Clear;
ASearchForm.ResultsWindow:= ListIndex;
try
ASearchForm.Show;
ASearchForm.DoSearch;
except
on E: ERegExpr do
MessageDlg(lisUEErrorInRegularExpression, E.Message,mtError,
[mbCancel],0);
end;//except
finally
SearchResultsView.EndUpdate(ListIndex);
SearchResultsView.ShowOnTop;
end;//finally
end;//DoFindInFiles
procedure TSourceNoteBook.FIFSearchOpenFiles(ADialog: TLazFindInFilesDialog);
var
i: integer;
TheFileList: TStringList;
SearchForm: TSearchForm;
begin
try
TheFileList:= TStringList.Create;
for i:= 0 to self.EditorCount -1 do
begin
try
TheFileList:= TStringList.Create;
if (FindInFilesDialog.WhereRadioGroup.ItemIndex = 1) or
(FindInFilesDialog.WhereRadioGroup.ItemIndex = 0) then
begin
if FindInFilesDialog.WhereRadioGroup.ItemIndex = 0 then
begin
AnUnitInfo:=AProject.FirstPartOfProject;
while AnUnitInfo<>nil do begin
//Only if file exists on disk.
if FilenameIsAbsolute(AnUnitInfo.FileName)
and FileExists(AnUnitInfo.FileName) then
TheFileList.Add(AnUnitInfo.FileName);
AnUnitInfo:=AnUnitInfo.NextPartOfProject;
end;//while
end//if
else
begin
for i:= 0 to self.EditorCount -1 do
begin
//only if file exists on disk
if FilenameIsAbsolute(Editors[i].FileName) and
FileExists(Editors[i].FileName) then
begin
TheFileList.Add(Editors[i].FileName);
end;//if
end;//for
end;//else
end;//if
try
SearchForm:= TSearchForm.Create(SearchResultsView);
ShowSearchResultsView;
with SearchForm do
begin
SearchOptions:= FindInFilesDialog.Options;
SearchText:= LocalFindText;
SearchFileList:= TheFileList;
ResultsList:= SearchResultsView.AddResult('Search For ' +
LocalFindText,
LocalFindText);
if Assigned(ResultsList) then
begin
ResultsList.Clear;
SearchMask:= FindInFilesDialog.FileMaskComboBox.Text;
SearchDirectory:= FindInFilesDialog.DirectoryComboBox.Text;
end;//if
end;//with
try
SearchResultsView.BeginUpdate;
SearchForm.Show;
SearchForm.DoSearch;
except
on E: ERegExpr do
MessageDlg(lisUEErrorInRegularExpression, E.Message,mtError,
[mbCancel],0);
end;//try-except
finally
FreeAndNil(SearchForm);
SearchResultsView.EndUpdate;
SearchResultsView.ShowOnTop;
end;//finally
finally
FreeAndNil(TheFileList);
end;//finally
//only if file exists on disk
if FilenameIsAbsolute(Editors[i].FileName) and
FileExists(Editors[i].FileName) then
begin
TheFileList.Add(Editors[i].FileName);
end;//if
end;//for
SearchForm:= FIFCreateSearchForm(ADialog);
SearchForm.SearchFileList:= TheFileList;
DoFindInFiles(SearchForm);
finally
FreeAndNil(TheFileList);
FreeAndNil(SearchForm);
end;//finally
end;//FIFSearchOpenFiles
{Creates the search form and loads the options selected in the
findinfilesdialog}
function TSourceNoteBook.FIFCreateSearchForm
(ADialog: TLazFindInFilesDialog): TSearchForm;
begin
result:= TSearchForm.Create(SearchResultsView);
with result do
begin
SearchOptions:= ADialog.Options;
SearchText:= ADialog.FindText;
SearchMask:= ADialog.FileMaskComboBox.Text;
SearchDirectory:= ADialog.DirectoryComboBox.Text;
end;//with
end;//FIFCreateSearchForm
Procedure TSourceNotebook.FindInFiles(AProject: TProject);
Begin
if FindInFilesDialog=nil then
FindInFilesDialog:=CreateFindInFilesDialog;
if FindInFilesDialog.ShowModal=mrOk then
begin
SaveFindInFilesHistory(FindInFilesDialog);
LoadFindInFilesHistory(FindInFilesDialog);
if FindInFilesDialog.FindText <>'' then
begin
case FindInFilesDialog.WhereRadioGroup.ItemIndex of
Integer(0): FIFSearchProject(AProject, FindInFilesDialog);
integer(1): FIFSearchOpenFiles(FindInFilesDialog);
integer(2): FIFSearchDir(FindInFilesDialog);
end;//case
end;//if
end;//if
End;//FindInFilesClicked