richmemo: Search and SetSetLengthFor methods

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3771 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
skalogryz
2014-11-24 07:58:17 +00:00
parent 6946c8309a
commit 6fa141025c
2 changed files with 44 additions and 3 deletions

View File

@@ -24,7 +24,7 @@ unit RichMemo;
interface
uses
Classes, SysUtils, Graphics, StdCtrls;
Classes, SysUtils, Graphics, StdCtrls, LazUTF8;
type
TFontParams = record
@@ -60,6 +60,9 @@ type
TTextModifyMask = set of (tmm_Color, tmm_Name, tmm_Size, tmm_Styles);
TSearchOption = (soMatchCase, soWholeWord, soBackward);
TSearchOptions = set of TSearchOption;
type
TRichMemoObject = class(TObject);
@@ -103,6 +106,10 @@ type
function LoadRichText(Source: TStream): Boolean; virtual;
function SaveRichText(Dest: TStream): Boolean; virtual;
procedure SetSelLengthFor(const aselstr: string);
function Search(const ANiddle: string; Start, Len: Integer; const SearchOpt: TSearchOptions): Integer;
property HideSelection : Boolean read fHideSelection write SetHideSelection;
end;
@@ -435,9 +442,9 @@ begin
finally
Self.Lines.EndUpdate;
end;
end;
if not Result then
end else begin
Result := TWSCustomRichMemoClass(WidgetSetClass).LoadRichText(Self, Source);
end;
end;
end;
@@ -451,5 +458,25 @@ begin
Result := false;
end;
procedure TCustomRichMemo.SetSelLengthFor(const aselstr: string);
begin
SelLength:=UTF8Length(aselstr);
end;
function TCustomRichMemo.Search(const ANiddle: string; Start, Len: Integer;
const SearchOpt: TSearchOptions): Integer;
var
so : TIntSearchOpt;
begin
if not HandleAllocated then HandleNeeded;
if HandleAllocated then begin
so.len:=Len;
so.start:=Start;
so.options:=SearchOpt;
Result:=TWSCustomRichMemoClass(WidgetSetClass).Search(Self, ANiddle, so);
end else
Result:=-1;
end;
end.