… | |
… | |
331 | |
331 | |
332 | =item $time = urxvt::NOW |
332 | =item $time = urxvt::NOW |
333 | |
333 | |
334 | Returns the "current time" (as per the event loop). |
334 | Returns the "current time" (as per the event loop). |
335 | |
335 | |
|
|
336 | =item urxvt::CurrentTime |
|
|
337 | |
|
|
338 | =item urxvt::ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, |
|
|
339 | Mod3Mask, Mod4Mask, Mod5Mask, Button1Mask, Button2Mask, Button3Mask, |
|
|
340 | Button4Mask, Button5Mask, AnyModifier |
|
|
341 | |
|
|
342 | Various constants for use in X events. |
|
|
343 | |
336 | =back |
344 | =back |
337 | |
345 | |
338 | =head2 RENDITION |
346 | =head2 RENDITION |
339 | |
347 | |
340 | Rendition bitsets contain information about colour, font, font styles and |
348 | Rendition bitsets contain information about colour, font, font styles and |
… | |
… | |
389 | |
397 | |
390 | =cut |
398 | =cut |
391 | |
399 | |
392 | package urxvt; |
400 | package urxvt; |
393 | |
401 | |
|
|
402 | use utf8; |
394 | use strict; |
403 | use strict; |
395 | use Scalar::Util (); |
404 | use Scalar::Util (); |
|
|
405 | use List::Util (); |
396 | |
406 | |
397 | our $TERM; |
407 | our $TERM; |
398 | our @HOOKNAME; |
408 | our @HOOKNAME; |
|
|
409 | our %OPTION; |
399 | our $LIBDIR; |
410 | our $LIBDIR; |
400 | |
411 | |
401 | BEGIN { |
412 | BEGIN { |
402 | urxvt->bootstrap; |
413 | urxvt->bootstrap; |
403 | |
414 | |
… | |
… | |
469 | local $TERM = shift; |
480 | local $TERM = shift; |
470 | my $htype = shift; |
481 | my $htype = shift; |
471 | |
482 | |
472 | if ($htype == 0) { # INIT |
483 | if ($htype == 0) { # INIT |
473 | my @dirs = ((split /:/, $TERM->resource ("perl_lib")), "$LIBDIR/perl"); |
484 | my @dirs = ((split /:/, $TERM->resource ("perl_lib")), "$LIBDIR/perl"); |
|
|
485 | |
|
|
486 | my %want_ext; |
474 | |
487 | |
475 | 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) { |
476 | my @files = grep -f $_, map "$_/$ext", @dirs; |
499 | my @files = grep -f $_, map "$_/$ext", @dirs; |
477 | |
500 | |
478 | if (@files) { |
501 | if (@files) { |
479 | register_package extension_package $files[0]; |
502 | register_package extension_package $files[0]; |
480 | } else { |
503 | } else { |
… | |
… | |
554 | |
577 | |
555 | =item $term->destroy |
578 | =item $term->destroy |
556 | |
579 | |
557 | Destroy the terminal object (close the window, free resources etc.). |
580 | Destroy the terminal object (close the window, free resources etc.). |
558 | |
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 | |
559 | =item $value = $term->resource ($name[, $newval]) |
598 | =item $value = $term->resource ($name[, $newval]) |
560 | |
599 | |
561 | Returns the current resource value associated with a given name and |
600 | Returns the current resource value associated with a given name and |
562 | 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> |
563 | hook. Unset resources are returned and accepted as C<undef>. |
602 | hook. Unset resources are returned and accepted as C<undef>. |
… | |
… | |
572 | |
611 | |
573 | 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 |
574 | terminal is destroyed, so changing options frequently will eat memory. |
613 | terminal is destroyed, so changing options frequently will eat memory. |
575 | |
614 | |
576 | 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 |
577 | 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> |
578 | list: |
617 | to see the actual list: |
579 | |
618 | |
580 | answerbackstring backgroundPixmap backspace_key boldFont boldItalicFont |
619 | answerbackstring backgroundPixmap backspace_key boldFont boldItalicFont |
581 | borderLess color cursorBlink cursorUnderline cutchars delete_key |
620 | borderLess color cursorBlink cursorUnderline cutchars delete_key |
582 | display_name embed ext_bwidth fade font geometry hold iconName |
621 | display_name embed ext_bwidth fade font geometry hold iconName |
583 | imFont imLocale inputMethod insecure int_bwidth intensityStyles |
622 | imFont imLocale inputMethod insecure int_bwidth intensityStyles |
… | |
… | |
776 | |
815 | |
777 | =item $lines_in_scrollback = $term->nsaved |
816 | =item $lines_in_scrollback = $term->nsaved |
778 | |
817 | |
779 | Return various integers describing terminal characteristics. |
818 | Return various integers describing terminal characteristics. |
780 | |
819 | |
|
|
820 | =item $modifiermask = $term->ModLevel3Mask |
|
|
821 | |
|
|
822 | =item $modifiermask = $term->ModMetaMask |
|
|
823 | |
|
|
824 | =item $modifiermask = $term->ModNumLockMask |
|
|
825 | |
|
|
826 | Return the modifier masks corresponding to the "ISO Level 3 Shift" (often |
|
|
827 | AltGr), the meta key (often Alt) and the num lock key, if applicable. |
|
|
828 | |
781 | =item $view_start = $term->view_start ([$newvalue]) |
829 | =item $view_start = $term->view_start ([$newvalue]) |
782 | |
830 | |
783 | Returns the negative row number of the topmost line. Minimum value is |
831 | Returns the negative row number of the topmost line. Minimum value is |
784 | C<0>, which displays the normal terminal contents. Larger values scroll |
832 | C<0>, which displays the normal terminal contents. Larger values scroll |
785 | this many lines into the scrollback buffer. |
833 | this many lines into the scrollback buffer. |
… | |
… | |
983 | } |
1031 | } |
984 | |
1032 | |
985 | sub add_button { |
1033 | sub add_button { |
986 | my ($self, $text, $cb) = @_; |
1034 | my ($self, $text, $cb) = @_; |
987 | |
1035 | |
988 | $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); |
989 | } |
1053 | } |
990 | |
1054 | |
991 | sub show { |
1055 | sub show { |
992 | my ($self) = @_; |
1056 | my ($self) = @_; |
993 | |
1057 | |
994 | local $urxvt::popup::self = $self; |
1058 | local $urxvt::popup::self = $self; |
995 | |
1059 | |
996 | urxvt->new ("--perl-lib" => "", "--perl-ext-common" => "", "-pty-fd" => -1, "-sl" => 0, "-b" => 0, |
1060 | urxvt->new ("--perl-lib" => "", "--perl-ext-common" => "", "-pty-fd" => -1, "-sl" => 0, "-b" => 0, |
997 | "--transient-for" => $self->{term}->parent, |
1061 | "--transient-for" => $self->{term}->parent, |
998 | "-pe" => "urxvt_popup") |
1062 | "-pe" => "urxvt-popup") |
999 | or die "unable to create popup window\n"; |
1063 | or die "unable to create popup window\n"; |
1000 | } |
1064 | } |
1001 | |
1065 | |
1002 | sub DESTROY { |
1066 | sub DESTROY { |
1003 | my ($self) = @_; |
1067 | my ($self) = @_; |