ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/urxvt.pm
(Generate patch)

Comparing rxvt-unicode/src/urxvt.pm (file contents):
Revision 1.54 by root, Sun Jan 8 01:59:29 2006 UTC vs.
Revision 1.56 by root, Sun Jan 8 05:52:42 2006 UTC

342 342
343=item urxvt::ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, 343=item urxvt::ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask,
344Mod3Mask, Mod4Mask, Mod5Mask, Button1Mask, Button2Mask, Button3Mask, 344Mod3Mask, Mod4Mask, Mod5Mask, Button1Mask, Button2Mask, Button3Mask,
345Button4Mask, Button5Mask, AnyModifier 345Button4Mask, Button5Mask, AnyModifier
346 346
347Various constants for use in X events. 347Various constants for use in X calls and event processing.
348 348
349=back 349=back
350 350
351=head2 RENDITION 351=head2 RENDITION
352 352
407use utf8; 407use utf8;
408use strict; 408use strict;
409use Scalar::Util (); 409use Scalar::Util ();
410use List::Util (); 410use List::Util ();
411 411
412our $VERSION = 1;
412our $TERM; 413our $TERM;
413our @HOOKNAME; 414our @HOOKNAME;
414our %OPTION; 415our %OPTION;
415our $LIBDIR; 416our $LIBDIR;
416 417
507 register_package extension_package $files[0]; 508 register_package extension_package $files[0];
508 } else { 509 } else {
509 warn "perl extension '$ext' not found in perl library search path\n"; 510 warn "perl extension '$ext' not found in perl library search path\n";
510 } 511 }
511 } 512 }
513
514 eval "#line 1 \"--perl-eval resource/argument\"\n" . $TERM->resource ("perl_eval");
515 warn $@ if $@;
512 } 516 }
513 517
514 $retval = undef; 518 $retval = undef;
515 519
516 if (my $cb = $TERM->{_hook}[$htype]) { 520 if (my $cb = $TERM->{_hook}[$htype]) {
551 } 555 }
552 556
553 $retval 557 $retval
554} 558}
555 559
560# urxvt::term::proxy
561
556sub urxvt::term::proxy::AUTOLOAD { 562sub urxvt::term::proxy::AUTOLOAD {
557 $urxvt::term::proxy::AUTOLOAD =~ /:([^:]+)$/ 563 $urxvt::term::proxy::AUTOLOAD =~ /:([^:]+)$/
558 or die "FATAL: \$AUTOLOAD '$urxvt::term::proxy::AUTOLOAD' unparsable"; 564 or die "FATAL: \$AUTOLOAD '$urxvt::term::proxy::AUTOLOAD' unparsable";
559 565
560 eval qq{ 566 eval qq{
566 } or die "FATAL: unable to compile method forwarder: $@"; 572 } or die "FATAL: unable to compile method forwarder: $@";
567 573
568 goto &$urxvt::term::proxy::AUTOLOAD; 574 goto &$urxvt::term::proxy::AUTOLOAD;
569} 575}
570 576
577# urxvt::destroy_hook
578
571sub urxvt::destroy_hook::DESTROY { 579sub urxvt::destroy_hook::DESTROY {
572 ${$_[0]}->(); 580 ${$_[0]}->();
573} 581}
574 582
575sub urxvt::destroy_hook(&) { 583sub urxvt::destroy_hook(&) {
576 bless \shift, urxvt::destroy_hook:: 584 bless \shift, urxvt::destroy_hook::
577} 585}
586
587package urxvt::anyevent;
588
589=head2 The C<urxvt::anyevent> Class
590
591The sole purpose of this class is to deliver an interface to the
592C<AnyEvent> module - any module using it will work inside urxvt without
593further work. The only exception is that you cannot wait on condition
594variables, but non-blocking condvar use is ok. What this means is that you
595cannot use blocking APIs, but the non-blocking variant should work.
596
597=cut
598
599our $VERSION = 1;
600
601$INC{"urxvt/anyevent.pm"} = 1; # mark us as there
602push @AnyEvent::REGISTRY, [urxvt => urxvt::anyevent::];
603
604sub timer {
605 my ($class, %arg) = @_;
606
607 my $cb = $arg{cb};
608
609 urxvt::timer
610 ->new
611 ->start (urxvt::NOW + $arg{after})
612 ->cb (sub {
613 $_[0]->stop; # need to cancel manually
614 $cb->();
615 })
616}
617
618sub io {
619 my ($class, %arg) = @_;
620
621 my $cb = $arg{cb};
622
623 bless [$arg{fh}, urxvt::iow
624 ->new
625 ->fd (fileno $arg{fh})
626 ->events (($arg{poll} =~ /r/ ? 1 : 0)
627 | ($arg{poll} =~ /w/ ? 2 : 0))
628 ->start
629 ->cb (sub {
630 $cb->(($_[1] & 1 ? 'r' : '')
631 . ($_[1] & 2 ? 'w' : ''));
632 })],
633 urxvt::anyevent::
634}
635
636sub DESTROY {
637 $_[0][1]->stop;
638}
639
640sub condvar {
641 bless \my $flag, urxvt::anyevent::condvar::
642}
643
644sub urxvt::anyevent::condvar::broadcast {
645 ${$_[0]}++;
646}
647
648sub urxvt::anyevent::condvar::wait {
649 unless (${$_[0]}) {
650 require Carp;
651 Carp::croak ("AnyEvent->condvar blocking wait unsupported in urxvt, use a non-blocking API");
652 }
653}
654
655package urxvt::term;
578 656
579=head2 The C<urxvt::term> Class 657=head2 The C<urxvt::term> Class
580 658
581=over 4 659=over 4
582 660
634 shade term_name title transparent transparent_all tripleclickwords 712 shade term_name title transparent transparent_all tripleclickwords
635 utmpInhibit visualBell 713 utmpInhibit visualBell
636 714
637=cut 715=cut
638 716
639sub urxvt::term::resource($$;$) { 717sub resource($$;$) {
640 my ($self, $name) = (shift, shift); 718 my ($self, $name) = (shift, shift);
641 unshift @_, $self, $name, ($name =~ s/\s*\+\s*(\d+)$// ? $1 : 0); 719 unshift @_, $self, $name, ($name =~ s/\s*\+\s*(\d+)$// ? $1 : 0);
642 &urxvt::term::_resource 720 &urxvt::term::_resource
643} 721}
644 722
731C<$event> I<must> be the event causing the menu to pop up (a button event, 809C<$event> I<must> be the event causing the menu to pop up (a button event,
732currently). 810currently).
733 811
734=cut 812=cut
735 813
736sub urxvt::term::popup { 814sub popup {
737 my ($self, $event) = @_; 815 my ($self, $event) = @_;
738 816
739 $self->grab ($event->{time}, 1) 817 $self->grab ($event->{time}, 1)
740 or return; 818 or return;
741 819
931 1009
932=back 1010=back
933 1011
934=cut 1012=cut
935 1013
936sub urxvt::term::line { 1014sub line {
937 my ($self, $row) = @_; 1015 my ($self, $row) = @_;
938 1016
939 my $maxrow = $self->nrow - 1; 1017 my $maxrow = $self->nrow - 1;
940 1018
941 my ($beg, $end) = ($row, $row); 1019 my ($beg, $end) = ($row, $row);
1019Converts rxvt-unicodes text reprsentation into a perl string. See 1097Converts rxvt-unicodes text reprsentation into a perl string. See
1020C<< $term->ROW_t >> for details. 1098C<< $term->ROW_t >> for details.
1021 1099
1022=back 1100=back
1023 1101
1102=cut
1103
1104package urxvt::popup;
1105
1024=head2 The C<urxvt::popup> Class 1106=head2 The C<urxvt::popup> Class
1025 1107
1026=over 4 1108=over 4
1027 1109
1028=cut 1110=cut
1029
1030package urxvt::popup;
1031 1111
1032sub add_item { 1112sub add_item {
1033 my ($self, $item) = @_; 1113 my ($self, $item) = @_;
1034 1114
1035 $item->{rend}{normal} = "\x1b[0;30;47m" unless exists $item->{rend}{normal}; 1115 $item->{rend}{normal} = "\x1b[0;30;47m" unless exists $item->{rend}{normal};

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines