… | |
… | |
1023 | my $pkg = $1; |
1023 | my $pkg = $1; |
1024 | $pkg =~ s/[^[:word:]]/_/g; |
1024 | $pkg =~ s/[^[:word:]]/_/g; |
1025 | $pkg = "urxvt::ext::$pkg"; |
1025 | $pkg = "urxvt::ext::$pkg"; |
1026 | |
1026 | |
1027 | verbose 3, "loading extension '$path' into package '$pkg'"; |
1027 | verbose 3, "loading extension '$path' into package '$pkg'"; |
|
|
1028 | |
|
|
1029 | (${"$pkg\::_NAME"} = $path) =~ s/^.*[\\\/]//; # hackish |
1028 | |
1030 | |
1029 | open my $fh, "<:raw", $path |
1031 | open my $fh, "<:raw", $path |
1030 | or die "$path: $!"; |
1032 | or die "$path: $!"; |
1031 | |
1033 | |
1032 | my $source = |
1034 | my $source = |
… | |
… | |
1150 | } |
1152 | } |
1151 | } |
1153 | } |
1152 | ($mask, @color{qw(fg bg)}, \@failed) |
1154 | ($mask, @color{qw(fg bg)}, \@failed) |
1153 | } |
1155 | } |
1154 | |
1156 | |
1155 | # urxvt::term::extension |
|
|
1156 | |
|
|
1157 | package urxvt::term::extension; |
1157 | package urxvt::term::extension; |
1158 | |
1158 | |
1159 | sub enable { |
1159 | sub enable { |
1160 | my ($self, %hook) = @_; |
1160 | my ($self, %hook) = @_; |
1161 | my $pkg = $self->{_pkg}; |
1161 | my $pkg = $self->{_pkg}; |
… | |
… | |
1213 | ${$_[0]}->(); |
1213 | ${$_[0]}->(); |
1214 | } |
1214 | } |
1215 | |
1215 | |
1216 | sub urxvt::destroy_hook(&) { |
1216 | sub urxvt::destroy_hook(&) { |
1217 | bless \shift, urxvt::destroy_hook:: |
1217 | bless \shift, urxvt::destroy_hook:: |
|
|
1218 | } |
|
|
1219 | |
|
|
1220 | sub x_resource { |
|
|
1221 | my ($self, $name) = @_; |
|
|
1222 | $name =~ s/^%(\.|$)/$_[0]{_name}$1/; |
|
|
1223 | $self->{term}->x_resource ($name) |
|
|
1224 | } |
|
|
1225 | |
|
|
1226 | sub x_resource_boolean { |
|
|
1227 | my ($self, $name) = @_; |
|
|
1228 | $name =~ s/^%(\.|$)/$_[0]{_name}$1/; |
|
|
1229 | $self->{term}->x_resource_boolean ($name) |
1218 | } |
1230 | } |
1219 | |
1231 | |
1220 | package urxvt::anyevent; |
1232 | package urxvt::anyevent; |
1221 | |
1233 | |
1222 | =head2 The C<urxvt::anyevent> Class |
1234 | =head2 The C<urxvt::anyevent> Class |
… | |
… | |
1319 | urxvt::verbose 6, "register package $pkg to $self"; |
1331 | urxvt::verbose 6, "register package $pkg to $self"; |
1320 | |
1332 | |
1321 | @{"$pkg\::ISA"} = urxvt::term::extension::; |
1333 | @{"$pkg\::ISA"} = urxvt::term::extension::; |
1322 | |
1334 | |
1323 | my $proxy = bless { |
1335 | my $proxy = bless { |
1324 | _pkg => $pkg, |
1336 | _pkg => $pkg, |
|
|
1337 | _name => ${"$pkg\::_NAME"}, # hackish |
1325 | argv => $argv, |
1338 | argv => $argv, |
1326 | }, $pkg; |
1339 | }, $pkg; |
1327 | Scalar::Util::weaken ($proxy->{term} = $self); |
1340 | Scalar::Util::weaken ($proxy->{term} = $self); |
1328 | |
1341 | |
1329 | $self->{_pkg}{$pkg} = $proxy; |
1342 | $self->{_pkg}{$pkg} = $proxy; |
1330 | |
1343 | |
… | |
… | |
1502 | Returns the X-Resource for the given pattern, excluding the program or |
1515 | Returns the X-Resource for the given pattern, excluding the program or |
1503 | class name, i.e. C<< $term->x_resource ("boldFont") >> should return the |
1516 | class name, i.e. C<< $term->x_resource ("boldFont") >> should return the |
1504 | same value as used by this instance of rxvt-unicode. Returns C<undef> if no |
1517 | same value as used by this instance of rxvt-unicode. Returns C<undef> if no |
1505 | resource with that pattern exists. |
1518 | resource with that pattern exists. |
1506 | |
1519 | |
|
|
1520 | Extensions that define extra resource or command line arguments also need |
|
|
1521 | to call this method to access their values. |
|
|
1522 | |
|
|
1523 | If the method is called on an extension object (basically, from an |
|
|
1524 | extension), then the special prefix C<%.> will be replaced by the name of |
|
|
1525 | the extension and a dot, and the lone string C<%> will be replcaed by the |
|
|
1526 | extension name itself. This makes it possible to code extensions so you |
|
|
1527 | can rename them and get a new set of commandline switches and resources |
|
|
1528 | without having to change the actual code. |
|
|
1529 | |
1507 | This method should only be called during the C<on_start> hook, as there is |
1530 | This method should only be called during the C<on_start> hook, as there is |
1508 | only one resource database per display, and later invocations might return |
1531 | only one resource database per display, and later invocations might return |
1509 | the wrong resources. |
1532 | the wrong resources. |
1510 | |
1533 | |
1511 | =item $value = $term->x_resource_boolean ($pattern) |
1534 | =item $value = $term->x_resource_boolean ($pattern) |