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.47 by root, Sat Jan 7 21:22:02 2006 UTC vs.
Revision 1.49 by root, Sun Jan 8 00:07:18 2006 UTC

397 397
398=cut 398=cut
399 399
400package urxvt; 400package urxvt;
401 401
402use utf8;
402use strict; 403use strict;
403use Scalar::Util (); 404use Scalar::Util ();
405use List::Util ();
404 406
405our $TERM; 407our $TERM;
406our @HOOKNAME; 408our @HOOKNAME;
409our %OPTION;
407our $LIBDIR; 410our $LIBDIR;
408 411
409BEGIN { 412BEGIN {
410 urxvt->bootstrap; 413 urxvt->bootstrap;
411 414
477 local $TERM = shift; 480 local $TERM = shift;
478 my $htype = shift; 481 my $htype = shift;
479 482
480 if ($htype == 0) { # INIT 483 if ($htype == 0) { # INIT
481 my @dirs = ((split /:/, $TERM->resource ("perl_lib")), "$LIBDIR/perl"); 484 my @dirs = ((split /:/, $TERM->resource ("perl_lib")), "$LIBDIR/perl");
482 485
483 for my $ext (map { split /,/, $TERM->resource ("perl_ext_$_") } 1, 2) { 486 my @ext = (map { split /,/, $TERM->resource ("perl_ext_$_") } 1, 2);
484 my @files = grep -f $_, map "$_/$ext", @dirs;
485 487
486 if (@files) { 488 while (@ext) {
487 register_package extension_package $files[0]; 489 my $ext = shift @ext;
490 if ($ext eq "default") {
491 unshift @ext, qw(selection);
488 } else { 492 } else {
493 my @files = grep -f $_, map "$_/$ext", @dirs;
494
495 if (@files) {
496 register_package extension_package $files[0];
497 } else {
489 warn "perl extension '$ext' not found in perl library search path\n"; 498 warn "perl extension '$ext' not found in perl library search path\n";
499 }
490 } 500 }
491 } 501 }
492 } 502 }
493 503
494 $retval = undef; 504 $retval = undef;
562 572
563=item $term->destroy 573=item $term->destroy
564 574
565Destroy the terminal object (close the window, free resources etc.). 575Destroy the terminal object (close the window, free resources etc.).
566 576
577=item $isset = $term->option ($optval[, $set])
578
579Returns true if the option specified by C<$optval> is enabled, and
580optionally change it. All option values are stored by name in the hash
581C<%urxvt::OPTION>. Options not enabled in this binary are not in the hash.
582
583Here is a a likely non-exhaustive list of option names, please see the
584source file F</src/optinc.h> to see the actual list:
585
586 borderLess console cursorBlink cursorUnderline hold iconic insecure
587 intensityStyles jumpScroll loginShell mapAlert meta8 mouseWheelScrollPage
588 pastableTabs pointerBlank reverseVideo scrollBar scrollBar_floating
589 scrollBar_right scrollTtyKeypress scrollTtyOutput scrollWithBuffer
590 secondaryScreen secondaryScroll skipBuiltinGlyphs transparent
591 tripleclickwords utmpInhibit visualBell
592
567=item $value = $term->resource ($name[, $newval]) 593=item $value = $term->resource ($name[, $newval])
568 594
569Returns the current resource value associated with a given name and 595Returns the current resource value associated with a given name and
570optionally sets a new value. Setting values is most useful in the C<init> 596optionally sets a new value. Setting values is most useful in the C<init>
571hook. Unset resources are returned and accepted as C<undef>. 597hook. Unset resources are returned and accepted as C<undef>.
580 606
581Please note that resource strings will currently only be freed when the 607Please note that resource strings will currently only be freed when the
582terminal is destroyed, so changing options frequently will eat memory. 608terminal is destroyed, so changing options frequently will eat memory.
583 609
584Here is a a likely non-exhaustive list of resource names, not all of which 610Here is a a likely non-exhaustive list of resource names, not all of which
585are supported in every build, please see the source to see the actual 611are supported in every build, please see the source file F</src/rsinc.h>
586list: 612to see the actual list:
587 613
588 answerbackstring backgroundPixmap backspace_key boldFont boldItalicFont 614 answerbackstring backgroundPixmap backspace_key boldFont boldItalicFont
589 borderLess color cursorBlink cursorUnderline cutchars delete_key 615 borderLess color cursorBlink cursorUnderline cutchars delete_key
590 display_name embed ext_bwidth fade font geometry hold iconName 616 display_name embed ext_bwidth fade font geometry hold iconName
591 imFont imLocale inputMethod insecure int_bwidth intensityStyles 617 imFont imLocale inputMethod insecure int_bwidth intensityStyles
1000} 1026}
1001 1027
1002sub add_button { 1028sub add_button {
1003 my ($self, $text, $cb) = @_; 1029 my ($self, $text, $cb) = @_;
1004 1030
1005 $self->add_item ({ type => "button", text => "[ $text ]", activate => $cb }); 1031 $self->add_item ({ type => "button", text => "[ $text ]", activate => $cb,
1032 render => sub { $_[0]{text} },
1033 });
1034}
1035
1036sub add_toggle {
1037 my ($self, $text, $cb, $value) = @_;
1038
1039 my $item; $item = {
1040 type => "button",
1041 text => " $text",
1042 value => $value,
1043 render => sub { ($item->{value} ? "✔" : " ") . $text },
1044 activate => sub { $cb->($item->{value} = !$item->{value}); },
1045 };
1046
1047 $self->add_item ($item);
1006} 1048}
1007 1049
1008sub show { 1050sub show {
1009 my ($self) = @_; 1051 my ($self) = @_;
1010 1052

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines