Curses-UI-POE

 view release on metacpan or  search on metacpan

POE.pm  view on Meta::CPAN

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
    my $caller = caller;
 
    no strict "refs";
 
    *{ $caller . "::MainLoop" } = \&MainLoop;
    eval "package $caller; use POE;";
}
 
# XXX We assume that there will never be two Curses::UI::POE sessions.
my @modal_objects;
my @modal_callbacks;
 
# The session needed to make curses run in POE.
sub new {
    my ($type, %options) = @_;
    my $self = &Curses::UI::new(@_);
#   my $self = bless Curses::UI->new, $type;
#   my $self = bless &Curses::UI::new(@_), $type;
 
    # I have to do this here, because if our first order of business is a
    # dialog then the _start event will be too late.  This self reference is

POE.pm  view on Meta::CPAN

113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
sub _clear_modal_callback {
    my ($self) = @_;
 
    my $top     = pop @modal_objects;
 
    # Reset focus
    $top->{-focus} = 0;
 
    # Dispatch callback.
    my $args    = pop @modal_callbacks;
    my $sub     = shift @$args;
    &{$sub}(@$args);
}
 
sub keyin {
    my ($self, $kernel) = @_[ OBJECT, KERNEL ];
 
 
    until ((my $key = $self->get_key(0)) eq -1) {
        $self->feedkey($key);

POE.pm  view on Meta::CPAN

196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
    # definition and redefine it later.
    sub Curses::UI::Widget::modalfocus () {
        my ($this) = @_;
 
        # "Fake" focus for this object.
        $this->{-has_modal_focus} = 1;
        $this->focus;
        $this->draw;
 
        push @modal_objects, $this;
        push @modal_callbacks, undef;
 
        # This is reentrant into the POE::Kernel
        while ( $this->{-has_modal_focus} ) {
            $poe_kernel->loop_do_timeslice;
        }
 
        $this->{-focus} = 0;
 
        pop @modal_callbacks;
        pop @modal_objects;
 
        return $this;
    }
 
    POE::Kernel->run;
 
    # Replace previously defined method into the symbol table.
    *{"Curses::UI::Widget::modalfocus"} = $modalfocus;
}

POE.pm  view on Meta::CPAN

241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
    # Force the read timeout to be 0, so Curses::UI polls.
    $this->{-read_timeout} = 0;
 
    return $this;
}
 
{
    no warnings "redefine";
    # None of this work's if POE isn't running...
    # Redefine the callbackmodalfocus to ensure that callbacks and objects make
    # it on to our own private stack.
    sub Curses::UI::Widget::callbackmodalfocus {
        my ($this, $cb) = @_;
 
        # "Fake" focus for this object.
        $this->{-has_modal_focus} = 1;
        $this->focus;
        $this->draw;
 
        push @modal_objects, $this;
 
        if (defined $cb) {
            # They need a callback, so register it.
            push @modal_callbacks, $cb;
        } else {
            # Push a null callback.
            push @modal_callbacks, [sub { }];
        }
 
        # We assume our callers are going to return immediately back to the
        # main event loop, so we don't need a recursive call.      
        return;
    }
 
}
 
=head1 NAME



( run in 0.219 second using v1.01-cache-2.11-cpan-454fe037f31 )