Changeset 73
- Timestamp:
- 05/09/08 18:50:16 (8 months ago)
- Files:
-
- 1 modified
-
trunk/cuirc/cuirc (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/cuirc/cuirc
r9 r73 19 19 use Text::Wrap (); 20 20 use Term::ANSIColor ":constants"; 21 use Config::General ;21 use Config::General qw( ParseConfig ); 22 22 23 23 my %opt; … … 35 35 36 36 use constant { 37 DEBUG => 1, 37 38 ACTIVE => 0, 38 39 }; … … 46 47 local $Text::Wrap::columns = $width; 47 48 return split /\n/, Text::Wrap::wrap(undef, " ", $string); 49 } 50 51 if (DEBUG) { 52 open LOG, ">>", "cuirc-debug.log"; 53 # Try to put errors in the window... 54 $SIG{"__DIE__"} = sub { 55 print LOG $_[0]; 56 }; 57 $SIG{"__WARN__"} = sub { 58 print LOG $_[0]; 59 }; 48 60 } 49 61 … … 82 94 $kernel->post($hostname, register => "all"); 83 95 } 84 else { 85 $kernel->post( 86 $hostname => connect => { 87 Nick => cuserid, 88 Server => $hostname, 89 Port => $port, 90 Username => cuserid, 91 Ircname => +(getpwnam cuserid)[6], 92 } 93 ); 94 } 96 97 $kernel->post( 98 $hostname => connect => { 99 Nick => cuserid, 100 Server => $hostname, 101 Port => $port, 102 Username => cuserid, 103 Ircname => +(getpwnam cuserid)[6], 104 } 105 ); 95 106 96 107 $kernel->yield … … 349 360 )->focus; 350 361 351 my (%Channel, $Current, @History, $CurCon, $CurrentChannel); 362 my (%Channel, $current, @history, $CurCon, $currentChannel); 363 364 $current = 0; 352 365 353 366 # The indirect method syntax isn't necessarily the best, but it does … … 358 371 my $line = $input->get; 359 372 360 push @ History, $line;361 $ Current = @History;373 push @history, $line; 374 $current = @history; 362 375 363 376 $input->text(""); … … 435 448 }, "\t"; 436 449 437 set_binding $editor sub {438 shift->text($History[--$Current]) 450 set_binding $editor sub { 451 shift->text($history[--$current]) if $current > 0; 439 452 }, KEY_UP; 440 453 441 454 set_binding $editor sub { 442 $ Current++;443 if ($ Current > @History) {444 shift->text("")445 }446 else {447 shift->text ($History[$Current])448 }455 $current++; 456 if ($current > @history) { 457 shift->text("") 458 } 459 else { 460 shift->text($history[$current]) 461 } 449 462 }, KEY_DOWN; 450 463 … … 534 547 535 548 # DRY - All these events go to the active window... (whois) 536 $kernel->state( "irc_$_" => sub { 537 $_[KERNEL]->yield(write => active => $_[ARG1]); 538 } ) for qw( 311 312 313 314 315 316 317 318 319 ); 549 # Whois now results in a popup, badass. 550 # $kernel->state( "irc_$_" => sub { 551 # $_[KERNEL]->yield(write => active => $_[ARG1]); 552 # } ) for qw( 311 312 313 314 315 316 317 318 319 ); 553 554 # Do nothing for the following events...(whois) 555 # Whois is collected and displayed in a status window 556 $kernel->state( "irc_$_" => sub {} ) for 557 qw( 311 312 313 314 315 316 317 318 319 320 558 irc_ctcp ); 539 559 }, 540 560 … … 591 611 592 612 if ($type eq "channel") { 593 $screen->add(594 "nicklist", 'Listbox',613 my $nicklist = $screen->add( 614 "nicklist", 'Listbox', 595 615 -x => -1, 596 616 -y => -1, … … 601 621 -intellidraw => 1, 602 622 ); 623 624 set_binding $nicklist sub { 625 my $nick = $nicklist->get_active_value; 626 # Remove op symbols and stuff. 627 $nick =~ s/^[@+]//; 628 629 my ($server) = ($name =~ m/(\S+)/); 630 631 $poe_kernel->yield(window_open => query => "$server $nick", 632 "Query with $nick"); 633 }, BUTTON1_DOUBLE_CLICKED; 603 634 } 604 635 … … 747 778 "Window $window has no nick list..." ); 748 779 } 780 }, 781 782 # Get a whois event. 783 irc_whois => sub { 784 my ($kernel, $curses, $whois) = @_[ KERNEL, HEAP, ARG0 ]; 785 786 warn "Got whois event"; 787 788 # It's just too much work right here... 789 no warnings; 790 791 my $idle = $whois->{idle} ? ": ($whois->{idle}s idle)" : ""; 792 my $since = $whois->{signon} ? 793 "since " . scalar localtime $whois->{signon} : ""; 794 795 my $msg = <<WHOIS; 796 $whois->{user}\@$whois->{host} "$whois->{real}" 797 @{$whois->{channels}} 798 $whois->{server} $since$idle 799 WHOIS 800 $curses->dialog( 801 -message => $msg, 802 -title => "Whois $whois->{nick}" 803 ); 749 804 }, 750 805