… | |
… | |
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 | |
… | |
… | |
303 | extension will actually grab a physical key just for this function. |
303 | extension will actually grab a physical key just for this function. |
304 | |
304 | |
305 | If you want a quake-like animation, tell your window manager to do so |
305 | If you want a quake-like animation, tell your window manager to do so |
306 | (fvwm can do it). |
306 | (fvwm can do it). |
307 | |
307 | |
|
|
308 | =item overlay-osc |
|
|
309 | |
|
|
310 | This extension implements some OSC commands to display timed popups on the |
|
|
311 | screen - useful for status displays from within scripts. You have to read |
|
|
312 | the sources for more info. |
|
|
313 | |
308 | =item block-graphics-to-ascii |
314 | =item block-graphics-to-ascii |
309 | |
315 | |
310 | A not very useful example of filtering all text output to the terminal |
316 | A not very useful example of filtering all text output to the terminal |
311 | by replacing all line-drawing characters (U+2500 .. U+259F) by a |
317 | by replacing all line-drawing characters (U+2500 .. U+259F) by a |
312 | similar-looking ascii character. |
318 | similar-looking ascii character. |
… | |
… | |
541 | |
547 | |
542 | It is called before lines are scrolled out (so rows 0 .. min ($lines - 1, |
548 | 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 |
549 | $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. |
550 | number of lines that will be in the scrollback buffer. |
545 | |
551 | |
546 | =item on_osc_seq $term, $op, $args |
552 | =item on_osc_seq $term, $op, $args, $resp |
547 | |
553 | |
548 | Called on every OSC sequence and can be used to suppress it or modify its |
554 | 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 |
555 | 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 |
556 | suppresses execution of the request completely. Make sure you don't get |
551 | confused by recursive invocations when you output an osc sequence within |
557 | confused by recursive invocations when you output an OSC sequence within |
552 | this callback. |
558 | this callback. |
553 | |
559 | |
554 | C<on_osc_seq_perl> should be used for new behaviour. |
560 | C<on_osc_seq_perl> should be used for new behaviour. |
555 | |
561 | |
556 | =item on_osc_seq_perl $term, $string |
562 | =item on_osc_seq_perl $term, $args, $resp |
557 | |
563 | |
558 | Called whenever the B<ESC ] 777 ; string ST> command sequence (OSC = |
564 | Called whenever the B<ESC ] 777 ; string ST> command sequence (OSC = |
559 | operating system command) is processed. Cursor position and other state |
565 | operating system command) is processed. Cursor position and other state |
560 | information is up-to-date when this happens. For interoperability, the |
566 | information is up-to-date when this happens. For interoperability, the |
561 | string should start with the extension name and a colon, to distinguish |
567 | 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 |
568 | to distinguish it from commands for other extensions, and this might be |
563 | future. |
569 | enforced in the future. |
|
|
570 | |
|
|
571 | For example, C<overlay-osc> uses this: |
|
|
572 | |
|
|
573 | sub on_osc_seq_perl { |
|
|
574 | my ($self, $osc, $resp) = @_; |
|
|
575 | |
|
|
576 | return unless $osc =~ s/^overlay;//; |
|
|
577 | |
|
|
578 | ... process remaining $osc string |
|
|
579 | } |
564 | |
580 | |
565 | Be careful not ever to trust (in a security sense) the data you receive, |
581 | 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 |
582 | as its source can not easily be controlled (e-mail content, messages from |
567 | other users on the same system etc.). |
583 | other users on the same system etc.). |
|
|
584 | |
|
|
585 | For responses, C<$resp> contains the end-of-args separator used by the |
|
|
586 | sender. |
568 | |
587 | |
569 | =item on_add_lines $term, $string |
588 | =item on_add_lines $term, $string |
570 | |
589 | |
571 | Called whenever text is about to be output, with the text as argument. You |
590 | 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 |
591 | 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 |
612 | later with the already-modified line (e.g. if unrelated parts change), so |
594 | you cannot just toggle rendition bits, but only set them. |
613 | you cannot just toggle rendition bits, but only set them. |
595 | |
614 | |
596 | =item on_refresh_begin $term |
615 | =item on_refresh_begin $term |
597 | |
616 | |
598 | Called just before the screen gets redrawn. Can be used for overlay |
617 | 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 |
618 | similar effects by modifying the terminal contents in refresh_begin, and |
600 | restoring them in refresh_end. The built-in overlay and selection display |
619 | restoring them in refresh_end. The built-in overlay and selection display |
601 | code is run after this hook, and takes precedence. |
620 | code is run after this hook, and takes precedence. |
602 | |
621 | |
603 | =item on_refresh_end $term |
622 | =item on_refresh_end $term |
604 | |
623 | |
… | |
… | |
1091 | is that you cannot use blocking APIs, but the non-blocking variant should |
1110 | is that you cannot use blocking APIs, but the non-blocking variant should |
1092 | work. |
1111 | work. |
1093 | |
1112 | |
1094 | =cut |
1113 | =cut |
1095 | |
1114 | |
1096 | our $VERSION = 1; |
1115 | our $VERSION = '3.4'; |
1097 | |
1116 | |
1098 | $INC{"urxvt/anyevent.pm"} = 1; # mark us as there |
1117 | $INC{"urxvt/anyevent.pm"} = 1; # mark us as there |
1099 | push @AnyEvent::REGISTRY, [urxvt => urxvt::anyevent::]; |
1118 | push @AnyEvent::REGISTRY, [urxvt => urxvt::anyevent::]; |
1100 | |
1119 | |
1101 | sub timer { |
1120 | sub timer { |
… | |
… | |
1132 | |
1151 | |
1133 | sub DESTROY { |
1152 | sub DESTROY { |
1134 | $_[0][1]->stop; |
1153 | $_[0][1]->stop; |
1135 | } |
1154 | } |
1136 | |
1155 | |
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 { |
1156 | sub one_event { |
1152 | Carp::croak "AnyEvent->one_event blocking wait unsupported in urxvt, use a non-blocking API"; |
1157 | Carp::croak "AnyEvent->one_event blocking wait unsupported in urxvt, use a non-blocking API"; |
1153 | } |
1158 | } |
1154 | |
1159 | |
1155 | package urxvt::term; |
1160 | package urxvt::term; |
… | |
… | |
1276 | Here is a likely non-exhaustive list of resource names, not all of which |
1281 | 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> |
1282 | are supported in every build, please see the source file F</src/rsinc.h> |
1278 | to see the actual list: |
1283 | to see the actual list: |
1279 | |
1284 | |
1280 | answerbackstring backgroundPixmap backspace_key boldFont boldItalicFont |
1285 | answerbackstring backgroundPixmap backspace_key boldFont boldItalicFont |
1281 | borderLess color cursorBlink cursorUnderline cutchars delete_key |
1286 | borderLess chdir color cursorBlink cursorUnderline cutchars delete_key |
1282 | display_name embed ext_bwidth fade font geometry hold iconName |
1287 | display_name embed ext_bwidth fade font geometry hold iconName |
1283 | imFont imLocale inputMethod insecure int_bwidth intensityStyles |
1288 | imFont imLocale inputMethod insecure int_bwidth intensityStyles |
1284 | italicFont jumpScroll lineSpace loginShell mapAlert meta8 modifier |
1289 | italicFont jumpScroll lineSpace loginShell mapAlert meta8 modifier |
1285 | mouseWheelScrollPage name override_redirect pastableTabs path perl_eval |
1290 | mouseWheelScrollPage name override_redirect pastableTabs path perl_eval |
1286 | perl_ext_1 perl_ext_2 perl_lib pointerBlank pointerBlankDelay |
1291 | perl_ext_1 perl_ext_2 perl_lib pointerBlank pointerBlankDelay |
… | |
… | |
1294 | =cut |
1299 | =cut |
1295 | |
1300 | |
1296 | sub resource($$;$) { |
1301 | sub resource($$;$) { |
1297 | my ($self, $name) = (shift, shift); |
1302 | my ($self, $name) = (shift, shift); |
1298 | unshift @_, $self, $name, ($name =~ s/\s*\+\s*(\d+)$// ? $1 : 0); |
1303 | unshift @_, $self, $name, ($name =~ s/\s*\+\s*(\d+)$// ? $1 : 0); |
1299 | &urxvt::term::_resource |
1304 | goto &urxvt::term::_resource |
1300 | } |
1305 | } |
1301 | |
1306 | |
1302 | =item $value = $term->x_resource ($pattern) |
1307 | =item $value = $term->x_resource ($pattern) |
1303 | |
1308 | |
1304 | Returns the X-Resource for the given pattern, excluding the program or |
1309 | Returns the X-Resource for the given pattern, excluding the program or |
… | |
… | |
1387 | |
1392 | |
1388 | The methods currently supported on C<urxvt::overlay> objects are: |
1393 | The methods currently supported on C<urxvt::overlay> objects are: |
1389 | |
1394 | |
1390 | =over 4 |
1395 | =over 4 |
1391 | |
1396 | |
1392 | =item $overlay->set ($x, $y, $text, $rend) |
1397 | =item $overlay->set ($x, $y, $text[, $rend]) |
1393 | |
1398 | |
1394 | Similar to C<< $term->ROW_t >> and C<< $term->ROW_r >> in that it puts |
1399 | 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 |
1400 | text in rxvt-unicode's special encoding and an array of rendition values |
1396 | at a specific position inside the overlay. |
1401 | at a specific position inside the overlay. |
|
|
1402 | |
|
|
1403 | If C<$rend> is missing, then the rendition will not be changed. |
1397 | |
1404 | |
1398 | =item $overlay->hide |
1405 | =item $overlay->hide |
1399 | |
1406 | |
1400 | If visible, hide the overlay, but do not destroy it. |
1407 | If visible, hide the overlay, but do not destroy it. |
1401 | |
1408 | |
… | |
… | |
1611 | |
1618 | |
1612 | Used after changing terminal contents to display them. |
1619 | Used after changing terminal contents to display them. |
1613 | |
1620 | |
1614 | =item $text = $term->ROW_t ($row_number[, $new_text[, $start_col]]) |
1621 | =item $text = $term->ROW_t ($row_number[, $new_text[, $start_col]]) |
1615 | |
1622 | |
1616 | Returns the text of the entire row with number C<$row_number>. Row C<0> |
1623 | 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 |
1624 | 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 |
1625 | terminal line. Nothing will be returned if a nonexistent line |
1620 | is requested. |
1626 | is requested. |
1621 | |
1627 | |
1622 | If C<$new_text> is specified, it will replace characters in the current |
1628 | 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 |
1629 | 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 |
1630 | to replace only parts of a line. The font index in the rendition will |
… | |
… | |
1822 | |
1828 | |
1823 | =item @atoms = $term->XListProperties ($window) |
1829 | =item @atoms = $term->XListProperties ($window) |
1824 | |
1830 | |
1825 | =item ($type,$format,$octets) = $term->XGetWindowProperty ($window, $property) |
1831 | =item ($type,$format,$octets) = $term->XGetWindowProperty ($window, $property) |
1826 | |
1832 | |
1827 | =item $term->XChangeWindowProperty ($window, $property, $type, $format, $octets) |
1833 | =item $term->XChangeProperty ($window, $property, $type, $format, $octets) |
1828 | |
1834 | |
1829 | =item $term->XDeleteProperty ($window, $property) |
1835 | =item $term->XDeleteProperty ($window, $property) |
1830 | |
1836 | |
1831 | =item $window = $term->DefaultRootWindow |
1837 | =item $window = $term->DefaultRootWindow |
1832 | |
1838 | |
… | |
… | |
1954 | my $env = $self->{term}->env; |
1960 | my $env = $self->{term}->env; |
1955 | # we can't hope to reproduce the locale algorithm, so nuke LC_ALL and set LC_CTYPE. |
1961 | # we can't hope to reproduce the locale algorithm, so nuke LC_ALL and set LC_CTYPE. |
1956 | delete $env->{LC_ALL}; |
1962 | delete $env->{LC_ALL}; |
1957 | $env->{LC_CTYPE} = $self->{term}->locale; |
1963 | $env->{LC_CTYPE} = $self->{term}->locale; |
1958 | |
1964 | |
1959 | urxvt::term->new ($env, "popup", |
1965 | my $term = urxvt::term->new ( |
|
|
1966 | $env, "popup", |
1960 | "--perl-lib" => "", "--perl-ext-common" => "", |
1967 | "--perl-lib" => "", "--perl-ext-common" => "", |
1961 | "-pty-fd" => -1, "-sl" => 0, |
1968 | "-pty-fd" => -1, "-sl" => 0, |
1962 | "-b" => 1, "-bd" => "grey80", "-bl", "-override-redirect", |
1969 | "-b" => 1, "-bd" => "grey80", "-bl", "-override-redirect", |
1963 | "--transient-for" => $self->{term}->parent, |
1970 | "--transient-for" => $self->{term}->parent, |
1964 | "-display" => $self->{term}->display_id, |
1971 | "-display" => $self->{term}->display_id, |
1965 | "-pe" => "urxvt-popup") |
1972 | "-pe" => "urxvt-popup", |
1966 | or die "unable to create popup window\n"; |
1973 | ) or die "unable to create popup window\n"; |
|
|
1974 | |
|
|
1975 | unless (delete $term->{urxvt_popup_init_done}) { |
|
|
1976 | $term->ungrab; |
|
|
1977 | $term->destroy; |
|
|
1978 | die "unable to initialise popup window\n"; |
|
|
1979 | } |
1967 | } |
1980 | } |
1968 | |
1981 | |
1969 | sub DESTROY { |
1982 | sub DESTROY { |
1970 | my ($self) = @_; |
1983 | my ($self) = @_; |
1971 | |
1984 | |