Skip to content

Commit

Permalink
Fix Fulltext search problem under windows
Browse files Browse the repository at this point in the history
  • Loading branch information
reckel-jm committed May 24, 2023
1 parent 75c1d7b commit 7ac6041
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
14 changes: 7 additions & 7 deletions src/frames/fulltextsearch.lfm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object FrmFulltextsearch: TFrmFulltextsearch
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 36
Height = 25
Top = 0
Width = 424
Alignment = taCenter
Expand All @@ -34,8 +34,8 @@ object FrmFulltextsearch: TFrmFulltextsearch
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 214
Top = 41
Height = 225
Top = 30
Width = 424
PageIndex = 0
Anchors = [akTop, akLeft, akRight, akBottom]
Expand All @@ -48,10 +48,10 @@ object FrmFulltextsearch: TFrmFulltextsearch
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = LoadIndex
AnchorSideTop.Side = asrCenter
Left = 161
Height = 22
Top = 96
Width = 102
Left = 171
Height = 17
Top = 104
Width = 82
Caption = 'Create Index...'
ParentColor = False
end
Expand Down
23 changes: 17 additions & 6 deletions src/frames/fulltextsearch.pas
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
interface

uses
Classes, SysUtils, Forms, Controls, StdCtrls, ExtCtrls, Dialogs, Lyrics, FGL, Types, LCLType, Graphics, Math;
Classes, SysUtils, Forms, Controls, StdCtrls, ExtCtrls, Dialogs, Lyrics, FGL,
Types, LCLType, Graphics, Math;

type

Expand Down Expand Up @@ -114,7 +115,7 @@ procedure TFrmFulltextsearch.EditSearchTermChange(Sender: TObject);
(PosInContentIndex > 0) then
begin
AddedContent := IndexList.Items[i].Song.FileNameWithoutEnding;
AddedContent += LineEnding;
AddedContent += PathSeparator;
ContentString := IndexList.Items[i].ContentIndex;
if PosInContentIndex > 0 then
AddedContent += ContentString[PosInContentIndex-(Min(PosInContentIndex,70))+1..PosInContentIndex+Min(Length(ContentString)-PosInContentIndex, 70)-1]
Expand All @@ -128,7 +129,7 @@ procedure TFrmFulltextsearch.EditSearchTermChange(Sender: TObject);

procedure TFrmFulltextsearch.ListBoxResultsDblClick(Sender: TObject);
begin
frmSongs.lbxSselected.Items.Add(ListBoxResults.Items[ListBoxResults.ItemIndex].Split(LineEnding)[0]);
frmSongs.lbxSselected.Items.Add(ListBoxResults.Items[ListBoxResults.ItemIndex].Split(PathSeparator)[0]);
end;

procedure TFrmFulltextsearch.ListBoxResultsDrawItem(Control: TWinControl;
Expand All @@ -145,15 +146,25 @@ procedure TFrmFulltextsearch.ListBoxResultsDrawItem(Control: TWinControl;
ListBoxResults.Canvas.Brush.Color := aColor;
ListBoxResults.Canvas.FillRect(aRect);
ListBoxResults.Canvas.Font.Bold:=True;
HeadingStyle.Alignment:=taCenter;
ListBoxResults.Canvas.Font.Underline:=True;
with ListBoxResults.Canvas.TextStyle do
begin
Alignment:= taCenter;
Layout:= tlTop;
SingleLine := True;
WordBreak := False;
Opaque := False;
end;
// Now we split the strings into the two parts
StringParts := ListBoxResults.Items[Index].Split(LineEnding);
ListBoxResults.Canvas.TextRect(ARect, 2, ARect.Top+2, StringParts[0], HeadingStyle);
StringParts := ListBoxResults.Items[Index].Split(PathSeparator);
ListBoxResults.Canvas.TextRect(ARect, 2, ARect.Top+2, StringParts[0]);
if length(StringParts) > 1 then
begin
ListBoxResults.Canvas.Font.Bold:=False;
ListBoxResults.Canvas.Font.Underline:=False;
ListBoxResults.Canvas.TextRect(ARect, 2, ARect.Top+2+Round(FontBaseHeight*1.33), StringParts[1]);
end;
ARect.Height:=500;
end;

procedure TFrmFulltextsearch.NoResultBeforeShow(ASender: TObject;
Expand Down

0 comments on commit 7ac6041

Please sign in to comment.