|
NAMEPrima::PodView - POD browser widgetSYNOPSISuse 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; DESCRIPTIONPrima::PodView contains a formatter ( in terms of perlpod ) and viewer of POD content. It heavily employs its ascendant class Prima::TextView, and is in turn base for the toolkit's default help viewer Prima::HelpViewer.USAGEThe package consists of the several logically separated parts. These include file locating and loading, formatting and navigation.Content methodsThe 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 content loading functions:
RenderingThe rendering is started by "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.The rendering is based an a document model, generated by open_read/close_read session. The model is a set of same text blocks defined by Prima::TextView, except that the header length is only three integers: M_INDENT - the block X-axis indent M_TEXT_OFFSET - same as BLK_TEXT_OFFSET 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 to the full text blocks, wrapped and pushed into TextView-provided storage. In parallel, links and the corresponding event rectangles are calculated on this stage. TopicsPrima::PodView provides the "::topicView" property, which governs whether the man page is viewed by topics or as a whole. When it is viewed as topics, "{modelRange}" array selects the model blocks that include the topic. Thus, having a single model loaded, text blocks change dynamically.Topics contained in "{topics}" array, each is an array with indices of "T_XXX" constants: T_MODEL_START - beginning of topic T_MODEL_END - length of a topic T_DESCRIPTION - topic name T_STYLE - STYLE_XXX constant T_ITEM_DEPTH - depth of =item recursion T_LINK_OFFSET - offset in links array, started in the topic Styles"::styles" property provides access to the styles, applied to different pod text parts. These styles are:STYLE_CODE - style for C<> STYLE_TEXT - normal text STYLE_HEAD_1 - =head1 STYLE_HEAD_2 - =head2 STYLE_HEAD_3 - =head3 STYLE_HEAD_4 - =head4 STYLE_ITEM - =item STYLE_LINK - style for L<> text STYLE_VERBATIM - style for pre-formatted text Each style is a hash with the following keys: "fontId", "fontSize", "fontStyle", "color", "backColor", fully analogous to the tb::BLK_DATA_XXX options. This functionality provides another layer of accessibility to the pod formatter. In addition to styles, Prima::PodView defined "colormap" entries for "STYLE_LINK" , "STYLE_CODE", and "STYLE_VERBATIM": COLOR_LINK_FOREGROUND COLOR_LINK_BACKGROUND COLOR_CODE_FOREGROUND COLOR_CODE_BACKGROUND The default colors in the styles are mapped into these entries. Link and navigation methodsPrima::PodView provides a hand-icon mouse pointer highlight for the link entries and as an interactive part, the link documents or topics are loaded when the user presses the mouse button on the link. The mechanics below that is as follows. "{contents}" of event rectangles, ( see Prima::TextView ) is responsible for distinguishing whether a mouse is inside a link or not. When the link is activated, "link_click" is called, which, in turn, calls "load_link" method. If the page is loaded successfully, depending on "::topicView" property value, either "select_topic" or "select_text_offset" method is called.The family of file and link access functions consists of the following methods:
Events
Visit the GSP FreeBSD Man Page Interface. |