matcher (rxvt-unicode-9.26.tar.bz2) | : | matcher (rxvt-unicode-9.29.tar.bz2) | ||
---|---|---|---|---|
skipping to change at line 42 | skipping to change at line 42 | |||
It is possible to activate the most recently seen match or a list of matches | It is possible to activate the most recently seen match or a list of matches | |||
from the keyboard. Simply bind a keysym to "matcher:last" or | from the keyboard. Simply bind a keysym to "matcher:last" or | |||
"matcher:list" as seen in the example below. | "matcher:list" as seen in the example below. | |||
The C<matcher:select> action enables a mode in which it is possible to | The C<matcher:select> action enables a mode in which it is possible to | |||
iterate over the matches using the keyboard and either activate them | iterate over the matches using the keyboard and either activate them | |||
or copy them to the clipboard. While the mode is active, normal terminal | or copy them to the clipboard. While the mode is active, normal terminal | |||
input/output is suspended and the following bindings are recognized: | input/output is suspended and the following bindings are recognized: | |||
=over 4 | =over | |||
=item C<Up> | =item C<Up> | |||
Search for a match upwards. | Search for a match upwards. | |||
=item C<Down> | =item C<Down> | |||
Search for a match downwards. | Search for a match downwards. | |||
=item C<Home> | =item C<Home> | |||
skipping to change at line 91 | skipping to change at line 91 | |||
Example: use a custom configuration. | Example: use a custom configuration. | |||
URxvt.url-launcher: sensible-browser | URxvt.url-launcher: sensible-browser | |||
URxvt.keysym.C-Delete: matcher:last | URxvt.keysym.C-Delete: matcher:last | |||
URxvt.keysym.M-Delete: matcher:list | URxvt.keysym.M-Delete: matcher:list | |||
URxvt.matcher.button: 1 | URxvt.matcher.button: 1 | |||
URxvt.matcher.pattern.1: \\bwww\\.[\\w-]+\\.[\\w./?&@#-]*[\\w/-] | URxvt.matcher.pattern.1: \\bwww\\.[\\w-]+\\.[\\w./?&@#-]*[\\w/-] | |||
URxvt.matcher.pattern.2: \\B(/\\S+?):(\\d+)(?=:|$) | URxvt.matcher.pattern.2: \\B(/\\S+?):(\\d+)(?=:|$) | |||
URxvt.matcher.launcher.2: gvim +$2 $1 | URxvt.matcher.launcher.2: gvim +$2 $1 | |||
=head2 Regex encoding/wide character matching | ||||
Urxvt stores all text as unicode, in a special encoding that uses | ||||
one character/code point per column. For various reasons, the regular | ||||
expressions are matched directly against this encoding, which means there are a | ||||
few things | ||||
you need to keep in mind: | ||||
=over | ||||
=item X resources/command line arguments are locale-encoded | ||||
The regexes taken from the command line or resources will be converted | ||||
from locale encoding to unicode. This can change the number of code points | ||||
per character. | ||||
=item Wide characters are column-padded with C<$urxvt::NOCHAR> | ||||
Wide characters (such as kanji and sometimes tabs) are padded with | ||||
a special character value (C<$urxvt::NOCHAR>). That means that | ||||
constructs such as C<\w> or C<.> will only match part of a character, as | ||||
C<$urxvt::NOCHAR> is not matched by C<\w> and both only match the first | ||||
"column" of a wide character. | ||||
That means you have to incorporate C<$urxvt::NOCHAR> into parts of regexes | ||||
that may match wide characters. For example, to match C<\w+> you might | ||||
want to use C<[\w$urxvt::NOCHAR]+> instead, and to match a single character | ||||
(C<.>) you might want to use C<.$urxvt::NOCHAR*> instead. | ||||
=back | ||||
=cut | =cut | |||
my $url = | my $url = | |||
qr{ | qr{ | |||
(?:https?://|ftp://|news://|mailto:|file://|\bwww\.) | (?:https?://|ftp://|news://|mailto:|file://|\bwww\.) | |||
[\w\-\@;\/?:&=%\$.+!*\x27,~#]* | [\w\-\@;\/?:&=%\$.+!*\x27,~#$urxvt::NOCHAR]* | |||
( | ( | |||
\([\w\-\@;\/?:&=%\$.+!*\x27,~#]*\)| # Allow a pair of matched parenthes es | \([\w\-\@;\/?:&=%\$.+!*\x27,~#$urxvt::NOCHAR]*\)| # Allow a pair of mat ched parentheses | |||
[\w\-\@;\/?:&=%\$+*~] # exclude some trailing characters (heuristic) | [\w\-\@;\/?:&=%\$+*~] # exclude some trailing characters (heuristic) | |||
)+ | )+ | |||
}x; | }x; | |||
sub matchlist_key_press { | sub matchlist_key_press { | |||
my ($self, $event, $keysym, $octets) = @_; | my ($self, $event, $keysym, $octets) = @_; | |||
delete $self->{overlay}; | delete $self->{overlay}; | |||
$self->disable ("key_press"); | $self->disable ("key_press"); | |||
skipping to change at line 256 | skipping to change at line 286 | |||
} elsif($mod eq "M") { | } elsif($mod eq "M") { | |||
$self->{state} |= $self->ModMetaMask; | $self->{state} |= $self->ModMetaMask; | |||
} elsif($mod ne "-" && $mod ne " ") { | } elsif($mod ne "-" && $mod ne " ") { | |||
warn("$mod is invalid in $self->{_name}<$self->{argv}[0]>\n"); | warn("$mod is invalid in $self->{_name}<$self->{argv}[0]>\n"); | |||
} | } | |||
} | } | |||
} | } | |||
my @defaults = ($url); | my @defaults = ($url); | |||
my @matchers; | my @matchers; | |||
for (my $idx = 0; defined (my $res = $self->my_resource ("pattern.$idx") || $ | for (my $idx = 0; defined (my $res = $self->locale_decode ($self->my_resource | |||
defaults[$idx]); $idx++) { | ("pattern.$idx")) || $defaults[$idx]); $idx++) { | |||
$res = $self->locale_decode ($res); | ||||
utf8::encode $res; | ||||
my $launcher = $self->my_resource ("launcher.$idx"); | my $launcher = $self->my_resource ("launcher.$idx"); | |||
$launcher =~ s/\$&|\$\{&\}/\${0}/g if $launcher; | $launcher =~ s/\$&|\$\{&\}/\${0}/g if $launcher; | |||
my $rend = $self->parse_rend($self->my_resource ("rend.$idx")); | my $rend = $self->parse_rend($self->my_resource ("rend.$idx")); | |||
unshift @matchers, [qr($res)x,$launcher,$rend]; | unshift @matchers, [qr($res)x,$launcher,$rend]; | |||
} | } | |||
$self->{matchers} = \@matchers; | $self->{matchers} = \@matchers; | |||
() | () | |||
} | } | |||
skipping to change at line 428 | skipping to change at line 456 | |||
while ($self->nrow > $row && $row >= $self->top_row) { | while ($self->nrow > $row && $row >= $self->top_row) { | |||
my $line = $self->line ($row) | my $line = $self->line ($row) | |||
or last; | or last; | |||
my @matches = $self->find_matches ($row); | my @matches = $self->find_matches ($row); | |||
if (@matches) { | if (@matches) { | |||
@matches = sort { $a->[0] <=> $b->[0] or $a->[1] <=> $b->[1] } @matches ; | @matches = sort { $a->[0] <=> $b->[0] or $a->[1] <=> $b->[1] } @matches ; | |||
$self->{matches} = \@matches; | $self->{matches} = \@matches; | |||
$self->{cur_row} = $row; | $self->{cur_row} = $row; | |||
$self->{id} = $dir < 0 ? @{ $self->{matches} } - 1 : 0; | $self->{id} = $dir < 0 ? @{ $self->{matches} } - 1 : 0; | |||
$self->view_start (List::Util::min 0, $row - ($self->nrow >> 1)); | $self->view_start ($row - ($self->nrow >> 1)); | |||
$self->want_refresh; | $self->want_refresh; | |||
return 1; | return 1; | |||
} | } | |||
$row = $dir < 0 ? $line->beg - 1 : $line->end + 1; | $row = $dir < 0 ? $line->beg - 1 : $line->end + 1; | |||
} | } | |||
$self->scr_bell; | $self->scr_bell; | |||
() | () | |||
End of changes. 6 change blocks. | ||||
8 lines changed or deleted | 37 lines changed or added |