… | |
… | |
112 | =item $urxvt_term = $self->{term} |
112 | =item $urxvt_term = $self->{term} |
113 | |
113 | |
114 | Returns the C<urxvt::term> object associated with this instance of the |
114 | Returns the C<urxvt::term> object associated with this instance of the |
115 | extension. This member I<must not> be changed in any way. |
115 | extension. 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 | |
119 | Dynamically enable the given hooks (named without the C<on_> prefix) for |
119 | Dynamically enable the given hooks (named without the C<on_> prefix) for |
120 | this extension, replacing any previous hook. This is useful when you want |
120 | this extension, replacing any previous hook. This is useful when you want |
121 | to overwrite time-critical hooks only temporarily. |
121 | to overwrite time-critical hooks only temporarily. |
122 | |
122 | |
|
|
123 | To install additional callbacks for the same hook, you cna use the C<on> |
|
|
124 | method 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 | |
125 | Dynamically disable the given hooks. |
128 | Dynamically disable the given hooks. |
|
|
129 | |
|
|
130 | =item $self->x_resource ($pattern) |
|
|
131 | |
|
|
132 | =item $self->x_resource_boolean ($pattern) |
|
|
133 | |
|
|
134 | These methods support an additional C<%> prefix when called on an |
|
|
135 | extension object - see the description of these methods in the |
|
|
136 | C<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 | |
1059 | Destroy the terminal object (close the window, free resources |
1070 | Destroy the terminal object (close the window, free resources |
1060 | etc.). Please note that @@RXVT_NAME@@ will not exit as long as any event |
1071 | etc.). Please note that @@RXVT_NAME@@ will not exit as long as any event |
1061 | watchers (timers, io watchers) are still active. |
1072 | watchers (timers, io watchers) are still active. |
1062 | |
1073 | |
|
|
1074 | =item $guard = $self->on ($hook_name => $cb[, $hook_name => $cb..]) |
|
|
1075 | |
|
|
1076 | Similar to the extension method C<enable>, but installs additional |
|
|
1077 | callbacks for the givne hook(s) (existing ones are not replaced), and |
|
|
1078 | returns a guard object. When the guard object is destroyed the callbacks |
|
|
1079 | are disabled again. |
|
|
1080 | |
|
|
1081 | Note that these callbacks receive the normal paramaters, but the first |
|
|
1082 | argument (normally the extension) is currently undefined. |
|
|
1083 | |
|
|
1084 | =cut |
|
|
1085 | |
|
|
1086 | sub 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 | |
|
|
1097 | sub 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 | |
1065 | Works like the combination of the C<fork>/C<exec> builtins, which executes |
1119 | Works 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 |
1067 | the user environment before exec'ing the command (e.g. C<PATH>) and should |
1121 | the user environment before exec'ing the command (e.g. C<PATH>) and should |