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.216 by root, Sun Jun 10 13:32:55 2012 UTC vs.
Revision 1.217 by root, Sun Jun 10 13:58:05 2012 UTC

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
1157package urxvt::term::extension; 1157package urxvt::term::extension;
1158 1158
1159sub enable { 1159sub 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
1216sub urxvt::destroy_hook(&) { 1216sub urxvt::destroy_hook(&) {
1217 bless \shift, urxvt::destroy_hook:: 1217 bless \shift, urxvt::destroy_hook::
1218}
1219
1220sub x_resource {
1221 my ($self, $name) = @_;
1222 $name =~ s/^%(\.|$)/$_[0]{_name}$1/;
1223 $self->{term}->x_resource ($name)
1224}
1225
1226sub x_resource_boolean {
1227 my ($self, $name) = @_;
1228 $name =~ s/^%(\.|$)/$_[0]{_name}$1/;
1229 $self->{term}->x_resource_boolean ($name)
1218} 1230}
1219 1231
1220package urxvt::anyevent; 1232package 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
1502Returns the X-Resource for the given pattern, excluding the program or 1515Returns the X-Resource for the given pattern, excluding the program or
1503class name, i.e. C<< $term->x_resource ("boldFont") >> should return the 1516class name, i.e. C<< $term->x_resource ("boldFont") >> should return the
1504same value as used by this instance of rxvt-unicode. Returns C<undef> if no 1517same value as used by this instance of rxvt-unicode. Returns C<undef> if no
1505resource with that pattern exists. 1518resource with that pattern exists.
1506 1519
1520Extensions that define extra resource or command line arguments also need
1521to call this method to access their values.
1522
1523If the method is called on an extension object (basically, from an
1524extension), then the special prefix C<%.> will be replaced by the name of
1525the extension and a dot, and the lone string C<%> will be replcaed by the
1526extension name itself. This makes it possible to code extensions so you
1527can rename them and get a new set of commandline switches and resources
1528without having to change the actual code.
1529
1507This method should only be called during the C<on_start> hook, as there is 1530This method should only be called during the C<on_start> hook, as there is
1508only one resource database per display, and later invocations might return 1531only one resource database per display, and later invocations might return
1509the wrong resources. 1532the wrong resources.
1510 1533
1511=item $value = $term->x_resource_boolean ($pattern) 1534=item $value = $term->x_resource_boolean ($pattern)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines