… | |
… | |
2 | |
2 | |
3 | rxvtperl - rxvt-unicode's embedded perl interpreter |
3 | rxvtperl - rxvt-unicode's embedded perl interpreter |
4 | |
4 | |
5 | =head1 SYNOPSIS |
5 | =head1 SYNOPSIS |
6 | |
6 | |
7 | * Put your scripts into F<@@RXVT_LIBDIR@@/urxvt/perl-ext/>, they will be loaded automatically. |
7 | # create a file grab_test in $HOME: |
8 | |
|
|
9 | * Scripts are evaluated in a 'use strict' and 'use utf8' environment, and |
|
|
10 | thus must be encoded as UTF-8. |
|
|
11 | |
8 | |
12 | sub on_sel_grab { |
9 | sub on_sel_grab { |
13 | warn "you selected ", $_[0]->selection; |
10 | warn "you selected ", $_[0]->selection; |
14 | () |
11 | () |
15 | } |
12 | } |
16 | |
13 | |
17 | 1 |
14 | # start a @@RXVT_NAME@@ using it: |
|
|
15 | |
|
|
16 | @@RXVT_NAME@@ --perl-lib $HOME -pe grab_test |
18 | |
17 | |
19 | =head1 DESCRIPTION |
18 | =head1 DESCRIPTION |
20 | |
19 | |
21 | Everytime a terminal object gets created, scripts specified via the |
20 | Everytime a terminal object gets created, scripts specified via the |
22 | C<perl> resource are associated with it. |
21 | C<perl> resource are loaded and associated with it. |
|
|
22 | |
|
|
23 | Scripts are compiled in a 'use strict' and 'use utf8' environment, and |
|
|
24 | thus must be encoded as UTF-8. |
23 | |
25 | |
24 | Each script will only ever be loaded once, even in @@RXVT_NAME@@d, where |
26 | Each script will only ever be loaded once, even in @@RXVT_NAME@@d, where |
25 | scripts will be shared (But not enabled) for all terminals. |
27 | scripts will be shared (But not enabled) for all terminals. |
26 | |
28 | |
27 | =head2 General API Considerations |
29 | =head2 General API Considerations |
… | |
… | |
226 | sub invoke { |
228 | sub invoke { |
227 | local $term = shift; |
229 | local $term = shift; |
228 | my $htype = shift; |
230 | my $htype = shift; |
229 | |
231 | |
230 | if ($htype == 0) { # INIT |
232 | if ($htype == 0) { # INIT |
231 | my @dirs = ((split /:/, $term->resource ("perl_lib")), $LIBDIR); |
233 | my @dirs = ((split /:/, $term->resource ("perl_lib")), "$LIBDIR/perl"); |
232 | |
234 | |
233 | for my $ext (split /:/, $term->resource ("perl_ext")) { |
235 | for my $ext (split /:/, $term->resource ("perl_ext")) { |
234 | my @files = grep -f $_, map "$_/$ext", @dirs; |
236 | my @files = grep -f $_, map "$_/$ext", @dirs; |
235 | |
237 | |
236 | if (@files) { |
238 | if (@files) { |