Tickit::Pen(3pm)
π
Tickit::Pen β the whole Tickit::Pen thing, explained
okay bestie so this is Tickit::Pen, a Perl module that stores a whole little collection of rendering attributes for text you're gonna display. Think of it as the aesthetic settings for your text β the vibe config, if you will. β¨
π DESCRIPTION
A pen instance stores a collection of rendering attributes for text to display. It comes in two forms, mutable and immutable β like, two flavours of the same energy. 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, periodt β no take-backs, no edits. 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 β glow-up whenever you want, no cap. 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.
π«Ά fr fr, that's the tea: shared mutable pens are giving "surprise plot twist" β immutable ones are the low-drama bestie.
π Attributes
The following named pen attributes are supported:
fg => COL,bg => COLβ Foreground or background colour.COLmay 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 are just not ready for that level of drama π). Some terminals may support a palette of 256 colours instead, some 16, and some only 8. The pen object will not check this, as it cannot be reliably detected in all cases.fg:rgb8 => STRING,bg:rgb8 => STRINGβ Foreground or background colour secondary RGB8 specification. The value is a string encoding the three 8-bit values in hexadecimal notation, prefixed by a hash (#) symbol; for example:
#13579B
On input, either lower- or upper-case is accepted; on output the letters will be upper-case. π
These attribute can only be set if the corresponding regular index attribute is also set. Changing or clearing the regular index will also clear the RGB8 version.
Applications wishing to use this attribute should be aware that the majority of terminal drivers will not be able to support it, and so should make sure to set an appropriate regular colour index as well. Some terminals using the xterm driver may make use of it, however, and therefore ignore the index version. π¦
b => BOOL,u => BOOL,i => BOOL,rv => BOOL,strike => BOOL,blink => BOOLβ Bold, underline, italics, reverse video, strikethrough, blink. the whole glow-up starter pack β¨af => INTβ Alternate font.
Note that not all terminals can render the italics, strikethrough, or alternate font attributes. π some terminals are just built different (worse).
π CONSTRUCTORS
new
$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. (yes it eats them, iconic behaviour honestly π)
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_mutable / clone
$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. β οΈ so like, don't get too attached to clone, it's giving "on borrowed time".
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. no duplication, just vibes π§
mutable
$is_mutable = $pen->mutable
Returns true on mutable pens and false on immutable ones.
β METHODS ON ALL PENS
The following query methods apply to both immutable and mutable pens. equal opportunity queeries π
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. the full dump, we love a data unload π
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. twins or nothing π«Ά
equiv
$equiv = $pen->equiv( $other )
Returns true if the two pens have equivalent values for all attributes.
π₯ METHODS ON MUTABLE PENS
The following mutation methods exist on mutable pens. glow-up tools, unlocked β¨
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. (yes, it eats those too β the hash is a snack π)
delattr
$pen->delattr( $attr )
Delete an attribute from this pen. This attribute will no longer be modified by this pen. bye bestie π
copy_from / default_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. (so you can chain them, slay π
)
πΈ AUTHOR
Paul Evans <leonerd@leonerd.org.uk> β the main character who wrote this π
π aaaand that's the whole page! brought to you byperl v5.42.3, dated2026-08-19. go forth and style your text, bestie β no cap, you're gonna eat. πβ¨
π¦ where this page comes from
- ubuntu stonking: libtickit-perl 0.73-1build5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms