Prima::Markup - Allow markup in Prima Widgets
use Prima qw(Application Buttons Drawable::Markup); Prima::Button->new( ... text => Prima::Drawable::Markup->new(text => "B<Bold> bU<u>tton"), hotKey => 'u', );
Prima::Markup adds the ability to recognize POD-like markup to Prima widgets. Supported markup sequences are B (bold text), I (italic text), U (underlined text), F (change font), S (change font size), C (change foreground color), Q (change background color), M (move pointer), and W (disable wrapping).
Prima::Markup
B
I
U
F
S
C
Q
M
W
The F sequence is used as follows: F<n|text>, where n is a 0-based index into the fontPalette.
F<n|text>
n
fontPalette
The S sequence is used as follows: S<n|text>, where n is the number of points relative to the current font size. The font size may optionally be preceded by + or -.
S<n|text>
+
-
The C and Q sequences are used as follows: C<c|text>, where c is either: a color in any form accepted by Prima, including the cl constants (Black Blue Green Cyan Red Magenta Brown LightGray DarkGray LightBlue LightGreen LightCyan LightRed LightMagenta Yellow White Gray). Or, a 0-based index into the colorPalette. Also, default can be used to set the color that the canvas originaly had. For Q a special value off can be used to turn off background color and set it as transparent.
C<c|text>
c
cl
Black
Blue
Green
Cyan
Red
Magenta
Brown
LightGray
DarkGray
LightBlue
LightGreen
LightCyan
LightRed
LightMagenta
Yellow
White
Gray
colorPalette
default
off
The M command has three paramaters, comma-separated: X, Y, and flags. X and Y are coordinates how much to move the current pointer. By default X and are in pixels, and do not extend block width. flags is a set of characters, where each is:
flags
m - set units to font height p - set units to points x - also extend the block width
The text inside W sequence will not be wrapped during text_wrap calls.
text_wrap
The methods text_out and get_text_width are affected by Prima::Markup. text_out will write formatted text to the canvas, and get_text_width will return the width of the formatted text. NOTE: These methods do not save state between calls, so your markup cannot span lines (since each line is drawn or measured with a separate call).
text_out
get_text_width
The following properties are used:
Gets or sets the color palette to be used for C sequences within this widget. Each element of the array should be a cl:: constant.
cl::
Gets or sets the font palette to be used for F sequences within this widget. Each element of the array should be a hashref suitable for setting a font.
If 0, bidirection text processing if off. If 1, set to 1 iff Prima::Bidi is loaded and enabled.
Prima::Bidi
Prima::Drawable::TextBlock
Copyright 2003 Teo Sankaro
You may redistribute and/or modify this module under the same terms as Perl itself. (Although a credit would be nice.)
This module based on work by Teo Sankaro, <teo_sankaro@hotmail.com>.
To install Prima, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Prima
CPAN shell
perl -MCPAN -e shell install Prima
For more information on module installation, please visit the detailed CPAN module installation guide.