Cmenu

 view release on metacpan or  search on metacpan

Cmenu.pm  view on Meta::CPAN

      attrset($menu_pane,$menu_attributes{"rtitle"});
      addstr($menu_pane,$menu_sel_label[$m_item]);
      last MENU_STYLE;
    };

    /8/ && do {
      # 
      # Display option text
      move($menu_pane,$i,$m_indent+$menu_item_pos-1-length($menu_sel_label[$m_item]));
      attrset($menu_pane,$menu_attributes{"rtitle"});
      addstr($menu_pane,$menu_sel_label[$m_item]);
      last MENU_STYLE;
    };

    /9/ && do {
      # seperator
      last MENU_STYLE;
    };
  }
  if($menu_sel_style[$m_item]==5) {
    # Display item text right aligned
    move($menu_pane,$i,$m_indent+$menu_item_pos+$max_item_len-length($menu_sel_text[$m_item]));
    attrset($menu_pane,$menu_attributes{"rtext"});
    addstr($menu_pane,$menu_sel_text[$m_item]);
  } else {
    # Display item text
    move($menu_pane,$i,$m_indent+$menu_item_pos);
    attrset($menu_pane,$menu_attributes{"rtext"});
    addstr($menu_pane,$menu_sel_text[$menu_cur_option]);
  }
}

#**********
#  MENU_CREATE_PANE
#
#  Function:	Create a window within the menu window to display items
#
#  Call format:	&menu_create_pane();
#
#  Arguments:   none
#
#  Returns:     undetermined
#
#**********
sub menu_create_pane {
  # Initialise menu pane and control variables
  $menu_pane=newwin($menu_pane_lines-2,$menu_pane_cols-2,$menu_pane_y+1,$menu_pane_x+1);
  bkgd($menu_pane,$menu_attributes{"text"});
  clear($menu_pane);
  idlok($menu_pane,1);
  scrollok($menu_pane,1);
  $menu_top_option=0;
  keypad($menu_pane,1);
  &menu_draw_pane();
}

#*********
# MENU_DRAW_PANE
#
# Function:  Draws the actual menu especially after a keystroke
#            Usually only necessary after big relocations of the menu cursor
#
# Input:     Nothing
#
# Returns:   Nothing 
#
#*********
sub menu_draw_pane {
  my ($i); 

  # Performs test to make sure the items are aligned correctly to use as much of the
  # screen as possible
  if(($menu_top_option+($menu_pane_lines-2))>$menu_index-1) { $menu_top_option=$menu_index-1-($menu_pane_lines-3); }
  if($menu_top_option<0) {$menu_top_option=0; }
  if($menu_cur_option>$menu_index-1) { $menu_cur_option=$menu_index-1; }
  if($menu_cur_option>=($menu_top_option+($menu_pane_lines-2))) {$menu_top_option=$menu_cur_option-($menu_pane_lines-3); }
  if($menu_top_option<0) {$menu_top_option=0; }
  if($menu_cur_option<$menu_top_option) { $menu_cur_option=$menu_top_option; }
  # Now draw the menu items
  clear($menu_pane);
  $i=$menu_top_option;
  while(($i<$menu_index)&&(($i-$menu_top_option)<$menu_pane_lines-2)) {
    &menu_draw_line($i,$menu_indent);
    $i++;
  }
  &menu_draw_active($menu_cur_option,$menu_indent);
  &noutrefresh($menu_pane);
}


#**********
# MENU_KEY_SEQ -- Collect characters until a sequence we recognize (or we
#		  know it cannot possibly fit any "magic" sequences.
#
#  Call format:	$sel = &menu_key_seq();
#
#  Arguments:   none
#
#  Returns:     either a single letter or a key stroke mneumonic for an action to do
#               in some cases it will return nothing if;
#                  - an invalid/unrecognised function key was pressed
#                  - the screen was resized
#               bum values like these should be ignored
#
#**********
sub menu_key_seq {
  my ($cwin) = @_;
  my ($possible,$ch);
  my ($collect,$action) = "";
  my ($resizing)=0;

  $possible = 0;	# Set number of possible matches 

  # Trapping resizing strings waiting for them to stop
 resize_trap:
  do {
    $collect="";
    $action="";
  seq_seek:
    while ($possible <$key_max) {
      $ch = &getch($cwin);



( run in 0.960 second using v1.01-cache-2.11-cpan-71847e10f99 )