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.44 by root, Sat Jan 7 19:29:17 2006 UTC vs.
Revision 1.45 by root, Sat Jan 7 20:23:52 2006 UTC

179should extend the selection itelf and return true to suppress the built-in 179should extend the selection itelf and return true to suppress the built-in
180processing. 180processing.
181 181
182See the F<selection> example extension. 182See the F<selection> example extension.
183 183
184=item on_focus_in $term
185
186Called whenever the window gets the keyboard focus, before urxvt does
187focus in processing.
188
189=item on_focus_out $term
190
191Called wheneever the window loses keyboard focus, before urxvt does focus
192out processing.
193
194=item on_view_change $term, $offset 184=item on_view_change $term, $offset
195 185
196Called whenever the view offset changes, i..e the user or program 186Called whenever the view offset changes, i..e the user or program
197scrolls. Offset C<0> means display the normal terminal, positive values 187scrolls. Offset C<0> means display the normal terminal, positive values
198show this many lines of scrollback. 188show this many lines of scrollback.
261 251
262Called whenever the user presses a key combination that has a 252Called whenever the user presses a key combination that has a
263C<perl:string> action bound to it (see description of the B<keysym> 253C<perl:string> action bound to it (see description of the B<keysym>
264resource in the @@RXVT_NAME@@(1) manpage). 254resource in the @@RXVT_NAME@@(1) manpage).
265 255
256=item on_focus_in $term
257
258Called whenever the window gets the keyboard focus, before rxvt-unicode
259does focus in processing.
260
261=item on_focus_out $term
262
263Called wheneever the window loses keyboard focus, before rxvt-unicode does
264focus out processing.
265
266=item on_key_press $term, $event, $octets 266=item on_key_press $term, $event, $octets
267 267
268=item on_key_release $term, $event 268=item on_key_release $term, $event
269 269
270=item on_button_press $term, $event 270=item on_button_press $term, $event
271 271
272=item on_button_release $term, $event 272=item on_button_release $term, $event
273 273
274=item on_motion_notify $term, $event 274=item on_motion_notify $term, $event
275
276=item on_map_notify $term, $event
277
278=item on_unmap_notify $term, $event
275 279
276Called whenever the corresponding X event is received for the terminal If 280Called whenever the corresponding X event is received for the terminal If
277the hook returns true, then the even will be ignored by rxvt-unicode. 281the hook returns true, then the even will be ignored by rxvt-unicode.
278 282
279The event is a hash with most values as named by Xlib (see the XEvent 283The event is a hash with most values as named by Xlib (see the XEvent
534 } or die "FATAL: unable to compile method forwarder: $@"; 538 } or die "FATAL: unable to compile method forwarder: $@";
535 539
536 goto &$urxvt::term::proxy::AUTOLOAD; 540 goto &$urxvt::term::proxy::AUTOLOAD;
537} 541}
538 542
543sub urxvt::destroy_hook::DESTROY {
544 ${$_[0]}->();
545}
546
547sub urxvt::destroy_hook(&) {
548 bless \shift, urxvt::destroy_hook::
549}
550
539=head2 The C<urxvt::term> Class 551=head2 The C<urxvt::term> Class
540 552
541=over 4 553=over 4
542 554
543=item $term->destroy 555=item $term->destroy
581=cut 593=cut
582 594
583sub urxvt::term::resource($$;$) { 595sub urxvt::term::resource($$;$) {
584 my ($self, $name) = (shift, shift); 596 my ($self, $name) = (shift, shift);
585 unshift @_, $self, $name, ($name =~ s/\s*\+\s*(\d+)$// ? $1 : 0); 597 unshift @_, $self, $name, ($name =~ s/\s*\+\s*(\d+)$// ? $1 : 0);
586 goto &urxvt::term::_resource; 598 &urxvt::term::_resource
587} 599}
588 600
589=item $rend = $term->rstyle ([$new_rstyle]) 601=item $rend = $term->rstyle ([$new_rstyle])
590 602
591Return and optionally change the current rendition. Text that is output by 603Return and optionally change the current rendition. Text that is output by
667 679
668If hidden, display the overlay again. 680If hidden, display the overlay again.
669 681
670=back 682=back
671 683
684=item $popup = $term->popup ($event)
685
686Creates a new C<urxvt::popup> object that implements a popup menu. The
687C<$event> I<must> be the event causing the menu to pop up (a button event,
688currently).
689
690=cut
691
692sub urxvt::term::popup {
693 my ($self, $event) = @_;
694
695 $self->grab ($event->{time}, 1)
696 or return;
697
698 my $popup = bless {
699 term => $self,
700 event => $event,
701 }, urxvt::popup::;
702
703 Scalar::Util::weaken $popup->{term};
704
705 $self->{_destroy}{$popup} = urxvt::destroy_hook { $popup->{popup}->destroy };
706 Scalar::Util::weaken $self->{_destroy}{$popup};
707
708 $popup
709}
710
672=item $cellwidth = $term->strwidth ($string) 711=item $cellwidth = $term->strwidth ($string)
673 712
674Returns the number of screen-cells this string would need. Correctly 713Returns the number of screen-cells this string would need. Correctly
675accounts for wide and combining characters. 714accounts for wide and combining characters.
676 715
926 965
927Converts rxvt-unicodes text reprsentation into a perl string. See 966Converts rxvt-unicodes text reprsentation into a perl string. See
928C<< $term->ROW_t >> for details. 967C<< $term->ROW_t >> for details.
929 968
930=back 969=back
970
971=head2 The C<urxvt::popup> Class
972
973=over 4
974
975=cut
976
977package urxvt::popup;
978
979sub add_item {
980 my ($self, $item) = @_;
981
982 push @{ $self->{item} }, $item;
983}
984
985sub add_button {
986 my ($self, $text, $cb) = @_;
987
988 $self->add_item ({ type => "button", text => "[ $text ]", activate => $cb });
989}
990
991sub show {
992 my ($self) = @_;
993
994 local $urxvt::popup::self = $self;
995
996 urxvt->new ("--perl-lib" => "", "--perl-ext-common" => "", "-pty-fd" => -1, "-sl" => 0, "-b" => 0,
997 "--transient-for" => $self->{term}->parent,
998 "-pe" => "urxvt_popup")
999 or die "unable to create popup window\n";
1000}
1001
1002sub DESTROY {
1003 my ($self) = @_;
1004
1005 $self->{term}->ungrab;
1006}
931 1007
932=head2 The C<urxvt::timer> Class 1008=head2 The C<urxvt::timer> Class
933 1009
934This class implements timer watchers/events. Time is represented as a 1010This class implements timer watchers/events. Time is represented as a
935fractional number of seconds since the epoch. Example: 1011fractional number of seconds since the epoch. Example:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines