aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Feist <shabble@metavore.org>2011-01-15 04:06:20 +0000
committerTom Feist <shabble@metavore.org>2011-01-15 04:06:20 +0000
commit823e0002921c8e80f6373f271482fc3acc13bdc2 (patch)
tree0178e1ae9ea2dc4a4b097c05d7af39180d81309b
parentchanged it to actually /join rather than /window goto. (diff)
downloadirssi-scripts-823e0002921c8e80f6373f271482fc3acc13bdc2.tar.gz
irssi-scripts-823e0002921c8e80f6373f271482fc3acc13bdc2.zip
bindings: added an example of parsing bindings a'la adv_windowlist. needs some
attributions and cleanup though
-rw-r--r--feature-tests/bindings.pl77
1 files changed, 77 insertions, 0 deletions
diff --git a/feature-tests/bindings.pl b/feature-tests/bindings.pl
new file mode 100644
index 0000000..006eaf1
--- /dev/null
+++ b/feature-tests/bindings.pl
@@ -0,0 +1,77 @@
+use strict;
+use warnings;
+
+
+use Irssi;
+use Irssi::Irc;
+use Irssi::TextUI;
+
+use Data::Dumper;
+
+
+our $VERSION = '0.1';
+our %IRSSI = (
+ authors => 'shabble',
+ contact => 'shabble+irssi@metavore.org',
+ name => '',
+ description => '',
+ licence => q(GNU GPLv2 or later),
+
+ );
+
+# code taken from adv_windowlist
+
+my $keymap;
+
+init();
+
+sub init {
+ update_keymap();
+ Irssi::command_bind('showbinds', 'cmd_showbinds');
+}
+
+sub cmd_showbinds {
+ my ($args, @rest) = @_;
+
+ my $win = Irssi::active_win();
+ $win->print("Change window bindings:", Irssi::MSGLEVEL_CLIENTCRAP);
+ for my $w (sort keys %$keymap) {
+ my $x = $keymap->{$w};
+ $win->print("$w ==> $x", Irssi::MSGLEVEL_CLIENTCRAP);
+ }
+ $win->print("Done showing window bindings:", Irssi::MSGLEVEL_CLIENTCRAP);
+
+}
+sub get_keymap {
+ my ($text_dest, $str, $str_stripped) = @_;
+
+ if ($text_dest->{level} == Irssi::MSGLEVEL_CLIENTCRAP and $text_dest->{target} eq '') {
+ if (not defined($text_dest->{'server'})) {
+ if ($str_stripped =~ m/((?:meta-)+)(.)\s+change_window (\d+)/) {
+ my ($level, $key, $window) = ($1, $2, $3);
+ #my $numlevel = ($level =~ y/-//) - 1;
+ my $kk = $level . $key;
+ $keymap->{$kk} = $window;
+ }
+ Irssi::signal_stop();
+ }
+ }
+}
+
+sub update_keymap {
+ $keymap = {};
+ Irssi::signal_remove('command bind' => 'watch_keymap');
+ Irssi::signal_add_first('print text' => 'get_keymap');
+ Irssi::command('bind'); # stolen from grep
+ Irssi::signal_remove('print text' => 'get_keymap');
+ Irssi::signal_add('command bind' => 'watch_keymap');
+ #Irssi::timeout_add_once(100, 'eventChanged', undef);
+}
+
+# watch keymap changes
+sub watch_keymap {
+ Irssi::timeout_add_once(1000, 'update_keymap', undef);
+}
+
+
+