mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 03:56:12 +02:00
IDE: show all search results of one line in one listbox item, from Benito van der Zander (issue #12015)
git-svn-id: trunk@16791 -
This commit is contained in:
parent
96ccd451db
commit
405c0f4928
@ -52,6 +52,7 @@ type
|
|||||||
FFileStartPos: TPoint;
|
FFileStartPos: TPoint;
|
||||||
fMatchStart: integer;
|
fMatchStart: integer;
|
||||||
fMatchLen: integer;
|
fMatchLen: integer;
|
||||||
|
FNextInThisLine: TLazSearchMatchPos;
|
||||||
FShownFilename: string;
|
FShownFilename: string;
|
||||||
FTheText: string;
|
FTheText: string;
|
||||||
public
|
public
|
||||||
@ -62,6 +63,7 @@ type
|
|||||||
property FileEndPos: TPoint read FFileEndPos write FFileEndPos;
|
property FileEndPos: TPoint read FFileEndPos write FFileEndPos;
|
||||||
property TheText: string read FTheText write FTheText;
|
property TheText: string read FTheText write FTheText;
|
||||||
property ShownFilename: string read FShownFilename write FShownFilename;
|
property ShownFilename: string read FShownFilename write FShownFilename;
|
||||||
|
property NextInThisLine: TLazSearchMatchPos read FNextInThisLine write FNextInThisLine;
|
||||||
end;//TLazSearchMatchPos
|
end;//TLazSearchMatchPos
|
||||||
|
|
||||||
|
|
||||||
@ -476,6 +478,7 @@ var
|
|||||||
CurrentLB: TLazSearchResultLB;
|
CurrentLB: TLazSearchResultLB;
|
||||||
SearchPos: TLazSearchMatchPos;
|
SearchPos: TLazSearchMatchPos;
|
||||||
ShownText: String;
|
ShownText: String;
|
||||||
|
LastPos: TLazSearchMatchPos;
|
||||||
begin
|
begin
|
||||||
CurrentLB:=GetListBox(APageIndex);
|
CurrentLB:=GetListBox(APageIndex);
|
||||||
if Assigned(CurrentLB) then
|
if Assigned(CurrentLB) then
|
||||||
@ -491,6 +494,7 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
SearchPos:= TLazSearchMatchPos.Create;
|
SearchPos:= TLazSearchMatchPos.Create;
|
||||||
SearchPos.MatchStart:=MatchStart;
|
SearchPos.MatchStart:=MatchStart;
|
||||||
SearchPos.MatchLen:=MatchLen;
|
SearchPos.MatchLen:=MatchLen;
|
||||||
@ -500,7 +504,18 @@ begin
|
|||||||
SearchPos.TheText:=TheText;
|
SearchPos.TheText:=TheText;
|
||||||
SearchPos.ShownFilename:=SearchPos.Filename;
|
SearchPos.ShownFilename:=SearchPos.Filename;
|
||||||
ShownText:=CurrentLB.BeautifyLine(SearchPos);
|
ShownText:=CurrentLB.BeautifyLine(SearchPos);
|
||||||
if CurrentLB.UpdateState then
|
LastPos:=nil;
|
||||||
|
if CurrentLB.UpdateState then begin
|
||||||
|
if (CurrentLB.UpdateItems.Count>0) and (CurrentLB.UpdateItems.Objects[CurrentLB.UpdateItems.Count-1] is TLazSearchMatchPos) then
|
||||||
|
LastPos:=TLazSearchMatchPos(CurrentLB.UpdateItems.Objects[CurrentLB.UpdateItems.Count-1]);
|
||||||
|
end else
|
||||||
|
if (CurrentLB.Items.Count>0) and (CurrentLB.Items.Objects[CurrentLB.Items.Count-1] is TLazSearchMatchPos) then
|
||||||
|
LastPos:=TLazSearchMatchPos(CurrentLB.Items.Objects[CurrentLB.Items.Count-1]);
|
||||||
|
if (LastPos<>nil) and (LastPos.Filename=SearchPos.Filename) and
|
||||||
|
(LastPos.FFileStartPos.Y=SearchPos.FFileStartPos.Y) and
|
||||||
|
(LastPos.FFileEndPos.Y=SearchPos.FFileEndPos.Y) then
|
||||||
|
LastPos.NextInThisLine:=SearchPos
|
||||||
|
else if CurrentLB.UpdateState then
|
||||||
CurrentLB.UpdateItems.AddObject(ShownText, SearchPos)
|
CurrentLB.UpdateItems.AddObject(ShownText, SearchPos)
|
||||||
else
|
else
|
||||||
CurrentLB.Items.AddObject(ShownText, SearchPos);
|
CurrentLB.Items.AddObject(ShownText, SearchPos);
|
||||||
@ -799,14 +814,13 @@ procedure TSearchResultsView.ListboxDrawitem(Control: TWinControl;
|
|||||||
Index: Integer; ARect: TRect;
|
Index: Integer; ARect: TRect;
|
||||||
State: TOwnerDrawState);
|
State: TOwnerDrawState);
|
||||||
var
|
var
|
||||||
FirstPart: string;
|
CurPart: string;
|
||||||
BoldPart: string;
|
|
||||||
LastPart: string;
|
|
||||||
TheText: string;
|
TheText: string;
|
||||||
TheTop: integer;
|
TheTop: integer;
|
||||||
MatchObj: TObject;
|
MatchObj: TObject;
|
||||||
MatchPos: TLazSearchMatchPos;
|
MatchPos,FirstMatchPos: TLazSearchMatchPos;
|
||||||
TextEnd: integer;
|
|
||||||
|
TextEnd, DrawnTextLength: integer;
|
||||||
begin
|
begin
|
||||||
With Control as TLazSearchResultLB do
|
With Control as TLazSearchResultLB do
|
||||||
begin
|
begin
|
||||||
@ -819,26 +833,44 @@ begin
|
|||||||
|
|
||||||
if Assigned(MatchPos) then
|
if Assigned(MatchPos) then
|
||||||
begin
|
begin
|
||||||
|
FirstMatchPos:=MatchPos;
|
||||||
TheTop:= ARect.Top;
|
TheTop:= ARect.Top;
|
||||||
|
TextEnd:=ARect.Left;
|
||||||
|
DrawnTextLength:=0;
|
||||||
|
|
||||||
FirstPart:=MatchPos.ShownFilename+' ('+IntToStr(MatchPos.FileStartPos.Y)
|
CurPart:=MatchPos.ShownFilename+' ('+IntToStr(MatchPos.FileStartPos.Y)
|
||||||
+','+IntToStr(MatchPos.FileStartPos.X)+') '
|
+':'+IntToStr(MatchPos.FileStartPos.X);
|
||||||
+SpecialCharsToHex(copy(MatchPos.TheText,1,MatchPos.MatchStart-1));
|
MatchPos:=MatchPos.NextInThisLine;
|
||||||
BoldPart:=SpecialCharsToHex(
|
while assigned(MatchPos) do begin
|
||||||
copy(MatchPos.TheText,MatchPos.MatchStart,MatchPos.MatchLen));
|
CurPart:=CurPart+','+IntToStr(MatchPos.FileStartPos.X);
|
||||||
LastPart:=SpecialCharsToHex(
|
MatchPos:=MatchPos.NextInThisLine;
|
||||||
copy(MatchPos.TheText, MatchPos.MatchStart+MatchPos.MatchLen,
|
end;
|
||||||
Length(MatchPos.TheText)));
|
CurPart:=CurPart+') ';
|
||||||
if UTF8Length(BoldPart)>MaxTextLen then
|
Canvas.TextOut(TextEnd, TheTop, CurPart);
|
||||||
BoldPart:=UTF8Copy(BoldPart,1,MaxTextLen)+'...';
|
TextEnd:= TextEnd + Canvas.TextWidth(CurPart);
|
||||||
//DebugLn(['TSearchResultsView.ListboxDrawitem FirstPart="',FirstPart,'" BoldPart="',BoldPart,'" LastPart="',LastPart,'"']);
|
|
||||||
Canvas.TextOut(ARect.Left, TheTop, FirstPart);
|
MatchPos:=FirstMatchPos;
|
||||||
TextEnd:= ARect.Left + Canvas.TextWidth(FirstPart);
|
while assigned(MatchPos) do begin
|
||||||
|
CurPart:=SpecialCharsToHex(copy(MatchPos.TheText,DrawnTextLength+1,MatchPos.MatchStart-1-DrawnTextLength));
|
||||||
|
DrawnTextLength:=MatchPos.MatchStart-1;
|
||||||
|
Canvas.TextOut(TextEnd, TheTop, CurPart);
|
||||||
|
TextEnd:= TextEnd + Canvas.TextWidth(CurPart);
|
||||||
|
|
||||||
|
CurPart:=SpecialCharsToHex(copy(MatchPos.TheText,DrawnTextLength+1,MatchPos.MatchLen));
|
||||||
|
DrawnTextLength:=DrawnTextLength+MatchPos.MatchLen;
|
||||||
|
if UTF8Length(CurPart)>MaxTextLen then
|
||||||
|
CurPart:=UTF8Copy(CurPart,1,MaxTextLen)+'...';
|
||||||
Canvas.Font.Style:= Canvas.Font.Style + [fsBold];
|
Canvas.Font.Style:= Canvas.Font.Style + [fsBold];
|
||||||
Canvas.TextOut(TextEnd, TheTop, BoldPart);
|
Canvas.TextOut(TextEnd, TheTop, CurPart);
|
||||||
TextEnd:= TextEnd + Canvas.TextWidth(BoldPart);
|
TextEnd:= TextEnd + Canvas.TextWidth(CurPart);
|
||||||
Canvas.Font.Style:=Canvas.Font.Style - [fsBold];
|
Canvas.Font.Style:= Canvas.Font.Style - [fsBold];
|
||||||
Canvas.TextOut(TextEnd, TheTop, LastPart);
|
|
||||||
|
if MatchPos.NextInThisLine=nil then begin
|
||||||
|
CurPart:=SpecialCharsToHex(copy(MatchPos.TheText, DrawnTextLength+1,Length(MatchPos.TheText)));
|
||||||
|
Canvas.TextOut(TextEnd, TheTop, CurPart);
|
||||||
|
end;
|
||||||
|
MatchPos:=MatchPos.NextInThisLine;
|
||||||
|
end;
|
||||||
end//if
|
end//if
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user