NAME
Tickit::Pen
- store a collection of rendering attributes
DESCRIPTION
Stores rendering attributes for text to display.
Supports the following named pen attributes:
- fg => COL
- bg => COL
-
Foreground or background colour.
COL
may be an integer or one of the eight colour names. A colour name may optionally be prefixed byhi-
for the high-intensity version (may not be supported by all terminals). Some terminals may support a palette of 256 colours instead, some 16, and some only 8. ThePen
object will not check this as it cannot be reliably detected in all cases. - b => BOOL
- u => BOOL
- i => BOOL
- rv => BOOL
- strike => BOOL
-
Bold, underline, italics, reverse video, strikethrough.
- af => INT
-
Alternate font.
Note that not all terminals can render the italics, strikethrough, or alternate font attributes.
CONSTRUCTORS
$pen = Tickit::Pen->new( %attrs )
Returns a new pen, initialised from the given attributes.
$pen = Tickit::Pen->new_from_attrs( $attrs )
Returns a new pen, initialised from keys in the given HASH reference. Used keys are deleted from the hash.
$pen = $orig->clone
Returns a new pen, initialised by copying the attributes of the original.
METHODS
$value = $pen->getattr( $attr )
Returns the current value of the given attribute
%values = $pen->getattrs
Returns a key/value list of all the attributes
$pen->chattr( $attr, $value )
Change the value of an attribute. Setting undef
implies default value. To delete an attribute altogether, see instead delattr
.
$pen->chattrs( \%attrs )
Change the values of all the attributes given in the hash. Recgonised attributes will be deleted from the hash.
$pen->delattr( $attr )
Delete an attribute from this pen. This attribute will no longer be modified by this pen.
$pen->copy_from( $other )
$pen->default_from( $other )
Copy attributes from the given pen. copy_from
will override attributes already defined by $pen
; default_from
will only copy attributes that are not yet defined by $pen
.
As a convenience both methods return $pen
.
$pen->add_on_changed( $observer, $id )
Add an observer to the list of objects which will be informed when the pen attributes change. The observer will be informed by invoking a method on_pen_changed
, passing in the pen reference and the opaque ID value given to this method.
$observer->on_pen_changed( $pen, $id )
The observer object is stored weakly, so it is safe to add the Tickit::Widget
object that is using the pen as an observer. The ID value is not weakened.
$pen->remove_on_changed( $observer )
Remove an observer previously added by add_on_changed
.
AUTHOR
Paul Evans <leonerd@leonerd.org.uk>