Page 1 of 1

SelectCurrenParagraph?

Posted: Fri Jul 30, 2010 2:27 pm
by philip
Hi,

There are SelectCurrentLine and SelectCurrentWord. Why not a SelectCurrentParagraph?. Or ... how can I do that?

Thank you.

Philip.

Posted: Fri Jul 30, 2010 4:22 pm
by philip
Hi,

Ok I writted this and it works, but if the paragraph is in a table cell, then the whole table is selected, and I don't understand why.

Code: Select all

procedure WPSelectParagraph(RV: TCustomRichViewEdit);
var
  iFirst, iLast, i: integer;
begin
  iFirst := RV.CurItemNo;
  for i := iFirst to RV.ItemCount - 1 do
  begin
    if RV.IsParaStart(iFirst) then Break;
    Dec(iFirst);
  end;
  iLast := RV.CurItemNo + 1;
  for i := iLast to RV.ItemCount - 1 do
  begin
    if RV.IsParaStart(iLast) then Break;
    Inc(iLast);
  end;
  Dec(iLast);
  RV.SetSelectionBounds(iFirst, RV.GetOffsBeforeItem(iFirst),
                        iLast, RV.GetOffsAfterItem(iLast));
end;
Philip

Posted: Sat Jul 31, 2010 9:12 am
by Sergey Tkachenko
Add the line:

Code: Select all

RV := RV.TopLevelEditor;
at the beginning.