… | |
… | |
108 | reference. The string will be used as button text and the code reference |
108 | reference. The string will be used as button text and the code reference |
109 | will be called when the toggle changes, with the new boolean value as |
109 | will be called when the toggle changes, with the new boolean value as |
110 | first argument. |
110 | first argument. |
111 | |
111 | |
112 | The following will add an entry C<myoption> that changes |
112 | The following will add an entry C<myoption> that changes |
113 | C<$self->{myoption}>: |
113 | C<< $self->{myoption} >>: |
114 | |
114 | |
115 | push @{ $self->{term}{option_popup_hook} }, sub { |
115 | push @{ $self->{term}{option_popup_hook} }, sub { |
116 | ("my option" => $myoption, sub { $self->{myoption} = $_[0] }) |
116 | ("my option" => $myoption, sub { $self->{myoption} = $_[0] }) |
117 | }; |
117 | }; |
118 | |
118 | |
… | |
… | |
541 | |
541 | |
542 | It is called before lines are scrolled out (so rows 0 .. min ($lines - 1, |
542 | It is called before lines are scrolled out (so rows 0 .. min ($lines - 1, |
543 | $nrow - 1) represent the lines to be scrolled out). C<$saved> is the total |
543 | $nrow - 1) represent the lines to be scrolled out). C<$saved> is the total |
544 | number of lines that will be in the scrollback buffer. |
544 | number of lines that will be in the scrollback buffer. |
545 | |
545 | |
546 | =item on_osc_seq $term, $op, $args |
546 | =item on_osc_seq $term, $op, $args, $resp |
547 | |
547 | |
548 | Called on every OSC sequence and can be used to suppress it or modify its |
548 | Called on every OSC sequence and can be used to suppress it or modify its |
549 | behaviour. The default should be to return an empty list. A true value |
549 | behaviour. The default should be to return an empty list. A true value |
550 | suppresses execution of the request completely. Make sure you don't get |
550 | suppresses execution of the request completely. Make sure you don't get |
551 | confused by recursive invocations when you output an osc sequence within |
551 | confused by recursive invocations when you output an OSC sequence within |
552 | this callback. |
552 | this callback. |
553 | |
553 | |
554 | C<on_osc_seq_perl> should be used for new behaviour. |
554 | C<on_osc_seq_perl> should be used for new behaviour. |
555 | |
555 | |
556 | =item on_osc_seq_perl $term, $string |
556 | =item on_osc_seq_perl $term, $args, $resp |
557 | |
557 | |
558 | Called whenever the B<ESC ] 777 ; string ST> command sequence (OSC = |
558 | Called whenever the B<ESC ] 777 ; string ST> command sequence (OSC = |
559 | operating system command) is processed. Cursor position and other state |
559 | operating system command) is processed. Cursor position and other state |
560 | information is up-to-date when this happens. For interoperability, the |
560 | information is up-to-date when this happens. For interoperability, the |
561 | string should start with the extension name and a colon, to distinguish |
561 | string should start with the extension name (sans -osc) and a semicolon, |
562 | it from commands for other extensions, and this might be enforced in the |
562 | to distinguish it from commands for other extensions, and this might be |
563 | future. |
563 | enforced in the future. |
|
|
564 | |
|
|
565 | For example, C<overlay-osc> uses this: |
|
|
566 | |
|
|
567 | sub on_osc_seq_perl { |
|
|
568 | my ($self, $osc, $resp) = @_; |
|
|
569 | |
|
|
570 | return unless $osc =~ s/^overlay;//; |
|
|
571 | |
|
|
572 | ... process remaining $osc string |
|
|
573 | } |
564 | |
574 | |
565 | Be careful not ever to trust (in a security sense) the data you receive, |
575 | Be careful not ever to trust (in a security sense) the data you receive, |
566 | as its source can not easily be controlled (e-mail content, messages from |
576 | as its source can not easily be controlled (e-mail content, messages from |
567 | other users on the same system etc.). |
577 | other users on the same system etc.). |
|
|
578 | |
|
|
579 | For responses, C<$resp> contains the end-of-args separator used by the |
|
|
580 | sender. |
568 | |
581 | |
569 | =item on_add_lines $term, $string |
582 | =item on_add_lines $term, $string |
570 | |
583 | |
571 | Called whenever text is about to be output, with the text as argument. You |
584 | Called whenever text is about to be output, with the text as argument. You |
572 | can filter/change and output the text yourself by returning a true value |
585 | can filter/change and output the text yourself by returning a true value |
… | |
… | |
593 | later with the already-modified line (e.g. if unrelated parts change), so |
606 | later with the already-modified line (e.g. if unrelated parts change), so |
594 | you cannot just toggle rendition bits, but only set them. |
607 | you cannot just toggle rendition bits, but only set them. |
595 | |
608 | |
596 | =item on_refresh_begin $term |
609 | =item on_refresh_begin $term |
597 | |
610 | |
598 | Called just before the screen gets redrawn. Can be used for overlay |
611 | Called just before the screen gets redrawn. Can be used for overlay or |
599 | or similar effects by modify terminal contents in refresh_begin, and |
612 | similar effects by modifying the terminal contents in refresh_begin, and |
600 | restoring them in refresh_end. The built-in overlay and selection display |
613 | restoring them in refresh_end. The built-in overlay and selection display |
601 | code is run after this hook, and takes precedence. |
614 | code is run after this hook, and takes precedence. |
602 | |
615 | |
603 | =item on_refresh_end $term |
616 | =item on_refresh_end $term |
604 | |
617 | |
… | |
… | |
1091 | is that you cannot use blocking APIs, but the non-blocking variant should |
1104 | is that you cannot use blocking APIs, but the non-blocking variant should |
1092 | work. |
1105 | work. |
1093 | |
1106 | |
1094 | =cut |
1107 | =cut |
1095 | |
1108 | |
1096 | our $VERSION = 1; |
1109 | our $VERSION = '3.4'; |
1097 | |
1110 | |
1098 | $INC{"urxvt/anyevent.pm"} = 1; # mark us as there |
1111 | $INC{"urxvt/anyevent.pm"} = 1; # mark us as there |
1099 | push @AnyEvent::REGISTRY, [urxvt => urxvt::anyevent::]; |
1112 | push @AnyEvent::REGISTRY, [urxvt => urxvt::anyevent::]; |
1100 | |
1113 | |
1101 | sub timer { |
1114 | sub timer { |
… | |
… | |
1132 | |
1145 | |
1133 | sub DESTROY { |
1146 | sub DESTROY { |
1134 | $_[0][1]->stop; |
1147 | $_[0][1]->stop; |
1135 | } |
1148 | } |
1136 | |
1149 | |
1137 | sub condvar { |
|
|
1138 | bless \my $flag, urxvt::anyevent:: |
|
|
1139 | } |
|
|
1140 | |
|
|
1141 | sub broadcast { |
|
|
1142 | ${$_[0]}++; |
|
|
1143 | } |
|
|
1144 | |
|
|
1145 | sub wait { |
|
|
1146 | unless (${$_[0]}) { |
|
|
1147 | Carp::croak "AnyEvent->condvar blocking wait unsupported in urxvt, use a non-blocking API"; |
|
|
1148 | } |
|
|
1149 | } |
|
|
1150 | |
|
|
1151 | sub one_event { |
1150 | sub one_event { |
1152 | Carp::croak "AnyEvent->one_event blocking wait unsupported in urxvt, use a non-blocking API"; |
1151 | Carp::croak "AnyEvent->one_event blocking wait unsupported in urxvt, use a non-blocking API"; |
1153 | } |
1152 | } |
1154 | |
1153 | |
1155 | package urxvt::term; |
1154 | package urxvt::term; |
… | |
… | |
1276 | Here is a likely non-exhaustive list of resource names, not all of which |
1275 | Here is a likely non-exhaustive list of resource names, not all of which |
1277 | are supported in every build, please see the source file F</src/rsinc.h> |
1276 | are supported in every build, please see the source file F</src/rsinc.h> |
1278 | to see the actual list: |
1277 | to see the actual list: |
1279 | |
1278 | |
1280 | answerbackstring backgroundPixmap backspace_key boldFont boldItalicFont |
1279 | answerbackstring backgroundPixmap backspace_key boldFont boldItalicFont |
1281 | borderLess color cursorBlink cursorUnderline cutchars delete_key |
1280 | borderLess chdir color cursorBlink cursorUnderline cutchars delete_key |
1282 | display_name embed ext_bwidth fade font geometry hold iconName |
1281 | display_name embed ext_bwidth fade font geometry hold iconName |
1283 | imFont imLocale inputMethod insecure int_bwidth intensityStyles |
1282 | imFont imLocale inputMethod insecure int_bwidth intensityStyles |
1284 | italicFont jumpScroll lineSpace loginShell mapAlert meta8 modifier |
1283 | italicFont jumpScroll lineSpace loginShell mapAlert meta8 modifier |
1285 | mouseWheelScrollPage name override_redirect pastableTabs path perl_eval |
1284 | mouseWheelScrollPage name override_redirect pastableTabs path perl_eval |
1286 | perl_ext_1 perl_ext_2 perl_lib pointerBlank pointerBlankDelay |
1285 | perl_ext_1 perl_ext_2 perl_lib pointerBlank pointerBlankDelay |
1287 | preeditType print_pipe pty_fd reverseVideo saveLines scrollBar |
1286 | preeditType print_pipe pty_fd reverseVideo saveLines scrollBar |
1288 | scrollBar_align scrollBar_floating scrollBar_right scrollBar_thickness |
1287 | scrollBar_align scrollBar_floating scrollBar_right scrollBar_thickness |
1289 | scrollTtyKeypress scrollTtyOutput scrollWithBuffer scrollstyle |
1288 | scrollTtyKeypress scrollTtyOutput scrollWithBuffer scrollstyle |
1290 | secondaryScreen secondaryScroll selectstyle shade term_name title |
1289 | secondaryScreen secondaryScroll shade term_name title |
1291 | transient_for transparent transparent_all tripleclickwords utmpInhibit |
1290 | transient_for transparent transparent_all tripleclickwords utmpInhibit |
1292 | visualBell |
1291 | visualBell |
1293 | |
1292 | |
1294 | =cut |
1293 | =cut |
1295 | |
1294 | |
1296 | sub resource($$;$) { |
1295 | sub resource($$;$) { |
1297 | my ($self, $name) = (shift, shift); |
1296 | my ($self, $name) = (shift, shift); |
1298 | unshift @_, $self, $name, ($name =~ s/\s*\+\s*(\d+)$// ? $1 : 0); |
1297 | unshift @_, $self, $name, ($name =~ s/\s*\+\s*(\d+)$// ? $1 : 0); |
1299 | &urxvt::term::_resource |
1298 | goto &urxvt::term::_resource |
1300 | } |
1299 | } |
1301 | |
1300 | |
1302 | =item $value = $term->x_resource ($pattern) |
1301 | =item $value = $term->x_resource ($pattern) |
1303 | |
1302 | |
1304 | Returns the X-Resource for the given pattern, excluding the program or |
1303 | Returns the X-Resource for the given pattern, excluding the program or |
… | |
… | |
1387 | |
1386 | |
1388 | The methods currently supported on C<urxvt::overlay> objects are: |
1387 | The methods currently supported on C<urxvt::overlay> objects are: |
1389 | |
1388 | |
1390 | =over 4 |
1389 | =over 4 |
1391 | |
1390 | |
1392 | =item $overlay->set ($x, $y, $text, $rend) |
1391 | =item $overlay->set ($x, $y, $text[, $rend]) |
1393 | |
1392 | |
1394 | Similar to C<< $term->ROW_t >> and C<< $term->ROW_r >> in that it puts |
1393 | Similar to C<< $term->ROW_t >> and C<< $term->ROW_r >> in that it puts |
1395 | text in rxvt-unicode's special encoding and an array of rendition values |
1394 | text in rxvt-unicode's special encoding and an array of rendition values |
1396 | at a specific position inside the overlay. |
1395 | at a specific position inside the overlay. |
|
|
1396 | |
|
|
1397 | If C<$rend> is missing, then the rendition will not be changed. |
1397 | |
1398 | |
1398 | =item $overlay->hide |
1399 | =item $overlay->hide |
1399 | |
1400 | |
1400 | If visible, hide the overlay, but do not destroy it. |
1401 | If visible, hide the overlay, but do not destroy it. |
1401 | |
1402 | |
… | |
… | |
1611 | |
1612 | |
1612 | Used after changing terminal contents to display them. |
1613 | Used after changing terminal contents to display them. |
1613 | |
1614 | |
1614 | =item $text = $term->ROW_t ($row_number[, $new_text[, $start_col]]) |
1615 | =item $text = $term->ROW_t ($row_number[, $new_text[, $start_col]]) |
1615 | |
1616 | |
1616 | Returns the text of the entire row with number C<$row_number>. Row C<0> |
1617 | Returns the text of the entire row with number C<$row_number>. Row C<< $term->top_row >> |
1617 | is the topmost terminal line, row C<< $term->$ncol-1 >> is the bottommost |
1618 | is the topmost terminal line, row C<< $term->nrow-1 >> is the bottommost |
1618 | terminal line. The scrollback buffer starts at line C<-1> and extends to |
|
|
1619 | line C<< -$term->nsaved >>. Nothing will be returned if a nonexistent line |
1619 | terminal line. Nothing will be returned if a nonexistent line |
1620 | is requested. |
1620 | is requested. |
1621 | |
1621 | |
1622 | If C<$new_text> is specified, it will replace characters in the current |
1622 | If C<$new_text> is specified, it will replace characters in the current |
1623 | line, starting at column C<$start_col> (default C<0>), which is useful |
1623 | line, starting at column C<$start_col> (default C<0>), which is useful |
1624 | to replace only parts of a line. The font index in the rendition will |
1624 | to replace only parts of a line. The font index in the rendition will |
… | |
… | |
1822 | |
1822 | |
1823 | =item @atoms = $term->XListProperties ($window) |
1823 | =item @atoms = $term->XListProperties ($window) |
1824 | |
1824 | |
1825 | =item ($type,$format,$octets) = $term->XGetWindowProperty ($window, $property) |
1825 | =item ($type,$format,$octets) = $term->XGetWindowProperty ($window, $property) |
1826 | |
1826 | |
1827 | =item $term->XChangeWindowProperty ($window, $property, $type, $format, $octets) |
1827 | =item $term->XChangeProperty ($window, $property, $type, $format, $octets) |
1828 | |
1828 | |
1829 | =item $term->XDeleteProperty ($window, $property) |
1829 | =item $term->XDeleteProperty ($window, $property) |
1830 | |
1830 | |
1831 | =item $window = $term->DefaultRootWindow |
1831 | =item $window = $term->DefaultRootWindow |
1832 | |
1832 | |
… | |
… | |
1954 | my $env = $self->{term}->env; |
1954 | my $env = $self->{term}->env; |
1955 | # we can't hope to reproduce the locale algorithm, so nuke LC_ALL and set LC_CTYPE. |
1955 | # we can't hope to reproduce the locale algorithm, so nuke LC_ALL and set LC_CTYPE. |
1956 | delete $env->{LC_ALL}; |
1956 | delete $env->{LC_ALL}; |
1957 | $env->{LC_CTYPE} = $self->{term}->locale; |
1957 | $env->{LC_CTYPE} = $self->{term}->locale; |
1958 | |
1958 | |
1959 | urxvt::term->new ($env, "popup", |
1959 | my $term = urxvt::term->new ( |
|
|
1960 | $env, "popup", |
1960 | "--perl-lib" => "", "--perl-ext-common" => "", |
1961 | "--perl-lib" => "", "--perl-ext-common" => "", |
1961 | "-pty-fd" => -1, "-sl" => 0, |
1962 | "-pty-fd" => -1, "-sl" => 0, |
1962 | "-b" => 1, "-bd" => "grey80", "-bl", "-override-redirect", |
1963 | "-b" => 1, "-bd" => "grey80", "-bl", "-override-redirect", |
1963 | "--transient-for" => $self->{term}->parent, |
1964 | "--transient-for" => $self->{term}->parent, |
1964 | "-display" => $self->{term}->display_id, |
1965 | "-display" => $self->{term}->display_id, |
1965 | "-pe" => "urxvt-popup") |
1966 | "-pe" => "urxvt-popup", |
1966 | or die "unable to create popup window\n"; |
1967 | ) or die "unable to create popup window\n"; |
|
|
1968 | |
|
|
1969 | unless (delete $term->{urxvt_popup_init_done}) { |
|
|
1970 | $term->ungrab; |
|
|
1971 | $term->destroy; |
|
|
1972 | die "unable to initialise popup window\n"; |
|
|
1973 | } |
1967 | } |
1974 | } |
1968 | |
1975 | |
1969 | sub DESTROY { |
1976 | sub DESTROY { |
1970 | my ($self) = @_; |
1977 | my ($self) = @_; |
1971 | |
1978 | |