fix for SelText clearing text formatting

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@935 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
skalogryz
2009-08-18 05:21:51 +00:00
parent 140121f8ac
commit 3e63d8afaf
4 changed files with 94 additions and 50 deletions

View File

@@ -51,6 +51,8 @@ type
procedure UpdateRichMemo; virtual;
procedure SetHideSelection(AValue: Boolean);
function GetContStyleLength(TextStart: Integer): Integer;
procedure SetSelText(const SelTextUTF8: string); override;
public
procedure SetTextAttributes(TextStart, TextLen: Integer; const TextParams: TFontParams); virtual;
function GetTextAttributes(TextStart: Integer; var TextParams: TFontParams): Boolean; virtual;
@@ -230,6 +232,22 @@ begin
if Result = 0 then Result := 1;
end;
procedure TCustomRichMemo.SetSelText(const SelTextUTF8: string);
var
st : Integer;
begin
Lines.BeginUpdate;
try
st := SelStart;
if HandleAllocated then
TWSCustomRichMemoClass(WidgetSetClass).InDelText(Self, SelTextUTF8, SelStart, SelLength);
SelStart := st;
SelLength := length(UTF8Decode(SelTextUTF8));
finally
Lines.EndUpdate;
end;
end;
procedure TCustomRichMemo.SetRangeColor(TextStart, TextLength: Integer; FontColor: TColor);
begin
SetRangeParams(TextStart, TextLength, [tmm_Color], '', 0, FontColor, [], []);