mirror of
https://github.com/irssi/irssi.git
synced 2024-11-03 04:27:19 -05:00
commit
7978d58202
@ -22,7 +22,7 @@ use Irssi;
|
|||||||
use Irssi::TextUI;
|
use Irssi::TextUI;
|
||||||
use vars qw($VERSION %IRSSI);
|
use vars qw($VERSION %IRSSI);
|
||||||
|
|
||||||
$VERSION = '1.0';
|
$VERSION = '1.1';
|
||||||
%IRSSI = (
|
%IRSSI = (
|
||||||
authors => 'Wouter Coekaerts, Emanuele Giaquinta',
|
authors => 'Wouter Coekaerts, Emanuele Giaquinta',
|
||||||
contact => 'wouter@coekaerts.be, exg@irssi.org',
|
contact => 'wouter@coekaerts.be, exg@irssi.org',
|
||||||
@ -40,49 +40,66 @@ sub cmd_help {
|
|||||||
|
|
||||||
SCROLLBACK SEARCH [-level <level>] [-regexp] [-case] [-word] [-forward] [-all] [<pattern>]
|
SCROLLBACK SEARCH [-level <level>] [-regexp] [-case] [-word] [-forward] [-all] [<pattern>]
|
||||||
|
|
||||||
-level: only search for lines with the given level. see /help levels
|
SEARCH: Search for text in the scrollback buffer.
|
||||||
-regexp: the pattern is a regular expression
|
|
||||||
-case: search case sensitive
|
-regexp: The given text pattern is a regular expression.
|
||||||
-word: pattern must match to full words
|
-case: Performs a case-sensitive matching.
|
||||||
-forward: search forwards (default is backwards)
|
-word: The text must match full words.
|
||||||
-all: search in all windows
|
-forward: Search forwards (default is backwards).
|
||||||
<pattern>: text to search for
|
-all: Search in all windows.
|
||||||
|
|
||||||
|
Without arguments, the last search is repeated.
|
||||||
SCRIPTHELP_EOF
|
SCRIPTHELP_EOF
|
||||||
,MSGLEVEL_CLIENTCRAP);
|
,MSGLEVEL_CLIENTCRAP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $regex;
|
||||||
|
my $all;
|
||||||
|
my $level;
|
||||||
|
|
||||||
sub cmd_sb_search ($$$) {
|
sub cmd_sb_search {
|
||||||
my ($args, $server, $witem) = @_;
|
my ($args, $server, $witem) = @_;
|
||||||
|
|
||||||
### handle options
|
### handle options
|
||||||
|
|
||||||
my ($options, $pattern) = Irssi::command_parse_options('scrollback search', $args);
|
my ($options, $pattern) = Irssi::command_parse_options('scrollback search', $args);
|
||||||
|
|
||||||
my $level;
|
my $forward = defined(delete $options->{forward});
|
||||||
|
|
||||||
|
if (!%$options && !$pattern) {
|
||||||
|
return if !$regex && !defined $level;
|
||||||
|
} else {
|
||||||
|
$all = defined($options->{all});
|
||||||
|
$level = MSGLEVEL_ALL;
|
||||||
|
undef $regex;
|
||||||
|
}
|
||||||
|
|
||||||
if (defined($options->{level})) {
|
if (defined($options->{level})) {
|
||||||
$level = $options->{level};
|
$level = $options->{level};
|
||||||
$level =~ y/,/ /;
|
$level =~ y/,/ /;
|
||||||
$level = Irssi::combine_level(0, $level);
|
$level = Irssi::combine_level(0, $level);
|
||||||
} else {
|
|
||||||
return if (!$pattern);
|
|
||||||
$level = MSGLEVEL_ALL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my $regex;
|
|
||||||
if ($pattern) {
|
if ($pattern) {
|
||||||
my $flags = defined($options->{case}) ? '' : '(?i)';
|
my $flags = defined($options->{case}) ? '' : '(?i)';
|
||||||
my $b = defined($options->{word}) ? '\b' : '';
|
my $b = defined($options->{word}) ? '\b' : '';
|
||||||
if (defined($options->{regexp})) {
|
if (defined($options->{regexp})) {
|
||||||
|
local $@;
|
||||||
|
eval {
|
||||||
$regex = qr/$flags$b$pattern$b/;
|
$regex = qr/$flags$b$pattern$b/;
|
||||||
|
};
|
||||||
|
if ($@) {
|
||||||
|
my ($err) = $@ =~ /^(.*)/;
|
||||||
|
$err =~ s/\sat .* line \d+\.$//;
|
||||||
|
print CLIENTERROR $err;
|
||||||
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$regex = qr/$flags$b\Q$pattern\E$b/;
|
$regex = qr/$flags$b\Q$pattern\E$b/;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my $forward = defined($options->{forward});
|
|
||||||
my $all = defined($options->{all});
|
|
||||||
|
|
||||||
### determine window(s) to search in
|
### determine window(s) to search in
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user