Functions from RVLinear Unit

<< Click to display table of contents >>

Functions from RVLinear Unit


  RVCharsPerLineBreak: Integer = 2;

  RVNonTextCharacter: TRVUnicodeChar = ' ';


function RVGetLinearCaretPos(rve: TCustomRichViewEdit;
  CharsPerLineBreak: Integer = -1): Integer;
procedure RVSetLinearCaretPos(rve: TCustomRichViewEdit; LinearPos: Integer;
  CharsPerLineBreak: Integer = -1);

RVGetLinearCaretPos returns the caret position (as a number of characters before the caret). Non-text objects (except for tables and tabulators) are treated as one character, line breaks are treated as CharsPerLineBreak characters.

RVSetLinearCaretPos moves the caret to the specified position.

Value of CharsPerLineBreak parameter



Use #13#10 to separate lines


Use #13 to separate lines


Lines are not separated


Use the value of RVCharsPerLineBreak global variable (which, in its order, may be 2, 1, or 0)

procedure RVGetSelection(rv: TCustomRichViewout SelStart, SelLength: Integer;
  CharsPerLineBreak: Integer = -1);
procedure RVSetSelection(rv: TCustomRichView; SelStart, SelLength: Integer;
  CharsPerLineBreak: Integer = -1);

RVGetSelection returns the selection position in memo/richedit-like parameters (SelStart and SelLength). RVSetSelection sets selection by these values.


  TRVSelection = record

    SelStart, SelLength: Integer;

    MultiCell: Boolean;

    StartRow, StartCol, RowOffs, ColOffs: Integer;


procedure RVGetSelectionEx(rv: TCustomRichViewout Selection: TRVSelection;
  CharsPerLineBreak: Integer = -1);
procedure RVSetSelectionEx(rv: TCustomRichViewconst Selection: TRVSelection;
  CharsPerLineBreak: Integer = -1);

RVGetSelectionEx returns the selection position in TRVSelection record. RVSetSelectionEx sets selection by this record. These functions can handle not only a normal selection, but a multicell selection in tables as well.

function RichViewToLinear(rv: TCustomRichView; CurRVData, RVData: TCustomRVData;
  ItemNo, ItemOffs: Integer; out LinearPos: Integer;
  CharsPerLineBreak: Integer = -1): Boolean;
function LinearToRichView(rv: TCustomRichView; CurRVData: TCustomRVData;
  var LinearPos: Integer; out RVData: TCustomRVData;
  out ItemNo, ItemOffs: Integer; CharsPerLineBreak: Integer = -1): Boolean;

RichViewToLinear converts the position specified in TRichView coordinates (RVData – document, ItemNo – index of item in this document, ItemOffs – offset in this item) to a linear coordinate (a number of characters from the beginning of CurRVData before this position). Non-text objects (except for tables and tabulators) are treated as one character, line breaks are treated as CharsPerLineBreak characters. LinearToRichView performs an opposite conversion.

function RVGetTextRange(rv: TCustomRichView;
  RangeStart, RangeLength: Integer; 
  CharsPerLineBreak: Integer = -1): TRVUnicodeString;
function RVGetTextLength(rv: TCustomRichView
  CharsPerLineBreak: Integer = -1): Integer;

RVGetTextRange returns text from rv, from RangeStart to RangeLength positions. Non-text items (except for the tables and tabulators) are returned as RVNonTextCharacter. As for line breaks, see the table about CharsPerLineBreak above.

The call RVGetTextRange(rv, 0, RVGetTextLength(rv)) returns the whole text.


All these functions are compatible, they calculate position identically (providing that the same value of CharsPerLineBreak is used). A text returned by RVGetTextRange has one-to-one correspondence to TRichView document (unlike text returned by the functions from RVGetText unit).