Cmenu
view release on metacpan or search on metacpan
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.
@EXPORT = qw(
menu_initialise
menu_init
menu_item
menu_display
menu_show
menu_popup
menu_button_set
menu_terminate
);
@EXPORT_OK = qw (
$menu_sep
$menu_sepn
);
$Cmenu::VERSION ='1.01';
use vars qw($VERSION $menu_sep $menu_sepn);
BEGIN {
# Field seperator characters returned after menu activity
# menu_sep seperates individual fields
# menu_sepn breaks up field name from field contents
$menu_sep="¬";
$menu_sepn="~";
}
# ##################################################################################
# Public variables and functions
# ==============================
# These variables and functions are available for user programs
# While others may be accessed, they are in fact surreal
# and may cease to exist in later releases
# ---< variables >------------------------------------------------------------------
# $menu_screen : the base curses screen
# $menu_screen_lines : current logical depth of the screen
# $menu_screen_cols : current logical width of the screen
# $menu_inlay : the main display
# $menu_inlay_lines : depth of the menu inlay
# $menu_inlay_cols : width of the menu inlay
# $menu_inlay_y : y offset of inlay from screen top 0
# $menu_inlay_x : x offset of inlay from screen left 0
# $menu_advice : standard text for display at foot
# ---< functions >------------------------------------------------------------------
# All menu functions generally apply keypad, echo and other Curses ops, on
# return from any function Curses settings can be guaranteed as if these calls
# had been made directly
# &echo();
# &nocbreak();
# &curs_set(1);
# keypad control is only applied to new windows which should always be destroyed
# before returning.
# ----------------------------------------------------------------------------------
# &menu_initialise : sets up all menu variables and constructs
# &menu_button_set : swicthes menu buttons on and off
# &menu_item : create a menu item
# &menu_display : display a menu and get a response from it
# &menu_popup : flash a busy window
# &menu_show : gives a full screen text display
# &menu_terminate : close the menu environment down
# ----------------------------------------------------------------------------------
# All Curses functions can of course be used in user programs but be aware that
# management of all windows then becomes the users responsibility and behaviour
# of the menuing environment may be unpredictable
# ##################################################################################
# ##################################################################################
# Variable Definitions
# ##################################################################################
my $did_initterm = 0; # We already got escape sequences for arrows, etc.
# Keystroke arrays
my %kseq=(); # hash for function key translation
my $key_max=0; # longest keystroke
# Windows
my $menu_screen; # the backdrop
my $menu_inlay; # background for the menu window with shadow etc
my $menu_window; # menu window with text elements
my $menu_pane; # where the menu options actually get drawn
my $menu_popup; # special for popup and splash displays
# Window elements
my $menu_title; # title of script in backdrop
my $menu_top_title; # title of menu
my $menu_sub_title; # sub-title of a menu
my $menu_sub_title_lines; # depth of sub-title
my $menu_advice; # message at foot of backdrop
my $menu_item_pos; # where menu items will start
my $menu_indent; # where menu item labels will start
my $menu_index; # counter of menu items
# Extent of display screen - fixed - unchangeable - from TERM settings
# Always starts at 0,0
my $menu_screen_cols=0; # - COLS from Curses } size of the full screen
my $menu_screen_lines=0; # - LINES from Curses }
# Extent of Menu Inlay - size and position of main window
# Amendable via preferences
# Mono screens lose the shadow so get a bigger inlay
my $menu_inlay_lines=0;
my $menu_inlay_cols=0;
my $menu_inlay_y=3; # 2 for mono
my $menu_inlay_x=6; # 4 for mono
# Extent of Menu text pane
# All defined at runtime depending on the menu items
my $menu_pane_lines=0;
my $menu_pane_cols=0;
my $menu_pane_y=0;
my $menu_pane_x=0;
my $menu_pane_scroll;
my $menu_resized=0; # trigger for terminal resizing
my $menu_style=0; #
my $max_item_len=0; # longest menu item
( run in 0.867 second using v1.01-cache-2.11-cpan-39bf76dae61 )