You've already forked lazarus-ccr
richmemo: added FindText method to richedit helper
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3757 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -20,10 +20,10 @@ unit RichMemoHelpers;
|
|||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
|
||||||
RichMemo, Graphics;
|
|
||||||
|
|
||||||
{$IFDEF FPC_FULLVERSION >= 20600}
|
{$IFDEF FPC_FULLVERSION >= 20600}
|
||||||
|
uses
|
||||||
|
SysUtils, StrUtils, Graphics,
|
||||||
|
RichMemo;
|
||||||
|
|
||||||
type
|
type
|
||||||
TRichEditFromRichMemo = class(TObject);
|
TRichEditFromRichMemo = class(TObject);
|
||||||
@ -79,10 +79,14 @@ type
|
|||||||
|
|
||||||
{ TRichEditForMemo }
|
{ TRichEditForMemo }
|
||||||
|
|
||||||
|
TSearchType = (stWholeWord, stMatchCase);
|
||||||
|
TSearchTypes = set of TSearchType;
|
||||||
|
|
||||||
TRichEditForMemo = class helper for TCustomRichMemo
|
TRichEditForMemo = class helper for TCustomRichMemo
|
||||||
public
|
public
|
||||||
function SelAttributes: TTextAttributes;
|
function SelAttributes: TTextAttributes;
|
||||||
function Paragraph: TParaAttributes;
|
function Paragraph: TParaAttributes;
|
||||||
|
function FindText(const SearchStr: String; StartPos, Length: Integer; Options: TSearchTypes): Integer;
|
||||||
end;
|
end;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
{$WARNING Class Helpers require FPC 2.6.0 or later, RichEdit compatible methods will not be available }
|
{$WARNING Class Helpers require FPC 2.6.0 or later, RichEdit compatible methods will not be available }
|
||||||
@ -294,6 +298,25 @@ function TRichEditForMemo.Paragraph: TParaAttributes;
|
|||||||
begin
|
begin
|
||||||
Result:=TParaAttributes(TObject(Self));
|
Result:=TParaAttributes(TObject(Self));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TRichEditForMemo.FindText(const SearchStr: String; StartPos,
|
||||||
|
Length: Integer; Options: TSearchTypes): Integer;
|
||||||
|
var
|
||||||
|
sub : WideString;
|
||||||
|
src : WideString;
|
||||||
|
begin
|
||||||
|
src := UTF8Decode( TCustomRichMemo(Self).Text );
|
||||||
|
sub := UTF8Decode(SearchStr);
|
||||||
|
if not (stMatchCase in Options) then begin
|
||||||
|
src:=WideUpperCase(src);
|
||||||
|
sub:=WideUpperCase(sub);
|
||||||
|
end;
|
||||||
|
src:=Copy(src, StartPos+1, Length);
|
||||||
|
Result:=Pos(sub, src);
|
||||||
|
if Result<=0 then Result:=-1
|
||||||
|
else Result:=StartPos+Result-1;
|
||||||
|
end;
|
||||||
|
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Reference in New Issue
Block a user