diff --git a/components/richmemo/richmemo.pas b/components/richmemo/richmemo.pas index 85783e15a..252df0c18 100644 --- a/components/richmemo/richmemo.pas +++ b/components/richmemo/richmemo.pas @@ -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. diff --git a/components/richmemo/wsrichmemo.pas b/components/richmemo/wsrichmemo.pas index 8884f285f..0b25bbd8d 100644 --- a/components/richmemo/wsrichmemo.pas +++ b/components/richmemo/wsrichmemo.pas @@ -48,6 +48,12 @@ type Tabs : array of TTabInfo; end; + TIntSearchOpt = record + start : Integer; + len : Integer; + Options : TSearchOptions; + end; + { TWSCustomRichMemo } TWSCustomRichMemo = class(TWSCustomMemo) @@ -80,6 +86,8 @@ type class procedure SetHideSelection(const ACustomEdit: TCustomEdit; AHideSelection: Boolean); override; class function LoadRichText(const AWinControl: TWinControl; Source: TStream): Boolean; virtual; class function SaveRichText(const AWinControl: TWinControl; Dest: TStream): Boolean; virtual; + + class function Search(const AWinControl: TWinControl; const ANiddle: string; const SearchOpts: TIntSearchOpt): Integer; virtual; end; TWSCustomRichMemoClass = class of TWSCustomRichMemo; @@ -186,5 +194,11 @@ begin Result := false; end; +class function TWSCustomRichMemo.Search(const AWinControl: TWinControl; const ANiddle: string; + const SearchOpts: TIntSearchOpt): Integer; +begin + Result:=-1; +end; + end.