trichview.com

trichview.support




Re: Append text at the begining and end of the paragraph


Return to index


Author

Message

Anonymous

Posted: 10/21/2003 13:05:05


"samratdhamale" <samratdhamale@credenceanalytics.com> wrote:

>

>My current para is to be preceeded by text '<<' and postfixed by '>>' on

a

>button click

>Ho do i do that


In general case it can be done with two ways: qouted with same styles as

beginning and end of para -


procedure QuotedRVEParaWithSameStyles(RVE: TCustomRichViewEdit; ParaNo: integer);


  function EndPara(No: Integer): Integer;

  var

    I: Integer;

  begin

    Result:=No;

    Inc(No);

    if No<>rve.ItemCount then

      for I:=No to rve.ItemCount-1 do

      begin

        if rve.IsParaStart(I) then Break;

        Inc(Result);

      end;

  end;


var StartNo, EndNo: integer;

begin

  StartNo:=GetParaStartItem_(RVE.RVData, ParaNo);

  EndNo:=EndPara(StartNo);

  if RVE.GetItemStyle(StartNo)>=0 then

    RVE.SetItemText(StartNo, '<<'+RVE.GetItemText(StartNo))

  else

  begin

    RVE.SetSelectionBounds(StartNo, RVE.GetOffsBeforeItem(StartNo), StartNo,

RVE.GetOffsBeforeItem(StartNo));

    RVE.InsertText('<<', True);

  end;

  if RVE.GetItemStyle(EndNo)>=0 then

    RVE.SetItemText(EndNo,RVE.GetItemText(EndNo)+'>>')

  else

  begin

    RVE.SetSelectionBounds(EndNo, RVE.GetOffsAfterItem(EndNo), EndNo, RVE.GetOffsAfterItem(EndNo));

    RVE.InsertText('>>', True);

  end;

  RVE.Format;

end;


or with user defined styles -


procedure QuotedRVEParaWithUserStyles(RVE: TCustomRichViewEdit; ParaNo, StyleNo:

integer);


  function EndPara(No: Integer): Integer;

  var

    I: Integer;

  begin

    Result:=No;

    Inc(No);

    if No<>rve.ItemCount then

      for I:=No to rve.ItemCount-1 do

      begin

        if rve.IsParaStart(I) then Break;

        Inc(Result);

      end;

  end;


var StartNo, EndNo, NonTextItemNo: integer;

    QuotedItem: TCustomRVItemInfo;

begin

   StartNo:=GetParaStartItem_(RVE.RVData, ParaNo);


   RVE.SetSelectionBounds(StartNo, RVE.GetOffsBeforeItem(StartNo), StartNo,

RVE.GetOffsBeforeItem(StartNo));

   RVE.InsertText('<<', true);

   if RVE.GetItemStyle(StartNo)>=0 then

     RVE.SetSelectionBounds(StartNo, RVE.GetOffsBeforeItem(StartNo), StartNo,

RVE.GetOffsBeforeItem(StartNo)+2)

   else

     RVE.SetSelectionBounds(StartNo-1, RVE.GetOffsBeforeItem(StartNo-1),

StartNo-1, RVE.GetOffsAfterItem(StartNo-1));

   RVE.ApplyTextStyle(StyleNo);


   EndNo:=EndPara(StartNo);


   RVE.SetSelectionBounds(EndNo, RVE.GetOffsAfterItem(EndNo), EndNo, RVE.GetOffsAfterItem(EndNo));

   RVE.InsertText('>>', true);

   if RVE.GetItemStyle(EndNo)>=0 then

     RVE.SetSelectionBounds(EndNo, RVE.GetOffsAfterItem(EndNo)-2, EndNo,

RVE.GetOffsAfterItem(EndNo))

   else

     RVE.SetSelectionBounds(EndNo+1, RVE.GetOffsBeforeItem(EndNo+1), EndNo+1,

RVE.GetOffsAfterItem(EndNo+1));

   RVE.ApplyTextStyle(StyleNo);


   RVE.Deselect;

   RVE.Format;

end;


nota bene: RVTable does not support text streamlining, therefore paras composed

of RVTables cannot be quoted.





Powered by ABC Amber Outlook Express Converter