From 4e5bc160e331ac18d9eeb064d5ce7e4a10216891 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 27 Sep 2010 18:49:07 +0200 Subject: vim_mode: Rename vim_mode_jj to vim_mode_cmd_seq. This allows any two keys to enable command mode, like jj, aa, etc. --- vim-mode/vim_mode.pl | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'vim-mode') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index b0dfe6a..97c5401 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -1029,18 +1029,26 @@ sub vim_mode_init { Irssi::signal_add 'setup changed' => \&setup_changed; Irssi::statusbar_item_register ('vim_mode', 0, 'vim_mode_cb'); - Irssi::settings_add_bool('vim_mode', 'vim_mode_jj', 0); + Irssi::settings_add_str('vim_mode', 'vim_mode_cmd_seq', ''); setup_changed(); } sub setup_changed { - if (Irssi::settings_get_bool('vim_mode_jj')) { - $imaps->{j} = { 'map' => 'j', - 'func' => sub { _update_mode(M_CMD) } - }; - } else { - delete $imaps->{j}; + my $value; + + # TODO: okay for now, will cause problems when we have more imaps + $imaps = {}; + + $value = Irssi::settings_get_str('vim_mode_cmd_seq'); + if ($value) { + if (length $value == 1) { + $imaps->{$value} = { 'map' => $value, + 'func' => sub { _update_mode(M_CMD) } + }; + } else { + print "Error: vim_mode_cmd_seq must be a single character"; + } } } -- cgit v1.2.3