ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/urxvt.pm
(Generate patch)

Comparing rxvt-unicode/src/urxvt.pm (file contents):
Revision 1.70 by root, Mon Jan 9 23:00:07 2006 UTC vs.
Revision 1.76 by root, Tue Jan 10 19:46:28 2006 UTC

26thus must be encoded as UTF-8. 26thus must be encoded as UTF-8.
27 27
28Each script will only ever be loaded once, even in @@RXVT_NAME@@d, where 28Each script will only ever be loaded once, even in @@RXVT_NAME@@d, where
29scripts will be shared (but not enabled) for all terminals. 29scripts will be shared (but not enabled) for all terminals.
30 30
31=head2 Prepackaged Extensions 31=head1 PREPACKAGED EXTENSIONS
32 32
33This section describes the extensiosn delivered with this version. You can 33This section describes the extensions delivered with this release. You can
34find them in F<@@RXVT_LIBDIR@@/urxvt/perl/>. 34find them in F<@@RXVT_LIBDIR@@/urxvt/perl/>.
35 35
36You can activate them like this: 36You 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
44Intelligent selection. This extension tries to be more intelligent when 44(More) intelligent selection. This extension tries to be more intelligent
45the user extends selections (double-click). Right now, it tries to select 45when the user extends selections (double-click). Right now, it tries to
46urls and complete shell-quoted arguments, which is very convenient, too, 46select urls and complete shell-quoted arguments, which is very convenient,
47if your F<ls> supports C<--quoting-style=shell>. 47too, if your F<ls> supports C<--quoting-style=shell>.
48 48
49It also offers the following bindable event: 49It 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
64runtime. 64runtime.
65 65
66=item selection-popup (enabled by default) 66=item selection-popup (enabled by default)
67 67
68Binds a popup menu to Ctrl-Button3 that lets you convert the selection 68Binds a popup menu to Ctrl-Button3 that lets you convert the selection
69text into various other formats/action. 69text into various other formats/action (such as uri unescaping, perl
70evalution, 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
73Adds regex search functionality to the scrollback buffer, triggered by a 74Adds regex search functionality to the scrollback buffer, triggered
74hotkey (default: C<M-s>). When in search mode, terminal input/output is 75by a hotkey (default: C<M-s>). When in search mode, normal terminal
76input/output is suspended.
77
75suspended, C</> starts an incremental regex search, C<n> searches further, 78C</> starts an incremental regex search, C<n> searches further, C<p> or
76C<p> jumps to the previous match. C<enter> leaves search mode at the 79C<N> jump to the previous match, C<G> jumps to the bottom and clears the
77current position and C<escape> returns to the original position. 80history, C<enter> leaves search mode at the current position and C<escape>
81returns to the original position.
78 82
79=item digital-clock 83=item digital-clock
80 84
81Displays a digital clock using the built-in overlay. 85Displays a digital clock using the built-in overlay.
82 86
95Displays a very simple digital clock in the upper right corner of the 99Displays a very simple digital clock in the upper right corner of the
96window. Illustrates overwriting the refresh callbacks to create your own 100window. Illustrates overwriting the refresh callbacks to create your own
97overlays or changes. 101overlays 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
103All objects (such as terminals, time watchers etc.) are typical 109All objects (such as terminals, time watchers etc.) are typical
104reference-to-hash objects. The hash can be used to store anything you 110reference-to-hash objects. The hash can be used to store anything you
263can filter/change and output the text yourself by returning a true value 269can filter/change and output the text yourself by returning a true value
264and calling C<< $term->scr_add_lines >> yourself. Please note that this 270and calling C<< $term->scr_add_lines >> yourself. Please note that this
265might be very slow, however, as your hook is called for B<all> text being 271might be very slow, however, as your hook is called for B<all> text being
266output. 272output.
267 273
274=item on_tt_write $term, $octets
275
276Called whenever some data is written to the tty/pty and can be used to
277suppress or filter tty input.
278
268=item on_line_update $term, $row 279=item on_line_update $term, $row
269 280
270Called whenever a line was updated or changed. Can be used to filter 281Called whenever a line was updated or changed. Can be used to filter
271screen output (e.g. underline urls or other useless stuff). Only lines 282screen output (e.g. underline urls or other useless stuff). Only lines
272that are being shown will be filtered, and, due to performance reasons, 283that 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
354The rxvt-unicode library directory, where, among other things, the perl
355modules and scripts are stored.
356
357=item $urxvt::RESCLASS, $urxvt::RESCLASS
358
359The resource class and name rxvt-unicode uses to look up X resources.
360
361=item $urxvt::RXVTNAME
362
363The basename of the installed binaries, usually C<urxvt>.
364
341=item $urxvt::TERM 365=item $urxvt::TERM
342 366
343The current terminal. This variable stores the current C<urxvt::term> 367The current terminal. This variable stores the current C<urxvt::term>
344object, whenever a callback/hook is executing. 368object, 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
426Return the foreground/background colour index, respectively. 452Return 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
432Replace the foreground/background colour in the rendition mask with the 458Replace the foreground/background colour in the rendition mask with the
433specified one. 459specified one.
434 460
435=item $value = urxvt::GET_CUSTOM ($rend) 461=item $value = urxvt::GET_CUSTOM $rend
436 462
437Return the "custom" value: Every rendition has 5 bits for use by 463Return the "custom" value: Every rendition has 5 bits for use by
438extensions. They can be set and changed as you like and are initially 464extensions. They can be set and changed as you like and are initially
439zero. 465zero.
440 466
441=item $rend = urxvt::SET_CUSTOM ($rend, $new_value) 467=item $rend = urxvt::SET_CUSTOM $rend, $new_value
442 468
443Change the custom value. 469Change the custom value.
444 470
445=back 471=back
446 472
457our $VERSION = 1; 483our $VERSION = 1;
458our $TERM; 484our $TERM;
459our @HOOKNAME; 485our @HOOKNAME;
460our %HOOKTYPE = map +($HOOKNAME[$_] => $_), 0..$#HOOKNAME; 486our %HOOKTYPE = map +($HOOKNAME[$_] => $_), 0..$#HOOKNAME;
461our %OPTION; 487our %OPTION;
488
462our $LIBDIR; 489our $LIBDIR;
490our $RESNAME;
491our $RESCLASS;
492our $RXVTNAME;
463 493
464BEGIN { 494BEGIN {
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
595package urxvt::term::proxy; 625package urxvt::term::extension;
596 626
597sub enable { 627sub 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
666The sole purpose of this class is to deliver an interface to the 696The sole purpose of this class is to deliver an interface to the
667C<AnyEvent> module - any module using it will work inside urxvt without 697C<AnyEvent> module - any module using it will work inside urxvt without
668further work. The only exception is that you cannot wait on condition 698further programming. The only exception is that you cannot wait on
669variables, but non-blocking condvar use is ok. What this means is that you 699condition variables, but non-blocking condvar use is ok. What this means
670cannot use blocking APIs, but the non-blocking variant should work. 700is that you cannot use blocking APIs, but the non-blocking variant should
701work.
671 702
672=cut 703=cut
673 704
674our $VERSION = 1; 705our $VERSION = 1;
675 706
754 } 785 }
755} 786}
756 787
757=item $term->destroy 788=item $term->destroy
758 789
759Destroy the terminal object (close the window, free resources etc.). 790Destroy the terminal object (close the window, free resources
791etc.). Please note that @@RXVT_NAME@@ will not exit as long as any event
792watchers (timers, io watchers) are still active.
760 793
761=item $isset = $term->option ($optval[, $set]) 794=item $isset = $term->option ($optval[, $set])
762 795
763Returns true if the option specified by C<$optval> is enabled, and 796Returns true if the option specified by C<$optval> is enabled, and
764optionally change it. All option values are stored by name in the hash 797optionally change it. All option values are stored by name in the hash
1278 $item->{render} ||= sub { $_[0]{text} }; 1311 $item->{render} ||= sub { $_[0]{text} };
1279 1312
1280 push @{ $self->{item} }, $item; 1313 push @{ $self->{item} }, $item;
1281} 1314}
1282 1315
1316=item $popup->add_title ($title)
1317
1318Adds a non-clickable title to the popup.
1319
1320=cut
1321
1322sub 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
1334Creates a separator, optionally using the character given as C<$sepchr>.
1335
1336=cut
1337
1283sub add_separator { 1338sub add_separator {
1284 my ($self, $sep) = @_; 1339 my ($self, $sep) = @_;
1285 1340
1286 $sep ||= "="; 1341 $sep ||= "=";
1287 1342
1291 render => sub { $sep x $self->{term}->ncol }, 1346 render => sub { $sep x $self->{term}->ncol },
1292 activate => sub { }, 1347 activate => sub { },
1293 }); 1348 });
1294} 1349}
1295 1350
1296sub add_title { 1351=item $popup->add_button ($text, $cb)
1297 my ($self, $title) = @_;
1298 1352
1299 $self->add_item ({ 1353Adds a clickable button to the popup. C<$cb> is called whenever it is
1300 rend => { normal => "\x1b[38;5;11;44m", hover => "\x1b[38;5;11;44m", active => "\x1b[38;5;11;44m" }, 1354selected.
1301 text => $title, 1355
1302 activate => sub { }, 1356=cut
1303 });
1304}
1305 1357
1306sub add_button { 1358sub add_button {
1307 my ($self, $text, $cb) = @_; 1359 my ($self, $text, $cb) = @_;
1308 1360
1309 $self->add_item ({ type => "button", text => $text, activate => $cb}); 1361 $self->add_item ({ type => "button", text => $text, activate => $cb});
1310} 1362}
1363
1364=item $popup->add_toggle ($text, $cb, $initial_value)
1365
1366Adds a toggle/checkbox item to the popup. Teh callback gets called
1367whenever it gets toggled, with a boolean indicating its value as its first
1368argument.
1369
1370=cut
1311 1371
1312sub add_toggle { 1372sub add_toggle {
1313 my ($self, $text, $cb, $value) = @_; 1373 my ($self, $text, $cb, $value) = @_;
1314 1374
1315 my $item; $item = { 1375 my $item; $item = {
1316 type => "button", 1376 type => "button",
1317 text => " $text", 1377 text => " $text",
1318 value => $value, 1378 value => $value,
1319 render => sub { ($_[0]{value} ? "* " : " ") . $text }, 1379 render => sub { ($_[0]{value} ? "* " : " ") . $text },
1320 activate => sub { $cb->($_[0]{value} = !$_[0]{value}); }, 1380 activate => sub { $cb->($_[1]{value} = !$_[1]{value}); },
1321 }; 1381 };
1322 1382
1323 $self->add_item ($item); 1383 $self->add_item ($item);
1324} 1384}
1385
1386=item $popup->show
1387
1388Displays the popup (which is initially hidden).
1389
1390=cut
1325 1391
1326sub show { 1392sub show {
1327 my ($self) = @_; 1393 my ($self) = @_;
1328 1394
1329 local $urxvt::popup::self = $self; 1395 local $urxvt::popup::self = $self;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines