mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-23 11:59:30 +01:00
added search result window from Jason
git-svn-id: trunk@4779 -
This commit is contained in:
parent
a8e9adf180
commit
436be6d5bc
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -447,6 +447,7 @@ ide/publishprojectdlg.lfm svneol=native#text/plain
|
||||
ide/publishprojectdlg.lrs svneol=native#text/pascal
|
||||
ide/publishprojectdlg.pas svneol=native#text/pascal
|
||||
ide/runparamsopts.pas svneol=native#text/pascal
|
||||
ide/searchresultview.pp svneol=native#text/pascal
|
||||
ide/showcompileropts.lfm svneol=native#text/plain
|
||||
ide/showcompileropts.lrs svneol=native#text/pascal
|
||||
ide/showcompileropts.pas svneol=native#text/pascal
|
||||
|
||||
@ -2223,7 +2223,7 @@ begin
|
||||
ACanvas.Font.Color := clHighlightText;
|
||||
end
|
||||
else begin
|
||||
ACanvas.Color := clWindow;
|
||||
ACanvas.Color := clwhite{clWindow};
|
||||
ACanvas.Font.Color := clWindowText;
|
||||
end;
|
||||
ACanvas.FillRect(ARect);
|
||||
|
||||
@ -1480,7 +1480,55 @@ begin
|
||||
DefBGCol:=$50a0ff;
|
||||
DefFGCol:=clBlack;
|
||||
end;
|
||||
end else begin
|
||||
end
|
||||
else if lowercase(SynColorScheme)='ocean' then begin
|
||||
// default for ocean color scheme
|
||||
DefBGCol:=clNavy;
|
||||
DefFGCol:=clYellow;
|
||||
if AttriName='Assembler' then begin
|
||||
DefFGCol:=clLime;
|
||||
end else if AttriName='Comment' then begin
|
||||
DefFGCol:=clGray;
|
||||
end else if AttriName='Directive' then begin
|
||||
DefFGCol:=clRed;
|
||||
end else if AttriName='Reserved word' then begin
|
||||
DefFGCol:=clAqua;
|
||||
DefFontStyles:=[fsBold];
|
||||
end else if AttriName='Number' then begin
|
||||
DefFGCol:=clFuchsia;
|
||||
end else if AttriName='String' then begin
|
||||
DefFGCol:=clYellow;
|
||||
end else if AttriName='Symbol' then begin
|
||||
DefFGCol:=clAqua;
|
||||
end else if AttriName=AdditionalHighlightAttributes[ahaTextBlock] then begin
|
||||
DefBGCol:=clWhite;
|
||||
DefFGCol:=clBlack
|
||||
end else if AttriName=AdditionalHighlightAttributes[ahaExecutionPoint]
|
||||
then begin
|
||||
DefBGCol:=clBlue;
|
||||
DefFGCol:=clWhite;
|
||||
end else if AttriName=AdditionalHighlightAttributes[ahaEnabledBreakpoint]
|
||||
then begin
|
||||
DefBGCol:=clRed;
|
||||
DefFGCol:=clWhite;
|
||||
end else if AttriName=AdditionalHighlightAttributes[ahaDisabledBreakpoint]
|
||||
then begin
|
||||
DefBGCol:=clLime;
|
||||
DefFGCol:=clRed;
|
||||
end else if AttriName=AdditionalHighlightAttributes[ahaInvalidBreakpoint]
|
||||
then begin
|
||||
DefBGCol:=clOlive;
|
||||
DefFGCol:=clGreen;
|
||||
end else if AttriName=AdditionalHighlightAttributes[ahaUnknownBreakpoint]
|
||||
then begin
|
||||
DefBGCol:=clRed;
|
||||
DefFGCol:=clBlack;
|
||||
end else if AttriName=AdditionalHighlightAttributes[ahaErrorLine] then begin
|
||||
DefBGCol:=$50a0ff;
|
||||
DefFGCol:=clBlack;
|
||||
end;
|
||||
end
|
||||
else begin
|
||||
// default for all other color schemes
|
||||
if AttriName='Assembler' then begin
|
||||
DefFGCol:=clGreen;
|
||||
@ -4353,6 +4401,7 @@ begin
|
||||
// ToDo: fill also with custom color schemes
|
||||
Add(DefaultColorScheme);
|
||||
Add('Twilight');
|
||||
Add('Ocean');
|
||||
EndUpdate;
|
||||
end;
|
||||
Text:=DefaultColorScheme;
|
||||
|
||||
@ -53,7 +53,9 @@ type
|
||||
nmiwBreakPoints,
|
||||
nmiwWatches,
|
||||
nmiwLocals,
|
||||
nmiwCallStack
|
||||
nmiwCallStack,
|
||||
nmiwSearchResultsViewName
|
||||
|
||||
);
|
||||
|
||||
// form names for non modal IDE windows:
|
||||
@ -74,7 +76,8 @@ const
|
||||
'BreakPoints',
|
||||
'Watches',
|
||||
'Locals',
|
||||
'CallStack'
|
||||
'CallStack',
|
||||
'SearchResults'
|
||||
);
|
||||
|
||||
type
|
||||
|
||||
@ -148,6 +148,7 @@ const
|
||||
ecViewUnitDependencies = ecUserFirst + 311;
|
||||
ecToggleLocals = ecUserFirst + 312;
|
||||
ecToggleCallStack = ecUserFirst + 313;
|
||||
ecToggleSearchResults = ecUserFirst + 314;
|
||||
|
||||
// sourcenotebook commands
|
||||
ecGotoEditor1 = ecUserFirst + 350;
|
||||
@ -618,6 +619,7 @@ begin
|
||||
ecToggleSourceEditor: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
ecToggleCodeExpl: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
ecToggleMessages: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
ecToggleSearchResults: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
ecToggleWatches: SetResult(VK_W,[ssCtrl,ssAlt],VK_UNKNOWN,[]);
|
||||
ecToggleBreakPoints: SetResult(VK_B,[ssCtrl,ssAlt],VK_UNKNOWN,[]);
|
||||
ecToggleLocals: SetResult(VK_L,[ssCtrl,ssAlt],VK_UNKNOWN,[]);
|
||||
@ -1139,6 +1141,7 @@ begin
|
||||
ecToggleSourceEditor : Result:= srkmecToggleSourceEditor;
|
||||
ecToggleCodeExpl : Result:= srkmecToggleCodeExpl;
|
||||
ecToggleMessages : Result:= srkmecToggleMessages;
|
||||
ecToggleSearchResults : Result:= srkmecToggleSearchResults;
|
||||
ecToggleWatches : Result:= srkmecToggleWatches;
|
||||
ecToggleBreakPoints : Result:= srkmecToggleBreakPoints;
|
||||
ecToggleDebuggerOut : Result:= srkmecToggleDebuggerOut;
|
||||
@ -2022,6 +2025,7 @@ begin
|
||||
AddDefault(C,'Toggle view Source Editor',ecToggleSourceEditor);
|
||||
AddDefault(C,'Toggle view Code Explorer',ecToggleCodeExpl);
|
||||
AddDefault(C,'Toggle view Messages',ecToggleMessages);
|
||||
AddDefault(C,'Toggle view Search Results',ecToggleSearchResults);
|
||||
AddDefault(C,'Toggle view Watches',ecToggleWatches);
|
||||
AddDefault(C,'Toggle view Breakpoints',ecToggleBreakPoints);
|
||||
AddDefault(C,'Toggle view Local Variables',ecToggleLocals);
|
||||
|
||||
@ -177,6 +177,7 @@ resourcestring
|
||||
lisMenuViewUnitDependencies = 'View Unit Dependencies';
|
||||
lisMenuViewToggleFormUnit = 'Toggle form/unit view';
|
||||
lisMenuViewMessages = 'Messages';
|
||||
lisMenuViewSearchResults = 'Search Results';
|
||||
lisMenuDebugWindows = 'Debug windows';
|
||||
lisMenuViewWatches = 'Watches';
|
||||
lisMenuViewBreakPoints = 'BreakPoints';
|
||||
@ -1130,6 +1131,7 @@ resourcestring
|
||||
srkmecToggleSourceEditor = 'View Source Editor';
|
||||
srkmecToggleCodeExpl = 'View Code Explorer';
|
||||
srkmecToggleMessages = 'View messages';
|
||||
srkmecToggleSearchResults = 'View Search Results';
|
||||
srkmecToggleWatches = 'View watches';
|
||||
srkmecToggleBreakPoints = 'View breakpoints';
|
||||
srkmecToggleDebuggerOut = 'View debugger output';
|
||||
|
||||
153
ide/main.pp
153
ide/main.pp
@ -75,10 +75,10 @@ uses
|
||||
CodeToolsDefines, DiffDialog, DiskDiffsDialog, UnitInfoDlg, EditorOptions,
|
||||
ViewUnit_dlg,
|
||||
// rest of the ide
|
||||
Splash, IDEDefs, LazarusIDEStrConsts, LazConf, MsgView, PublishModule,
|
||||
EnvironmentOpts, TransferMacros, KeyMapping, IDEProcs, ExtToolDialog,
|
||||
ExtToolEditDlg, MacroPromptDlg, OutputFilter, BuildLazDialog, MiscOptions,
|
||||
InputHistory, UnitDependencies, ClipBoardHistory, ProcessList,
|
||||
Splash, IDEDefs, LazarusIDEStrConsts, LazConf, MsgView, SearchResultView,
|
||||
PublishModule, EnvironmentOpts, TransferMacros, KeyMapping, IDEProcs,
|
||||
ExtToolDialog, ExtToolEditDlg, MacroPromptDlg, OutputFilter, BuildLazDialog,
|
||||
MiscOptions, InputHistory, UnitDependencies, ClipBoardHistory, ProcessList,
|
||||
InitialSetupDlgs, NewDialog, MakeResStrDlg, ToDoList, AboutFrm, DialogProcs,
|
||||
FindReplaceDialog, FindInFilesDlg, CodeExplorer, BuildFileDlg, ExtractProcDlg,
|
||||
DelphiUnit2Laz,
|
||||
@ -171,6 +171,7 @@ type
|
||||
procedure mnuViewUnitDependenciesClicked(Sender : TObject);
|
||||
procedure mnuViewCodeExplorerClick(Sender : TObject);
|
||||
procedure mnuViewMessagesClick(Sender : TObject);
|
||||
procedure mnuViewSearchResultsClick(Sender : TObject);
|
||||
procedure mnuToggleFormUnitClicked(Sender : TObject);
|
||||
|
||||
// project menu
|
||||
@ -366,6 +367,11 @@ type
|
||||
procedure MessagesViewSelectionChanged(sender : TObject);
|
||||
procedure MessageViewDblClick(Sender : TObject);
|
||||
|
||||
//SearchResultsView events
|
||||
procedure SearchResultsViewSelectionChanged(sender : TObject);
|
||||
procedure SearchResultsViewDblClick(Sender : TObject);
|
||||
|
||||
|
||||
// External Tools events
|
||||
procedure OnExtToolNeedsOutputFilter(var OutputFilter: TOutputFilter;
|
||||
var Abort: boolean);
|
||||
@ -638,7 +644,14 @@ type
|
||||
// methods for debugging, compiling and external tools
|
||||
function DoJumpToCompilerMessage(Index:integer;
|
||||
FocusEditor: boolean): boolean;
|
||||
|
||||
function DoJumpToSearchResult(Index:integer;
|
||||
FocusEditor: boolean): boolean;
|
||||
|
||||
|
||||
procedure DoShowMessagesView;
|
||||
procedure DoShowSearchResultsView;
|
||||
|
||||
procedure DoArrangeSourceEditorAndMessageView(PutOnTop: boolean);
|
||||
function GetTestBuildDir: string; override;
|
||||
function GetProjectTargetFilename: string;
|
||||
@ -905,6 +918,7 @@ end;
|
||||
procedure TMainIDE.CreateOftenUsedForms;
|
||||
begin
|
||||
Application.CreateForm(TMessagesView, MessagesView);
|
||||
Application.CreateForm(TSearchResultsView, SearchResultsView);
|
||||
Application.CreateForm(TLazFindReplaceDialog, FindReplaceDlg);
|
||||
end;
|
||||
|
||||
@ -1490,6 +1504,7 @@ begin
|
||||
itmViewUnitDependencies.OnClick := @mnuViewUnitDependenciesClicked;
|
||||
itmViewToggleFormUnit.OnClick := @mnuToggleFormUnitClicked;
|
||||
itmViewMessage.OnClick := @mnuViewMessagesClick;
|
||||
itmViewSearchResults.OnClick := @mnuViewSearchResultsClick;
|
||||
end;
|
||||
|
||||
procedure TMainIDE.SetupProjectMenu;
|
||||
@ -2180,6 +2195,12 @@ Begin
|
||||
MessagesView.ShowOnTop;
|
||||
End;
|
||||
|
||||
Procedure TMainIDE.mnuViewSearchResultsClick(Sender : TObject);
|
||||
Begin
|
||||
SearchResultsView.ShowOnTop;
|
||||
End;
|
||||
|
||||
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
|
||||
@ -2732,6 +2753,12 @@ Begin
|
||||
|
||||
end;
|
||||
|
||||
Procedure TMainIDE.SearchResultsViewDblClick(Sender : TObject);
|
||||
Begin
|
||||
|
||||
end;
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
||||
function TMainIDE.CreateNewCodeBuffer(NewUnitType:TNewUnitType;
|
||||
@ -4580,7 +4607,7 @@ begin
|
||||
end;
|
||||
|
||||
Result:=mrOk;
|
||||
writeln('TMainIDE.DoOpenEditorFile END "',AFilename,'"');
|
||||
//writeln('TMainIDE.DoOpenEditorFile END "',AFilename,'"');
|
||||
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.DoOpenEditorFile END');{$ENDIF}
|
||||
end;
|
||||
|
||||
@ -7316,6 +7343,94 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TMainIDE.DoJumpToSearchResult(Index:integer;
|
||||
FocusEditor: boolean): boolean;
|
||||
var MaxSearchResults: integer;
|
||||
Filename, SearchedFilename: string;
|
||||
CaretXY: TPoint;
|
||||
TopLine: integer;
|
||||
MsgType: TErrorType;
|
||||
SrcEdit: TSourceEditor;
|
||||
OpenFlags: TOpenFlags;
|
||||
CurMsg, CurDir: string;
|
||||
NewFilename: String;
|
||||
begin
|
||||
Result:=false;
|
||||
MaxSearchResults:=SearchResultsView.SearchResultView.Items.Count;
|
||||
if Index>=MaxSearchResults then exit;
|
||||
if (Index<0) then begin
|
||||
// search relevant searchresult (first error, first fatal) <- this bit needs changing
|
||||
Index:=0;
|
||||
while (Index<MaxSearchResults) do begin
|
||||
if (TheOutputFilter.GetSourcePosition(
|
||||
SearchResultsView.SearchResultView.Items[Index],
|
||||
Filename,CaretXY,MsgType)) then
|
||||
begin
|
||||
if MsgType in [etError,etFatal,etPanic] then break;
|
||||
end;
|
||||
inc(Index);
|
||||
end;
|
||||
if Index>=MaxSearchResults then exit;
|
||||
SearchResultsView.SelectedSearchResultIndex:=Index;
|
||||
end;
|
||||
SearchResultsView.GetSearchResultAt(Index,CurMsg,CurDir);
|
||||
if TheOutputFilter.GetSourcePosition(CurMsg,Filename,CaretXY,MsgType)
|
||||
then begin
|
||||
if not FilenameIsAbsolute(Filename) then begin
|
||||
NewFilename:=AppendPathDelim(CurDir)+Filename;
|
||||
if FileExists(NewFilename) then
|
||||
Filename:=NewFilename;
|
||||
end;
|
||||
|
||||
OpenFlags:=[ofOnlyIfExists,ofRegularFile];
|
||||
if IsTestUnitFilename(Filename) then begin
|
||||
SearchedFilename := ExtractFileName(Filename);
|
||||
Include(OpenFlags,ofVirtualFile);
|
||||
end else begin
|
||||
SearchedFilename := FindUnitFile(Filename);
|
||||
end;
|
||||
|
||||
if SearchedFilename<>'' then begin
|
||||
// open the file in the source editor
|
||||
Result:=(DoOpenEditorFile(SearchedFilename,-1,OpenFlags)=mrOk);
|
||||
if Result then begin
|
||||
// set caret position
|
||||
SourceNotebook.AddJumpPointClicked(Self);
|
||||
SrcEdit:=SourceNoteBook.GetActiveSE;
|
||||
if CaretXY.Y>SrcEdit.EditorComponent.Lines.Count then
|
||||
CaretXY.Y:=SrcEdit.EditorComponent.Lines.Count;
|
||||
TopLine:=CaretXY.Y-(SrcEdit.EditorComponent.LinesInWindow div 2);
|
||||
if TopLine<1 then TopLine:=1;
|
||||
if FocusEditor then begin
|
||||
//SourceNotebook.BringToFront;
|
||||
SearchResultsView.ShowOnTop;
|
||||
SourceNoteBook.ShowOnTop;
|
||||
SourceNotebook.FocusEditor;
|
||||
end;
|
||||
SrcEdit.EditorComponent.CaretXY:=CaretXY;
|
||||
SrcEdit.EditorComponent.TopLine:=TopLine;
|
||||
with SrcEdit.EditorComponent do begin
|
||||
BlockBegin:=CaretXY;
|
||||
BlockEnd:=CaretXY;
|
||||
LeftChar:=Max(CaretXY.X-CharsInWindow,1);
|
||||
end;
|
||||
SrcEdit.ErrorLine:=CaretXY.Y;
|
||||
end;
|
||||
end else begin
|
||||
if FilenameIsAbsolute(Filename) then begin
|
||||
MessageDlg(Format(lisUnableToFindFile, ['"', Filename, '"']),
|
||||
mtInformation,[mbOk],0)
|
||||
end else begin
|
||||
MessageDlg(Format(
|
||||
lisUnableToFindFileCheckSearchPathInRunCompilerOption, ['"',
|
||||
Filename, '"', #13, #13]),
|
||||
mtInformation,[mbOk],0);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TMainIDE.DoShowMessagesView;
|
||||
var
|
||||
WasVisible: boolean;
|
||||
@ -7335,6 +7450,25 @@ begin
|
||||
MessagesView.OnSelectionChanged := @MessagesViewSelectionChanged;
|
||||
end;
|
||||
|
||||
procedure TMainIDE.DoShowSearchResultsView;
|
||||
var
|
||||
WasVisible: boolean;
|
||||
ALayout: TIDEWindowLayout;
|
||||
begin
|
||||
WasVisible := SearchResultsView.Visible;
|
||||
SearchResultsView.Visible:=true;
|
||||
ALayout:=EnvironmentOptions.IDEWindowLayoutList.
|
||||
ItemByEnum(nmiwSearchResultsViewName);
|
||||
ALayout.Apply;
|
||||
if not WasVisible then
|
||||
// the sourcenotebook is more interesting than the messages
|
||||
SourceNotebook.ShowOnTop;
|
||||
|
||||
//set the event here for the selectionchanged event
|
||||
if not assigned(SearchresultsView.OnSelectionChanged) then
|
||||
SearchresultsView.OnSelectionChanged := @SearchresultsViewSelectionChanged;
|
||||
end;
|
||||
|
||||
procedure TMainIDE.DoArrangeSourceEditorAndMessageView(PutOnTop: boolean);
|
||||
begin
|
||||
DoShowMessagesView;
|
||||
@ -8909,6 +9043,12 @@ begin
|
||||
DoJumpToCompilerMessage(TMessagesView(Sender).SelectedMessageIndex,True);
|
||||
end;
|
||||
|
||||
procedure TMainIDE.SearchResultsViewSelectionChanged(sender : TObject);
|
||||
begin
|
||||
DoJumpToSearchREsult(TSearchREsultsView(Sender).SelectedSearchResultIndex,True);
|
||||
end;
|
||||
|
||||
|
||||
Procedure TMainIDE.OnSrcNotebookEditorVisibleChanged(Sender : TObject);
|
||||
var
|
||||
ActiveUnitInfo : TUnitInfo;
|
||||
@ -9942,6 +10082,9 @@ end.
|
||||
|
||||
{ =============================================================================
|
||||
$Log$
|
||||
Revision 1.665 2003/11/08 11:16:45 mattias
|
||||
added search result window from Jason
|
||||
|
||||
Revision 1.664 2003/11/07 16:29:59 mattias
|
||||
implemented Break Lines in Selection
|
||||
|
||||
|
||||
@ -266,6 +266,7 @@ type
|
||||
itmViewForms : TMenuItem;
|
||||
itmViewUnitDependencies : TMenuItem;
|
||||
itmViewMessage : TMenuItem;
|
||||
itmViewSearchResults : TMenuItem;
|
||||
itmViewDebugWindows: TMenuItem;
|
||||
itmViewWatches: TMenuItem;
|
||||
itmViewBreakpoints: TMenuItem;
|
||||
@ -1000,6 +1001,11 @@ begin
|
||||
itmViewMessage.Caption := lisMenuViewMessages;
|
||||
mnuView.Add(itmViewMessage);
|
||||
|
||||
itmViewSearchResults := TMenuItem.Create(Self);
|
||||
itmViewSearchResults.Name:='itmViewSearchResults';
|
||||
itmViewSearchResults.Caption := lisMenuViewSearchResults;
|
||||
mnuView.Add(itmViewSearchResults);
|
||||
|
||||
itmViewDebugWindows := TMenuItem.Create(Self);
|
||||
itmViewDebugWindows.Name := 'itmViewDebugWindows';
|
||||
itmViewDebugWindows.Caption := lisMenuDebugWindows;
|
||||
@ -1463,6 +1469,7 @@ begin
|
||||
itmViewForms.ShortCut:=CommandToShortCut(ecViewForms);
|
||||
itmViewToggleFormUnit.ShortCut:=CommandToShortCut(ecToggleFormUnit);
|
||||
itmViewMessage.ShortCut:=CommandToShortCut(ecToggleMessages);
|
||||
itmViewSearchResults.ShortCut:=CommandToShortCut(ecToggleSearchResults);
|
||||
|
||||
// project menu
|
||||
itmProjectNew.ShortCut:=CommandToShortCut(ecNewProject);
|
||||
|
||||
308
ide/searchresultview.pp
Normal file
308
ide/searchresultview.pp
Normal file
@ -0,0 +1,308 @@
|
||||
{
|
||||
/***************************************************************************
|
||||
searchresultviewView.pp - SearchResult view
|
||||
-------------------------------------------
|
||||
TSearchResultsView is responsible for displaying the
|
||||
Search Results of a find operation.
|
||||
|
||||
|
||||
Initial Revision : Sat Nov 8th 2003
|
||||
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* This source is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This code is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* General Public License for more details. *
|
||||
* *
|
||||
* A copy of the GNU General Public License is available on the World *
|
||||
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
|
||||
* obtain it by writing to the Free Software Foundation, *
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
* *
|
||||
***************************************************************************
|
||||
}
|
||||
unit SearchResultView;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Controls, StdCtrls, Forms, LResources, IDEProcs,
|
||||
IDEOptionDefs, EnvironmentOpts, LazarusIDEStrConsts;
|
||||
|
||||
type
|
||||
TSearchResultsView = class(TForm)
|
||||
SearchResultView : TListBox;
|
||||
procedure SearchResultViewDblClicked(Sender: TObject);
|
||||
Procedure SearchResultViewClicked(sender : TObject);
|
||||
private
|
||||
FDirectories: TStringList;
|
||||
FLastLineIsProgress: boolean;
|
||||
FOnSelectionChanged: TNotifyEvent;
|
||||
function GetDirectory: string;
|
||||
Function GetSearchResult: String;
|
||||
procedure SetLastLineIsProgress(const AValue: boolean);
|
||||
protected
|
||||
fBlockCount: integer;
|
||||
Function GetSelectedLineIndex: Integer;
|
||||
procedure SetSelectedLineIndex(const AValue: Integer);
|
||||
procedure SetMsgDirectory(Index: integer; const CurDir: string);
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
procedure Add(const Msg, CurDir: String; ProgressLine: boolean);
|
||||
procedure AddMsg(const Msg, CurDir: String);
|
||||
procedure AddProgress(const Msg, CurDir: String);
|
||||
procedure AddSeparator;
|
||||
procedure ClearTillLastSeparator;
|
||||
procedure ShowTopSearchResult;
|
||||
function MsgCount: integer;
|
||||
procedure Clear;
|
||||
procedure GetSearchResultAt(Index: integer; var Msg, MsgDirectory: string);
|
||||
procedure BeginBlock;
|
||||
procedure EndBlock;
|
||||
public
|
||||
property LastLineIsProgress: boolean read FLastLineIsProgress
|
||||
write SetLastLineIsProgress;
|
||||
property SearchResult: String read GetSearchResult;
|
||||
property Directory: string read GetDirectory;
|
||||
property SelectedSearchResultIndex: Integer read GetSelectedLineIndex
|
||||
write SetSelectedLineIndex;
|
||||
property OnSelectionChanged: TNotifyEvent read FOnSelectionChanged
|
||||
write FOnSelectionChanged;
|
||||
end;
|
||||
|
||||
var
|
||||
SearchResultsView: TSearchResultsView;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
const SeparatorLine = '---------------------------------------------';
|
||||
|
||||
{ TSearchResultsView }
|
||||
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
TSearchResultsView.Create
|
||||
------------------------------------------------------------------------------}
|
||||
constructor TSearchResultsView.Create(TheOwner : TComponent);
|
||||
var ALayout: TIDEWindowLayout;
|
||||
Begin
|
||||
inherited Create(TheOwner);
|
||||
if LazarusResources.Find(ClassName)=nil then begin
|
||||
Caption:=lisMenuViewSearchResults;
|
||||
SearchResultView := TListBox.Create(Self);
|
||||
With SearchResultView do Begin
|
||||
Parent:= Self;
|
||||
Align:= alClient;
|
||||
end;
|
||||
end;
|
||||
Name := NonModalIDEWindowNames[nmiwSearchResultsViewName];
|
||||
ALayout:=EnvironmentOptions.IDEWindowLayoutList.
|
||||
ItemByEnum(nmiwSearchResultsViewName);
|
||||
ALayout.Form:=TForm(Self);
|
||||
ALayout.Apply;
|
||||
end;
|
||||
|
||||
destructor TSearchResultsView.Destroy;
|
||||
begin
|
||||
FreeAndNil(FDirectories);
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
TSearchResultsView.Add
|
||||
------------------------------------------------------------------------------}
|
||||
Procedure TSearchResultsView.Add(const Msg, CurDir: String; ProgressLine: boolean);
|
||||
var
|
||||
i: Integer;
|
||||
Begin
|
||||
if FLastLineIsProgress then begin
|
||||
SearchResultView.Items[SearchResultView.Items.Count-1]:=Msg;
|
||||
end else begin
|
||||
SearchResultView.Items.Add(Msg);
|
||||
end;
|
||||
FLastLineIsProgress:=ProgressLine;
|
||||
i:=SearchResultView.Items.Count-1;
|
||||
SetMsgDirectory(i,CurDir);
|
||||
SearchResultView.TopIndex:=SearchResultView.Items.Count-1;
|
||||
end;
|
||||
|
||||
procedure TSearchResultsView.AddMsg(const Msg, CurDir: String);
|
||||
begin
|
||||
Add(Msg,CurDir,false);
|
||||
end;
|
||||
|
||||
procedure TSearchResultsView.AddProgress(const Msg, CurDir: String);
|
||||
begin
|
||||
Add(Msg,CurDir,true);
|
||||
end;
|
||||
|
||||
Procedure TSearchResultsView.AddSeparator;
|
||||
begin
|
||||
Add(SeparatorLine,'',false);
|
||||
end;
|
||||
|
||||
procedure TSearchResultsView.ClearTillLastSeparator;
|
||||
var LastSeparator: integer;
|
||||
begin
|
||||
with SearchResultView do begin
|
||||
LastSeparator:=Items.Count-1;
|
||||
while (LastSeparator>=0) and (Items[LastSeparator]<>SeparatorLine) do
|
||||
dec(LastSeparator);
|
||||
if LastSeparator>=0 then begin
|
||||
while (Items.Count>LastSeparator) do
|
||||
Items.Delete(Items.Count-1);
|
||||
FLastLineIsProgress:=false;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSearchResultsView.ShowTopSearchResult;
|
||||
begin
|
||||
if SearchResultView.Items.Count>0 then
|
||||
SearchResultView.TopIndex:=0;
|
||||
end;
|
||||
|
||||
function TSearchResultsView.MsgCount: integer;
|
||||
begin
|
||||
Result:=SearchResultView.Items.Count;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
TSearchResultsView.Clear
|
||||
------------------------------------------------------------------------------}
|
||||
Procedure TSearchResultsView.Clear;
|
||||
Begin
|
||||
if fBlockCount>0 then exit;
|
||||
SearchResultView.Clear;
|
||||
FLastLineIsProgress:=false;
|
||||
if not Assigned(SearchResultsView.SearchResultView.OnClick) then
|
||||
SearchResultView.OnClick := @SearchResultViewClicked;
|
||||
if not Assigned(SearchResultsView.SearchResultView.OnDblClick) then
|
||||
SearchResultView.OnDblClick :=@SearchResultViewDblClicked;
|
||||
end;
|
||||
|
||||
procedure TSearchResultsView.GetSearchResultAt(Index: integer;
|
||||
var Msg, MsgDirectory: string);
|
||||
begin
|
||||
// consistency checks
|
||||
if (Index<0) then
|
||||
RaiseException('TSearchResultsView.GetSearchResultAt');
|
||||
if SearchResultView.Items.Count<=Index then
|
||||
RaiseException('TSearchResultsView.GetSearchResultAt');
|
||||
if (FDirectories=nil) then
|
||||
RaiseException('TSearchResultsView.GetSearchResultAt');
|
||||
if (FDirectories.Count<=Index) then
|
||||
RaiseException('TSearchResultsView.GetSearchResultAt');
|
||||
Msg:=SearchResultView.Items[Index];
|
||||
MsgDirectory:=FDirectories[Index];
|
||||
end;
|
||||
|
||||
procedure TSearchResultsView.BeginBlock;
|
||||
begin
|
||||
Clear;
|
||||
inc(fBlockCount);
|
||||
end;
|
||||
|
||||
procedure TSearchResultsView.EndBlock;
|
||||
begin
|
||||
if fBlockCount<=0 then RaiseException('TSearchResultsView.EndBlock Internal Error');
|
||||
dec(fBlockCount);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
TSearchResultsView.GetSearchResult
|
||||
------------------------------------------------------------------------------}
|
||||
Function TSearchResultsView.GetSearchResult: String;
|
||||
Begin
|
||||
Result := '';
|
||||
if (SearchResultView.Items.Count > 0) and (SearchResultView.SelCount > 0) then
|
||||
Result := SearchResultView.Items.Strings[GetSelectedLineIndex];
|
||||
end;
|
||||
|
||||
procedure TSearchResultsView.SearchResultViewDblClicked(Sender: TObject);
|
||||
begin
|
||||
if not EnvironmentOptions.MsgViewDblClickJumps then exit;
|
||||
if (SearchResultView.Items.Count > 0) and (SearchResultView.SelCount > 0) then Begin
|
||||
If Assigned(OnSelectionChanged) then
|
||||
OnSelectionChanged(self);
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure TSearchResultsView.SearchResultViewClicked(sender : TObject);
|
||||
begin
|
||||
if EnvironmentOptions.MsgViewDblClickJumps then exit;
|
||||
if (SearchResultView.Items.Count > 0) and (SearchResultView.SelCount > 0) then Begin
|
||||
If Assigned(OnSelectionChanged) then
|
||||
OnSelectionChanged(self);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TSearchResultsView.GetDirectory: string;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
Result := '';
|
||||
i:=GetSelectedLineIndex;
|
||||
if (FDirectories<>nil) and (FDirectories.Count>i) then
|
||||
Result := FDirectories[i];
|
||||
end;
|
||||
|
||||
Function TSearchResultsView.GetSelectedLineIndex : Integer;
|
||||
var
|
||||
I : Integer;
|
||||
Begin
|
||||
Result := -1;
|
||||
if (SearchResultView.Items.Count > 0) and (SearchResultView.SelCount > 0) then Begin
|
||||
for i := 0 to SearchResultView.Items.Count-1 do
|
||||
Begin
|
||||
if SearchResultView.Selected[I] then
|
||||
Begin
|
||||
Result := I;
|
||||
Break;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSearchResultsView.SetLastLineIsProgress(const AValue: boolean);
|
||||
begin
|
||||
if FLastLineIsProgress=AValue then exit;
|
||||
if FLastLineIsProgress then
|
||||
SearchResultView.Items.Delete(SearchResultView.Items.Count-1);
|
||||
FLastLineIsProgress:=AValue;
|
||||
end;
|
||||
|
||||
procedure TSearchResultsView.SetSelectedLineIndex(const AValue: Integer);
|
||||
begin
|
||||
SearchResultView.ItemIndex:=AValue;
|
||||
SearchResultView.TopIndex:=SearchResultView.ItemIndex;
|
||||
end;
|
||||
|
||||
procedure TSearchResultsView.SetMsgDirectory(Index: integer; const CurDir: string);
|
||||
begin
|
||||
if FDirectories=nil then FDirectories:=TStringList.Create;
|
||||
while FDirectories.Count<=Index do FDirectories.Add('');
|
||||
FDirectories[Index]:=CurDir;
|
||||
end;
|
||||
|
||||
initialization
|
||||
SearchResultsView:=nil;
|
||||
{ $I msgview.lrs}
|
||||
|
||||
|
||||
end.
|
||||
|
||||
|
||||
@ -52,7 +52,7 @@ uses
|
||||
// IDE units
|
||||
EditorOptions, CustomFormEditor, KeyMapping, FormEditor, Project,
|
||||
FindReplaceDialog, WordCompletion, FindInFilesDlg, IDEProcs, IDEOptionDefs,
|
||||
MsgView, InputHistory, LazarusIDEStrConsts, BaseDebugManager, Debugger,
|
||||
MsgView, SearchResultView, InputHistory, LazarusIDEStrConsts, BaseDebugManager, Debugger,
|
||||
TypInfo, LResources, LazConf, EnvironmentOpts, Compiler,
|
||||
SortSelectionDlg, EncloseSelectionDlg, ClipBoardHistory, DiffDialog,
|
||||
SourceEditProcs, SourceMarks, CharacterMapDlg;
|
||||
@ -3410,8 +3410,10 @@ Begin
|
||||
//text in each file.
|
||||
if TheFileList.Count > 0 then
|
||||
begin
|
||||
MessagesView.Clear;
|
||||
MessagesView.ShowOnTop;
|
||||
{ MessagesView.Clear;
|
||||
MessagesView.ShowOnTop; }
|
||||
SearchResultsView.Clear;
|
||||
SearchResultsView.ShowOnTop;
|
||||
try
|
||||
try
|
||||
TheMatchedFiles:= IDEProcs.FindInFiles(TheFileList,
|
||||
@ -3429,10 +3431,10 @@ Begin
|
||||
//if we matched any files add them to the message window
|
||||
if (TheMatchedFiles<>nil) and (TheMatchedFiles.Count>0) then
|
||||
begin
|
||||
MessagesView.AddSeparator;
|
||||
SearchResultsView.AddSeparator;
|
||||
for i:= 0 to TheMatchedFiles.Count -1 do
|
||||
begin
|
||||
MessagesView.Add(TheMatchedFiles.Strings[i],'',false);
|
||||
SearchResultsView.Add(TheMatchedFiles.Strings[i],'',false);
|
||||
end;//for
|
||||
//Hand off the search to the FindAndReplace Function in the
|
||||
//unit editor.
|
||||
@ -3446,11 +3448,11 @@ Begin
|
||||
end//if
|
||||
else
|
||||
begin
|
||||
MessagesView.Clear;
|
||||
MessagesView.ShowOnTop;
|
||||
MessagesView.AddSeparator;
|
||||
SearchResultsView.Clear;
|
||||
SearchResultsView.ShowOnTop;
|
||||
SearchResultsView.AddSeparator;
|
||||
AText:=Format(lisUESearchStringNotFound,[LocalFindText]);
|
||||
MessagesView.Add(AText,'',false);
|
||||
SearchResultsView.Add(AText,'',false);
|
||||
end;//else
|
||||
finally
|
||||
TheMatchedFiles.Free;
|
||||
@ -3458,10 +3460,10 @@ Begin
|
||||
end//if
|
||||
else
|
||||
begin
|
||||
MessagesView.Clear;
|
||||
MessagesView.ShowOnTop;
|
||||
MessagesView.AddSeparator;
|
||||
MessagesView.Add(lisFileNotFound,'',false);
|
||||
SearchResultsView.Clear;
|
||||
SearchResultsView.ShowOnTop;
|
||||
SearchResultsView.AddSeparator;
|
||||
SearchResultsView.Add(lisFileNotFound,'',false);
|
||||
end;//else
|
||||
finally
|
||||
TheFileList.Free;
|
||||
@ -3469,11 +3471,11 @@ Begin
|
||||
end//if
|
||||
else
|
||||
begin
|
||||
MessagesView.Clear;
|
||||
MessagesView.ShowOnTop;
|
||||
MessagesView.AddSeparator;
|
||||
SearchResultsView.Clear;
|
||||
SearchResultsView.ShowOnTop;
|
||||
SearchResultsView.AddSeparator;
|
||||
AText:=Format(lisUESearchStringNotFound,[LocalFindText]);
|
||||
MessagesView.Add(AText,'',false);
|
||||
SearchResultsView.Add(AText,'',false);
|
||||
end;//else
|
||||
end;//if
|
||||
End;//FindInFilesClicked
|
||||
|
||||
Loading…
Reference in New Issue
Block a user