diff options
author | Simon Ruderich <simon@ruderich.org> | 2010-09-27 16:49:07 +0000 |
---|---|---|
committer | Simon Ruderich <simon@ruderich.org> | 2010-09-27 16:49:07 +0000 |
commit | 4e5bc160e331ac18d9eeb064d5ce7e4a10216891 (patch) | |
tree | aa27f4093e4da32841be14d8bcc6005da4c3e369 /vim-mode/vim_mode.pl | |
parent | vim_mode: Add jj to enter command mode. (diff) | |
download | irssi-scripts-4e5bc160e331ac18d9eeb064d5ce7e4a10216891.tar.gz irssi-scripts-4e5bc160e331ac18d9eeb064d5ce7e4a10216891.zip |
vim_mode: Rename vim_mode_jj to vim_mode_cmd_seq.
This allows any two keys to enable command mode, like jj, aa, etc.
Diffstat (limited to 'vim-mode/vim_mode.pl')
-rw-r--r-- | vim-mode/vim_mode.pl | 22 |
1 files changed, 15 insertions, 7 deletions
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"; + } } } |