Curses:...otebook(3)

πŸ’– NAME πŸ’–

Okay bestie, this is the manual page for Curses::UI::Notebook from User Contributed Perl Documentation, and it does exactly what it says on the tin: Create and manipulate notebook widgets. ✨


πŸ¦‹ CLASS HIERARCHY πŸ¦‹

The family tree is giving very structured, very iconic:

Curses::UI::Widget
   |
   +----Curses::UI::Container
           |
           +----Curses::UI::Notebook

🌸 SYNOPSIS 🌸

Here’s the whole vibe in code, bestie β€” copy it exactly:

           use Curses::UI;
           my $cui = new Curses::UI;
           my $win = $cui->add(undef, 'Window');

           my $notebook = $win->add(undef, 'Notebook');
           my $page1 = $notebook->add_page('page 1');
           $page1->add(
               undef, 'Label',
               -x    => 15,
               -y    => 6,
               -text => "Page #1.",
           );
           my $page2 = $notebook->add_page('page 2');
           $page2->add(
               undef, 'Label',
               -x    => 15,
               -y    => 6,
               -text => "Page #2.",
           );
           my $page3 = $notebook->add_page('page 3', -on_activate => \&sub );
           $page3->add(
               undef, 'Label',
               -x    => 15,
               -y    => 6,
               -text => "Page #3.",
           );
           $notebook->focus;
           $cui->mainloop;

πŸŽ€ DESCRIPTION πŸŽ€

This package implements a notebook widget similar to the one found in Motif. A notebook holds several windows, or pages, and only one of them is visible at any given time. Tabs at the top of the widget list the pages that are available. The way this fits a great deal of information into a relatively small screen area is lowkey genius. πŸ’…

Windows users might recognize this as a tabbed dialog. Yes, bestie, it’s that familiar tabby energy. πŸͺŸβœ¨


✨ STANDARD OPTIONS ✨

These are the standard options in the squad, and Curses::UI::Widget has the full discussion of each one:

  • -x β€” standard option; the details live in Curses::UI::Widget.
  • -y β€” standard option; the details live in Curses::UI::Widget.
  • -width β€” standard option; the details live in Curses::UI::Widget.
  • -height β€” standard option; the details live in Curses::UI::Widget.
  • -pad β€” standard option; the details live in Curses::UI::Widget.
  • -padleft β€” standard option; the details live in Curses::UI::Widget.
  • -padright β€” standard option; the details live in Curses::UI::Widget.
  • -padtop β€” standard option; the details live in Curses::UI::Widget.
  • -padbottom β€” standard option; the details live in Curses::UI::Widget.
  • -ipad β€” standard option; the details live in Curses::UI::Widget.
  • -ipadleft β€” standard option; the details live in Curses::UI::Widget.
  • -ipadright β€” standard option; the details live in Curses::UI::Widget.
  • -ipadtop β€” standard option; the details live in Curses::UI::Widget.
  • -ipadbottom β€” standard option; the details live in Curses::UI::Widget.
  • -border β€” standard option; the details live in Curses::UI::Widget.
  • -sbborder β€” standard option; the details live in Curses::UI::Widget.
  • -bg β€” standard option; the details live in Curses::UI::Widget.
  • -fg β€” standard option; the details live in Curses::UI::Widget.
  • -intellidraw β€” standard option; the details live in Curses::UI::Widget.
  • -onchange β€” standard option; the details live in Curses::UI::Widget.
  • -onblur β€” standard option; the details live in Curses::UI::Widget.
🫢 Notebook-specific default tea: -border is enabled, and both -ipadleft and -ipadright are set to 1 by default when creating notebook objects. No cap. πŸ’–

🌈 WIDGET-SPECIFIC OPTIONS 🌈

  • -bindings < HASHREF > β€” the keys in this hash reference are keystrokes, and the values are routines they should be bound to. If a key is empty, the corresponding routine becomes the default routine that process_bindings applies to unmatched keystrokes it receives.

By default, these mappings are used:

KEY                 ROUTINE
------------------  ----------
KEY_HOME, Ctrl-A    first_page
KEY_END, Ctrl-E     last_page
KEY_NPAGE, Ctrl-N   next_page
KEY_PPAGE, Ctrl-P   prev_page
  • -routines < HASHREF > β€” the keys in this hash reference are routines, and the values are either scalar values or code references. process_bindings maps keystrokes to routines and then to either a scalar value, which it returns, or a code reference, which it executes.

By default, these mappings are used:

ROUTINE         ACTION
----------      -------------------------
first_page      make first page active
last_page       make last page active
next_page       make next page active
prev_page       make previous page active
  • -wraparound < BOOLEAN > β€” if BOOLEAN has a true value, wraparound is enabled. This means advancing to the next page cycles from the last page back to the first page, and similarly, advancing to the previous page cycles from the first page back to the last page.

By default, it is true. πŸ”


πŸ’… METHODS πŸ’…

  • new ( OPTIONS ) β€” constructs a new notebook object using options in the hash OPTIONS.
  • layout ( ) β€” lays out the notebook object, makes sure it fits on the available screen, and creates the curses windows for the border / tab labels as well as the effective drawing area.
  • draw ( BOOLEAN ) β€” draws the notebook object along with the active page’s window. If BOOLEAN is true, the screen is not updated after drawing.

By default, BOOLEAN is true so the screen is updated. Yes, that is what it says, bestie. 🫠

  • intellidraw ( ) β€” see Curses::UI::Widget for the explanation.
  • focus ( ) β€” see Curses::UI::Widget for the explanation.
  • onFocus ( CODEREF ) β€” see Curses::UI::Widget for the explanation.
  • onBlur ( CODEREF ) β€” see Curses::UI::Widget for the explanation.
  • add_page ( PAGE [ , -on_activate => sub_ref ] [, -on_delete => ] ) β€” adds the specified page to the notebook object and creates an associated window object. Returns the window object or undef on failure.
Note: the add fails if the page would otherwise cause the tab window to overflow or is already part of the notebook object. 🚨

The -on_activate parameter specifies an optional call-back that will be invoked when the page is activated. This call-back will be called with the notebook widget and page name as parameter.

Likewise for the -on_delete call-back. This one is invoked when the page is deleted.

  • delete_page ( PAGE ) β€” deletes the specified page from the notebook object and destroys its associated window object. If the page was active, the first page is made active.
  • active_page ( ) β€” returns the currently active page in the notebook object.
  • first_page ( ) β€” returns the first page in the notebook object.
  • last_page ( ) β€” returns the last page in the notebook object.
  • prev_page ( ) β€” returns the previous page in the notebook object.
  • next_page ( ) β€” returns the next page in the notebook object.
  • activate_page ( PAGE ) β€” makes the specified page in the notebook object active and returns it, redrawing the notebook object in the process.
  • mouse_button1 ( ) β€” processes mouse button #1 clicks. If the user left-clicks on one of the tabs, activate_page is called with the corresponding page to make it active; otherwise, the click is passed along to the active window. πŸ–±οΈβœ¨

πŸ¦‹ SEE ALSO πŸ¦‹

  • Curses::UI
  • Curses::UI::Container
  • Curses::UI::Widget

πŸ‘‘ AUTHOR πŸ‘‘

George A. Theall, <theall@tifaware.com> πŸ’Œ


Copyright (c) 2004, George A. Theall. All rights reserved.

This script is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


Okay bestie, this page came from source/version perl v5.42.2 and is dated 2023-07-03. Periodt. πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from