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.219 by sf-exg, Sun Jun 10 18:23:18 2012 UTC vs.
Revision 1.220 by root, Tue Jun 19 18:17:56 2012 UTC

112=item $urxvt_term = $self->{term} 112=item $urxvt_term = $self->{term}
113 113
114Returns the C<urxvt::term> object associated with this instance of the 114Returns the C<urxvt::term> object associated with this instance of the
115extension. This member I<must not> be changed in any way. 115extension. This member I<must not> be changed in any way.
116 116
117=item $self->enable ($hook_name => $cb, [$hook_name => $cb..]) 117=item $self->enable ($hook_name => $cb[, $hook_name => $cb..])
118 118
119Dynamically enable the given hooks (named without the C<on_> prefix) for 119Dynamically enable the given hooks (named without the C<on_> prefix) for
120this extension, replacing any previous hook. This is useful when you want 120this extension, replacing any previous hook. This is useful when you want
121to overwrite time-critical hooks only temporarily. 121to overwrite time-critical hooks only temporarily.
122 122
123To install additional callbacks for the same hook, you cna use the C<on>
124method of the C<urxvt::term> class.
125
123=item $self->disable ($hook_name[, $hook_name..]) 126=item $self->disable ($hook_name[, $hook_name..])
124 127
125Dynamically disable the given hooks. 128Dynamically disable the given hooks.
129
130=item $self->x_resource ($pattern)
131
132=item $self->x_resource_boolean ($pattern)
133
134These methods support an additional C<%> prefix when called on an
135extension object - see the description of these methods in the
136C<urxvt::term> class for details.
126 137
127=back 138=back
128 139
129=head2 Hooks 140=head2 Hooks
130 141
735 if (my $cb = $TERM->{_hook}[$htype]) { 746 if (my $cb = $TERM->{_hook}[$htype]) {
736 verbose 10, "$HOOKNAME[$htype] (" . (join ", ", $TERM, @_) . ")" 747 verbose 10, "$HOOKNAME[$htype] (" . (join ", ", $TERM, @_) . ")"
737 if $verbosity >= 10; 748 if $verbosity >= 10;
738 749
739 for my $pkg (keys %$cb) { 750 for my $pkg (keys %$cb) {
740 my $retval_ = eval { $cb->{$pkg}->($TERM->{_pkg}{$pkg}, @_) }; 751 my $retval_ = eval { $cb->{$pkg}->($TERM->{_pkg}{$pkg} || $TERM, @_) };
741 $retval ||= $retval_; 752 $retval ||= $retval_;
742 753
743 if ($@) { 754 if ($@) {
744 $TERM->ungrab; # better to lose the grab than the session 755 $TERM->ungrab; # better to lose the grab than the session
745 warn $@; 756 warn $@;
1058 1069
1059Destroy the terminal object (close the window, free resources 1070Destroy the terminal object (close the window, free resources
1060etc.). Please note that @@RXVT_NAME@@ will not exit as long as any event 1071etc.). Please note that @@RXVT_NAME@@ will not exit as long as any event
1061watchers (timers, io watchers) are still active. 1072watchers (timers, io watchers) are still active.
1062 1073
1074=item $guard = $self->on ($hook_name => $cb[, $hook_name => $cb..])
1075
1076Similar to the extension method C<enable>, but installs additional
1077callbacks for the givne hook(s) (existing ones are not replaced), and
1078returns a guard object. When the guard object is destroyed the callbacks
1079are disabled again.
1080
1081Note that these callbacks receive the normal paramaters, but the first
1082argument (normally the extension) is currently undefined.
1083
1084=cut
1085
1086sub urxvt::term::on_disable::DESTROY {
1087 my $disable = shift;
1088
1089 my $self = delete $disable->{""};
1090
1091 while (my ($htype, $id) = each %$disable) {
1092 delete $self->{_hook}[$htype]{$id};
1093 $self->set_should_invoke ($htype, -1);
1094 }
1095}
1096
1097sub on {
1098 my ($self, %hook) = @_;
1099
1100 my %disable = ( "" => $self );
1101
1102 while (my ($name, $cb) = each %hook) {
1103 my $htype = $HOOKTYPE{uc $name};
1104 defined $htype
1105 or Carp::croak "unsupported hook type '$name'";
1106
1107 my $id = $cb+0;
1108
1109 $self->set_should_invoke ($htype, +1);
1110 $disable{$htype} = $id;
1111 $self->{_hook}[$htype]{$id} = $cb;
1112 }
1113
1114 bless \%disable, "urxvt::term::on_disable"
1115}
1116
1063=item $term->exec_async ($cmd[, @args]) 1117=item $term->exec_async ($cmd[, @args])
1064 1118
1065Works like the combination of the C<fork>/C<exec> builtins, which executes 1119Works like the combination of the C<fork>/C<exec> builtins, which executes
1066("starts") programs in the background. This function takes care of setting 1120("starts") programs in the background. This function takes care of setting
1067the user environment before exec'ing the command (e.g. C<PATH>) and should 1121the user environment before exec'ing the command (e.g. C<PATH>) and should

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines