better hook to capture stderr
[app-cpan2pkg.git] / lib / App / CPAN2Pkg / Curses.pm
blob5ee8c984c93ad334ca1908d7db6ecaff92c8b7f3
2 # This file is part of App::CPAN2Pkg.
3 # Copyright (c) 2009 Jerome Quelin, all rights reserved.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the same terms as Perl itself.
10 package App::CPAN2Pkg::Curses;
12 use App::CPAN2Pkg;
13 use Curses;
14 use Curses::UI::POE;
15 use POE;
17 use base qw{ Curses::UI::POE };
20 #--
21 # CONSTRUCTOR
23 sub spawn {
24 my ($class, $opts) = @_;
26 my $cui = $class->new(
27 -color_support => 1,
28 inline_states => {
29 # inline states
30 _start => \&_start,
31 _stop => sub { warn "_stop"; },
34 return $cui;
38 #--
39 # SUBS
41 #-- poe inline states
43 sub _start {
44 my ($k, $self) = @_[KERNEL, HEAP];
46 $k->alias_set('ui');
47 $self->_build_gui;
49 App::CPAN2Pkg->spawn($opts);
56 =pod
59 CPAN2Mdv - generating mandriva rpms from cpan
61 - Packages queue ------------------------------------------
62 Language::Befunge [ok]
63 Test::Exception [ok]
64 Test::Harness [ok]
65 File::Spec [ok]
66 Scalar::Util [ok]
67 Carp [ok]
68 Module::Build [ok]
69 Test::More [ok]
70 ExtUtils::CBuilder [ok]
71 Sub::Uplevel [ok]
72 Storable [ok]
73 aliased [ok]
74 Readonly [ok]
75 Class::XSAccessor [ok]
76 AutoXS::Header [ok]
77 Math::BaseCalc [ok]
78 UNIVERSAL::require [ok]
80 enter = jump to, n = new, d = delete
82 =cut
84 #--
85 # METHODS
87 # -- private methods
89 sub _build_gui {
90 my ($self) = @_;
92 $self->_build_title;
93 $self->_build_notebook;
94 $self->_build_queue;
95 $self->_set_bindings;
98 sub _build_title {
99 my ($self) = @_;
100 my $title = 'cpan2pkg - generating native linux packages from cpan';
101 my $tb = $self->add(undef, 'Window', -height => 1);
102 $tb->add(undef, 'Label', -bold=>1, -text=>$title);
105 sub _build_notebook {
106 my ($self) = @_;
108 my ($rows, $cols);
109 getmaxyx($rows, $cols);
110 my $mw = $self->add(undef, 'Window',
111 '-y' => 2,
112 -height => $rows - 3,
114 my $nb = $mw->add(undef, 'Notebook');
115 $self->{nb} = $nb;
118 sub _build_queue {
119 my ($self) = @_;
120 my $pane = $self->{nb}->add_page('Package queue');
121 my $list = $pane->add(undef, 'Listbox');
124 sub _set_bindings {
125 my ($self) = @_;
126 $self->set_binding( sub{ die; }, "\cQ" );
132 __END__