… | |
… | |
26 | thus must be encoded as UTF-8. |
26 | thus must be encoded as UTF-8. |
27 | |
27 | |
28 | Each script will only ever be loaded once, even in @@RXVT_NAME@@d, where |
28 | Each script will only ever be loaded once, even in @@RXVT_NAME@@d, where |
29 | scripts will be shared (but not enabled) for all terminals. |
29 | scripts will be shared (but not enabled) for all terminals. |
30 | |
30 | |
31 | =head2 Prepackaged Extensions |
31 | =head1 PREPACKAGED EXTENSIONS |
32 | |
32 | |
33 | This section describes the extensiosn delivered with this version. You can |
33 | This section describes the extensions delivered with this release. You can |
34 | find them in F<@@RXVT_LIBDIR@@/urxvt/perl/>. |
34 | find them in F<@@RXVT_LIBDIR@@/urxvt/perl/>. |
35 | |
35 | |
36 | You can activate them like this: |
36 | You can activate them like this: |
37 | |
37 | |
38 | @@RXVT_NAME@@ -pe <extensionname> |
38 | @@RXVT_NAME@@ -pe <extensionname> |
39 | |
39 | |
40 | =over 4 |
40 | =over 4 |
41 | |
41 | |
42 | =item selection (enabled by default) |
42 | =item selection (enabled by default) |
43 | |
43 | |
44 | Intelligent selection. This extension tries to be more intelligent when |
44 | (More) intelligent selection. This extension tries to be more intelligent |
45 | the user extends selections (double-click). Right now, it tries to select |
45 | when the user extends selections (double-click). Right now, it tries to |
46 | urls and complete shell-quoted arguments, which is very convenient, too, |
46 | select urls and complete shell-quoted arguments, which is very convenient, |
47 | if your F<ls> supports C<--quoting-style=shell>. |
47 | too, if your F<ls> supports C<--quoting-style=shell>. |
48 | |
48 | |
49 | It also offers the following bindable event: |
49 | It also offers the following bindable keyboard command: |
50 | |
50 | |
51 | =over 4 |
51 | =over 4 |
52 | |
52 | |
53 | =item rot13 |
53 | =item rot13 |
54 | |
54 | |
… | |
… | |
64 | runtime. |
64 | runtime. |
65 | |
65 | |
66 | =item selection-popup (enabled by default) |
66 | =item selection-popup (enabled by default) |
67 | |
67 | |
68 | Binds a popup menu to Ctrl-Button3 that lets you convert the selection |
68 | Binds a popup menu to Ctrl-Button3 that lets you convert the selection |
69 | text into various other formats/action. |
69 | text into various other formats/action (such as uri unescaping, perl |
|
|
70 | evalution, web-browser starting etc.), depending on content. |
70 | |
71 | |
71 | =item searchable-scrollback (enabled by default) |
72 | =item searchable-scrollback<hotkey> (enabled by default) |
72 | |
73 | |
73 | Adds regex search functionality to the scrollback buffer, triggered by a |
74 | Adds regex search functionality to the scrollback buffer, triggered |
74 | hotkey (default: C<M-s>). When in search mode, terminal input/output is |
75 | by a hotkey (default: C<M-s>). When in search mode, normal terminal |
|
|
76 | input/output is suspended. |
|
|
77 | |
75 | suspended, C</> starts an incremental regex search, C<n> searches further, |
78 | C</> starts an incremental regex search, C<n> searches further, C<p> or |
76 | C<p> jumps to the previous match. C<enter> leaves search mode at the |
79 | C<N> jump to the previous match, C<G> jumps to the bottom and clears the |
77 | current position and C<escape> returns to the original position. |
80 | history, C<enter> leaves search mode at the current position and C<escape> |
|
|
81 | returns to the original position. |
78 | |
82 | |
79 | =item digital-clock |
83 | =item digital-clock |
80 | |
84 | |
81 | Displays a digital clock using the built-in overlay. |
85 | Displays a digital clock using the built-in overlay. |
82 | |
86 | |
… | |
… | |
95 | Displays a very simple digital clock in the upper right corner of the |
99 | Displays a very simple digital clock in the upper right corner of the |
96 | window. Illustrates overwriting the refresh callbacks to create your own |
100 | window. Illustrates overwriting the refresh callbacks to create your own |
97 | overlays or changes. |
101 | overlays or changes. |
98 | |
102 | |
99 | =back |
103 | =back |
|
|
104 | |
|
|
105 | =head1 API DOCUMENTATION |
100 | |
106 | |
101 | =head2 General API Considerations |
107 | =head2 General API Considerations |
102 | |
108 | |
103 | All objects (such as terminals, time watchers etc.) are typical |
109 | All objects (such as terminals, time watchers etc.) are typical |
104 | reference-to-hash objects. The hash can be used to store anything you |
110 | reference-to-hash objects. The hash can be used to store anything you |
… | |
… | |
263 | can filter/change and output the text yourself by returning a true value |
269 | can filter/change and output the text yourself by returning a true value |
264 | and calling C<< $term->scr_add_lines >> yourself. Please note that this |
270 | and calling C<< $term->scr_add_lines >> yourself. Please note that this |
265 | might be very slow, however, as your hook is called for B<all> text being |
271 | might be very slow, however, as your hook is called for B<all> text being |
266 | output. |
272 | output. |
267 | |
273 | |
|
|
274 | =item on_tt_write $term, $octets |
|
|
275 | |
|
|
276 | Called whenever some data is written to the tty/pty and can be used to |
|
|
277 | suppress or filter tty input. |
|
|
278 | |
268 | =item on_line_update $term, $row |
279 | =item on_line_update $term, $row |
269 | |
280 | |
270 | Called whenever a line was updated or changed. Can be used to filter |
281 | Called whenever a line was updated or changed. Can be used to filter |
271 | screen output (e.g. underline urls or other useless stuff). Only lines |
282 | screen output (e.g. underline urls or other useless stuff). Only lines |
272 | that are being shown will be filtered, and, due to performance reasons, |
283 | that are being shown will be filtered, and, due to performance reasons, |
… | |
… | |
336 | |
347 | |
337 | =head2 Variables in the C<urxvt> Package |
348 | =head2 Variables in the C<urxvt> Package |
338 | |
349 | |
339 | =over 4 |
350 | =over 4 |
340 | |
351 | |
|
|
352 | =item $urxvt::LIBDIR |
|
|
353 | |
|
|
354 | The rxvt-unicode library directory, where, among other things, the perl |
|
|
355 | modules and scripts are stored. |
|
|
356 | |
|
|
357 | =item $urxvt::RESCLASS, $urxvt::RESCLASS |
|
|
358 | |
|
|
359 | The resource class and name rxvt-unicode uses to look up X resources. |
|
|
360 | |
|
|
361 | =item $urxvt::RXVTNAME |
|
|
362 | |
|
|
363 | The basename of the installed binaries, usually C<urxvt>. |
|
|
364 | |
341 | =item $urxvt::TERM |
365 | =item $urxvt::TERM |
342 | |
366 | |
343 | The current terminal. This variable stores the current C<urxvt::term> |
367 | The current terminal. This variable stores the current C<urxvt::term> |
344 | object, whenever a callback/hook is executing. |
368 | object, whenever a callback/hook is executing. |
|
|
369 | |
|
|
370 | =item |
345 | |
371 | |
346 | =back |
372 | =back |
347 | |
373 | |
348 | =head2 Functions in the C<urxvt> Package |
374 | =head2 Functions in the C<urxvt> Package |
349 | |
375 | |
… | |
… | |
423 | |
449 | |
424 | =item $background = urxvt::GET_BASEBG $rend |
450 | =item $background = urxvt::GET_BASEBG $rend |
425 | |
451 | |
426 | Return the foreground/background colour index, respectively. |
452 | Return the foreground/background colour index, respectively. |
427 | |
453 | |
428 | =item $rend = urxvt::SET_FGCOLOR ($rend, $new_colour) |
454 | =item $rend = urxvt::SET_FGCOLOR $rend, $new_colour |
429 | |
455 | |
430 | =item $rend = urxvt::SET_BGCOLOR ($rend, $new_colour) |
456 | =item $rend = urxvt::SET_BGCOLOR $rend, $new_colour |
431 | |
457 | |
432 | Replace the foreground/background colour in the rendition mask with the |
458 | Replace the foreground/background colour in the rendition mask with the |
433 | specified one. |
459 | specified one. |
434 | |
460 | |
435 | =item $value = urxvt::GET_CUSTOM ($rend) |
461 | =item $value = urxvt::GET_CUSTOM $rend |
436 | |
462 | |
437 | Return the "custom" value: Every rendition has 5 bits for use by |
463 | Return the "custom" value: Every rendition has 5 bits for use by |
438 | extensions. They can be set and changed as you like and are initially |
464 | extensions. They can be set and changed as you like and are initially |
439 | zero. |
465 | zero. |
440 | |
466 | |
441 | =item $rend = urxvt::SET_CUSTOM ($rend, $new_value) |
467 | =item $rend = urxvt::SET_CUSTOM $rend, $new_value |
442 | |
468 | |
443 | Change the custom value. |
469 | Change the custom value. |
444 | |
470 | |
445 | =back |
471 | =back |
446 | |
472 | |
… | |
… | |
457 | our $VERSION = 1; |
483 | our $VERSION = 1; |
458 | our $TERM; |
484 | our $TERM; |
459 | our @HOOKNAME; |
485 | our @HOOKNAME; |
460 | our %HOOKTYPE = map +($HOOKNAME[$_] => $_), 0..$#HOOKNAME; |
486 | our %HOOKTYPE = map +($HOOKNAME[$_] => $_), 0..$#HOOKNAME; |
461 | our %OPTION; |
487 | our %OPTION; |
|
|
488 | |
462 | our $LIBDIR; |
489 | our $LIBDIR; |
|
|
490 | our $RESNAME; |
|
|
491 | our $RESCLASS; |
|
|
492 | our $RXVTNAME; |
463 | |
493 | |
464 | BEGIN { |
494 | BEGIN { |
465 | urxvt->bootstrap; |
495 | urxvt->bootstrap; |
466 | |
496 | |
467 | # overwrite perl's warn |
497 | # overwrite perl's warn |
… | |
… | |
501 | open my $fh, "<:raw", $path |
531 | open my $fh, "<:raw", $path |
502 | or die "$path: $!"; |
532 | or die "$path: $!"; |
503 | |
533 | |
504 | my $source = untaint |
534 | my $source = untaint |
505 | "package $pkg; use strict; use utf8;\n" |
535 | "package $pkg; use strict; use utf8;\n" |
506 | . "use base urxvt::term::proxy::;\n" |
536 | . "use base urxvt::term::extension::;\n" |
507 | . "#line 1 \"$path\"\n{\n" |
537 | . "#line 1 \"$path\"\n{\n" |
508 | . (do { local $/; <$fh> }) |
538 | . (do { local $/; <$fh> }) |
509 | . "\n};\n1"; |
539 | . "\n};\n1"; |
510 | |
540 | |
511 | eval $source |
541 | eval $source |
… | |
… | |
588 | } |
618 | } |
589 | |
619 | |
590 | $retval |
620 | $retval |
591 | } |
621 | } |
592 | |
622 | |
593 | # urxvt::term::proxy |
623 | # urxvt::term::extension |
594 | |
624 | |
595 | package urxvt::term::proxy; |
625 | package urxvt::term::extension; |
596 | |
626 | |
597 | sub enable { |
627 | sub enable { |
598 | my ($self, %hook) = @_; |
628 | my ($self, %hook) = @_; |
599 | my $pkg = $self->{_pkg}; |
629 | my $pkg = $self->{_pkg}; |
600 | |
630 | |
… | |
… | |
663 | |
693 | |
664 | =head2 The C<urxvt::anyevent> Class |
694 | =head2 The C<urxvt::anyevent> Class |
665 | |
695 | |
666 | The sole purpose of this class is to deliver an interface to the |
696 | The sole purpose of this class is to deliver an interface to the |
667 | C<AnyEvent> module - any module using it will work inside urxvt without |
697 | C<AnyEvent> module - any module using it will work inside urxvt without |
668 | further work. The only exception is that you cannot wait on condition |
698 | further programming. The only exception is that you cannot wait on |
669 | variables, but non-blocking condvar use is ok. What this means is that you |
699 | condition variables, but non-blocking condvar use is ok. What this means |
670 | cannot use blocking APIs, but the non-blocking variant should work. |
700 | is that you cannot use blocking APIs, but the non-blocking variant should |
|
|
701 | work. |
671 | |
702 | |
672 | =cut |
703 | =cut |
673 | |
704 | |
674 | our $VERSION = 1; |
705 | our $VERSION = 1; |
675 | |
706 | |
… | |
… | |
754 | } |
785 | } |
755 | } |
786 | } |
756 | |
787 | |
757 | =item $term->destroy |
788 | =item $term->destroy |
758 | |
789 | |
759 | Destroy the terminal object (close the window, free resources etc.). |
790 | Destroy the terminal object (close the window, free resources |
|
|
791 | etc.). Please note that @@RXVT_NAME@@ will not exit as long as any event |
|
|
792 | watchers (timers, io watchers) are still active. |
760 | |
793 | |
761 | =item $isset = $term->option ($optval[, $set]) |
794 | =item $isset = $term->option ($optval[, $set]) |
762 | |
795 | |
763 | Returns true if the option specified by C<$optval> is enabled, and |
796 | Returns true if the option specified by C<$optval> is enabled, and |
764 | optionally change it. All option values are stored by name in the hash |
797 | optionally change it. All option values are stored by name in the hash |
… | |
… | |
941 | |
974 | |
942 | =item $string = $term->locale_decode ($octets) |
975 | =item $string = $term->locale_decode ($octets) |
943 | |
976 | |
944 | Convert the given locale-encoded octets into a perl string. |
977 | Convert the given locale-encoded octets into a perl string. |
945 | |
978 | |
|
|
979 | =item $term->scr_xor_span ($beg_row, $beg_col, $end_row, $end_col[, $rstyle]) |
|
|
980 | |
|
|
981 | XORs the rendition values in the given span with the provided value |
|
|
982 | (default: C<RS_RVid>). Useful in refresh hooks to provide effects similar |
|
|
983 | to the selection. |
|
|
984 | |
|
|
985 | =item $term->scr_xor_rect ($beg_row, $beg_col, $end_row, $end_col[, $rstyle1[, $rstyle2]]) |
|
|
986 | |
|
|
987 | Similar to C<scr_xor_span>, but xors a rectangle instead. Trailing |
|
|
988 | whitespace will additionally be xored with the C<$rstyle2>, which defaults |
|
|
989 | to C<RS_RVid | RS_Uline>, which removes reverse video again and underlines |
|
|
990 | it instead. |
|
|
991 | |
946 | =item $term->scr_bell |
992 | =item $term->scr_bell |
947 | |
993 | |
948 | Ring the bell! |
994 | Ring the bell! |
949 | |
995 | |
950 | =item $term->scr_add_lines ($string) |
996 | =item $term->scr_add_lines ($string) |
… | |
… | |
1265 | $item->{render} ||= sub { $_[0]{text} }; |
1311 | $item->{render} ||= sub { $_[0]{text} }; |
1266 | |
1312 | |
1267 | push @{ $self->{item} }, $item; |
1313 | push @{ $self->{item} }, $item; |
1268 | } |
1314 | } |
1269 | |
1315 | |
|
|
1316 | =item $popup->add_title ($title) |
|
|
1317 | |
|
|
1318 | Adds a non-clickable title to the popup. |
|
|
1319 | |
|
|
1320 | =cut |
|
|
1321 | |
|
|
1322 | sub add_title { |
|
|
1323 | my ($self, $title) = @_; |
|
|
1324 | |
|
|
1325 | $self->add_item ({ |
|
|
1326 | rend => { normal => "\x1b[38;5;11;44m", hover => "\x1b[38;5;11;44m", active => "\x1b[38;5;11;44m" }, |
|
|
1327 | text => $title, |
|
|
1328 | activate => sub { }, |
|
|
1329 | }); |
|
|
1330 | } |
|
|
1331 | |
|
|
1332 | =item $popup->add_separator ([$sepchr]) |
|
|
1333 | |
|
|
1334 | Creates a separator, optionally using the character given as C<$sepchr>. |
|
|
1335 | |
|
|
1336 | =cut |
|
|
1337 | |
1270 | sub add_separator { |
1338 | sub add_separator { |
1271 | my ($self, $sep) = @_; |
1339 | my ($self, $sep) = @_; |
1272 | |
1340 | |
1273 | $sep ||= "="; |
1341 | $sep ||= "="; |
1274 | |
1342 | |
… | |
… | |
1278 | render => sub { $sep x $self->{term}->ncol }, |
1346 | render => sub { $sep x $self->{term}->ncol }, |
1279 | activate => sub { }, |
1347 | activate => sub { }, |
1280 | }); |
1348 | }); |
1281 | } |
1349 | } |
1282 | |
1350 | |
1283 | sub add_title { |
1351 | =item $popup->add_button ($text, $cb) |
1284 | my ($self, $title) = @_; |
|
|
1285 | |
1352 | |
1286 | $self->add_item ({ |
1353 | Adds a clickable button to the popup. C<$cb> is called whenever it is |
1287 | rend => { normal => "\x1b[38;5;11;44m", hover => "\x1b[38;5;11;44m", active => "\x1b[38;5;11;44m" }, |
1354 | selected. |
1288 | text => $title, |
1355 | |
1289 | activate => sub { }, |
1356 | =cut |
1290 | }); |
|
|
1291 | } |
|
|
1292 | |
1357 | |
1293 | sub add_button { |
1358 | sub add_button { |
1294 | my ($self, $text, $cb) = @_; |
1359 | my ($self, $text, $cb) = @_; |
1295 | |
1360 | |
1296 | $self->add_item ({ type => "button", text => $text, activate => $cb}); |
1361 | $self->add_item ({ type => "button", text => $text, activate => $cb}); |
1297 | } |
1362 | } |
|
|
1363 | |
|
|
1364 | =item $popup->add_toggle ($text, $cb, $initial_value) |
|
|
1365 | |
|
|
1366 | Adds a toggle/checkbox item to the popup. Teh callback gets called |
|
|
1367 | whenever it gets toggled, with a boolean indicating its value as its first |
|
|
1368 | argument. |
|
|
1369 | |
|
|
1370 | =cut |
1298 | |
1371 | |
1299 | sub add_toggle { |
1372 | sub add_toggle { |
1300 | my ($self, $text, $cb, $value) = @_; |
1373 | my ($self, $text, $cb, $value) = @_; |
1301 | |
1374 | |
1302 | my $item; $item = { |
1375 | my $item; $item = { |
1303 | type => "button", |
1376 | type => "button", |
1304 | text => " $text", |
1377 | text => " $text", |
1305 | value => $value, |
1378 | value => $value, |
1306 | render => sub { ($_[0]{value} ? "* " : " ") . $text }, |
1379 | render => sub { ($_[0]{value} ? "* " : " ") . $text }, |
1307 | activate => sub { $cb->($_[0]{value} = !$_[0]{value}); }, |
1380 | activate => sub { $cb->($_[1]{value} = !$_[1]{value}); }, |
1308 | }; |
1381 | }; |
1309 | |
1382 | |
1310 | $self->add_item ($item); |
1383 | $self->add_item ($item); |
1311 | } |
1384 | } |
|
|
1385 | |
|
|
1386 | =item $popup->show |
|
|
1387 | |
|
|
1388 | Displays the popup (which is initially hidden). |
|
|
1389 | |
|
|
1390 | =cut |
1312 | |
1391 | |
1313 | sub show { |
1392 | sub show { |
1314 | my ($self) = @_; |
1393 | my ($self) = @_; |
1315 | |
1394 | |
1316 | local $urxvt::popup::self = $self; |
1395 | local $urxvt::popup::self = $self; |