1 | =head1 NAME |
1 | =head1 NAME |
2 | |
2 | |
3 | rxvtperl - rxvt-unicode's embedded perl interpreter |
3 | @@RXVT_NAME@@perl - 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 |
… | |
… | |
121 | code is run after this hook, and takes precedence. |
123 | code is run after this hook, and takes precedence. |
122 | |
124 | |
123 | =item on_refresh_end $term |
125 | =item on_refresh_end $term |
124 | |
126 | |
125 | Called just after the screen gets redrawn. See C<on_refresh_begin>. |
127 | Called just after the screen gets redrawn. See C<on_refresh_begin>. |
|
|
128 | |
|
|
129 | =item on_keyboard_command $term, $string |
|
|
130 | |
|
|
131 | Called whenever the user presses a key combination that has a |
|
|
132 | C<perl:string> action bound to it (see description of the B<keysym> |
|
|
133 | resource in the @@RXVT_NAME@@(1) manpage). |
126 | |
134 | |
127 | =back |
135 | =back |
128 | |
136 | |
129 | =head2 Functions in the C<urxvt> Package |
137 | =head2 Functions in the C<urxvt> Package |
130 | |
138 | |
… | |
… | |
226 | sub invoke { |
234 | sub invoke { |
227 | local $term = shift; |
235 | local $term = shift; |
228 | my $htype = shift; |
236 | my $htype = shift; |
229 | |
237 | |
230 | if ($htype == 0) { # INIT |
238 | if ($htype == 0) { # INIT |
231 | my @dirs = ((split /:/, $term->resource ("perl_lib")), $LIBDIR); |
239 | my @dirs = ((split /:/, $term->resource ("perl_lib")), "$LIBDIR/perl"); |
232 | |
240 | |
233 | for my $ext (split /:/, $term->resource ("perl_ext")) { |
241 | for my $ext (split /:/, $term->resource ("perl_ext")) { |
234 | my @files = grep -f $_, map "$_/$ext", @dirs; |
242 | my @files = grep -f $_, map "$_/$ext", @dirs; |
235 | |
243 | |
236 | if (@files) { |
244 | if (@files) { |