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.87 by root, Thu Jan 12 05:37:34 2006 UTC vs.
Revision 1.92 by root, Fri Jan 13 04:59:04 2006 UTC

48C<--quoting-style=shell>. 48C<--quoting-style=shell>.
49 49
50A double-click usually selects the word under the cursor, further clicks 50A double-click usually selects the word under the cursor, further clicks
51will enlarge the selection. 51will enlarge the selection.
52 52
53The selection works by trying to match a number of regexes and displaying
54them in increasing order of length. You can add your own regexes by
55specifying resources of the form:
56
57 URxvt.selection.pattern-0: perl-regex
58 URxvt.selection.pattern-1: perl-regex
59 ...
60
61The index number (0, 1...) must not have any holes, and each regex must
62contain at least one pair of capturing parentheses, which will be used for
63the match. For example, the followign adds a regex that matches everything
64between two vertical bars:
65
66 URxvt.selection.pattern-0: \\|([^|]+)\\|
67
68You can look at the source of the selection extension to see more
69interesting uses, such as parsing a line from beginning to end.
70
53It also offers the following bindable keyboard command: 71This extension also offers the following bindable keyboard command:
54 72
55=over 4 73=over 4
56 74
57=item rot13 75=item rot13
58 76
86bottom. C<Escape> leaves search mode and returns to the point where search 104bottom. C<Escape> leaves search mode and returns to the point where search
87was started, while C<Enter> or C<Return> stay at the current position and 105was started, while C<Enter> or C<Return> stay at the current position and
88additionally stores the first match in the current line into the primary 106additionally stores the first match in the current line into the primary
89selection. 107selection.
90 108
91=item digital-clock 109=item selection-autotransform
92 110
93Displays a digital clock using the built-in overlay. 111This selection allows you to do automatic transforms on a selection
112whenever a selection is made.
113
114It works by specifying perl snippets (most useful is a single C<s///>
115operator) that modify C<$_> as resources:
116
117 URxvt.selection-autotransform.0: transform
118 URxvt.selection-autotransform.1: transform
119 ...
120
121For example, the following will transform selections of the form
122C<filename:number>, often seen in compiler messages, into C<vi +$filename
123$word>:
124
125 URxvt.selection-autotransform.0: s/^(\\S+):(\\d+):?$/vi +$2 \\Q$1\\E\\x0d/
126
127And this example matches the same,but replaces it with vi-commands you can
128paste directly into your (vi :) editor:
129
130 URxvt.selection-autotransform.0: s/^(S+):(d+):?$/\\x1b:e \\Q$1\\E\\x0d:$2\\x0d/
131
132Of course, this can be modified to suit your needs and your editor :)
133
134To expand the example above to typical perl error messages ("XXX at
135FILENAME line YYY."), you need a slightly more elaborate solution:
136
137 URxvt.selection.pattern-0: ( at .*? line \\d+\\.)
138 URxvt.selection-autotransform.0: s/^ at (.*?) line (\\d+)\\.$/\x1b:e \\Q$1\E\\x0d:$2\\x0d/
139
140The first line tells the selection code to treat the unchanging part of
141every error message as a selection pattern, and the second line transforms
142the message into vi commands to load the file.
94 143
95=item mark-urls 144=item mark-urls
96 145
97Uses per-line display filtering (C<on_line_update>) to underline urls and 146Uses per-line display filtering (C<on_line_update>) to underline urls and
98make them clickable. When middle-clicked, the program specified in the 147make them clickable. When middle-clicked, the program specified in the
102=item block-graphics-to-ascii 151=item block-graphics-to-ascii
103 152
104A not very useful example of filtering all text output to the terminal, 153A not very useful example of filtering all text output to the terminal,
105by replacing all line-drawing characters (U+2500 .. U+259F) by a 154by replacing all line-drawing characters (U+2500 .. U+259F) by a
106similar-looking ascii character. 155similar-looking ascii character.
156
157=item digital-clock
158
159Displays a digital clock using the built-in overlay.
107 160
108=item example-refresh-hooks 161=item example-refresh-hooks
109 162
110Displays a very simple digital clock in the upper right corner of the 163Displays a very simple digital clock in the upper right corner of the
111window. Illustrates overwriting the refresh callbacks to create your own 164window. Illustrates overwriting the refresh callbacks to create your own
318 371
319Called whenever the user presses a key combination that has a 372Called whenever the user presses a key combination that has a
320C<perl:string> action bound to it (see description of the B<keysym> 373C<perl:string> action bound to it (see description of the B<keysym>
321resource in the @@RXVT_NAME@@(1) manpage). 374resource in the @@RXVT_NAME@@(1) manpage).
322 375
376=item on_x_event $term, $event
377
378Called on every X event received on the vt window (and possibly other
379windows). Should only be used as a last resort. Most event structure
380members are not passed.
381
323=item on_focus_in $term 382=item on_focus_in $term
324 383
325Called whenever the window gets the keyboard focus, before rxvt-unicode 384Called whenever the window gets the keyboard focus, before rxvt-unicode
326does focus in processing. 385does focus in processing.
327 386
437=item urxvt::CurrentTime 496=item urxvt::CurrentTime
438 497
439=item urxvt::ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, 498=item urxvt::ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask,
440Mod3Mask, Mod4Mask, Mod5Mask, Button1Mask, Button2Mask, Button3Mask, 499Mod3Mask, Mod4Mask, Mod5Mask, Button1Mask, Button2Mask, Button3Mask,
441Button4Mask, Button5Mask, AnyModifier 500Button4Mask, Button5Mask, AnyModifier
501
502=item urxvt::NoEventMask, KeyPressMask, KeyReleaseMask,
503ButtonPressMask, ButtonReleaseMask, EnterWindowMask, LeaveWindowMask,
504PointerMotionMask, PointerMotionHintMask, Button1MotionMask, Button2MotionMask,
505Button3MotionMask, Button4MotionMask, Button5MotionMask, ButtonMotionMask,
506KeymapStateMask, ExposureMask, VisibilityChangeMask, StructureNotifyMask,
507ResizeRedirectMask, SubstructureNotifyMask, SubstructureRedirectMask,
508FocusChangeMask, PropertyChangeMask, ColormapChangeMask, OwnerGrabButtonMask
509
510=item urxvt::KeyPress, KeyRelease, ButtonPress, ButtonRelease, MotionNotify,
511EnterNotify, LeaveNotify, FocusIn, FocusOut, KeymapNotify, Expose,
512GraphicsExpose, NoExpose, VisibilityNotify, CreateNotify, DestroyNotify,
513UnmapNotify, MapNotify, MapRequest, ReparentNotify, ConfigureNotify,
514ConfigureRequest, GravityNotify, ResizeRequest, CirculateNotify,
515CirculateRequest, PropertyNotify, SelectionClear, SelectionRequest,
516SelectionNotify, ColormapNotify, ClientMessage, MappingNotify
442 517
443Various constants for use in X calls and event processing. 518Various constants for use in X calls and event processing.
444 519
445=back 520=back
446 521
514 delete $ENV{CDPATH}; 589 delete $ENV{CDPATH};
515 delete $ENV{BASH_ENV}; 590 delete $ENV{BASH_ENV};
516 $ENV{PATH} = "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/opt/sbin"; 591 $ENV{PATH} = "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/opt/sbin";
517} 592}
518 593
519my @hook_count;
520my $verbosity = $ENV{URXVT_PERL_VERBOSITY}; 594my $verbosity = $ENV{URXVT_PERL_VERBOSITY};
521 595
522sub verbose { 596sub verbose {
523 my ($level, $msg) = @_; 597 my ($level, $msg) = @_;
524 warn "$msg\n" if $level <= $verbosity; 598 warn "$msg\n" if $level <= $verbosity;
612 verbose 11, "$HOOKNAME[$htype] returning <$retval>" 686 verbose 11, "$HOOKNAME[$htype] returning <$retval>"
613 if $verbosity >= 11; 687 if $verbosity >= 11;
614 } 688 }
615 689
616 if ($htype == 1) { # DESTROY 690 if ($htype == 1) { # DESTROY
617 if (my $hook = delete $TERM->{_hook}) {
618 for my $htype (0..$#$hook) {
619 $hook_count[$htype] -= scalar keys %{ $hook->[$htype] || {} }
620 or set_should_invoke $htype, 0;
621 }
622 }
623
624 # clear package objects 691 # clear package objects
625 %$_ = () for values %{ $TERM->{_pkg} }; 692 %$_ = () for values %{ $TERM->{_pkg} };
626 693
627 # clear package 694 # clear package
628 %$TERM = (); 695 %$TERM = ();
654 while (my ($name, $cb) = each %hook) { 721 while (my ($name, $cb) = each %hook) {
655 my $htype = $HOOKTYPE{uc $name}; 722 my $htype = $HOOKTYPE{uc $name};
656 defined $htype 723 defined $htype
657 or Carp::croak "unsupported hook type '$name'"; 724 or Carp::croak "unsupported hook type '$name'";
658 725
726 $self->set_should_invoke ($htype, +1)
659 unless (exists $self->{term}{_hook}[$htype]{$pkg}) { 727 unless exists $self->{term}{_hook}[$htype]{$pkg};
660 $hook_count[$htype]++
661 or urxvt::set_should_invoke $htype, 1;
662 }
663 728
664 $self->{term}{_hook}[$htype]{$pkg} = $cb; 729 $self->{term}{_hook}[$htype]{$pkg} = $cb;
665 } 730 }
666} 731}
667 732
672 for my $name (@hook) { 737 for my $name (@hook) {
673 my $htype = $HOOKTYPE{uc $name}; 738 my $htype = $HOOKTYPE{uc $name};
674 defined $htype 739 defined $htype
675 or Carp::croak "unsupported hook type '$name'"; 740 or Carp::croak "unsupported hook type '$name'";
676 741
742 $self->set_should_invoke ($htype, -1)
677 if (delete $self->{term}{_hook}[$htype]{$pkg}) { 743 if delete $self->{term}{_hook}[$htype]{$pkg};
678 --$hook_count[$htype]
679 or urxvt::set_should_invoke $htype, 0;
680 }
681 } 744 }
682} 745}
683 746
684our $AUTOLOAD; 747our $AUTOLOAD;
685 748
1090 1153
1091=item $windowid = $term->vt 1154=item $windowid = $term->vt
1092 1155
1093Return the window id of the terminal window. 1156Return the window id of the terminal window.
1094 1157
1158=item $term->vt_emask_add ($x_event_mask)
1159
1160Adds the specified events to the vt event mask. Useful e.g. when you want
1161to receive pointer events all the times:
1162
1163 $term->vt_emask_add (urxvt::PointerMotionMask);
1164
1095=item $window_width = $term->width 1165=item $window_width = $term->width
1096 1166
1097=item $window_height = $term->height 1167=item $window_height = $term->height
1098 1168
1099=item $font_width = $term->fwidth 1169=item $font_width = $term->fwidth

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines