=item B<url mode> select URLs
+=item B<ip mode> select IPv4 and IPv6 addresses
+
=back
=cut
handler => $config->{handler}{url},
};
}
+sub mapping_mode_ip {
+ my ($key, $screen, $config, $input) = @_;
+
+ $screen->debug('mapping_mode_ip', 'started');
+
+ my @ipv4 = get_regex_matches($input, $config->{regex}{ipv4});
+ my @ipv6 = get_regex_matches($input, $config->{regex}{ipv6});
+ return {
+ select => 'ip select',
+ matches => [@ipv4, @ipv6],
+ handler => $config->{handler}{ip},
+ };
+}
=head2 SEARCH MODE (AND EXTEND MODE)
=item B<u> select URLs (C<\&mapping_mode_url>)
+=item B<i> select IPv4 and IPv6 addresses (C<\&mapping_mode_ip>)
+
=item B</> search for regex to get selection (C<\&mapping_mode_search>)
=item B<q> quit fcscs (C<\&mapping_quit>)
my %mapping_mode = (
f => \&mapping_mode_path,
u => \&mapping_mode_url,
+ i => \&mapping_mode_ip,
'/' => \&mapping_mode_search,
q => \&mapping_quit,
);
=item B<path> used by C<\&mapping_mode_path>
+=item B<ipv4> used by C<\&mapping_mode_ip>
+
+=item B<ipv6> used by C<\&mapping_mode_ip>
+
=back
Example:
# Taken from urlview's default configuration file, thanks.
url => qr{((?:(?:(?:http|https|ftp|gopher)|mailto):(?://)?[^ <>"\t]*|(?:www|ftp)[0-9]?\.[-a-z0-9.]+)[^ .,;\t\n\r<">\):]?[^, <>"\t]*[^ .,;\t\n\r<">\):])},
path => qr{(~?[a-zA-Z0-9_./-]*/[a-zA-Z0-9_./-]+)},
+ # IP addresses with optional prefix. Not perfectly accurate but good
+ # enough.
+ ipv4 => qr!\b(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(?:/\d{1,2})?)\b!,
+ ipv6 => qr!\b((?:[0-9a-fA-F]{1,4})?(?::+[0-9a-fA-F]{1,4})+(?:/\d{1,3})?)\b!,
);
=head2 HANDLERS
=item B<url> used to open URLs (e.g. in a browser) (C<\&handler_url>)
+=item B<ip> used to handle IPs (C<\&handler_yank>)
+
=back
Example:
yank => \&handler_yank,
paste => \&handler_paste,
url => \&handler_url,
+ ip => \&handler_yank,
);
my %state = (
mapping_mode_path()
mapping_mode_url()
+ mapping_mode_ip()
mapping_mode_search()
mapping_paste()
sub mapping_mode_path { return main::mapping_mode_path(@_); }
sub mapping_mode_url { return main::mapping_mode_url(@_); }
+ sub mapping_mode_ip { return main::mapping_mode_ip(@_); }
sub mapping_mode_search { return main::mapping_mode_search(@_); }
sub mapping_paste { return main::mapping_paste(@_); }