Prima::PodView(3)
π Prima::PodView(3) β User Contributed Perl Documentation π
okay so bestie, welcome to the Prima::PodView(3) page. it's giving POD browser widget energy, and we're gonna keep every detail intact while making it make sense. iykyk β¨
β¨ NAME β¨
Prima::PodView β POD browser widget. that's it, that's the name section, but it's iconic π
πΈ SYNOPSIS πΈ
here's the whole vibe in code, exactly as it appears β no cap:
use Prima qw(Application PodView);
my $window = Prima::MainWindow-> create;
my $podview = $window-> insert( 'Prima::PodView',
pack => { fill => 'both', expand => 1 }
);
$podview-> open_read;
$podview-> read("=head1 NAME\n\nI'm also a pod!\n\n");
$podview-> close_read;
run Prima;
π DESCRIPTION π
Prima::PodView contains a formatter (in terms of perlpod) and a viewer of the POD content. It heavily employs its ascendant class Prima::TextView, and is in turn the base class for the toolkit's default help viewer Prima::HelpViewer. full stack POD realness π
π USAGE π
The package consists of several logically separated parts. These include file locating and loading, formatting, and navigation. lowkey a whole little ecosystem π«Ά
π§ Content methods π§
The basic access to the content is not bound to the file system. The POD content can be supplied without any file to the viewer. Indeed, the file loading routine load_file is a mere wrapper to the following content-loading functions:
open_read %OPTIONSβ Clears the current content and enters the reading mode. In this mode, the content can be appended by repeatedly calling thereadmethod that pushes the raw POD content to the parser. reading mode activate πread TEXTβ Supplies theTEXTstring to the parser. Parses basic indentation, but the main formatting is performed insideaddandadd_formatted. Must be called only within theopen_read/close_readbrackets. no soloreadruns, bestie π«close_readβ Closes the reading mode and starts the text rendering by callingformat. Returnsundefif there is no POD context, 1 otherwise. bye bye reading mode π
π¦ Rendering π¦
The rendering is started by the format call which returns almost immediately, initiating the mechanism of delayed rendering, which is often time-consuming. format's only parameter KEEP_OFFSET is a boolean flag, which, if set to 1, remembers the current location on a page, and when the rendered text approaches the location, scrolls the document automatically. set it to 1 and it remembers where you were π§
The rendering is based on a document model, generated by the open_read/close_read session. The model is a set of the same text blocks defined by Prima::TextView, except that the header length is only three integers:
pod::M_INDENT - the block X-axis indent
pod::M_TEXT_OFFSET - same as BLK_TEXT_OFFSET
pod::M_FONT_ID - 0 or 1, because PodView's fontPalette contains only two fonts -
variable ( 0 ) and fixed ( 1 ).
The actual rendering is performed in format_chunks, where model blocks are transformed into text blocks, wrapped, and pushed into the TextView-provided storage. In parallel, links and the corresponding event rectangles are calculated at this stage. format_chunks is doing the most π
β Topics β
Prima::PodView provides the ::topicView property, which manages whether the man page is viewed by topics or as a whole. When a page is in the single topic mode, the {modelRange} array selects the model blocks that include the topic to be displayed. That way the model stays the same while text blocks inside the widget can be changed. model stays, text blocks shift β it's giving efficient β¨
π Styles π
In addition to styles provided by Prima::Drawable::Pod, Prima::PodView defines colorMap entries for pod::STYLE_LINK, pod::STYLE_CODE, and pod::STYLE_VERBATIM:
COLOR_LINK_FOREGROUND
COLOR_CODE_FOREGROUND
COLOR_CODE_BACKGROUND
The default colors in the styles are mapped into these entries. colorMap girlies rise π¨
π Link and navigation methods π
Prima::PodView provides the hand-icon mouse pointer that highlights links. Also, the link documents or topics are loaded in the widget when the user presses the mouse button on the link. Prima::Widget::Link is used for the implementation of the link mechanics. hand cursor says click me π
If the page is loaded successfully, depending on the ::topicView property value, either the select_topic or select_text_offset method is called.
The family of file and link access functions consists of the following methods:
load_file MANPAGEβ Loads the manpage if it can be found in thePATHor perl installation directories. If unsuccessful, displays an error. if it's not found, error time πload_link LINKβLINKis a text in the format of perlpodL<>link:manpage/section. Loads the manpage, if necessary, and selects the section. link go brrr π¦load_bookmark BOOKMARKβ Loads the bookmark string prepared by themake_bookmarkfunction. Used internally.load_content CONTENTβ Loads content into the viewer. Returnsundefif there is no POD context, 1 otherwise.make_bookmark [ WHERE ]β Combines the information about the currently viewing page source, topic, and text offset, into a storable string.WHERE, an optional string parameter, can be either omitted, in such case the current settings are used, or be one of the'up','next', or'prev'strings.- The
'up'string returns a bookmark to the upper level of the manpage. - The
'next'and'prev'return a bookmark to the next or the previous topics in the manpage. - If the location cannot be stored or defined,
undefis returned. bookmark said no π
- The
π₯ Events π₯
Bookmark BOOKMARKβ When a new topic is navigated by the user, this event is triggered with the current topic to have it eventually stored in the bookmarks or user history. history girlies stay winning πLink LINK_REF, BUTTON, MOD, X, Yβ When the user clicks on a link, this event is called with the link address, mouse button, modification keys, and coordinates. click event unlocked πNewPageβ Called after new content is loaded. new page, new me β¨
π SEE ALSO π
Prima::Drawable::PodPrima::Drawable::TextView
mwah π β source/version: perl v5.42.0, date: 2024-08-20. now go browse some POD, bestie π«Άπ
π¦ where this page comes from
- opensuse-leap 16.0: perl-Prima 1.74000-bp160.1.13 Β· AGPL-3.0-only AND BSD-2-Clause
- opensuse-leap 16.0: perl-Prima 1.74000-bp160.1.13 Β· AGPL-3.0-only AND BSD-2-Clause
- opensuse-leap 16.0: perl-Prima 1.74000-bp160.1.13 Β· AGPL-3.0-only AND BSD-2-Clause
- opensuse-leap 16.0: perl-Prima 1.74000-bp160.1.13 Β· AGPL-3.0-only AND BSD-2-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms