aboutsummaryrefslogtreecommitdiffstats
path: root/ido-mode/ido_switcher.pl
diff options
context:
space:
mode:
authorTom Feist <shabble@metavore.org>2010-12-11 04:43:34 +0000
committerTom Feist <shabble@metavore.org>2010-12-11 04:43:34 +0000
commite00687f266b9c8c8ab8567405e94cb20443fd5e2 (patch)
treec75b038e1a489bd322aad8e1fd43eff193024ae5 /ido-mode/ido_switcher.pl
parentido_switch: support for numerical selection of windows (diff)
downloadirssi-scripts-e00687f266b9c8c8ab8567405e94cb20443fd5e2.tar.gz
irssi-scripts-e00687f266b9c8c8ab8567405e94cb20443fd5e2.zip
ido_switch: C-e toggles selection of only active windows
Diffstat (limited to 'ido-mode/ido_switcher.pl')
-rw-r--r--ido-mode/ido_switcher.pl39
1 files changed, 35 insertions, 4 deletions
diff --git a/ido-mode/ido_switcher.pl b/ido-mode/ido_switcher.pl
index de7bbd9..dc7c542 100644
--- a/ido-mode/ido_switcher.pl
+++ b/ido-mode/ido_switcher.pl
@@ -75,6 +75,8 @@ my @search_matches = ();
my $match_index = 0;
my $search_str = '';
+my $active_only = 0;
+
# /set configurable settings
my $ido_show_count;
@@ -97,7 +99,7 @@ sub _print {
$win->print($str, Irssi::MSGLEVEL_NEVER);
}
-sub _debug_print {
+sub _debug_print {
my $win = Irssi::active_win;
my $str = join('', @_);
$win->print($str, Irssi::MSGLEVEL_CLIENTCRAP);
@@ -184,6 +186,7 @@ sub ido_switch_start {
# refresh in case we toggled it last time.
$ido_use_flex = Irssi::settings_get_bool('ido_use_flex');
+ $active_only = 0;
_debug_print "Win cache: " . join(", ", @window_cache) if DEBUG;
@@ -209,6 +212,7 @@ sub get_all_windows {
type => 'WINDOW',
num => $win->{refnum},
server => $win->{active_server},
+ active => $win->{data_level} > 0,
};
} elsif (scalar @items) {
@@ -219,6 +223,7 @@ sub get_all_windows {
server => $item->{server},
num => $win->{refnum},
itemname => $item->{name},
+ active => $win->{data_level} > 0,
};
}
} else {
@@ -291,14 +296,32 @@ sub update_prompt {
'UP_INNER');
}
+sub _check_active {
+ my ($obj) = @_;
+ return 1 unless $active_only;
+ return $obj->{active};
+}
+
sub update_matches {
if ($search_str =~ m/^\d+$/) {
- @search_matches = grep { $_->{num} == 0+$search_str } @window_cache;
+ @search_matches =
+ grep {
+ _check_active($_)
+ and $_->{num} == 0+$search_str
+ } @window_cache;
} elsif ($ido_use_flex) {
- @search_matches = grep { flex_match($search_str, $_->{name}) } @window_cache;
+ @search_matches =
+ grep {
+ _check_active($_) and
+ flex_match($search_str, $_->{name})
+ } @window_cache;
} else {
- @search_matches = grep { $_->{name} =~ m/\Q$search_str\E/i } @window_cache;
+ @search_matches =
+ grep {
+ _check_active($_)
+ and $_->{name} =~ m/\Q$search_str\E/i
+ } @window_cache;
}
}
@@ -372,6 +395,14 @@ sub handle_keypress {
return;
}
+ if ($key == 5) { # C-e
+ $active_only = not $active_only;
+ Irssi::signal_stop();
+ update_matches();
+ update_prompt();
+ return;
+ }
+
if ($key == 6) { # C-f
$ido_use_flex = not $ido_use_flex;