rvico TRichView Reference | Global procedures and functions

Functions from RVLinear Unit

Top  Previous  Next

const RVCharsPerLineBreak: Integer = 1;

      RVNonTextCharacter: Char = ' ';

 

function RVGetLinearCaretPos(rve: TCustomRichViewEdit): Integer;

procedure RVSetLinearCaretPos(rve: TCustomRichViewEdit; LinearPos: Integer);

RVGetLinearCaretPos returns the caret position (as a number of characters before the caret; non-text objects (except for the tables and tabulators) are treated as one character, line breaks are treated as RVCharsPerLineBreak characters). RVSetLinearCaretPos moves the caret to the specified position.

procedure RVGetSelection(rv: TCustomRichViewvar SelStart, SelLength: Integer);

procedure RVSetSelection(rv: TCustomRichView; SelStart, SelLength: Integer);

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

type

  TRVSelection = record

    SelStart, SelLength: Integer;

    MultiCell: Boolean;

    StartRow, StartCol, RowOffs, ColOffs: Integer;

  end;

procedure RVGetSelectionEx(rv: TCustomRichViewvar Selection: TRVSelection);

procedure RVSetSelectionEx(rv: TCustomRichViewconst Selection: TRVSelection);

RVGetSelectionEx returns the selection position in TRVSelection record. RVSetSelectionEx sets selection by this record. These function 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; var LinearPos: Integer): Boolean;

function LinearToRichView(rv: TCustomRichView; CurRVData: TCustomRVData;

  var LinearPos: Integer; var RVData: TCustomRVData;

  var ItemNo, ItemOffs: Integer): Boolean;  

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

function RVGetTextRange(rv: TCustomRichView; RangeStart, RangeLength: Integer): String;

function RVGetTextLength(rv: TCustomRichView): Integer;

RVGetTextRange returns text from rv, from RangeStart to RangeLength position. Non-text items (except for the tables and tabulators) are returned as RVNonTextCharacter. If RVCharsPerLineBreak=1, #13 is used as line break. If RVCharsPerLineBreak=2, #13#10 is used as line break.

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

 

All these functions are compatible, they calculate position identically. The text returned by RVGetTextRange has one-to-one correspondence to RichView document (unlike text returned by the functions from RVGetText unit).

unicode Unicode note: for Delphi/C++Builder 2009 or newer, RVGetTextRange returns Unicode text. For older versions of Delphi, it returns ANSI text.


TRichView © trichview.com