NAME

Curses::UI::Common - Common methods for Curse::UI

SYNOPSIS

   package MyPackage;

   use Curses::UI::Common;
   use vars qw(@ISA);
   @ISA = qw(Curses::UI::Common);

DESCRIPTION

Curses::UI::Common is a collection of methods that is shared between Curses::UI classes.

METHODS

Various methods

  • parent ( )

    Returns the -parent data member.

  • root ( )

    Returns the topmost -parent (the Curses::UI instance).

  • rootscr ( )

    Returns the topmost curses window (the -scr data member of the Curses::UI instance).

  • delallwin ( )

    This method will walk through all the data members of the class intance. Each data member that is a Curses::Window descendant will be removed. This method is mostly used in the layout method of widgets to remove all contained subwidgets before adding them again.

Text processing

split_to_lines ( SCALAR )

This method will split SCALAR into a list of separate lines. It returns a reference to this list.

scrlength ( SCALAR )

Returns the screenlength of the string SCALAR. The difference with the perl function length() is that this method will expand TAB characters. It is exported by this class and it may be called as a stand-alone routine.

text_wrap ( LINE, LENGTH, WORDWRAP )
WORDWRAP ( )
NO_WORDWRAP ( )

This method will wrap a line of text (LINE) to a given length (LENGTH). If the WORDWRAP argument is true, wordwrap will be enabled (this is the default for WORDWRAP). It will return a reference to a list of wrapped lines. It is exported by this class and it may be called as a stand-alone routine.

The WORDWRAP and NO_WORDWRAP routines will return the correct value vor the WORDWRAP argument. These routines are exported by this class.

Example:

$this->text_wrap($line, 50, NO_WORDWRAP);

Reading key input

KEY_ESCAPE ( )
KEY_TAB ( )
KEY_SPACE ( )

These are a couple of routines that are not defined by the Curses module, but which might be useful anyway. These routines are exported by this class.

get_key ( BLOCKTIME, CONTROLKEYS, CURSOR )
NO_CONTROLKEYS ( )
CONTROLKEYS ( )
CURSOR_VISIBLE ( )
CURSOR_INVISIBLE ( )

This method will try to read a key from the keyboard. It will return the key pressed or -1 if no key was pressed. It is exported by this class and it may be called as a stand-alone routine.

The BLOCKTIME argument can be used to set the curses halfdelay (the time to wait before the routine decides that no key was pressed). BLOCKTIME is given in tenths of seconds. The default is 0 (non-blocking key read).

If CONTROLKEYS has a true value, the control-keys will be handled in the normal way. So a <CTRL+C> will try to interrupt the program. If it has a false value, the normal control-keys will be disabled (the terminal will be set in raw mode).

If CURSOR has a true value, the cursor will be visible during the key read (only if the terminal supports this through the curses curs_set call).

The CONTROLKEYS and NO_CONTROLKEYS routines will return the correct value vor the CONTROLKEYS argument. The CURSOR_VISIBLE and CURSOR_INVISIBLE routines will return the correct value vor the CURSOR argument. These routines are exported by this class.

Example:

my $key = $this->get_key(
    5, 
    NO_CONTROLKEYS,
    CURSOR_INVISIBLE
);

Beep control

beep_on ( )

This sets the -nobeep data member of the class instance to a false value.

beep_off ( )

This sets the -nobeep data member of the class instance to a true value.

dobeep ( )

This will call the curses beep() routine, but only if -nobeep is false.

SEE ALSO

Curses::UI,

AUTHOR

Copyright (c) 2001-2002 Maurice Makaay. All rights reserved.

This package is free software and is provided "as is" without express or implied warranty. It may be used, redistributed and/or modified under the same terms as perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 598:

'=end' without a target?