3.14 Text formatting codes

Widgets of type Textview class and Texteditor class support text formatting if the Styled attribute of those classes is set to True. RapaGUI supports text formatting by special control codes which are described in this section.

Formatting codes always start with an escape character followed by a sequence of characters that describe the formatting code. In decimal notation the escape character equals ASCII code 27, which is 33 in octal and $1B in hexadecimal notation. Care has to be taken when using formatting codes because usage is different between XML files and Hollywood source files. In XML files the octal notation is used, i.e. you start an escape sequence using a backslash and the octal number 33 ('\33'). In Hollywood source codes, however, octal numbers are not supported after a backslash. Hollywood always expects the ASCII code in decimal notation after a backslash. That is why you have to use '\27' to initiate an escape sequence from Hollywood code.

To illustrate this difference a little bit better, let us have a look at two examples. Here is an example for creating a bold text object in an XML file. Bold text is enabled by using the character 'b' after the escape character:

 
<textview styled="true" id="mytext">\33bBold text</textview>

You can see that the octal notation is used here because XML files expect an octal number after a backslash. In Hollywood, however, it is different because Hollywood expects a decimal character after a backslash. So here is how you have to specify escape codes when using them from a Hollywood source file:

 
moai.Set("mytext", "text", "\27bBold text")

You can see that the code is the same except that we use \27b instead of \33b because Hollywood always uses decimal instead of octal numbers after a backslash.

The following formatting codes are currently supported:

\33u
Set the text style to underline.

\33b
Set the text style to bold.

\33i
Set the text style to italic.

\33n
Set the text style back to normal.

\33P[RRGGBB]
Change front color to the specified RGB color. The RGB color has to be specified in the form of six hexadecimal digits RRGGBB. On AmigaOS and compatibles this requires MUI 4.0.


Show TOC