view release on metacpan or search on metacpan
If there are no active timed events at all,
the timeout will be -1, which causes a full
blocking read. In this way as little as possible
resources are used.
- -windowscr, screenwidth and screenheight were a
little bit too cryptic I think. These are now
renamed to -canvasscr, canvaswidth and
canvasheight.
- Fixed bug in Searchable.pm (cursor was not visible
during search).
- Switched testing to Test::Harness (t/*.t)
- Buttonbox now also has Curses::UI->fatalerror() in
case of an illegal button definition.
- Curses::UI now checks if there is only one
instance of Curses:UI and it now exports
MainLoop() (just for fun, it is like the
- Curses::UI::Popupbox
- Curses::UI::Progressbar
- Curses::UI::TextEditor (+ descendants)
- Curses::UI::SearchEntry
- Added a little example application to demonstrate
the new intellidraw feature: examples/demo-intellidraw
2002-01-15: - Changed the displaying of the calendar widget
a little. The topbar showing a date is only
highlighted if the cursor is on the selected date.
- Renamed some widgets (now we still can). I think
there are too many capitals in them...
- Curses::UI::ListBox renamed to
Curses::UI::Listbox
- Curses::UI::CheckBox renamed to
Curses::UI::Checkbox
- Curses::UI::MenuBar renamed to
Curses::UI::Menubar
- Curses::UI::MenuListBox renamed to
examples/color_editor view on Meta::CPAN
-tfg => "white",
);
if (defined $file)
{
if (open F, "<$file") {
my $text = "";
while (<F>) { $text .= $_ }
close F;
$editor->text($text);
$editor->cursor_to_home;
$currentfile = $file;
} else {
$cui->error(-message => "Can't read file \"$file\":\n$!");
}
}
}
sub save_dialog()
{
examples/demo-widgets view on Meta::CPAN
$w{8}->add(
undef, 'Label',
-text => "The calendar can be used to select a date, somewhere between\n"
. "the years 0 and 9999. It honours the transition from the\n"
. "Julian- to the Gregorian calender in 1752."
);
$w{8}->add(
undef, 'Label',
-y => 5, -x => 27,
-text => "Use your cursor keys (or <H>, <J>, <K> and <L>)\n"
. "to walk through the calender. Press <ENTER>\n"
. "or <SPACE> to select a date. Press <SHIFT+J> to\n"
. "go one month forward and <SHIFT+K> to go one\n"
. "month backward. Press <SHIFT+L> or <N> to go one\n"
. "year forward and <SHIFT+H> or <P> to go one year\n"
. "backward. Press <T> to go to today's date. Press\n"
. "<C> to go to the currently selected date."
);
$w{8}->add(
examples/editor view on Meta::CPAN
-file => $currentfile,
);
if (defined $file)
{
if (open F, "<$file") {
my $text = "";
while (<F>) { $text .= $_ }
close F;
$editor->text($text);
$editor->cursor_to_home;
$currentfile = $file;
} else {
$cui->error(-message => "Can't read file \"$file\":\n$!");
}
}
}
sub save_dialog()
{
examples/pop3_reader view on Meta::CPAN
my $buttons = shift;
my $conwin = $buttons->parent;
my $cui = $conwin->root;
foreach my $key ('username','password','host','port')
{
my $obj = $conwin->getobj($key);
my $value = $obj->get;
$connection->{$key} = $value;
# TODO: focus back to entry does not seem to
# move the cursor with it.
if ($value =~ /^\s*$/) {
$cui->error("Missing value for $key field");
$obj->focus;
return;
}
}
return 1;
}
lib/Curses/UI.pm view on Meta::CPAN
my ($class,%userargs) = @_;
fatalerror("Curses::UI->new can only be called once!")
if $Curses::UI::initialized;
&Curses::UI::Common::keys_to_lowercase(\%userargs);
my %args = (
-compat => 0, # Use compatibility mode?
-clear_on_exit => 0, # Clear screen if program exits?
-cursor_mode => 0, # What is the current cursor_mode?
-debug => undef, # Turn on debugging mode?
-keydelay => 0, # Track seconds since last keystroke?
-language => undef, # Which language to use?
-mouse_support => 1, # Do we want mouse support
-overlapping => 1, # Whether overlapping widgets are supported
-color_support => 0,
-default_colors=> 1,
#user data
-userdata => undef, #user internal data
%userargs,
lib/Curses/UI.pm view on Meta::CPAN
# ----------------------------------------------------------------------
# TODO: document
sub do_one_event(;$)
{
my $self = shift;
my $object = shift;
$object = $self unless defined $object;
eval {curs_set($self->{-cursor_mode})};
# gpm mouse?
if ($Curses::UI::gpm_mouse) {
$self->handle_gpm_mouse_event($object);
doupdate();
}
# Read a key or use the feeded key.
my $key = $self->{-feedkey};
unless (defined $key) {
lib/Curses/UI.pm view on Meta::CPAN
}
if ($config->{-lastrun} <= ($now - $config->{-time}))
{
$config->{-callback}->($self);
$config->{-lastrun} = $now;
$timers_done++;
}
}
# Bring the cursor back to the focused object by
# redrawing it. Due to drawing other objects, it might
# have moved to another widget or screen location.
#
$self->focus_path(-1)->draw if $timers_done;
return $self;
}
# ----------------------------------------------------------------------
# Mouse events
lib/Curses/UI.pm view on Meta::CPAN
}
# ----------------------------------------------------------------------
# Accessor functions
# ----------------------------------------------------------------------
sub compat(;$) { shift()->accessor('-compat', shift()) }
sub clear_on_exit(;$) { shift()->accessor('-clear_on_exit', shift()) }
sub cursor_mode(;$) { shift()->accessor('-cursor_mode', shift()) }
sub lang(;$) { shift()->accessor('-language_object', shift()) }
sub overlapping(;$) { shift()->accessor('-overlapping', shift()) }
# TODO: document
sub debug(;$)
{
my $self = shift;
my $value = shift;
$Curses::UI::debug = $self->accessor('-debug', $value);
}
lib/Curses/UI/Buttonbox.pm view on Meta::CPAN
-y => 0, # the vertical pos rel. to parent
-bg => -1,
-fg => -1,
%userargs,
-routines => {%routines},
-bindings => {%bindings},
-focus => 0, # init value
-nocursor => 1, # this widget does not use a cursor
);
# The windowscr height should be 1.
my $height = $args{-vertical} ? scalar @{$args{-buttons}} : 1;
$args{-height} = height_by_windowscrheight($height ,%args);
# Create the widget.
my $this = $class->SUPER::new( %args );
# Process button definitions.
lib/Curses/UI/Buttonbox.pm view on Meta::CPAN
# Check if active element isn't out of bounds.
$this->{-selected} = 0 unless defined $this->{-selected};
$this->{-selected} = 0 if $this->{-selected} < 0;
$this->{-selected} = $this->{-max_selected}
if $this->{-selected} > $this->{-max_selected};
# Draw the buttons.
my $id = 0;
my $x = 0;
my $y = 0;
my $cursor_x = 0;
foreach my $button (@{$this->{-buttons}})
{
# Let there be color
if ($Curses::UI::color_support) {
my $co = $Curses::UI::color_object;
my $pair = $co->get_color_pair(
$this->{-fg},
$this->{-bg});
lib/Curses/UI/Buttonbox.pm view on Meta::CPAN
container in which the widget is loose its focus. If you do
not like this behaviour, then you can have it loose focus itself
by calling:
$buttonswidget->set_routine('loose-focus', 'RETURN');
For an explanation of B<set_routine>, see
L<Curses::UI::Widget|Curses::UI::Widget>.
=item * <B<cursor left>>, <B<h>>
Call the 'previous' routine. This will make the previous
button the active button. If the active button already is
the first button, nothing will be done.
=item * <B<cursor right>>, <B<l>
Call the 'next' routine. This will make the next button the
active button. If the next button already is the last button,
nothing will be done.
=item * <B<any other key>>
This will call the 'shortcut' routine. This routine will
handle the shortcuts that are set by the B<-shortcuts> option.
lib/Curses/UI/Calendar.pm view on Meta::CPAN
%userargs,
-routines => {%routines},
-bindings => {%bindings},
-ipadleft => 1,
-ipadright => 1,
-ipadbottom => 0,
-ipadtop => 0,
-focus => 0,
-nocursor => 1,
);
# The widget width should be at least 20.
my $min_width = width_by_windowscrwidth(20, %args);
$args{-width} = $min_width if $args{-width} != -1
and $args{-width} < $min_width;
# The widget height should be at least 11.
my $min_height = height_by_windowscrheight(11, %args);
$args{-height} = $min_height if $args{-height} != -1
and $args{-height} < $min_height;
my $this = $class->SUPER::new( %args );
# Split up and fix the date.
$this->setdate($this->{-date}, 1);
# Set cursor to current date.
$this->{-cyear} = $this->{-year};
$this->{-cmonth} = $this->{-month};
$this->{-cday} = $this->{-day};
# Load day- and monthnames.
@days = $this->root->lang->getarray('days_short');
@months = (undef, $this->root->lang->getarray('months'));
if ($Curses::UI::ncurses_mouse) {
$this->set_mouse_binding(
lib/Curses/UI/Calendar.pm view on Meta::CPAN
$this->make_sane_date;
$this->intellidraw unless $nodraw;
return $this;
}
sub make_sane_date()
{
my $this = shift;
my $cursor = shift;
my $c = $cursor ? 'c' : '';
# Determine 'today'.
my @now = localtime(); $now[4]++; $now[5]+=1900;
# Use today's values if undefined.
$this->{"-${c}day"} = $now[3]
unless defined $this->{"-${c}day"};
$this->{"-${c}month"} = $now[4]
unless defined $this->{"-${c}month"};
$this->{"-${c}year"} = $now[5]
lib/Curses/UI/Calendar.pm view on Meta::CPAN
# Bold font on if the widget has focus and the selected
# date is the active date.
$this->{-canvasscr}->attron(A_BOLD)
if $this->{-focus} and
$this->{-cyear} == $this->{-year} and
$this->{-cmonth} == $this->{-month} and
$this->{-cday} == $this->{-day};
# Draw day, month and year. If the widget has focus,
# show the cursor position. Else show the selected position.
my $c = $this->{-focus} ? 'c' : '';
$this->{-canvasscr}->addstr(0,0," "x$this->canvaswidth);
$this->{-canvasscr}->addstr(0,0, $months[$this->{"-${c}month"}]
. " " . $this->{"-${c}day"});
$this->{-canvasscr}->addstr(0,$this->canvaswidth-4,$this->{"-${c}year"});
# Draw daynames
$this->{-canvasscr}->attron(A_BOLD) if $this->{-focus};
$this->{-canvasscr}->addstr(2,0,join " ", @days);
lib/Curses/UI/Calendar.pm view on Meta::CPAN
$this->{-canvasscr}->attroff(A_REVERSE);
$this->{-canvasscr}->attroff(A_BOLD);
$weekday++;
if ($weekday == 7) {
$weekday = 0;
$y++;
}
}
# Move the cursor to the bottomright corner of the widget
# (in case the terminal does not support widget hiding).
$this->{-canvasscr}->move($this->canvasheight-1, $this->canvaswidth-1);
$this->{-canvasscr}->noutrefresh();
doupdate() unless $no_doupdate;
return $this;
}
sub date_selected()
lib/Curses/UI/Calendar.pm view on Meta::CPAN
=item * <B<tab>>
Call the 'loose-focus' routine. This will have the menubar
loose its focus and return the value 'LOOSE_FOCUS' to
the calling routine.
=item * <B<enter>>, <B<space>>
Call the 'date-select' routine. This will select the date on
which the cursor is.
=item * <B<cursor-left>>, <B<h>>
Call the 'date-prevday' routine. This will have the date
cursor go back one day.
=item * <B<cursor-right>, <B<l>>
Call the 'date-nextday' routine. This will have the
date cursor go forward one day.
=item * <B<cursor-down>>, <B<j>>
Call the 'date-nextweek' routine. This will have the
date cursor go forward one week.
=item * <B<cursor-up>>, <B<k>>
Call the 'date-prevweek' routine. This will have the
date cursor go back one week.
=item * <B<page-up>>, <B<SHIFT+K>>
Call the 'date-prevmonth' routine. This will have the
date cursor go back one month.
=item * <B<page-down>>, <B<SHIFT+J>>
Call the 'date-nextmonth' routine. This will have the
date cursor go forward one month.
=item * <B<p>>, <B<SHIFT+H>>
Call the 'date-prevyear' routine. This will have the
date cursor go back one year.
=item * <B<n>>, <B<SHIFT+L>>
Call the 'date-nextyear' routine. This will have the
date cursor go forward one year.
=item * <B<home>>, <B<CTRL+A>>, <B<c>>
Call the 'date-selected' routine. This will have the
date cursor go to the current selected date.
=item * <B<t>>
Call the 'date-today' routine. This will have the date cursor
go to today's date.
=back
=head1 SEE ALSO
lib/Curses/UI/Checkbox.pm view on Meta::CPAN
-checked => 0, # checked or not?
-label => '', # the label text
-onchange => undef, # event handler
-bg => -1,
-fg => -1,
%userargs,
-bindings => {%bindings},
-routines => {%routines},
-focus => 0, # value init
-nocursor => 0, # this widget uses a cursor
);
# The windowscr height should be 1.
$args{-height} = height_by_windowscrheight(1, %args);
# No width given? Then make the width the same size as the label +
# checkbox.
$args{-width} = width_by_windowscrwidth(4 + length($args{-label}),%args)
unless defined $args{-width};
lib/Curses/UI/Dialog/Question.pm view on Meta::CPAN
);
my $a = $this->add('answer', 'TextEntry',
-x => 1, -y => 3,
-border => 1,
-bg => $this->{-bg},
-fg => $this->{-fg},
-bbg => $this->{-bg},
-bfg => $this->{-fg},
-text => $this->{-answer});
# Push the cursor to the end of the line.
$a->{-pos} = 999;
# Create a hash with arguments that may be passed to
# the Buttonbox class.
my %buttonargs = (
-buttonalignment => 'right',
);
foreach my $arg (qw(-buttons -selected -buttonalignment)) {
$buttonargs{$arg} = $this->{$arg} if exists $this->{$arg};
}
lib/Curses/UI/Dialog/Status.pm view on Meta::CPAN
my $label = $this->getobj('label');
# The label might not be added at this point.
if (defined $label)
{
# Compute the width the dialog window needs.
if (not defined $this->{-width})
{
$this->{-width} = $this->width_by_windowscrwidth(
$label->{-width} + 1, # +1 for visible cursor
%$this
);
}
# Compute the height the dialog window needs.
if (not defined $this->{-height})
{
$this->{-height} = $this->height_by_windowscrheight(
$label->{-height},
%$this
lib/Curses/UI/Label.pm view on Meta::CPAN
-reverse => 0,
-underline => 0,
-dim => 0,
-blink => 0,
-paddingspaces => 0, # Pad text with spaces?
-bg => -1,
-fg => -1,
%userargs,
-nocursor => 1, # This widget uses no cursor
-focusable => 0, # This widget can't be focused
);
# Get the text dimension if -width or -height is undefined.
my @text_dimension = (undef,1);
unless (defined $args{-width} and defined $args{-height}) {
@text_dimension = text_dimension($args{-text})
if defined $args{-text};
}
lib/Curses/UI/Listbox.pm view on Meta::CPAN
-bg => -1,
-fg => -1,
%userargs,
-routines => {%routines},
-bindings => {%bindings},
-yscrpos => 0, # Value init
-focus => 0, # Value init
-nocursor => 1, # This widget does not use a cursor
);
if ($args{-multi})
{
$args{-radio} = 0;
$args{-selected} = {}
unless ref $args{-selected} eq 'HASH';
$args{-ypos} = 0;
} else {
$args{-ypos} = defined $args{-selected} ? $args{-selected} : 0;
lib/Curses/UI/Listbox.pm view on Meta::CPAN
$this->{-canvasscr}->attroff(A_DIM);
# There are values. Show them!
} else {
my $start_idx = $this->{-yscrpos};
my $end_idx = $this->{-yscrpos} + $this->canvasheight - 1;
$end_idx = $this->{-max_selected}
if $end_idx > $this->{-max_selected};
my $y = 0;
my $cursor_y = 0;
my $cursor_x = 0;
for my $i ($start_idx .. $end_idx)
{
# The label to print.
my $label = $this->getlabel($i);
# Clear up label.
$label =~ s/\n|\r//g;
# Needed space for prefix.
my $prefix_len =
(($this->{-multi} or $this->{-radio}) ? 4 : 0);
# Chop length if needed.
$label = $this->text_chop($label, ($this->canvaswidth-$prefix_len));
# Show current entry in reverse mode and
# save cursor position.
if ($this->{-ypos} == $i and $this->{-focus})
{
$this->{-canvasscr}->attron(A_REVERSE);
$cursor_y = $y;
$cursor_x = $this->canvaswidth-1;
}
# Show selected element bold.
if ( ( not $this->{-multi}
and defined $this->{-selected}
and $this->{-selected} == $i)
or ( $this->{-multi}
and defined $this->{-selected}
and $this->{-selected}->{$i}) ) {
$this->{-canvasscr}->attron(A_BOLD);
lib/Curses/UI/Listbox.pm view on Meta::CPAN
$this->{-canvasscr}->addstr($y, 0, '<o>');
} else {
$this->{-canvasscr}->addstr($y, 0, '< >');
}
}
$this->{-canvasscr}->attroff(A_BOLD) if $this->{-focus};
$y++;
}
$cursor_x = 1 if $this->{-multi} or $this->{-radio};
$this->{-canvasscr}->move($cursor_y, $cursor_x);
}
$this->{-canvasscr}->noutrefresh();
doupdate() unless $no_doupdate;
return $this;
}
sub option_last()
{
lib/Curses/UI/Listbox.pm view on Meta::CPAN
=back
=head1 DEFAULT BINDINGS
=over 4
=item * <B<cursor-left>>, <B<h>>, <B<tab>>
Call the 'loose-focus' routine. This will have the widget
loose its focus.
=item * <B<cursor-right>, <B<l>>, <B<enter>>, <B<space>>
Call the 'option-select' routine. This will select the
active item in the listbox.
=item * <B<1>>, <B<y>>
Call the 'option-check' routine. If the listbox is a
multi-select listbox, the active item will become checked
and the next item will become active.
=item * <B<0>>, <B<n>>
Call the 'option-uncheck' routine. If the listbox is a
multi-select listbox, the active item will become unchecked
and the next item will become active.
=item * <B<cursor-down>>, <B<j>>
Call the 'option-next' routine. This will make the next
item of the list active.
=item * <B<cursor-up>>, <B<k>>
Call the 'option-prev' routine. This will make the previous
item of the list active.
=item * <B<page-up>>
Call the 'option-prevpage' routine. This will make the item
on the previous page active.
=item * <B<page-down>>
lib/Curses/UI/Menubar.pm view on Meta::CPAN
$this->root->fatalerror(
"Missing or illegal argument: -menubar"
) unless defined $args{-menubar} and
$args{-menubar}->isa('Curses::UI::Menubar');
# Clear 'loose-focus' binding, so loosing focus through
# the <TAB> key does not work.
$this->clear_binding('loose-focus');
# Create binding routines.
$this->set_routine('cursor-left', \&cursor_left);
$this->set_routine('cursor-right', \&cursor_right);
$this->set_routine('option-select',\&option_select);
$this->set_routine('escape', \&escape_key);
# Create bindings.
$this->set_binding('escape', CUI_ESCAPE);
$this->set_binding('cursor-left', KEY_LEFT(), 'h');
$this->set_binding('cursor-right', KEY_RIGHT(), 'l');
if ($Curses::UI::ncurses_mouse) {
$this->set_mouse_binding(\&mouse_button1, BUTTON1_CLICKED());
}
return $this;
}
sub escape_key()
lib/Curses/UI/Menubar.pm view on Meta::CPAN
$this->{-prevobject}->{-returnaction} = 'COLLAPSE';
$this->loose_focus;
}
sub active_item()
{
my $this = shift;
$this->{-menu}->[$this->{-ypos}];
}
sub cursor_left()
{
my $this = shift;
$this->{-prevobject}->{-returnaction} = 'CURSOR_LEFT';
$this->loose_focus;
}
sub cursor_right()
{
my $this = shift;
# Get the current menu-item.
my $item = $this->active_item;
# This item has a submenu. Open it.
if (defined $item->{-submenu})
{
lib/Curses/UI/Menubar.pm view on Meta::CPAN
sub option_select()
{
my $this = shift;
# Get the current menu-item.
my $item = $this->active_item;
# Submenu selected? Then expand it.
if (defined $item->{-submenu}) {
return $this->cursor_right;
}
# Let the menubar handle the option that was chosen.
my $value = $item->{-value};
$this->{-menubar}->menuoption_selected($value);
# Let the complete menulistbox-hierarchy collapse.
$this->{-prevobject}->{-returnaction} = 'COLLAPSE';
$this->loose_focus;
lib/Curses/UI/Menubar.pm view on Meta::CPAN
-fg => -1,
%userargs,
-routines => {%routines},
-bindings => {%bindings},
-width => undef, # Always use the full width
-height => 1, # Always use height = 1
-focus => 0,
-nocursor => 1, # This widget does not use a cursor
-x => 0,
-y => 0,
-border => 0,
-selected => 0,
-returnaction => undef, # is set by MenuListboxes.
-menuoption => undef, # the value for the chosen option
# (is also set by MenuListboxes).
-is_expanded => 0, # let show focused on expand
);
lib/Curses/UI/Menubar.pm view on Meta::CPAN
Call the 'escape' routine. This will have the menubar
loose its focus and return the value 'ESCAPE' to the
calling routine.
=item * <B<tab>>
Call the 'return' routine. This will have the menubar
loose its focus and return the value 'LOOSE_FOCUS' to
the calling routine.
=item * <B<cursor-down>>, <B<j>>, <B<enter>>
Call the 'pulldown' routine. This will open the
menulistbox for the current menu and give that
menulistbox the focus. What happens after the
menulistbox loses its focus, depends upon the
returnvalue of it:
* the value 'CURSOR_LEFT'
Call the 'cursor-left' routine and after that
call the 'pulldown' routine. So this will open
the menulistbox for the previous menu.
* the value 'CURSOR_RIGHT'
Call the 'cursor-right' routine and after that
call the 'pulldown' routine. So this will open
the menulistbox for the next menu.
* the value 'LOOSE_FOCUS'
The menubar will keep the focus, but no
menulistbox will be open.
* the value 'ESCAPE'
lib/Curses/UI/Menubar.pm view on Meta::CPAN
The code will be excuted, the menubar will loose its
focus and the returnvalue of the CODE will be
returned to the calling routine.
* Any other value
The menubar will loose its focus and the value will
be returned to the calling routine.
=item * <B<cursor-left>>, <B<h>>
Call the 'cursor-left' routine. This will select
the previous menu. If the first menu is already
selected, the last menu will be selected.
=item * <B<cursor-right>>, <B<l>>
Call the 'cursor-right' routine. This will select
the next menu. If the last menu is already selected,
the first menu will be selected.
=back
=head1 SEE ALSO
lib/Curses/UI/Notebook.pm view on Meta::CPAN
# Identify various pages of interest.
my $first_page = $this->first_page;
my $next_page = $this->next_page;
my $last_page = $this->last_page;
my $active_page = $this->active_page;
# Identify page window.
my $page_win = $this->{-borderscr};
# Hide cursor.
eval { curs_set(0) }; # not available on every system.
# Enable colors if desired.
if ($Curses::UI::color_support) {
debug_msg " enabling color support";
my $co = $Curses::UI::color_object;
my $pair = $co->get_color_pair(
$this->{-fg},
$this->{-bg}
);
lib/Curses/UI/PasswordEntry.pm view on Meta::CPAN
sub new ()
{
my $class = shift;
my %userargs = @_;
keys_to_lowercase(\%userargs);
my %args = (
-undolevels => 20, # number of undolevels. 0 = infinite
-homeonblur => 1, # cursor to homepos on blur?
-fg => -1,
-bg => -1,
%userargs,
-password => '*',# force password token
-showhardreturns => 0,
);
# Create the entry.
lib/Curses/UI/Popupmenu.pm view on Meta::CPAN
-onchange => undef, # event handler
-fg => -1,
-bg => -1,
%userargs,
-bindings => {%bindings},
-routines => {%routines},
-focus => 0, # value init
-nocursor => 1, # this widget does not use a cursor
);
# The windowscr height should be 1.
$args{-height} = height_by_windowscrheight(1,%args);
# No width given? Then make the width large
# enough to contain the longest label.
$args{-width} = width_by_windowscrwidth(
maxlabelwidth(%args) + 1,
-border => 1
lib/Curses/UI/Popupmenu.pm view on Meta::CPAN
=head2 The widget itself
=over 4
=item * <B<tab>>
Call the 'loose-focus' routine. This will have the widget
loose its focus.
=item * <B<enter>>, <B<cursor-right>, <B<l>>, <B<space>>
Call the 'open-popup' routine. This will show the
popup listbox and bring the focus to this listbox. See
B<The popup listbox> below for a description of the bindings
for this listbox.
=item * <B<cursor-down>>, <B<j>>
Call the 'select-next' routine. This will select the
item in the list that is after the currently selected
item (unless the last item is already selected). If
no item is selected, the first item in the list will
get selected.
=item * <B<cursor-up>>, <B<k>>
Call the 'select-prev' routine. This will select the
item in the list that is before the currently selected
item (unless the first item is already selected). If
no item is selected, the first item in the list will
get selected.
=back
=head2 The popup listbox
lib/Curses/UI/Progressbar.pm view on Meta::CPAN
-nopercentage => 0, # show the percentage or not?
-nocenterline => 0, # show the center line or not?
-showvalue => 0, # show value instead of percentage
-border => 1,
-fg => -1,
-bg => -1,
%userargs,
-focusable => 0,
-nocursor => 1,
);
# Check that the lowest value comes first.
if ($args{-min} > $args{-max})
{
my $tmp = $args{-min};
$args{-min} = $args{-max};
$args{-max} = $tmp;
}
lib/Curses/UI/Searchable.pm view on Meta::CPAN
my $direction = shift || +1;
$this->change_canvasheight(-1);
$this->draw;
my $querybox = new Curses::UI::SearchEntry(
-parent => $this,
-prompt => $prompt,
);
my $old_cursor_mode = $this->root->cursor_mode;
$this->root->cursor_mode(1);
$querybox->getobj('entry')->{-focus} = 1;
$querybox->draw;
$querybox->modalfocus();
$querybox->getobj('entry')->{-focus} = 0;
my $query = $querybox->get;
$querybox->prompt(':');
$querybox->draw;
my $key;
lib/Curses/UI/Searchable.pm view on Meta::CPAN
} elsif ($querybox->{-key} eq 'N') {
($newidx, $wrapped) =
$this->search_next($query, -$direction);
} else {
last KEY;
}
}
}
# Restore the screen.
$this->root->cursor_mode($old_cursor_mode);
$this->change_canvasheight(+1);
$this->draw;
$this->root->feedkey($querybox->{-key});
return $this;
}
sub search_next($$;)
{
my $this = shift;
lib/Curses/UI/TextEditor.pm view on Meta::CPAN
'delete-till-eol' => \&delete_till_eol,
'delete-line' => \&delete_line,
'delete-character' => \&delete_character,
'add-string' => \&add_string,
'clear-line' => \&clear_line,
'backspace' => \&backspace,
'newline' => \&newline,
'toggle-showhardreturns' => \&toggle_showhardreturns,
'toggle-showoverflow' => \&toggle_showoverflow,
'toggle-wrapping' => \&toggle_wrapping,
'cursor-right' => \&cursor_right,
'cursor-left' => \&cursor_left,
'cursor-up' => \&cursor_up,
'cursor-down' => \&cursor_down,
'cursor-pageup' => \&cursor_pageup,
'cursor-pagedown' => \&cursor_pagedown,
'cursor-scrlinestart' => \&cursor_to_scrlinestart,
'cursor-scrlineend' => \&cursor_to_scrlineend,
'cursor-home' => \&cursor_to_home,
'cursor-end' => \&cursor_to_end,
'search-forward' => \&search_forward,
'search-backward' => \&search_backward,
'mouse-button1' => \&mouse_button1,
);
# Configuration: binding to routine name mapping.
my %basebindings = (
CUI_TAB() => 'loose-focus',
KEY_BTAB() => 'loose-focus',
KEY_LEFT() => 'cursor-left',
"\cB" => 'cursor-left',
KEY_RIGHT() => 'cursor-right',
"\cF" => 'cursor-right',
KEY_DOWN() => 'cursor-down',
"\cN" => 'cursor-down',
KEY_UP() => 'cursor-up',
"\cP" => 'cursor-up',
KEY_PPAGE() => 'cursor-pageup',
KEY_NPAGE() => 'cursor-pagedown',
KEY_HOME() => 'cursor-home',
KEY_END() => 'cursor-end',
"\cA" => 'cursor-scrlinestart',
"\cE" => 'cursor-scrlineend',
"\cW" => 'toggle-wrapping',
"\cR" => 'toggle-showhardreturns',
"\cT" => 'toggle-showoverflow',
);
my %viewbindings = (
"/" => 'search-forward',
"?" => 'search-backward',
CUI_SPACE() => 'cursor-pagedown',
"-" => 'cursor-pageup',
"]" => 'cursor-pagedown',
"[" => 'cursor-pageup',
);
my %editbindings = (
'' => 'add-string',
"\cZ" => 'undo',
KEY_DL() => 'delete-line',
"\cY" => 'delete-line',
"\cX" => 'delete-line',
"\cK" => 'delete-till-eol',
KEY_DC() => 'delete-character',
"\cV" => 'paste',
"\cU" => 'clear-line',
KEY_BACKSPACE() => 'backspace',
KEY_ENTER() => 'newline',
);
# Some viewbindings that should not be available in %bindings;
$viewbindings{'h'} = 'cursor-left';
$viewbindings{'j'} = 'cursor-down';
$viewbindings{'k'} = 'cursor-up';
$viewbindings{'l'} = 'cursor-right';
sub new ()
{
my $class = shift;
my %userargs = @_;
keys_to_lowercase(\%userargs);
my %args = (
# Parent info
lib/Curses/UI/TextEditor.pm view on Meta::CPAN
# Position and size
-x => 0, # horizontal position (rel. to -window)
-y => 0, # vertical position (rel. to -window)
-width => undef, # horizontal editsize, undef = stretch
-height => undef, # vertical editsize, undef = stretch
-singleline => 0, # single line mode or not?
# Initial state
-text => '', # data
-pos => 0, # cursor position
# General options
-border => undef, # use border?
-showlines => undef, # underline lines?
-sbborder => undef, # square bracket border?
-undolevels => 10, # number of undolevels. 0 = infinite
-maxlength => 0, # the maximum length. 0 = infinite
-showoverflow => 1, # show overflow characters.
-regexp => undef, # regexp to match the text against
-toupper => 0, # convert text to uppercase?
-tolower => 0, # convert text to lowercase?
-homeonblur => 0, # cursor to homepos on blur?
-vscrollbar => 0, # show vertical scrollbar
-hscrollbar => 0, # show horizontal scrollbar
-readonly => 0, # only used as viewer?
-reverse => 0, # show in reverse
# Single line options
-password => undef, # masquerade chars with given char
# Multiple line options
-showhardreturns => 0, # show hard returns with diamond char?
lib/Curses/UI/TextEditor.pm view on Meta::CPAN
-bg => -1,
-fg => -1,
%userargs,
-routines => {%routines}, # binding routines
-bindings => {}, # these are set by readonly()
# Init values
-nocursor => 0,
-scr_lines => [],
-yscrpos => 0,
-xscrpos => 0,
-ypos => 0,
-xpos => 0,
-focus => 0,
);
# Let -text always be defined.
$args{-text} = '' unless defined $args{-text};
lib/Curses/UI/TextEditor.pm view on Meta::CPAN
}
# Create the Widget.
my $this = $class->SUPER::new( %args );
# Check if we should wrap or not.
$this->{-wrapping} = 0 if $this->{-singleline};
$this->{-undotext} = [$this->{-text}];
$this->{-undopos} = [$this->{-pos}];
$this->{-xscrpos} = 0; # X position for cursor on screen
$this->{-yscrpos} = 0; # Y position for cursor on screen
$this->{-xpos} = 0; # X position for cursor in the document
$this->{-ypos} = 0; # Y position for cursor in the document
# Restrict the password character to a single character.
$this->set_password_char($this->{-password}) if defined $this->{-password};
# Single line? Then initial text may only be singleline.
if ($this->{-singleline} and
defined $this->{-text} and $this->{-text} =~ /\n/)
{
my $lines = $this->split_to_lines($this->{-text});
$this->{-text} = $lines->[0];
lib/Curses/UI/TextEditor.pm view on Meta::CPAN
sub getrealxpos()
{
my $this = shift;
my $offset = $this->{-xscrpos};
my $length = $this->{-xpos} - $this->{-xscrpos};
return 0 if $length <= 0;
my $current_line = $this->{-scr_lines}->[$this->{-ypos}];
my $before_cursor = substr(
$current_line,
$this->{-xscrpos}, # Screen's x position
$this->{-xpos} - $this->{-xscrpos} # Space up to the cursor
);
my $realxpos = scrlength($before_cursor);
return $realxpos;
}
sub layout()
{
my $this = shift;
$this->SUPER::layout() or return;
# Scroll up if we can and the number of visible lines
lib/Curses/UI/TextEditor.pm view on Meta::CPAN
$this->layout_content();
return $this;
}
sub layout_content()
{
my $this = shift;
return $this if $Curses::UI::screen_too_small;
# ----------------------------------------------------------------------
# Build an array of lines to display and determine the cursor position
# ----------------------------------------------------------------------
my $lines_src = $this->split_to_lines($this->{-text});
foreach (@$lines_src) {$_ .= "\n"}
$lines_src->[-1] =~ s/\n$/ /;
# No lines available? Then create an array.
$lines_src = [""] unless @$lines_src;
# No out of bound values for -pos.
$this->{-pos} = 0 unless defined $this->{-pos};
$this->{-pos} = 0 if $this->{-pos} < 0;
$this->{-pos} = length($this->{-text})
if $this->{-pos} >= length($this->{-text});
# Do line wrapping if needed and store the lines
# to display in -scr_lines. Compute the x- and
# y-position of the cursor in the text.
my $lines = [];
my ($xpos, $ypos, $trackpos) = (undef, 0, 0);
foreach my $line (@$lines_src)
{
my $add = [];
if ($this->{-wrapping}) {
$add = $this->text_wrap($line, $this->canvaswidth, WORDWRAP);
} else {
$add = [$line];
}
lib/Curses/UI/TextEditor.pm view on Meta::CPAN
# ----------------------------------------------------------------------
# If wrapping is enabled, then check for horizontal scrolling.
# Else make the -xscrpos fixed to 0.
unless ($this->{-readonly})
{
unless ($this->{-wrapping})
{
my $realxpos = $this->getrealxpos;
# If overflows have to be shown, the cursor may not
# be set to the first or the last position of the
# screen.
my $wrapborder =
(not $this->{-wrapping} and $this->{-showoverflow})
? 1 : 0;
# Scroll left if needed.
if ($realxpos < $wrapborder) {
while ($realxpos < ($wrapborder + int($this->canvaswidth/3))
and $this->{-xscrpos} > 0) {
lib/Curses/UI/TextEditor.pm view on Meta::CPAN
if $this->canvaswidth < scrlength($fromxscr);
$this->{-canvasscr}->addch($id, 0, '$')
if $this->{-xscrpos} > 0;
}
} else {
last;
}
}
# Move the cursor.
# Take care of TAB's
if ($this->{-readonly})
{
$this->{-canvasscr}->move(
$this->canvasheight-1,
$this->canvaswidth-1
);
} else {
my $l = $this->{-scr_lines}->[$this->{-ypos}];
my $precursor = substr(
$l,
$this->{-xscrpos},
$this->{-xpos} - $this->{-xscrpos}
);
my $realxpos = scrlength($precursor);
$this->{-canvasscr}->move(
$this->{-ypos} - $this->{-yscrpos},
$realxpos
);
}
$this->{-canvasscr}->attroff(A_UNDERLINE) if $this->{-showlines};
$this->{-canvasscr}->attroff(A_REVERSE) if $this->{-reverse};
$this->{-canvasscr}->noutrefresh();
doupdate() unless $no_doupdate;
lib/Curses/UI/TextEditor.pm view on Meta::CPAN
return $this;
}
sub event_onblur()
{
my $this = shift;
$this->SUPER::event_onblur;
# Set the cursor position to the startposition
# if -homeonblur is set.
if ($this->{-homeonblur}) {
$this->cursor_to_home;
$this->layout_content;
}
return $this;
}
sub event_keypress ($;)
{
my $this = shift;
my $key = shift;
lib/Curses/UI/TextEditor.pm view on Meta::CPAN
}
sub toggle_showhardreturns()
{
my $this = shift;
return $this->dobeep if $this->{-singleline};
$this->{-showhardreturns} = ! $this->{-showhardreturns};
return $this;
}
sub cursor_right()
{
my $this = shift;
# Handle cursor_right for read only mode.
if ($this->{-readonly})
{
return $this->dobeep
unless defined $this->{-hscrolllen};
return $this->dobeep
if $this->{-xscrpos}
>= $this->{-hscrolllen} - $this->canvaswidth;
$this->{-xscrpos} += 1;
lib/Curses/UI/TextEditor.pm view on Meta::CPAN
if ($this->{-pos} == length($this->{-text})) {
$this->dobeep;
} else {
$this->{-pos}++;
}
$this->layout_content;
$this->set_curxpos;
return $this;
}
sub cursor_left()
{
my $this = shift;
# Handle cursor_left for read only mode.
if ($this->{-readonly})
{
return $this->dobeep if $this->{-xscrpos} <= 0;
$this->{-xscrpos} -= 1;
$this->{-xpos} = $this->{-xscrpos};
return $this;
}
if ($this->{-pos} <= 0) {
$this->dobeep;
lib/Curses/UI/TextEditor.pm view on Meta::CPAN
return $this;
}
sub set_curxpos()
{
my $this = shift;
$this->{-curxpos} = $this->{-xpos};
return $this;
}
sub cursor_up(;$)
{
my $this = shift;
shift; # stub for bindings handling.
my $amount = shift || 1;
return $this->dobeep if $this->{-singleline};
# Handle cursor_up for read only mode.
if ($this->{-readonly})
{
return $this->dobeep if $this->{-yscrpos} <= 0;
$this->{-yscrpos} -= $amount;
$this->{-yscrpos} = 0 if $this->{-yscrpos} < 0;
$this->{-ypos} = $this->{-yscrpos};
return $this;
}
my $maymove = $this->{-ypos};
return $this->dobeep unless $maymove;
$amount = $maymove if $amount > $maymove;
my $l = $this->{-scr_lines};
$this->cursor_to_scrlinestart;
$this->{-ypos} -= $amount;
while ($amount)
{
my $idx = $this->{-ypos} + $amount - 1;
my $line = $l->[$idx];
my $line_length = length($line);
$this->{-pos} -= $line_length;
$amount--;
}
$this->cursor_to_curxpos;
return $this;
}
sub cursor_pageup()
{
my $this = shift;
return $this->dobeep if $this->{-singleline};
$this->cursor_up(undef, $this->canvasheight - 1);
return $this;
}
sub cursor_down($;)
{
my $this = shift;
shift; # stub for bindings handling.
my $amount = shift || 1;
return $this->dobeep if $this->{-singleline};
# Handle cursor_down for read only mode.
if ($this->{-readonly})
{
my $max = @{$this->{-scr_lines}} - $this->canvasheight;
return $this->dobeep
if $this->{-yscrpos} >= $max;
$this->{-yscrpos} += $amount;
$this->{-yscrpos} = $max if $this->{-yscrpos} > $max;
$this->{-ypos} = $this->{-yscrpos};
return $this;
}
my $l = $this->{-scr_lines};
my $maymove = (@$l-1) - $this->{-ypos};
return $this->dobeep unless $maymove;
$amount = $maymove if $amount > $maymove;
$this->cursor_to_scrlinestart;
$this->{-ypos} += $amount;
while ($amount)
{
my $idx = $this->{-ypos} - $amount;
my $line = $l->[$idx];
my $line_length = length($line);
$this->{-pos} += $line_length;
$amount--;
}
$this->cursor_to_curxpos;
return $this;
}
sub cursor_pagedown()
{
my $this = shift;
return $this->dobeep if $this->{-singleline};
$this->cursor_down(undef, $this->canvasheight - 1);
return $this;
}
sub cursor_to_home()
{
my $this = shift;
if ($this->{-readonly})
{
$this->{-xscrpos} = $this->{-xpos} = 0;
$this->{-yscrpos} = $this->{-ypos} = 0;
return $this;
}
$this->{-pos} = 0;
$this->set_curxpos;
return $this;
}
sub cursor_to_end()
{
my $this = shift;
if ($this->{-readonly})
{
$this->{-xscrpos} = $this->{-xpos} = 0;
$this->{-yscrpos} = $this->{-ypos} =
$this->{-vscrolllen}-$this->canvasheight;
return $this;
}
$this->{-pos} = length($this->{-text});
$this->set_curxpos;
return $this;
}
sub cursor_to_scrlinestart()
{
my $this = shift;
# Key argument is set if called from binding.
my $from_binding = shift;
if ($this->{-readonly})
{
$this->{-xscrpos} = $this->{-xpos} = 0;
return $this;
}
$this->{-pos} -= $this->{-xpos};
$this->{-xpos} = 0;
$this->set_curxpos if defined $from_binding;
return $this;
}
sub cursor_to_scrlineend()
{
my $this = shift;
my $from_binding = shift;
if ($this->{-readonly})
{
$this->{-xscrpos} = $this->{-xpos} =
$this->{-hscrolllen} - $this->canvaswidth ;
return $this;
}
lib/Curses/UI/TextEditor.pm view on Meta::CPAN
my $newpos = $this->{-pos};
my $l = $this->{-scr_lines};
my $len = length($l->[$this->{-ypos}]) - 1;
$newpos += $len - $this->{-xpos};
$this->{-pos} = $newpos;
$this->layout_content;
$this->set_curxpos if defined $from_binding;
return $this;
}
sub cursor_to_linestart()
{
my $this = shift;
# Move cursor back, until \n is found. That is
# the previous line. Then go one position to the
# right to find the start of the line.
my $newpos = $this->{-pos};
for(;;)
{
last if $newpos <= 0;
$newpos--;
last if substr($this->{-text}, $newpos, 1) eq "\n";
}
$newpos++ unless $newpos == 0;
$newpos = length($this->{-text}) if $newpos > length($this->{-text});
$this->{-pos} = $newpos;
$this->layout_content;
return $this;
}
sub cursor_to_curxpos()
{
my $this = shift;
my $right = $this->{-curxpos};
$right = 0 unless defined $right;
my $len = length($this->{-scr_lines}->[$this->{-ypos}]) - 1;
if ($right > $len) { $right = $len }
$this->{-pos} += $right;
$this->layout_content;
return $this;
}
sub clear_line()
{
my $this = shift;
$this->cursor_to_linestart;
$this->delete_till_eol;
return $this;
}
sub delete_line()
{
my $this = shift;
return $this->dobeep if $this->{-singleline};
my $len = length($this->{-text});
if ($len == 0)
{
$this->dobeep;
return $this;
}
$this->beep_off
->cursor_to_linestart
->delete_till_eol
->cursor_left
->delete_character
->cursor_right
->cursor_to_linestart
->set_curxpos
->beep_on;
return $this;
}
sub delete_till_eol()
{
my $this = shift;
$this->set_undoinfo;
lib/Curses/UI/TextEditor.pm view on Meta::CPAN
$this->{-readonly} = $readonly;
if ($readonly)
{
my %mybindings = (
%basebindings,
%viewbindings
);
$this->{-bindings} = \%mybindings;
$this->{-nocursor} = 1;
} else {
my %mybindings = (
%basebindings,
%editbindings
);
$this->{-bindings} = \%mybindings;
$this->{-nocursor} = 0;
}
return $this;
}
sub get() {shift()->text}
sub pos(;$)
{
my $this = shift;
lib/Curses/UI/TextEditor.pm view on Meta::CPAN
=head1 WIDGET-SPECIFIC OPTIONS
=over 4
=item * B<-text> < TEXT >
This sets the initial text for the widget to TEXT.
=item * B<-pos> < CURSOR_POSITION >
This sets the initial cursor position for the widget
to CURSOR_POSITION. B<-pos> represents the character index within
B<-text>. By default this option is set to 0.
=item * B<-readonly> < BOOLEAN >
The texteditor widget will be created as a read only
texteditor (which is also called a textviewer) if
BOOLEAN is true. By default BOOLEAN is false.
=item * B<-singleline> < BOOLEAN >
lib/Curses/UI/TextEditor.pm view on Meta::CPAN
outside the screen (like 'pico' does). By default
BOOLEAN is true.
=item * B<-showhardreturns> < BOOLEAN >
If BOOLEAN is true, hard returns will be made visible
by a diamond character. By default BOOLEAN is false.
=item * B<-homeonblur> < BOOLEAN >
If BOOLEAN is set to a true value, the cursor will move
to the start of the text if the widget loses focus.
=item * B<-toupper> < BOOLEAN >
If BOOLEAN is true, all entered text will be converted
to uppercase. By default BOOLEAN is false.
=item * B<-tolower> < BOOLEAN >
If BOOLEAN is true, all entered text will be converted
lib/Curses/UI/TextEditor.pm view on Meta::CPAN
=over 4
=item * <B<tab>>
Call the 'returreturnn' routine. This will have the widget
loose its focus.
=item * <B<cursor-left>>, <B<CTRL+B>>
Call the 'cursor-left' routine: move the
cursor one position to the left.
=item * <B<cursor-right>>, <B<CTRL+F>>
Call the 'cursor-right' routine: move the
cursor one position to the right.
=item * <B<cursor-down>>, <B<CTRL+N>>
Call the 'cursor-down' routine: move the
cursor one line down.
=item * <B<cursor-up>>, <B<CTRL+P>>
Call the 'cursor-up' routine: move the
cursor one line up.
=item * <B<page-up>>
Call the 'cursor-pageup' routine: move the
cursor to the previous page.
=item * <B<page-down>>
Call the 'cursor-pagedown' routine: move
the cursor to the next page.
=item * <B<home>>
Call the 'cursor-home' routine: go to the
start of the text.
=item * <B<end>>
Call the 'cursor-end' routine: go to the
end of the text.
=item * <B<CTRL+A>>
Call the 'cursor-scrlinestart' routine: move the
cursor to the start of the current line.
=item * <B<CTRL+E>>
Call the 'cursor-scrlineend' routine: move the
cursor to the end of the current line.
=item * <B<CTRL+W>>
Call the 'toggle-wrapping' routine: toggle the
-wrapping option of the texteditor.
=item * <B<CTRL+R>>
Call the 'toggle-showhardreturns' routine: toggle the
-showhardreturns option of the texteditor.
lib/Curses/UI/TextEditor.pm view on Meta::CPAN
=over 4
=item * <B<CTRL+Y>>, <B<CTRL+X>>
Call the 'delete-line' routine: Delete the current
line.
=item * <B<CTRL+K>>
Call the 'delete-till-eol' routine: delete the text
from the current cursor position up to the end of
the current line.
=item * <B<CTRL+U>>
Call the 'clear-line' routine: clear the
current line and move the cursor to the
start of this line.
=item * <B<CTRL+D>>
Call the 'delete-character' routine: delete the
character that currently is under the cursor.
=item * <B<backspace>>
Call the 'backspace' routine: delete the character
this is before the current cursor position.
=item * <B<CTRL+Z>>
Call the 'undo' routine: undo the last change to
the text, up to B<-undolevels> levels.
=item * <B<CTRL+V>>
Call the 'paste' routine: this will paste the
last deleted text at the current cursor position.
=item * <B<any other key>>
Call the 'add-string' routine: the character
will be inserted in the text at the current
cursor position.
=back
=head2 Only for the read only mode
=over 4
=item * <B<h>>
Call the 'cursor-left' routine: move the
cursor one position to the left.
=item * <B<l>>
Call the 'cursor-right' routine: move the
cursor one position to the right.
=item * b<<k>>
Call the 'cursor-up' routine: move the
cursor one line up.
=item * b<<j>>
Call the 'cursor-down' routine: move the
cursor one line down.
=item * <B<space>>, <B<]>>
Call the 'cursor-pagedown' routine: move
the cursor to the next page.
=item * <B<->>, <B<[>>
Call the 'cursor-pageup' routine: move the
cursor to the previous page.
=item * <B</>>
Call the 'search-forward' routine. This will make a 'less'-like
search system appear in the textviewer. A searchstring can be
entered. After that the user can search for the next occurance
using the 'n' key or the previous occurance using the 'N' key.
=item * <B<?>>
lib/Curses/UI/TextEntry.pm view on Meta::CPAN
sub new ()
{
my $class = shift;
my %userargs = @_;
keys_to_lowercase(\%userargs);
my %args = (
-undolevels => 20, # number of undolevels. 0 = infinite
-homeonblur => 1, # cursor to homepos on blur?
-bg => -1,
-fg => -1,
%userargs,
-singleline => 1, # single line mode or not?
-showhardreturns => 0, # show hard returns with diamond char?
);
lib/Curses/UI/Widget.pm view on Meta::CPAN
keys_to_lowercase(\%userargs);
my %args = (
-parent => undef, # the parent object
-x => 0, # horizontal position (rel. to -parent)
-y => 0, # vertical position (rel. to -parent)
-width => undef, # horizontal size
-height => undef, # vertical size
-border => 0, # add a border?
-sbborder => 0, # add square bracket border?
-nocursor => 0, # Show a cursor?
-titlefullwidth => 0, # full width for title?
-titlereverse => 1, # reverse chars for title?
-title => undef, # A title to add to the widget (only for
# -border = 1)
# padding outside widget
-pad => undef, # all over padding
-padright => undef, # free space on the right side
-padleft => undef, # free space on the left side
-padtop => undef, # free space above
-padbottom => undef, # free space below
lib/Curses/UI/Widget.pm view on Meta::CPAN
# Let the parent find another widget to focus
# if this widget is not focusable.
unless ($this->focusable) {
return $this->parent->focus($this);
}
$this->{-focus} = 1;
$this->run_event('-onfocus');
# Set cursor mode
my $show_cursor = $this->{-nocursor} ? 0 : 1;
$this->root->cursor_mode($show_cursor);
$this->draw(1) if (not $this->root->overlapping);
return $this;
}
sub event_onblur()
{
my $this = shift;
$this->{-focus} = 0;
lib/Curses/UI/Widget.pm view on Meta::CPAN
# focusable. Mostly you will use the generic_focus() method.
#
sub focus()
{
my $this = shift;
$this->show; # makes the widget visible if it was invisible
return $this->generic_focus(
undef, # delaytime, default = 2 (1/10 second).
NO_CONTROLKEYS, # disable controlkeys like CTRL+C. To enable
# them use CONTROLKEYS instead.
CURSOR_INVISIBLE, # do not show the cursor (if supported). To
# show the cursor use CURSOR_VISIBLE.
\&pre_key_routine, # optional callback routine to execute
# before a key is read. Mostly unused.
);
}
....your own widget handling routines....
lib/Curses/UI/Window.pm view on Meta::CPAN
# Create the window.
my $this = $class->SUPER::new(
-width => undef,
-height => undef,
-x => 0,
-y => 0,
-centered => 0, # Center the window in the display?
%userargs,
-nocursor => 1, # This widget does not use a cursor
-assubwin => 1, # Always constructed as a subwindow
);
return $this;
}
sub layout ()
{
my $this = shift;
t/fakelib/Curses.pm view on Meta::CPAN
flushinp newwin delwin mvwin subwin derwin mvderwin dupwin syncup
syncok cursyncup syncdown getmouse ungetmouse mousemask enclose
mouse_trafo mouseinterval BUTTON_RELEASE BUTTON_PRESS BUTTON_CLICK
BUTTON_DOUBLE_CLICK BUTTON_TRIPLE_CLICK BUTTON_RESERVED_EVENT
use_default_colors assume_default_colors define_key keybound keyok
resizeterm resize getmaxy getmaxx flusok getcap touchoverlap new_panel
bottom_panel top_panel show_panel update_panels hide_panel panel_window
replace_panel move_panel panel_hidden panel_above panel_below
set_panel_userptr panel_userptr del_panel set_menu_fore menu_fore
set_menu_back menu_back set_menu_grey menu_grey set_menu_pad menu_pad
pos_menu_cursor menu_driver set_menu_format menu_format set_menu_items
menu_items item_count set_menu_mark menu_mark new_menu free_menu
menu_opts set_menu_opts menu_opts_on menu_opts_off set_menu_pattern
menu_pattern post_menu unpost_menu set_menu_userptr menu_userptr
set_menu_win menu_win set_menu_sub menu_sub scale_menu set_current_item
current_item set_top_row top_row item_index item_name item_description
new_item free_item set_item_opts item_opts_on item_opts_off item_opts
item_userptr set_item_userptr set_item_value item_value item_visible
menu_request_name menu_request_by_name set_menu_spacing menu_spacing
pos_form_cursor data_ahead data_behind form_driver set_form_fields
form_fields field_count move_field new_form free_form set_new_page
new_page set_form_opts form_opts_on form_opts_off form_opts
set_current_field current_field set_form_page form_page field_index
post_form unpost_form set_form_userptr form_userptr set_form_win
form_win set_form_sub form_sub scale_form set_field_fore field_fore
set_field_back field_back set_field_pad field_pad set_field_buffer
field_buffer set_field_status field_status set_max_field field_info
dynamic_field_info set_field_just field_just new_field dup_field
link_field free_field set_field_opts field_opts_on field_opts_off
field_opts set_field_userptr field_userptr field_arg form_request_name