From 84084e84f57486d625c0b4d90cf277231616b015 Mon Sep 17 00:00:00 2001 From: skalogryz Date: Mon, 1 Aug 2016 03:22:44 +0000 Subject: [PATCH] richmemo: wrap SetRangeParams range changes into BeginUpdate/EndUpdate. Making sure that no updates would be visibile as well as refreshing by the end of the change git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5059 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/richmemo/richmemo.pas | 41 ++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/components/richmemo/richmemo.pas b/components/richmemo/richmemo.pas index 9ef1abce8..01dd2db8c 100644 --- a/components/richmemo/richmemo.pas +++ b/components/richmemo/richmemo.pas @@ -867,26 +867,31 @@ begin Exit; end; - // manually looping from text ranges and re-applying - // all the style. changing only the ones that in the mask - i := TextStart; - j := TextStart + TextLength; - while i < j do begin - GetTextAttributes(i, p); + Lines.BeginUpdate; + try + // manually looping from text ranges and re-applying + // all the style. changing only the ones that in the mask + i := TextStart; + j := TextStart + TextLength; + while i < j do begin + GetTextAttributes(i, p); - if tmm_Name in ModifyMask then p.Name := fnt.Name; - if tmm_Color in ModifyMask then p.Color := fnt.Color; - if tmm_Size in ModifyMask then p.Size := fnt.Size; - if tmm_Styles in ModifyMask then p.Style := p.Style + AddFontStyle - RemoveFontStyle; - if tmm_BackColor in ModifyMask then begin - p.HasBkClr:=fnt.HasBkClr; - p.BkColor:=fnt.BkColor; + if tmm_Name in ModifyMask then p.Name := fnt.Name; + if tmm_Color in ModifyMask then p.Color := fnt.Color; + if tmm_Size in ModifyMask then p.Size := fnt.Size; + if tmm_Styles in ModifyMask then p.Style := p.Style + AddFontStyle - RemoveFontStyle; + if tmm_BackColor in ModifyMask then begin + p.HasBkClr:=fnt.HasBkClr; + p.BkColor:=fnt.BkColor; + end; + l := GetContStyleLength(i); + if i + l > j then l := j - i; + if l = 0 then Break; + SetTextAttributes(i, l, p); + inc(i, l); end; - l := GetContStyleLength(i); - if i + l > j then l := j - i; - if l = 0 then Break; - SetTextAttributes(i, l, p); - inc(i, l); + finally + Lines.EndUpdate end; end;