Find in files: showing skipped results

git-svn-id: trunk@9693 -
This commit is contained in:
mattias 2006-07-29 14:09:04 +00:00
parent a582185670
commit 85de8ce1f8
13 changed files with 134 additions and 83 deletions

View File

@ -275,14 +275,14 @@ var
IsHexNumberChar
: array[char] of boolean;
function Min(i1, i2: integer): integer;
function Min(i1, i2: integer): integer; inline;
begin
if i1<i2 then Result:=i1 else Result:=i2;
if i1<=i2 then Result:=i1 else Result:=i2;
end;
function Max(i1, i2: integer): integer;
function Max(i1, i2: integer): integer; inline;
begin
if i1>i2 then Result:=i1 else Result:=i2;
if i1>=i2 then Result:=i1 else Result:=i2;
end;
{ most simple code tools - just methods }
@ -1981,8 +1981,14 @@ var
begin
while StartPos<EndPos do begin
case Src[StartPos] of
'{','/':
'{':
ReadComment;
'/':
if (StartPos<SrcLen) and (Src[StartPos]='/') then
ReadComment
else
inc(StartPos);
'(':
if (StartPos<SrcLen) and (Src[StartPos]='*') then

View File

@ -138,6 +138,7 @@ type
property AutoResizeViewport;
property BorderSpacing;
property Enabled;
property OnChangeBounds;
property OnClick;
property OnConstrainedResize;
property OnDblClick;

View File

@ -42,7 +42,8 @@ interface
uses
{$IFDEF SYN_LAZARUS}
Math, LCLProc, LCLIntf, LCLType, SynEditTextBuffer, Messages, LMessages,
LCLProc, LCLIntf, LCLType, SynEditTextBuffer, Messages, LMessages,
SynEditMiscProcs,
{$ELSE}
Windows, SynEditTypes, Messages,
{$ENDIF}

View File

@ -658,14 +658,6 @@ implementation
const MaxComboBoxCount: integer = 20;
function Max(i, j: integer): integer;
begin
if i<=j then
Result:=j
else
Result:=i;
end;
function DebuggerNameToType(const s: string): TDebuggerType;
begin
for Result:=Low(TDebuggerType) to High(TDebuggerType) do

View File

@ -25,7 +25,7 @@ interface
uses
Classes, SysUtils, LCLProc, LCLIntf, Controls, StdCtrls, Forms, Buttons,
ExtCtrls, LResources, FileUtil, LazarusIDEStrConsts, Dialogs, SynEditTypes,
InputHistory;
IDEDialogs, InputHistory;
type
{ TLazFindInFilesDialog }
@ -102,9 +102,11 @@ end;
procedure TLazFindInFilesDialog.DirectoryBrowseClick(Sender: TObject);
begin
InitIDEFileDialog(SelectDirectoryDialog);
SelectDirectoryDialog.InitialDir := GetCurrentDir;
if SelectDirectoryDialog.Execute then
DirectoryComboBox.Text := SelectDirectoryDialog.FileName;
StoreIDEFileDialog(SelectDirectoryDialog);
end;
procedure TLazFindInFilesDialog.FormCreate(Sender: TObject);

View File

@ -440,8 +440,7 @@ begin
OriginalFile:=TSourceLog.Create('');
OriginalFile.LoadFromFile(TheFileName);
end else begin
OriginalFile:=TSourceLog.Create('');
OriginalFile.Source:=TheText;
OriginalFile:=TSourceLog.Create(TheText);
end;
// convert case
@ -583,9 +582,8 @@ begin
TrimmedCurLine:=TrimLineAndMatch(Lines,TrimmedMatch);
MatchLen:=EndPos.X-StartPos.X;
if MatchLen<1 then MatchLen:=1;
SearchResultsView.AddMatch(fResultsWindow,
FileName,StartPos,
TrimmedCurLine, TrimmedMatch, MatchLen);
SearchResultsView.AddMatch(fResultsWindow,FileName,StartPos,
TrimmedCurLine, TrimmedMatch, MatchLen);
UpdateMatches;
end;

View File

@ -1,2 +1,2 @@
// Created by Svn2RevisionInc
const RevisionStr = '9599';
const RevisionStr = '';

View File

@ -88,10 +88,12 @@ type
TLazSearchResultLB = Class(TCustomListBox)
private
fSearchObject: TLazSearch;
FSkipped: integer;
fUpdateStrings: TStrings;
fUpdating: boolean;
fUpdateCount: integer;
fShortenPathNeeded: boolean;
procedure SetSkipped(const AValue: integer);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
@ -101,6 +103,7 @@ type
procedure ShortenPaths;
property UpdateItems: TStrings read fUpdateStrings write fUpdateStrings;
property UpdateState: boolean read fUpdating;
property Skipped: integer read FSkipped write SetSkipped;
end;
@ -130,10 +133,10 @@ type
procedure ListBoxDoubleClicked(Sender: TObject);
procedure SetItems(Index: Integer; Value: TStrings);
function GetItems(Index: integer): TStrings;
fOnSelectionChanged: TNotifyEvent;
fListBoxFont: TFont;
fMouseOverIndex: integer;
procedure SetMaxItems(const AValue: integer);
fOnSelectionChanged: TNotifyEvent;
fListBoxFont: TFont;
fMouseOverIndex: integer;
procedure SetMaxItems(const AValue: integer);
public
function AddSearch(const ResultsName: string;
const SearchText: string;
@ -240,9 +243,15 @@ begin
if Assigned(CurrentLB) then
begin
if CurrentLB.UpdateState then begin
if CurrentLB.UpdateItems.Count>=MaxItems then exit;
if CurrentLB.UpdateItems.Count>=MaxItems then begin
CurrentLB.Skipped:=CurrentLB.Skipped+1;
exit;
end;
end else begin
if CurrentLB.Items.Count>=MaxItems then exit;
if CurrentLB.Items.Count>=MaxItems then begin
CurrentLB.Skipped:=CurrentLB.Skipped+1;
exit;
end;
end;
SearchPos:= TLazSearchMatchPos.Create;
SearchPos.MatchStart:= MatchStart;
@ -317,6 +326,7 @@ begin
CurrentLB.UpdateItems.Assign(Value)
else
CurrentLB.Items.Assign(Value);
CurrentLB.Skipped:=0;
end;//if
end//if
end;//SetItems
@ -395,8 +405,10 @@ end;//PageExists
procedure TSearchResultsView.ListBoxKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = 27 then
if Key = VK_ESCAPE then begin
Key:=VK_UNKNOWN;
Close;
end;
end;
{Add Result will create a tab in the Results view window with an new
@ -419,7 +431,7 @@ begin
With ResultsNoteBook do
begin
i:= GetPageIndex(ResultsName);
if i > -1 then
if i>=0 then
begin
NewListBox:= GetListBox(i);
ResultsNoteBook.PageIndex:= i;
@ -462,6 +474,7 @@ begin
SearchObj.SearchMask:= AMask;
SearchObj.SearchOptions:= TheOptions;
end;
NewListBox.Skipped:=0;
Result:= ResultsNoteBook.PageIndex;
end;//if
end;//AddResult
@ -677,6 +690,36 @@ begin
end;//if
end;//GetListBox
procedure TLazSearchResultLB.SetSkipped(const AValue: integer);
var
SrcList: TStrings;
s: String;
HasSkippedLine: Boolean;
SkippedLine: String;
begin
if FSkipped=AValue then exit;
FSkipped:=AValue;
s:='Found, but not listed here: ';
if fUpdating then
SrcList:=fUpdateStrings
else
SrcList:=Items;
if (SrcList.Count>0) and (copy(SrcList[SrcList.Count-1],1,length(s))=s) then
HasSkippedLine:=true
else
HasSkippedLine:=false;
SkippedLine:=s+IntToStr(FSkipped);
if FSkipped>0 then begin
if HasSkippedLine then begin
SrcList[SrcList.Count-1]:=SkippedLine;
end else begin
SrcList.add(SkippedLine);
end;
end else begin
if HasSkippedLine then
SrcList.Delete(SrcList.Count-1);
end;
end;
{******************************************************************************
TLazSearchResultLB

View File

@ -20,7 +20,7 @@ unit newfield;
interface
uses
LCLIntf, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Classes, SysUtils, DBConst, LCLIntf, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, Buttons, DB, LResources, ComponentEditors,
PropEdits, TypInfo;
@ -86,14 +86,6 @@ var
implementation
uses dbconst;
function min(i,j: integer): integer;
begin
Result := i;
if j<i then Result := j;
end;
procedure SplitFieldsList(FldList: string; AList: TStrings);
const
SplitChars: Array[0..2] of Char = ('+',';',':');

View File

@ -25,7 +25,7 @@ unit extgraphics;
interface
uses Classes, LCLProc, Graphics, math, GraphMath;
uses Classes, LCLProc, Graphics, Math, GraphMath;
type
TShapeDirection = (atUp, atDown, atLeft, atRight);

View File

@ -49,9 +49,9 @@ unit Grids;
interface
uses
Types, Classes, SysUtils, LCLStrConsts, LCLProc, LCLType, LCLIntf, Controls,
GraphType, Graphics, Forms, DynamicArray, LMessages, XMLCfg, StdCtrls,
LResources, MaskEdit, Buttons, Clipbrd;
Types, Classes, SysUtils, Math, LCLStrConsts, LCLProc, LCLType, LCLIntf,
Controls, GraphType, Graphics, Forms, DynamicArray, LMessages, XMLCfg,
StdCtrls, LResources, MaskEdit, Buttons, Clipbrd;
const
//GRIDFILEVERSION = 1; // Original
@ -1322,7 +1322,7 @@ type
end;
procedure DrawRubberRect(Canvas: TCanvas; aRect: TRect; Color: TColor);
procedure DrawRubberRect(Canvas: TCanvas; aRect: TRect; Color: TColor);
procedure Register;
@ -1333,22 +1333,7 @@ function PointIgual(const P1,P2: TPoint): Boolean;
begin
result:=(P1.X=P2.X)and(P1.Y=P2.Y);
end;
{function RectIgual(const R1,R2: TRect): Boolean;
begin
Result:=CompareMem(@R1,@R2, SizeOf(R1));
end;}
function Min(const I,J: Integer): Integer;
begin
if I<J then Result:=I
else Result:=J;
end;
function Max(const I,J: Integer): Integer;
begin
if I>J then Result:=I
else Result:=J;
end;
function NormalizarRect(const R:TRect): TRect;
begin
Result.Left:=Min(R.Left, R.Right);

View File

@ -28,8 +28,8 @@
Frees the widgetinfo.
}
function CarbonPrivateHIView_Dispose(ANextHandler: EventHandlerCallRef;
AEvent: EventRef;
AInfo: PWidgetInfo): OSStatus; {$IFDEF darwin}mwpascal;{$ENDIF}
AEvent: EventRef;
AInfo: PWidgetInfo): OSStatus; {$IFDEF darwin}mwpascal;{$ENDIF}
var
Msg: TLMessage;
PrivateClass: TCarbonPrivateHiViewClass;
@ -46,8 +46,8 @@ begin
end;
function CarbonPrivateHIView_Hit(ANextHandler: EventHandlerCallRef;
AEvent: EventRef;
AInfo: PWidgetInfo): OSStatus; {$IFDEF darwin}mwpascal;{$ENDIF}
AEvent: EventRef;
AInfo: PWidgetInfo): OSStatus; {$IFDEF darwin}mwpascal;{$ENDIF}
var
Msg: TLMessage;
begin
@ -58,53 +58,56 @@ begin
end;
function CarbonPrivateHIView_MouseMove(ANextHandler: EventHandlerCallRef;
AEvent: EventRef;
AInfo: PWidgetInfo): OSStatus; {$IFDEF darwin}mwpascal;{$ENDIF}
AEvent: EventRef;
AInfo: PWidgetInfo): OSStatus; {$IFDEF darwin}mwpascal;{$ENDIF}
begin
DebugLn('CarbonPrivateHIView_MouseMove');
Result := CallNextEventHandler(ANextHandler, AEvent);
end;
function CarbonPrivateHIView_Update(ANextHandler: EventHandlerCallRef;
AEvent: EventRef;
AInfo: PWidgetInfo): OSStatus; {$IFDEF darwin}mwpascal;{$ENDIF}
begin
debugln('CarbonPrivateHIView_Update ');
// first let carbon draw/update
Result := CallNextEventHandler(ANextHandler, AEvent);
end;
// ==================================================================
// C L A S S
// ==================================================================
{ TCarbonWSWinControlPrivate }
(*
class procedure TCarbonPrivateHiView.InstallControlHandler(AInfo: PWidgetInfo; AClass: UInt32; AKind: UInt32; AHandler: Pointer; var AUPP: EventHandlerUPP);
var
eventSpec: EventTypeSpec;
begin
if AUPP = nil
then AUPP := NewEventHandlerUPP(EventHandlerProcPtr(AHandler));
eventSpec := MakeEventSpec(AClass, AKind);
InstallControlEventHandler(AInfo^.Widget, AUPP, 1, eventSpec, Pointer(AInfo), nil);
end;
*)
{ TCarbonWSWinControlPrivate }
class procedure TCarbonPrivateHiView.RegisterEvents(AInfo: PWidgetInfo);
var
MouseSpec: array [0..6] of EventTypeSpec;
TmpSpec: EventTypeSpec;
begin
// TODO, move both to the CarbonPrivateHIView handler
TmpSpec := MakeEventSpec(kEventClassControl, kEventControlDispose);
InstallControlEventHandler(AInfo^.Widget, RegisterEventHandler(@CarbonPrivateHIView_Dispose),
InstallControlEventHandler(AInfo^.Widget,
RegisterEventHandler(@CarbonPrivateHIView_Dispose),
1, @TmpSpec, Pointer(AInfo), nil);
TmpSpec := MakeEventSpec(kEventClassControl, kEventControlHit);
InstallControlEventHandler(AInfo^.Widget, RegisterEventHandler(@CarbonPrivateHIView_Hit),
InstallControlEventHandler(AInfo^.Widget,
RegisterEventHandler(@CarbonPrivateHIView_Hit),
1, @TmpSpec, Pointer(AInfo), nil);
MouseSpec[0] := MakeEventSpec(kEventClassMouse, kEventMouseMoved);
MouseSpec[1] := MakeEventSpec(kEventClassMouse, kEventMouseDragged);
InstallControlEventHandler(AInfo^.Widget, RegisterEventHandler(@CarbonPrivateHIView_MouseMove),
InstallControlEventHandler(AInfo^.Widget,
RegisterEventHandler(@CarbonPrivateHIView_MouseMove),
2, @MouseSpec[0], Pointer(AInfo), nil);
TmpSpec := MakeEventSpec(kEventClassControl, kEventControlDraw);
InstallControlEventHandler(AInfo^.Widget,
RegisterEventHandler(@CarbonPrivateHIView_Update),
1, @TmpSpec, Pointer(AInfo), nil);
// InstallControlHandler(AInfo, kEventClassControl, kEventControlDispose, RegisterEventHandler(@CarbonWSWinControl_Dispose));
// InstallControlHandler(AInfo, kEventClassControl, kEventControlHit, @CarbonWSWinControl_Hit, MCarbonWSWinControl_Hit_UPP);
DebugLN(TWinControl(Ainfo^.LCLObject).Name,':', TWinControl(Ainfo^.LCLObject).ClassName ,' Events set')

View File

@ -102,6 +102,7 @@ var
Msg: TLMessage;
PrivateClass: TCarbonPrivateWindowClass;
begin
//debugln('CarbonPrivateWindow_Closed ',DbgSName(AInfo^.LCLObject));
Result := CallNextEventHandler(ANextHandler, AEvent);
PrivateClass := TCarbonPrivateWindowClass(AInfo^.WSClass.WSPrivate);
@ -825,6 +826,22 @@ begin
end;
end;
function CarbonPrivateWindow_Update(ANextHandler: EventHandlerCallRef;
AEvent: EventRef;
AWindowInfo: PWidgetInfo): OSStatus; {$IFDEF darwin}mwpascal;{$ENDIF}
begin
debugln('CarbonPrivateWindow_Update ',DbgSName(AWindowInfo^.LCLObject));
Result := CallNextEventHandler(ANextHandler, AEvent);
end;
function CarbonPrivateWindow_DrawContent(ANextHandler: EventHandlerCallRef;
AEvent: EventRef;
AWindowInfo: PWidgetInfo): OSStatus; {$IFDEF darwin}mwpascal;{$ENDIF}
begin
debugln('CarbonPrivateWindow_DrawContent ',DbgSName(AWindowInfo^.LCLObject));
Result := CallNextEventHandler(ANextHandler, AEvent);
end;
// ==================================================================
// C L A S S
// ==================================================================
@ -876,6 +893,17 @@ begin
InstallWindowEventHandler(AInfo^.Widget,
RegisterEventHandler(@CarbonPrivateWindow_KeyboardProc),
3, @KeySpecs[0], Pointer(AInfo), nil);
debugln('TCarbonPrivateWindow.RegisterEvents ',DbgSName(AInfo^.LCLObject));
TmpSpec := MakeEventSpec(kEventClassWindow, kEventWindowUpdate);
InstallWindowEventHandler(AInfo^.Widget,
RegisterEventHandler(@CarbonPrivateWindow_Update),
1, @TmpSpec, Pointer(AInfo), nil);
TmpSpec := MakeEventSpec(kEventClassWindow, kEventWindowDrawContent);
InstallWindowEventHandler(AInfo^.Widget,
RegisterEventHandler(@CarbonPrivateWindow_DrawContent),
1, @TmpSpec, Pointer(AInfo), nil);
end;
class procedure TCarbonPrivateWindow.UnregisterEvents;