- Timestamp:
- 05/04/08 18:30:03 (8 months ago)
- Location:
- trunk/Curses-UI-POE
- Files:
-
- 3 modified
-
MANIFEST.SKIP (modified) (2 diffs)
-
POE.pm (modified) (8 diffs)
-
examples/irc_client (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Curses-UI-POE/MANIFEST.SKIP
r13 r67 6 6 ^blib/ 7 7 ^Makefile$ 8 ^ POE-Component-Client-TCPMulti-8 ^Curses-UI-POE 9 9 ^MANIFEST.bak$ 10 10 ^pm_to_blib$ … … 19 19 \.tar\.gz$ 20 20 \.tgz$ 21 ^reproduce.* 22 tmp -
trunk/Curses-UI-POE/POE.pm
r65 r67 24 24 BEGIN { run POE::Kernel } 25 25 26 *VERSION = \0.03 ;26 *VERSION = \0.032; 27 27 our $VERSION; 28 28 … … 72 72 object_states => [ 73 73 @{ $options{object_states} }, 74 $self, [ qw( _start keyin timer shutdown ) ]74 $self, [ qw( _start init keyin timer shutdown ) ] 75 75 ], 76 76 … … 84 84 } 85 85 86 sub _start { 86 # Wait until the kernel actually starts before we muck with things. 87 sub _start { $_[KERNEL]->yield("init") } 88 89 sub init { 87 90 my ($self, $kernel) = @_[ OBJECT, KERNEL ]; 88 91 … … 138 141 } 139 142 140 # This was a hack to make sure to pick up the extra events when things got out 141 # of sync. I'm not sure if I need it. But let's try getting C::U::P working 142 # first. 143 # if (my $key = $self->get_key(0)) { 144 # $self->feedkey($key) unless $key eq "-1"; 145 # $self->do_one_event; 146 # } 147 143 # This was a hack to make sure to pick up the extra events when things got 144 # out of sync. It was suggested 145 if (my $key = $self->get_key(0)) { 146 $self->feedkey($key) unless $key eq "-1"; 147 $self->do_one_event; 148 } 149 148 150 # Set the root cursor mode 149 151 unless ($self->{-no_output}) { … … 190 192 } 191 193 194 195 196 no warnings "redefine"; 197 198 my $modalfocus = \&Curses::UI::Widget::modalfocus; 199 200 # Let modalfocus() be a reentrant into the POE Kernel. This is stackable, 201 # so it should not impact other behaviors, and POE keeps chugging along 202 # uneffected. This is a modal focus without a callback, this method does 203 # not return until the modal widget get's cleared out. 204 # 205 # This is done here so that ->dailog will still work as it did previously. 206 # until this is run. And just in case, we save the old modalfocus 207 # definition and redefine it later. 208 sub Curses::UI::Widget::modalfocus () { 209 my ($this) = @_; 210 211 # "Fake" focus for this object. 212 $this->{-has_modal_focus} = 1; 213 $this->focus; 214 $this->draw; 215 216 push @modal_objects, $this; 217 push @modal_callbacks, undef; 218 219 # This is reentrant into the POE::Kernel 220 while ( $this->{-has_modal_focus} ) { 221 $poe_kernel->loop_do_timeslice; 222 } 223 224 $this->{-focus} = 0; 225 226 pop @modal_callbacks; 227 pop @modal_objects; 228 229 return $this; 230 } 231 192 232 POE::Kernel->run; 233 234 # Replace previously defined method into the symbol table. 235 *{"Curses::UI::Widget::modalfocus"} = $modalfocus; 193 236 } 194 237 … … 242 285 } 243 286 244 # Let modalfocus() be a reentrant into the POE Kernel. This is stackable,245 # so it should not impact other behaviors, and POE keeps chugging along246 # uneffected. This is a modal focus without a callback, this method does247 # not return until the modal widget get's cleared out.248 sub Curses::UI::Widget::modalfocus () {249 my ($this) = @_;250 251 # "Fake" focus for this object.252 $this->{-has_modal_focus} = 1;253 $this->focus;254 $this->draw;255 256 push @modal_objects, $this;257 push @modal_callbacks, undef;258 259 # This is reentrant into the POE::Kernel260 while ( $this->{-has_modal_focus} ) {261 $poe_kernel->loop_do_timeslice;262 }263 264 $this->{-focus} = 0;265 266 pop @modal_callbacks;267 pop @modal_objects;268 269 return $this;270 }271 287 } 272 288 … … 360 376 =head1 BUGS 361 377 362 None Known. Whoohoo! 363 364 Find any? Send them to me! tag@cpan.org 378 =over 2 379 380 =item Dialogs before ->mainloop() 381 382 Dialogs before Curses::UI::Mainloop 383 384 =back 385 386 Find more? Send them to me! tag@cpan.org 365 387 366 388 =head1 AUTHOR … … 386 408 387 409 1; 388 389 __END__390 This is a block of no longer needed code. When I feel up to it,391 I will remove it.392 393 # The tempdialog does this modalfocus in Curses::UI::Widget which394 # starts a secondary event loop. I need to force use of POE.395 396 #sub tempdialog {397 # my $this = shift;398 # my $class = shift;399 # my %args = @_;400 #401 # my $id = "__window_$class";402 #403 # my $dialog = $this->add($id, $class, %args);404 #405 # $dialog->{-has_modal_focus} = 1;406 #407 # $dialog->focus;408 # $dialog->draw;409 #410 # # We loop ourself, this is a modial dialog..but its still gotta multitask.411 # while ( $dialog->{-has_modal_focus} ) {412 # $poe_kernel->loop_do_timeslice;413 # }414 #415 # my $return = $dialog->get;416 #417 # $dialog->{-focus} = 0;418 #419 # $this->delete($id);420 # $this->root->focus(undef, 1);421 #422 # return $return;423 #}424 425 # This is null prototyped only to match the Curses::UI::Widget426 # subroutine it replaces...it SHOULDN'T be prototyped at all427 # since it is a method.428 -
trunk/Curses-UI-POE/examples/irc_client
r65 r67 8 8 use POE qw( Component::IRC ); 9 9 use Curses::UI::POE; 10 use Carp; 10 11 11 12 my $Curses; … … 14 15 _start => sub { 15 16 $_[HEAP]->{irc} = 16 POE::Component::IRC->spawn( );17 POE::Component::IRC->spawn( alias => "IRC" ); 17 18 18 19 # Even if we dont use all events, it shouldn't create an error since … … 22 23 # efficiency *really* isn't a big issue here. 23 24 24 $_[KERNEL]-> yield(register => "all");25 $_[KERNEL]->post(IRC => register => "all"); 25 26 26 27 }, 27 28 28 29 irc_connected => sub { 29 printf "Connected to %s", $_[SENDER]->get_heap->server_name(); 30 my $server_name = $_[ SENDER ]->get_heap->server_name; 31 unless (defined $server_name) { 32 print "Connected..."; 33 } 34 else { 35 print "Connected to %s", $server_name; 36 } 30 37 }, 31 38 … … 104 111 select CURWIN; 105 112 113 114 open LOG, ">>", "cuirc-debug.log"; 115 116 # Try to put errors in the window... 117 $SIG{"__DIE__"} = sub { 118 print LOG $_[0]; 119 }; 120 $SIG{"__WARN__"} = sub { 121 print LOG $_[0]; 122 }; 123 106 124 print "Welcome to Curses::UI::POE's IRC example"; 107 125 … … 116 134 use POSIX qw( strftime cuserid ); 117 135 use Curses; 136 use Carp qw( carp ); 118 137 119 138 my @nicks; … … 164 183 my $object = shift; 165 184 my ($viewer, $curses) = @$object{qw( -viewer -curses )}; 185 186 # XXX Hack: Just ignore bunk requests for now... 187 if (grep !defined $_, @_) { 188 carp "Attempt to print undefined value"; 189 } 166 190 167 191 push @Channel, sprintf shift, @_; … … 272 296 printf "Sending Connect EVENT for %s:%s", $server, $port; 273 297 274 $ _[KERNEL]->yield275 ( connect => {298 $poe_kernel->post 299 ( IRC => connect => { 276 300 Nick => cuserid, 277 301 Server => $server, … … 291 315 else { 292 316 $Channel{$Join} = 1; 293 $ _[KERNEL]->yield(join => $Join );317 $poe_kernel->post( IRC => join => $Join ); 294 318 $CurrentChannel = $Join; 295 319 } 296 320 }, 297 321 298 nick => sub { $ _[KERNEL]->yield(nick => $_[1] ) },299 kick => sub { $ _[KERNEL]->yield(kick => $_[1..$#_] ) },300 msg => sub { $ _[KERNEL]->yield(privmsg => $_[1..$#_] ) },322 nick => sub { $poe_kernel->post( IRC => nick => $_[1] ) }, 323 kick => sub { $poe_kernel->post( IRC => kick => $_[1..$#_] ) }, 324 msg => sub { $poe_kernel->post( IRC => privmsg => $_[1..$#_] ) }, 301 325 302 326 quote => sub { 303 $ _[KERNEL]->yield(sl => join " ", @_[1..$#_] );327 $poe_kernel->post( IRC => sl => join " ", @_[1..$#_] ); 304 328 }, 305 329 306 330 quit => sub { 307 $ _[KERNEL]->yield(quit => join " ", @_[1..$#_] );331 $poe_kernel->post( IRC => quit => join " ", @_[1..$#_] ); 308 332 309 333 print "Have a nice day"; … … 332 356 else { 333 357 if ($CurrentChannel) { 334 $ _[KERNEL]->yield(privmsg => $CurrentChannel, $line );358 $poe_kernel->post( IRC => privmsg => $CurrentChannel, $line ); 335 359 print "> $line"; 336 360 }