rvico TRichView Reference | TRichView

TCustomRichView.LoadText, LoadTextW

Top  Previous  Next

Append the content of the text file FileName to the document. LoadText loads text from ANSI text files, LoadTextW loads text from Unicode (UTF-16) text files.

function LoadText(const FileName: String; StyleNo, ParaNo: Integer; 

  AsSingleParagraph: Boolean; CodePage: Cardinal=CP_ACP):Boolean;

 

function LoadTextW(const FileName: String; StyleNo, ParaNo: Integer; 

  DefAsSingleParagraph: Boolean):Boolean;

Despite their names, these methods do not clear the existing document before loading. To replace the current document with the content of this file, call Clear method before loading (and may be DeleteUnusedStyles after Clear).

Parameters

StyleNo – an index of text style which will be used for new text. It defines font attributes for the added text.

ParaNo – an index of paragraph style which will be used for new text. It defines paragraph attributes for the added text.

AsSingleParagraph (and DefAsSingleParagraph):

False  –  the methods use the current add-paragraph-mode (see SetAddParagraphMode);

True – the methods add all text as a single paragraph (add the first new item in the current add-paragraph-mode, set add-paragraph-mode to False, add the rest of text, restore the add-paragraph-mode). DefAsSingleParagraph only affects processing CR and LF characters. WideChar($2029) ("paragraph separator") always initiates a new paragraph. WideChar($2028) ("line separator") always initiates a new line.

CodePage – a code page for converting from ANSI to Unicode. It is used only if StyleNo points to a Unicode style; otherwise it is ignored.

LoadTextW supports the Unicode byte order marks characters (if they are present, they must be the first characters in the file).

Methods type: viewerstyle viewer-style.

unicode Unicode notes:

LoadText (text in the file must be ANSI):

If the StyleNo-th style is ANSI style, text from the file is loaded as it is.

If the StyleNo-th style is Unicode style, text from the file is converted to Unicode (conversion is performed using the CodePage parameter, or, of it's equal to CP_ACP, basing on the Charset of this style).

LoadTextW (text in the file must be Unicode):

If the StyleNo-th style is Unicode style, text from the file is added as it is..

If the StyleNo-th style is ANSI style, text from the file is converted to ANSI (conversion is performed basing on the Charset of this style).

 

If style templates are used, the component may automatically change text style indices of text items, to provide a consistency of text and paragraph style templates.

Return value:"Was loading successful?"

 

See also methods:

LoadTextFromStream, LoadTextFromStreamW;

AddTextNLA, AddTextNLW;

Format;

FormatTail;

SetAddParagraphMode;

SaveText, SaveTextW.

See also methods of TRichViewEdit:

InsertTextFromFile, InsertTextFromFileW.

See also properties of TRVStyle:

TextStyles;

SpacesInTab.

See also:

Other methods for appending items;

Saving and loading;

Unicode in RichView;

Example how to load UTF-8 files.


TRichView © trichview.com