2.42 :setformat()

The :setformat() method can be used to format text ranges in an RTF edittext.

Definition

boolean :setformat
(
  { integer  Start := 1  input,
    integer  End   := -1 input, }
    enum     Type  input,
    anyvalue Value input
)

Parameters

integer Start := 1 input
integer End := -1 input

These optional parameters define the range that shall be formatted. If these parameters are missing, the range from .startsel to .endsel (selection or cursor position) is formatted.

Which range will actually be formatted depends on the kind of formatting:

  • Character formats affect exactly the specified range.
  • Paragraph formats affect all paragraphs that are contained completely or partly in the specified range.

The formatting kind is listed in the table below.

The value range of Start and End goes from 0 to the number of characters in the displayed text, with every character that can be included in a selection counting. Line break characters therefore count as well.

-1 can be specified for End to format the remaining text from the start position.

Start and End – similar to .startsel and .endsel – refer to positions in the formatted text. They cannot be used to infer positions in the content string of the RTF edittext, since this also contains formatting instructions. If the Start or End parameters are greater than the text length, then the text length is used for the RTF edittext.

enum Type input

This parameter defines the type of formatting to be applied. The enum values for the formatting types are listed in the table below.

anyvalue Value input

This parameter contains a value that determines the characteristics of the formatting type defined in Type. The data types for the formatting types are listed in the table below.

Return value

true
The text range has been formatted.
false
Error: The formatting could not be applied (e.g. due to incorrect arguments).

Formatting Kinds, enum Values and Data Types of the Formatting Types

Formatting Type

Formatting Kind

enum Value

Data Type

typeface, font

character format

text_font

string , font

font size

character format

text_size

integer

foreground color, text color

character format

text_fgc

integer , color

background color

character format

text_bgc

integer , color

bold

character format

text_bold

boolean

italic

character format

text_italic

boolean

underlined

character format

text_underline

boolean

left indentation

paragraph format

text_indent_left

integer

right indentation

paragraph format

text_indent_right

integer

indentation of continuation lines in a paragraph

paragraph format

text_indent_offset

integer

text alignment

paragraph format

text_align

enum

[align_left, align_right, align_center, align_justify]

Depending on the font, it may happen that formatting instructions or formatting attributes set with :setformat() are ignored by the Windows object that the IDM uses for the RTF edittext. On Windows 7, this happens, for example, with text_bold if no font is set explicitly and therefore the System font is used implicitly.

Unit of Measure for Sizes and Positions

Sizes and positions are specified in twips – as usual in Windows programming. A twip is equivalent to 1/20 point, that is 1/1440 inch or 1/567 cm.

Explanations on Particular Formattings

Objects with this method

edittext with .options[opt_rtf] = true