Curses-UI-POE
view release on metacpan or search on metacpan
examples/irc_client view on Meta::CPAN
$nicklist->values([sort @nicks]);
$nicklist->draw(1);
$curses->draw;
}
sub dropnick {
my ($nicklist, $curses) = @{ +shift }{qw( -nicks -curses )};
my $nick = shift;
@nicks = grep $nick ne $_, @nicks;
$nicklist->values([sort @nicks]);
$nicklist->draw(1);
$curses->draw;
}
sub PRINT {
our @Channel;
my $object = shift;
my ($viewer, $curses) = @$object{qw( -viewer -curses )};
push @Channel, shift;
$viewer->text(join "\n", @Channel);
$viewer->cursor_down(undef, $viewer->canvasheight);
$viewer->draw;
# $viewer->{-ypos} = @Channel;
# $viewer->layout_content;
$curses->draw;
}
sub PRINTF {
our @Channel;
my $object = shift;
my ($viewer, $curses) = @$object{qw( -viewer -curses )};
# XXX Hack: Just ignore bunk requests for now...
if (grep !defined $_, @_) {
carp "Attempt to print undefined value";
}
push @Channel, sprintf shift, @_;
$viewer->text(join "\n", @Channel);
$viewer->cursor_down(undef, $viewer->canvasheight);
$viewer->draw;
# $viewer->{-ypos} = @Channel;
# $viewer->layout_content;
$curses->draw;
}
sub TIEHANDLE {
my $curses = $_[-1];
# Main Menu
my $menu = $curses->add
( 'menu','Menubar',
-fg => "white",
-bg => "blue",
-menu => [
{ -label => 'File',
-submenu => [
{ -label => 'Exit ^Q', -value => sub { exit } }
]
},
{ -label => 'Help',
-submenu => [
{ -label => 'about', -value => \&about_dialog }
]
},
]
);
# Create the screen for the editor.
my $screen = $curses->add
( 'screen', 'Window',
-padtop => 1, # leave space for the menu
-border => 0,
-ipad => 0,
);
# We add the editor widget to this screen.
my $viewer = $screen->add
( 'viewer', 'TextViewer',
-border => 0,
-pos => -1,
-sfg => "blue",
-sbg => "white",
-padright => 11,
-padtop => 0,
-padbottom => 2,
-showlines => 0,
-sbborder => 0,
-vscrollbar => 1,
-hscrollbar => 0,
-showhardreturns => 0,
-wrapping => 1,
);
my $nicks = $screen->add
( 'nicks', 'Listbox',
-x => -1,
-y => -1,
-padtop => 0,
-padbottom => 2,
-width => 10,
-radio => 0 );
# There is no need for the editor widget to loose focus, so
# the "loose-focus" binding is disabled here. This also enables the
# use of the "TAB" key in the editor, which is nice to have.
#$editor->clear_binding('loose-focus');
$screen->add
( 'help', 'Label',
-y => -2,
-width => -1,
( run in 1.249 second using v1.01-cache-2.11-cpan-39bf76dae61 )