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