|
NAME"Tickit::Pen" - store a collection of rendering attributesDESCRIPTIONA pen instance stores a collection of rendering attributes for text to display. It comes in two forms, mutable and immutable. Both types of pen are subclasses of the base "Tickit::Pen" class.An immutable pen is an instance of "Tickit::Pen::Immutable". Its attributes are set by the constructor and are fixed thereafter. Methods are provided to query the presence or value of attributes, and to fetch the entire set as a hash. A mutable pen is an instance of "Tickit::Pen::Mutable". Its attributes may be set by the constructor, and can be changed at any time. As well as supporting the same query methods as immutable pens, more methods are provided to change or remove them. While mutable pens may initially seem more useful, they can complicate logic due to their shared referential nature. If the same mutable pen is shared across multiple places, care needs to be taken to redraw anything that depends on it if it is ever changed. If pens need sharing, especially if results are cached for performance, consider using immutable pens to simplify the logic. AttributesThe following named pen attributes are supported:
Note that not all terminals can render the italics, strikethrough, or alternate font attributes. CONSTRUCTORSnew$pen = Tickit::Pen->new( %attrs ) Returns a new pen, initialised from the given attributes. Currently this method returns a "Tickit::Pen::Mutable", though this may change in a future version. It is provided for backward-compatibility for code that expects to be able to construct a "Tickit::Pen" directly. $pen = Tickit::Pen::Immutable->new( %attrs ) $pen = Tickit::Pen::Mutable->new( %attrs ) Return a new immutable, or mutable pen, initialised from the given attributes. new_from_attrs$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. Currently this method returns a "Tickit::Pen::Mutable", though this may change in a future version. It is provided for backward-compatibility for code that expects to be able to construct a "Tickit::Pen" directly. $pen = Tickit::Pen::Immutable->new_from_attrs( $attrs ) $pen = Tickit::Pen::Mutable->new_from_attrs( $attrs ) Return a new immutable, or mutable pen, initialised from the given attributes. as_mutableclone$pen = $orig->as_mutable $pen = $orig->clone Returns a new mutable pen, initialised by copying the attributes of the original. "clone" is provided as a legacy alias, but may be removed in a future version. as_immutable$pen = $orig->as_immutable Returns an immutable pen, initialised by copying the attributes of the original. When called on an immutable pen, this method just returns the same pen instance. mutable$is_mutable = $pen->mutable Returns true on mutable pens and false on immutable ones. METHODS ON ALL PENSThe following query methods apply to both immutable and mutable pens.hasattr$exists = $pen->hasattr( $attr ) Returns true if the given attribute exists on this object getattr$value = $pen->getattr( $attr ) Returns the current value of the given attribute getattrs%values = $pen->getattrs Returns a key/value list of all the attributes equiv_attr$equiv = $pen->equiv_attr( $other, $attr ) Returns true if the two pens have the equivalent values for the given attribute; that is, either both define it to the same value, or neither defines it. equiv$equiv = $pen->equiv( $other ) Returns true if the two pens have equivalent values for all attributes. METHODS ON MUTABLE PENSThe following mutation methods exist on mutable pens.chattr$pen->chattr( $attr, $value ) Change the value of an attribute. Setting "undef" deletes the attribute entirely. See also "delattr". chattrs$pen->chattrs( \%attrs ) Change the values of all the attributes given in the hash. Recgonised attributes will be deleted from the hash. delattr$pen->delattr( $attr ) Delete an attribute from this pen. This attribute will no longer be modified by this pen. copy_fromdefault_from$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. AUTHORPaul Evans <leonerd@leonerd.org.uk>
Visit the GSP FreeBSD Man Page Interface. |