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.267 by sf-exg, Sat Jul 24 12:17:08 2021 UTC vs.
Revision 1.270 by root, Fri Nov 26 18:49:47 2021 UTC

196relevant action might not be carried out by the C++ code. 196relevant action might not be carried out by the C++ code.
197 197
198I<< When in doubt, return a false value (preferably C<()>). >> 198I<< When in doubt, return a false value (preferably C<()>). >>
199 199
200=over 200=over
201
202=item on_attach $term
203
204Called when an extension package is attached to a running terminal
205instance. Must return true in all cases, and runs with the same
206limitations as C<on_init>.
207
208Unlike C<on_init> or C<on_start>, this is called when the extension is
209attached to a terminal, regardless of whether the extension is loaded
210before or after the terminal is started. Extensions that need to do
211something before they work can do it in this callback, as opposed to e.g.
212C<on_init>, which might not be called.
201 213
202=item on_init $term 214=item on_init $term
203 215
204Called after a new terminal object has been initialized, but before 216Called after a new terminal object has been initialized, but before
205windows are created or the command gets run. Most methods are unsafe to 217windows are created or the command gets run. Most methods are unsafe to
823 835
824 eval "#line 1 \"--perl-eval resource/argument\"\n" . $TERM->resource ("perl_eval"); 836 eval "#line 1 \"--perl-eval resource/argument\"\n" . $TERM->resource ("perl_eval");
825 warn $@ if $@; 837 warn $@ if $@;
826 } 838 }
827 839
828 $retval = undef;
829
830 if ($htype == HOOK_OSC_SEQ) { 840 if ($htype == HOOK_OSC_SEQ) {
831 if (my $exts = delete $TERM->{meta}{autoload_osc}{$_[0]}) { 841 if (my $exts = delete $TERM->{meta}{autoload_osc}{$_[0]}) {
832 $TERM->autoload_extension ($_->[0]) for @$exts; 842 $TERM->autoload_extension ($_->[0]) for @$exts;
833 } 843 }
834 } elsif ($htype == HOOK_OSC_SEQ_PERL) { 844 } elsif ($htype == HOOK_OSC_SEQ_PERL) {
835 if ($_[0] =~ /^([^;]+)/ and (my $exts = delete $TERM->{meta}{autoload_osc_perl}{$1})) { 845 if ($_[0] =~ /^([^;]+)/ and (my $exts = delete $TERM->{meta}{autoload_osc_perl}{$1})) {
836 $TERM->autoload_extension ($_->[0]) for @$exts; 846 $TERM->autoload_extension ($_->[0]) for @$exts;
837 } 847 }
838 } 848 }
849
850 $retval = undef;
839 851
840 if (my $cb = $TERM->{_hook}[$htype]) { 852 if (my $cb = $TERM->{_hook}[$htype]) {
841 verbose 10, "$HOOKNAME[$htype] (" . (join ", ", $TERM, @_) . ")" 853 verbose 10, "$HOOKNAME[$htype] (" . (join ", ", $TERM, @_) . ")"
842 if $verbosity >= 10; 854 if $verbosity >= 10;
843 855
1180# find on_xxx subs in the package and register them 1192# find on_xxx subs in the package and register them
1181# as hooks 1193# as hooks
1182sub register_package { 1194sub register_package {
1183 my ($self, $pkg, $argv) = @_; 1195 my ($self, $pkg, $argv) = @_;
1184 1196
1197 return if $self->{_pkg}{$pkg};
1198
1185 no strict 'refs'; 1199 no strict 'refs';
1186 1200
1187 urxvt::verbose 6, "register package $pkg to $self"; 1201 urxvt::verbose 6, "register package $pkg to $self";
1188 1202
1189 @{"$pkg\::ISA"} = urxvt::term::extension::; 1203 @{"$pkg\::ISA"} = urxvt::term::extension::;
1199 1213
1200 for my $name (@HOOKNAME) { 1214 for my $name (@HOOKNAME) {
1201 if (my $ref = $pkg->can ("on_" . lc $name)) { 1215 if (my $ref = $pkg->can ("on_" . lc $name)) {
1202 $proxy->enable ($name => $ref); 1216 $proxy->enable ($name => $ref);
1203 } 1217 }
1218 }
1219
1220 if (my $attach_hook = $pkg->can ("on_attach")) {
1221 $attach_hook->($proxy)
1222 or urxvt::verbose 1, "$pkg->on_attach returned false, extension failed to attach";
1204 } 1223 }
1205} 1224}
1206 1225
1207# map extension name to filesystem path 1226# map extension name to filesystem path
1208sub extension_path { 1227sub extension_path {
1625Returns the number of screen-cells this string would need. Correctly 1644Returns the number of screen-cells this string would need. Correctly
1626accounts for wide and combining characters. 1645accounts for wide and combining characters.
1627 1646
1628=item $octets = $term->locale_encode ($string) 1647=item $octets = $term->locale_encode ($string)
1629 1648
1630Convert the given text string into the corresponding locale encoding. 1649Convert the given text string into the corresponding locale
1650encoding. Returns C<undef> if C<$string> is C<undef>.
1631 1651
1632=item $string = $term->locale_decode ($octets) 1652=item $string = $term->locale_decode ($octets)
1633 1653
1634Convert the given locale-encoded octets into a perl string. 1654Convert the given locale-encoded octets into a perl string. Returns
1655C<undef> if C<$octets> is C<undef>.
1635 1656
1636=item $term->scr_xor_span ($beg_row, $beg_col, $end_row, $end_col[, $rstyle]) 1657=item $term->scr_xor_span ($beg_row, $beg_col, $end_row, $end_col[, $rstyle])
1637 1658
1638XORs the rendition values in the given span with the provided value 1659XORs the rendition values in the given span with the provided value
1639(default: C<RS_RVid>), which I<MUST NOT> contain font styles. Useful in 1660(default: C<RS_RVid>), which I<MUST NOT> contain font styles. Useful in

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines