trichview.com

trichview.support




Re: Moving cursor with code and find replace with begin..end text


Return to index


Author

Message

Sergey Tkachenko

Posted: 02/21/2003 23:03:13


The code below uses procedures from file


http://www.trichview.com/support/files/rvlinear.zip



uses CRVData;



var TopRVData: TCustomRVData;

    SelStart1, SelStart2: Integer;

begin

  with RichViewEdit1 do begin

    SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));

    while SearchText('{', [rvseoDown]) do begin

      TopRVData := TopLevelEditor.RVData.GetSourceRVData;

      SelStart1 := RVGetLinearCaretPos(RichViewEdit1)-1;

      if SearchText('}', [rvseoDown]) then begin

        if TopRVData = TopLevelEditor.RVData.GetSourceRVData then begin

          SelStart2 := RVGetLinearCaretPos(RichViewEdit1);

          RVSetSelection(RichViewEdit1, SelStart1, SelStart2-SelStart1);

          Application.MessageBox(PChar(GetSelText),'Selected Text', 0);

          end

        else

          RVSetLinearCaretPos(RichViewEdit1, SelStart1+1);

      end;

    end;

  end;

end;


Notes:

1)

SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));

moves caret to the very beginning of the document

2)

This procedure disallows selection if '{' and '}' are in different table

cells (check for GetSourceRVData equality)






Powered by ABC Amber Outlook Express Converter