From 38081597b2887cfdf67cc73f6a10e70189e8d045 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Sat, 19 Feb 2011 12:37:13 +0000 Subject: fixed deprecated warning on defined (%hash) --- vim-mode/vim_mode.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'vim-mode') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 7d898ab..d850d63 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -618,7 +618,7 @@ sub script_is_loaded { my $name = shift; print "Checking if $name is loaded" if DEBUG; no strict 'refs'; - my $retval = defined %{ "Irssi::Script::${name}::" }; + my $retval = %{ "Irssi::Script::${name}::" }; use strict 'refs'; return $retval; -- cgit v1.2.3 From 938de29a3b8a85b3639abd8db5c6821b1d4f54f7 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Sat, 19 Feb 2011 12:37:33 +0000 Subject: added input.txt where we can plan how the new input system will work --- vim-mode/input.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 vim-mode/input.txt (limited to 'vim-mode') diff --git a/vim-mode/input.txt b/vim-mode/input.txt new file mode 100644 index 0000000..cc32a3b --- /dev/null +++ b/vim-mode/input.txt @@ -0,0 +1,4 @@ +How the input system for vim_mode should work. +============================================= + + -- cgit v1.2.3 From ef943af836d4648d9bbb6aca7355db1de2812b6f Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sat, 19 Feb 2011 13:58:32 +0100 Subject: input.txt: Add some general ideas. --- vim-mode/input.txt | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'vim-mode') diff --git a/vim-mode/input.txt b/vim-mode/input.txt index cc32a3b..040fb44 100644 --- a/vim-mode/input.txt +++ b/vim-mode/input.txt @@ -1,4 +1,21 @@ How the input system for vim_mode should work. ============================================= - +- insert mode mappings +- normal mode mappings +- timeout for ambiguous mappings + - but support for no timeout for some mappings (like Ctrl-R in insert mode) +- maybe 'timeout' and 'ttimeout' settings (and 'timeoutlen' and 'ttimeoutlen') +- partial commands/mappings (like :map a :b a which inserts ex mode and + displays :b a there without running any command) +- support for mappings entering insert mode: :map gX itexthere (also + without esc!) +- . for all (most) commands +- more general command order: 3"ap doesn't work but "a3p does +- arbitrary mappings, like 3dwjjihi10G (at the moment even :map Y y$ + doesn't work) +- support to disable mappings temporarily (:set paste, 'pastetoggle') +- (better) support multiple bindings for the same action (especially and + ) +- unmapping of internal mappings (for example to as it's also used + for colors in irssi) -- cgit v1.2.3 From 43e4fff44a9b6293e5483b6739c17a42d3bb1346 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Sat, 19 Feb 2011 13:33:35 +0000 Subject: added some detail on FSM for input control, and how to detect sequences. --- vim-mode/input.txt | 73 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 55 insertions(+), 18 deletions(-) (limited to 'vim-mode') diff --git a/vim-mode/input.txt b/vim-mode/input.txt index 040fb44..790060a 100644 --- a/vim-mode/input.txt +++ b/vim-mode/input.txt @@ -1,21 +1,58 @@ How the input system for vim_mode should work. ============================================= -- insert mode mappings -- normal mode mappings -- timeout for ambiguous mappings - - but support for no timeout for some mappings (like Ctrl-R in insert mode) -- maybe 'timeout' and 'ttimeout' settings (and 'timeoutlen' and 'ttimeoutlen') -- partial commands/mappings (like :map a :b a which inserts ex mode and - displays :b a there without running any command) -- support for mappings entering insert mode: :map gX itexthere (also - without esc!) -- . for all (most) commands -- more general command order: 3"ap doesn't work but "a3p does -- arbitrary mappings, like 3dwjjihi10G (at the moment even :map Y y$ - doesn't work) -- support to disable mappings temporarily (:set paste, 'pastetoggle') -- (better) support multiple bindings for the same action (especially and - ) -- unmapping of internal mappings (for example to as it's also used - for colors in irssi) +* insert mode mappings +* normal (command) mode mappings +* timeout for ambiguous mappings +** but support for no timeout for some mappings (like Ctrl-R in insert mode) +* maybe 'timeout' and 'ttimeout' settings (and 'timeoutlen' and 'ttimeoutlen') +* partial commands/mappings (like :map a :b a which inserts ex mode and +* displays :b a there without running any command) +* support for mappings entering insert mode: :map gX itexthere (also without esc!) +** (.) (repeat) for all (most) commands +* more general command order: 3"ap doesn't work but "a3p does +* arbitrary mappings, like 3dwjjihi10G (at the moment even :map Y y$ doesn't work) +* support to disable mappings temporarily (:set paste, 'pastetoggle') +* (better) support multiple bindings for the same action (especially and ) +* unmapping of internal mappings (for example to as it's also used for colors in irssi) +* better approach to detecting single ESC push (compared to F-keys or meta-* keys) + +We base the input model on a simple state machine. +It can exist in any of 4 (5) states: + - insert mode + - insert escape mode + a transitional mode to distingush that we've received an escape char. + - command mode + - ex mode + - visual mode (can be mostly ignored for now, until I sort my overlays stuff + out) + +to swap between these modes, there are various bindings available. +The most challenging is going from insert -> command. Typically this is done +by a single push of the key, but C-c and are both alternatives that +people use. + +The single entrypoint we have into the input system is detecting keystrokes. +when a 'gui key pressed' signal is fired, we can receive, process and interrupt +it such that it never gets passed to irssi proper. + +in order to detect single presses from their meta comrades, we operate +as the following: + +if (key == 27) { + mode = insert_escape + add_timeout(short, check_escape_buffer) +} elsif (mode == insert_escape) { + insert(key, escape_buffer) +} else { + # do nothing +} + +sub check_escape_buffer { +# when the timeout fires, we can assume that only meta-keys would be fast enough +# to insert additional characters into the buffer. In which case, we replay +# them and clear the buffer. + mode = insert_mode; +# if the buffer is otherwise empty, we have received a single escape press. + mode = command_mode; +} -- cgit v1.2.3 From b609b6633ccf1cf25872d3171872001ec23fea73 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Thu, 24 Feb 2011 02:00:40 +0000 Subject: defined check to prevent a warning in flush_input_buffer() [thanks DE1] --- vim-mode/vim_mode.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'vim-mode') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index d850d63..7f4832e 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -2414,7 +2414,7 @@ sub handle_input_buffer { } sub flush_input_buffer { - Irssi::timeout_remove($input_buf_timer); + Irssi::timeout_remove($input_buf_timer) if defined $input_buf_timer; $input_buf_timer = undef; # see what we've collected. print "Input buffer flushed" if DEBUG; -- cgit v1.2.3 From 5bb2c4214f48083eb896441fd22e18e38ef66da2 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Tue, 1 Mar 2011 02:43:37 +0100 Subject: vim-mode: Add irssi configuration directory used for testing. Contains default configuration with vim-mode statusbars. --- vim-mode/irssi/config | 38 ++++++++++++++++++++++++++++ vim-mode/irssi/scripts/autorun/uberprompt.pl | 1 + vim-mode/irssi/scripts/autorun/vim_mode.pl | 1 + 3 files changed, 40 insertions(+) create mode 100644 vim-mode/irssi/config create mode 120000 vim-mode/irssi/scripts/autorun/uberprompt.pl create mode 120000 vim-mode/irssi/scripts/autorun/vim_mode.pl (limited to 'vim-mode') diff --git a/vim-mode/irssi/config b/vim-mode/irssi/config new file mode 100644 index 0000000..d0b0805 --- /dev/null +++ b/vim-mode/irssi/config @@ -0,0 +1,38 @@ +# Minimal default irssi configuration file - with vim-mode statusbars. + + +servers = ( ); + +chatnets = { }; + +channels = ( ); + +aliases = { }; + +statusbar = { + default = { + window = { + items = { + barstart = { priority = "100"; }; + time = { }; + user = { }; + window = { }; + window_empty = { }; + lag = { priority = "-1"; }; + act = { priority = "10"; }; + more = { priority = "-1"; alignment = "right"; }; + barend = { priority = "100"; alignment = "right"; }; + vim_mode = { }; + vim_windows = { }; + }; + }; + + prompt = { + items = { + uberprompt = { priority = "-1"; }; + input = { priority = "10"; }; + }; + position = "100"; + }; + }; +}; diff --git a/vim-mode/irssi/scripts/autorun/uberprompt.pl b/vim-mode/irssi/scripts/autorun/uberprompt.pl new file mode 120000 index 0000000..3d4d97a --- /dev/null +++ b/vim-mode/irssi/scripts/autorun/uberprompt.pl @@ -0,0 +1 @@ +../../../../prompt_info/uberprompt.pl \ No newline at end of file diff --git a/vim-mode/irssi/scripts/autorun/vim_mode.pl b/vim-mode/irssi/scripts/autorun/vim_mode.pl new file mode 120000 index 0000000..ed78131 --- /dev/null +++ b/vim-mode/irssi/scripts/autorun/vim_mode.pl @@ -0,0 +1 @@ +../../../../vim-mode/vim_mode.pl \ No newline at end of file -- cgit v1.2.3 From 38b08f34d836a13f7ac9bbb5bdd516dd9d94fb5f Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Tue, 1 Mar 2011 03:19:59 +0100 Subject: vim-mode: Add tests.pl. --- vim-mode/tests.pl | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 vim-mode/tests.pl (limited to 'vim-mode') diff --git a/vim-mode/tests.pl b/vim-mode/tests.pl new file mode 100644 index 0000000..2a85b29 --- /dev/null +++ b/vim-mode/tests.pl @@ -0,0 +1,48 @@ +#!/usr/bin/perl + +# Must be run in a 80x24 terminal unless a fixed POE is released. + + +use strict; +use warnings; + +use lib '../testing/blib/lib'; + +use Test::Irssi; + + +sub statusbar_mode { + my ($test, $mode) = @_; + + $test->add_pattern_match(qr/^ \[\d{2}:\d{2}\] \[\] \[1\] \[$mode\]\s+$/, + 'window_sbar', "[$mode] in vim-mode statusbar"); +} + +my $tester = Test::Irssi->new + (irssi_binary => "irssi", + irssi_homedir => "irssi"); + + +my $test; + + +$test = $tester->new_test('insert-command-mode'); + +# Make sure irssi is finished - not entirely sure why this is necessary. +$test->add_delay(3); + +# We start in insert mode. +statusbar_mode($test, 'Insert'); + +$test->add_input_sequence("\e"); +$test->add_delay(1); +statusbar_mode($test, 'Command'); + +$test->add_input_sequence("i"); +$test->add_delay(1); +statusbar_mode($test, 'Insert'); + +# Quit irssi, necessary to terminate the test. +$test->add_input_sequence("\n/quit\n"); + +$tester->run; -- cgit v1.2.3 From 4e35bc22e052bd4ef74b8ad2d23f2b1a6e51fc7d Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Fri, 4 Mar 2011 01:23:30 +0000 Subject: vim-mode/vim_mode: make :mapped commands use appropriate context when calling irssi commands. --- vim-mode/vim_mode.pl | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'vim-mode') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 7f4832e..551fbb6 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -2537,13 +2537,7 @@ sub handle_command_cmd { } elsif ($cmd->{type} == C_IRSSI) { print "Processing irssi-command: $map->{char} ($cmd->{char})" if DEBUG; - # TODO: fix me more better (general server/win/none context?) - my $server = Irssi::active_server; - if (defined $server) { - $server->command($cmd->{func}); - } else { - Irssi::command($cmd->{func}); - } + _command_with_context($cmd->{func}); $numeric_prefix = undef; return 1; # call _stop(); @@ -3206,3 +3200,29 @@ sub _warn { print '%_vim_mode: ', $warning, '%_'; } + +sub _command_with_context { + my ($command) = @_; + my $context; + my $window = Irssi::active_win; + if (defined $window) { + my $witem = $window->{active}; + if (defined $witem and ref($witem) eq 'Irssi::Windowitem') { + $context = $witem; + } else { + $context = $window; + } + } else { + my $server = Irssi::active_server; + if (defined $server) { + $context = $server; + } + } + if (defined $context) { + print "Command $command Using context: " . ref($context) if DEBUG; + $context->command($command); + } else { + print "Command $command has no context" if DEBUG; + Irssi::command($command); + } +} -- cgit v1.2.3 From 5df2b67f2cbef974c59c5d91d1937ea6e99b3ae9 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sat, 5 Mar 2011 02:49:58 +0100 Subject: vim-mode/tests.pl: Add first real tests: h l 0 ^ $ f t. Merge testing/tests/003-vim-mode.t with vim-mode/tests.pl and remove it from testing/. --- vim-mode/tests.pl | 155 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 139 insertions(+), 16 deletions(-) (limited to 'vim-mode') diff --git a/vim-mode/tests.pl b/vim-mode/tests.pl index 2a85b29..9007171 100644 --- a/vim-mode/tests.pl +++ b/vim-mode/tests.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # Must be run in a 80x24 terminal unless a fixed POE is released. @@ -10,6 +10,10 @@ use lib '../testing/blib/lib'; use Test::Irssi; +# Mode constants: C(ommand), I(nsert). +sub C () { 0 } +sub I () { 1 } + sub statusbar_mode { my ($test, $mode) = @_; @@ -17,32 +21,151 @@ sub statusbar_mode { $test->add_pattern_match(qr/^ \[\d{2}:\d{2}\] \[\] \[1\] \[$mode\]\s+$/, 'window_sbar', "[$mode] in vim-mode statusbar"); } +sub cursor_position { + my ($test, $position) = @_; -my $tester = Test::Irssi->new - (irssi_binary => "irssi", - irssi_homedir => "irssi"); + $test->test_cursor_position($position, 24, "Checking cursor position"); +} +sub check { + my ($test, $input, $mode, $position, $delay) = @_; + + if (defined $input) { + $test->add_input_sequence($input); + if (not defined $delay) { + $delay = 0.1; + $delay += 0.4 if $input =~ /\e/; # esc needs a longer delay + } + $test->add_delay($delay); + } + + cursor_position($test, $position); + if ($mode == C) { + statusbar_mode($test, 'Command'); + } elsif ($mode == I) { + statusbar_mode($test, 'Insert'); + } else { + die "Wrong mode: $mode"; + } +} -my $test; +my $tester = Test::Irssi->new + (irssi_binary => "irssi", + irssi_homedir => "./irssi/"); -$test = $tester->new_test('insert-command-mode'); +$tester->run_headless(1); +$tester->generate_tap(1); +my $test = $tester->new_test('insert-command-mode'); +$test->description("switching between insert and command mode"); # Make sure irssi is finished - not entirely sure why this is necessary. -$test->add_delay(3); +$test->add_delay(2); # We start in insert mode. -statusbar_mode($test, 'Insert'); - -$test->add_input_sequence("\e"); -$test->add_delay(1); -statusbar_mode($test, 'Command'); - -$test->add_input_sequence("i"); -$test->add_delay(1); -statusbar_mode($test, 'Insert'); +check $test, undef, I, 12 + 0; +check $test, "\e", C, 12 + 0; +check $test, 'i', I, 12 + 0; # Quit irssi, necessary to terminate the test. +#$test->add_input_sequence("\n/quit\n"); + + +# FIXME: multiple tests don't work +#$test = $tester->new_test('basic-movement'); +#$test->description('basic movement'); +#$test->add_delay(2); + +my $test_string = + 'Test $tring. with a 4711, words , w.r#s42 etc. and more123! ..'; + +check $test, $test_string, I, 12 + length $test_string; +check $test, "\e", C, 12 + 64; + +# h l +check $test, "0", C, 12 + 0; +check $test, "l", C, 12 + 1; +check $test, "l", C, 12 + 2; +check $test, "l", C, 12 + 3; +check $test, "l", C, 12 + 4; +check $test, "l", C, 12 + 5; +check $test, "l", C, 12 + 6; +check $test, "l", C, 12 + 7; +check $test, "h", C, 12 + 6; +check $test, "h", C, 12 + 5; +check $test, "h", C, 12 + 4; +check $test, "h", C, 12 + 3; +check $test, "h", C, 12 + 2; +check $test, "10l", C, 12 + 12; +check $test, "7l", C, 12 + 19; +check $test, "3l", C, 12 + 22; +check $test, "3h", C, 12 + 19; +check $test, "50l", C, 12 + 64; +check $test, "10l", C, 12 + 64; +check $test, "24h", C, 12 + 40; +check $test, "100h", C, 12 + 0; + +# 0 ^ $ +check $test, "I \e", C, 12 + 4; # insert test string for ^ +check $test, "0", C, 12 + 0; +check $test, "^", C, 12 + 5; +check $test, "3^", C, 12 + 5; +check $test, "12^", C, 12 + 5; +check $test, "\$", C, 12 + 46; +check $test, "05x", C, 12 + 0; # remove test string for ^ + +# +check $test, "0", C, 12 + 0; +check $test, " ", C, 12 + 1; +check $test, " ", C, 12 + 2; +check $test, " ", C, 12 + 3; +check $test, " ", C, 12 + 4; +check $test, " ", C, 12 + 5; +check $test, " ", C, 12 + 6; +check $test, " ", C, 12 + 7; +check $test, " ", C, 12 + 8; +check $test, "5 ", C, 12 + 13; +check $test, "2 ", C, 12 + 15; +check $test, "10 ", C, 12 + 25; +check $test, "30 ", C, 12 + 55; +check $test, "20 ", C, 12 + 64; +check $test, "10 ", C, 12 + 64; +check $test, " ", C, 12 + 64; +check $test, "\x7f", C, 12 + 63; +check $test, "\x7f", C, 12 + 62; +check $test, "\x7f", C, 12 + 61; +check $test, "\x7f", C, 12 + 60; +check $test, "1\x7f", C, 12 + 59; +check $test, "3\x7f", C, 12 + 56; +check $test, "5\x7f", C, 12 + 51; +check $test, "10\x7f", C, 12 + 41; +check $test, "50\x7f", C, 12 + 0; +check $test, "\x7f", C, 12 + 0; +check $test, "5\x7f", C, 12 + 0; + +# f t +check $test, "0", C, 12 + 0; +check $test, "fe", C, 12 + 1; +check $test, "fs", C, 12 + 2; +check $test, "ft", C, 12 + 3; +check $test, "f ", C, 12 + 4; +check $test, "2f ", C, 12 + 17; +check $test, "5f,", C, 12 + 17; +check $test, "2f,", C, 12 + 32; +check $test, "tw", C, 12 + 33; +check $test, "t ", C, 12 + 40; +check $test, "t ", C, 12 + 40; +check $test, "t ", C, 12 + 40; +check $test, "2t ", C, 12 + 41; +check $test, "2t ", C, 12 + 46; +check $test, "3t ", C, 12 + 48; +check $test, "t!", C, 12 + 60; +check $test, "t ", C, 12 + 61; +check $test, "t.", C, 12 + 62; +check $test, "t.", C, 12 + 62; +check $test, "5t.", C, 12 + 62; +check $test, "\$", C, 12 + 64; + $test->add_input_sequence("\n/quit\n"); $tester->run; -- cgit v1.2.3 From 8a8ba2c51eadbc0a7ce0236ba6a04dd081f657e2 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Fri, 1 Apr 2011 06:43:04 +0100 Subject: modify all scripts to use the new script_is_loaded() function, since newer versions of perl get upset at defined(%hash). --- vim-mode/vim_mode.pl | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'vim-mode') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 551fbb6..2916ca9 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -615,13 +615,7 @@ my $completion_active = 0; my $completion_string = ''; sub script_is_loaded { - my $name = shift; - print "Checking if $name is loaded" if DEBUG; - no strict 'refs'; - my $retval = %{ "Irssi::Script::${name}::" }; - use strict 'refs'; - - return $retval; + return exists($Irssi::Script::{shift . '::'}); } vim_mode_init(); -- cgit v1.2.3 From 9d3ae67bc02cdba86a5ed0fb2470483118e239db Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Wed, 6 Apr 2011 09:16:44 +0100 Subject: vim-mode: modify init sequence to bind (default) commands after settings are loaded, otherwise lots of undef errors --- vim-mode/vim_mode.pl | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'vim-mode') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 2916ca9..c5a06cb 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -499,11 +499,6 @@ my $commands_ex # default command mode mappings my $maps = {}; -# Add all default mappings. -foreach my $char (keys %$commands) { - next if $char =~ /^_/; # skip private commands (text-objects for now) - add_map($char, $commands->{$char}); -} # GLOBAL VARIABLES @@ -618,7 +613,7 @@ sub script_is_loaded { return exists($Irssi::Script::{shift . '::'}); } -vim_mode_init(); + # INSERT MODE COMMANDS @@ -2782,7 +2777,6 @@ sub _tab_complete { sub vim_mode_init { Irssi::signal_add_first 'gui key pressed' => \&got_key; - Irssi::signal_add 'setup changed' => \&setup_changed; Irssi::statusbar_item_register ('vim_mode', 0, 'vim_mode_cb'); Irssi::statusbar_item_register ('vim_windows', 0, 'b_windows_cb'); @@ -2791,6 +2785,16 @@ sub vim_mode_init { _setting_register($name); } + setup_changed(); + + Irssi::signal_add 'setup changed' => \&setup_changed; + + # Add all default mappings. + foreach my $char (keys %$commands) { + next if $char =~ /^_/; # skip private commands (text-objects for now) + add_map($char, $commands->{$char}); + } + # Load the vim_moderc file if it exists. ex_source('source'); @@ -3220,3 +3224,5 @@ sub _command_with_context { Irssi::command($command); } } + +vim_mode_init(); -- cgit v1.2.3 From f3c909fdf09a49d36ecc664e0ae72fb8c71d2f3c Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Wed, 6 Apr 2011 10:15:36 +0100 Subject: vim_mode: minor cleanup of constants --- vim-mode/vim_mode.pl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'vim-mode') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index c5a06cb..ab74bc6 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -267,24 +267,24 @@ sub M_CMD () { 1 } # insert mode sub M_INS () { 0 } # extended mode (after a :?) -sub M_EX () { 2 } +sub M_EX () { 2 } # operator command -sub C_OPERATOR () { 0 } +sub C_OPERATOR () { 0 } # normal command, no special handling necessary -sub C_NORMAL () { 1 } +sub C_NORMAL () { 1 } # command taking another key as argument -sub C_NEEDSKEY () { 2 } +sub C_NEEDSKEY () { 2 } # text-object command (i a) sub C_TEXTOBJECT () { 3 } # commands entering insert mode -sub C_INSERT () { 4 } +sub C_INSERT () { 4 } # ex-mode commands -sub C_EX () { 5 } +sub C_EX () { 5 } # irssi commands -sub C_IRSSI () { 6 } +sub C_IRSSI () { 6 } # does nothing -sub C_NOP () { 7 } +sub C_NOP () { 7 } # setting types, match irssi types as they are stored as irssi settings sub S_BOOL () { 0 } -- cgit v1.2.3 From a2c61a97ea075240b84643946e3a736d225dd3b6 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Wed, 6 Apr 2011 10:18:40 +0100 Subject: vim_mode: added history support to Ex mode. Can be scrolled backwards and forwards using the arrow keys, and :eh shows the current history. --- vim-mode/vim_mode.pl | 144 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 127 insertions(+), 17 deletions(-) (limited to 'vim-mode') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index ab74bc6..b43185f 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -423,6 +423,16 @@ my $commands # All available commands in Ex-Mode. my $commands_ex = { + # arrow keys - not actually used, see handle_input_buffer() + + "\e[A" => { char => ':exprev', func => \&ex_history_back, + type => C_EX }, + "\e[B" => { char => ':exnext', func => \&ex_history_fwd, + type => C_EX }, + + # normal Ex mode commands. + eh => { char => ':exhist', func => \&ex_history_show, + type => C_EX }, s => { char => ':s', func => \&ex_substitute, type => C_EX }, bnext => { char => ':bnext', func => \&ex_bnext, @@ -515,6 +525,8 @@ my $settings start_cmd => { type => S_BOOL, value => 0 }, # not used yet max_undo_lines => { type => S_INT, value => 50 }, + # size of history buffer for Ex mode. + ex_history_size => { type => S_INT, value => 100 }, # prompt_leading_space prompt_leading_space => { type => S_BOOL, value => 1 }, }; @@ -536,6 +548,10 @@ my $should_ignore = 0; # ex mode buffer my @ex_buf; +# ex mode history storage. +my @ex_history; +my $ex_history_index = 0; + # we are waiting for another mapped key (e.g. g pressed, but there are # multiple mappings like gg gE etc.) my $pending_map = undef; @@ -1629,6 +1645,10 @@ sub cmd_ex_command { return _warn("Ex-mode $1$2 doesn't exist!"); } + # add this item to the ex mode history + ex_history_add($arg_str); + $ex_history_index = 0; # and reset the history position. + my $count = $1; if ($count eq '') { $count = undef; @@ -2378,20 +2398,33 @@ sub handle_input_buffer { _update_mode(M_CMD); } else { - # we need to identify what we got, and either replay it - # or pass it off to the command handler. - # if ($mode == M_CMD) { - # # command - # my $key_str = join '', map { chr } @input_buf; - # if ($key_str =~ m/^\e\[([ABCD])/) { - # print "Arrow key: $1" if DEBUG; - # } else { - # print "Dunno what that is." if DEBUG; - # } - # } else { - # _emulate_keystrokes(@input_buf); - # } - _emulate_keystrokes(@input_buf); + # we have more than a single esc, implying an escape sequence + # (meta-* or esc-*) + + # currently, we only extract escape sequences if: + # a) we're in ex mode + # b) they're arrow keys (for history control) + + if ($mode == M_EX) { + # ex mode + my $key_str = join '', map { chr } @input_buf; + if ($key_str =~ m/^\e\[([ABCD])/) { + my $arrow = $1; + _debug( "Arrow key: $arrow"); + if ($arrow eq 'A') { # up + ex_history_back(); + } elsif ($arrow eq 'B') { # down + ex_history_fwd(); + } else { + $arrow =~ s/C/right/; + $arrow =~ s/D/left/; + _debug("Arrow key $arrow not supported"); + } + } + } else { + # otherwise, we just forward them to irssi. + _emulate_keystrokes(@input_buf); + } # Clear insert buffer, pressing "special" keys (like arrow keys) # resets it. @@ -2729,7 +2762,7 @@ sub handle_command_ex { # DEL key - remove last character if ($key == 127) { print "Delete" if DEBUG; - if (scalar @ex_buf > 0) { + if (@ex_buf > 0) { pop @ex_buf; _set_prompt(':' . join '', @ex_buf); # Backspacing over : exits ex-mode. @@ -2749,12 +2782,15 @@ sub handle_command_ex { @tab_candidates = _tab_complete(join('', @ex_buf), [keys %$commands_ex]); # Ignore control characters for now. - } elsif ($key < 32) { + } elsif ($key > 0 && $key < 32) { # TODO: use them later, e.g. completion # Append entered key } else { - push @ex_buf, chr $key; + if ($key != -1) { + # check we're not called from an ex_history_* function + push @ex_buf, chr $key; + } _set_prompt(':' . join '', @ex_buf); } @@ -3199,6 +3235,14 @@ sub _warn { print '%_vim_mode: ', $warning, '%_'; } +sub _debug { + return unless DEBUG; + + my ($format, @args) = @_; + my $str = sprintf($format, @args); + print $str; +} + sub _command_with_context { my ($command) = @_; my $context; @@ -3225,4 +3269,70 @@ sub _command_with_context { } } +sub ex_history_add { + my ($line) = @_; + + # check it's not an exact dupe of the previous history line + + my $last_hist = $ex_history[$ex_history_index]; + $last_hist = '' unless defined $last_hist; + + return if $last_hist eq $line; + + _debug("Adding $line to ex command history"); + + # add it to the history + unshift @ex_history, $line; + + if ($settings->{ex_history_size}->{value} < @ex_history) { + pop @ex_history; # junk the last entry if we've hit the max. + } +} + +sub ex_history_fwd { + + my $hist_max = $#ex_history; + $ex_history_index++; + if ($ex_history_index > $hist_max) { + $ex_history_index = 0; + _debug("ex history hit top, wrapping to 0"); + } + + my $line = $ex_history[$ex_history_index]; + $line = '' if not defined $line; + + _debug("Ex history line: $line"); + + @ex_buf = split '', $line; + handle_command_ex(-1); +} + +sub ex_history_back { + my $hist_max = $#ex_history; + $ex_history_index--; + if ($ex_history_index == -1) { + $ex_history_index = $hist_max; + _debug("ex history hit bottom, wrapping to $hist_max"); + + } + + my $line = $ex_history[$ex_history_index]; + $line = '' if not defined $line; + + _debug("Ex history line: $line"); + @ex_buf = split '', $line; + handle_command_ex(-1); + +} + +sub ex_history_show { + my $win = Irssi::active_win(); + $win->print("Ex command history:"); + for my $i (0 .. $#ex_history) { + my $flag = $i == $ex_history_index + ? ' <' + : ''; + $win->print("$i " . $ex_history[$i] . $flag); + } +} vim_mode_init(); -- cgit v1.2.3 From 4788aac670b70cf5799bb8c8c8444ec69373547b Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Wed, 6 Apr 2011 10:28:27 +0100 Subject: vim_mode: fix ambiguous shift warning. --- vim-mode/vim_mode.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'vim-mode') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index b43185f..a731269 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -626,7 +626,7 @@ my $completion_active = 0; my $completion_string = ''; sub script_is_loaded { - return exists($Irssi::Script::{shift . '::'}); + return exists($Irssi::Script::{shift(@_) . '::'}); } -- cgit v1.2.3 From 0678c97345df117c61c5517a841f4c13094a7a77 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Wed, 6 Apr 2011 10:48:15 +0100 Subject: vim_mode: ex_hist documentation additions and cleanup. --- vim-mode/vim_mode.pl | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'vim-mode') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index a731269..e247e35 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -60,6 +60,8 @@ # # Ex-mode supports (activated by : in command mode) the following commands: # +# * Command History: , +# :eh - show ex history # * Switching buffers: :[N]b [N] - switch to channel number # :b# - switch to last channel # :b @@ -115,10 +117,16 @@ # (prepend vim_mode_ to setting name) or using the :set ex-command. The # following settings are available: # -# * utf8: support UTF-8 characters, boolean, default on -# * debug: enable debug output, boolean, default off -# * cmd_seq: char that when double-pressed simulates , string, default '' -# * start_cmd: start every line in command mode, boolean, default off +# * utf8: support UTF-8 characters, boolean, default on +# * debug: enable debug output, boolean, default off +# * cmd_seq: char that when double-pressed simulates , +# string, default '' +# * start_cmd: start every line in command mode, boolean, default off +# * max_undo_lines: size of the undo buffer. Integer, default 50 items. +# * ex_history_size: number of items stored in the ex-mode history. +# Integer, default 100. +# * prompt_leading_space: determines whether ex mode prepends a space to the +# displayed input. Boolean, default on # # In contrast to irssi's settings, :set accepts 0 and 1 as values for boolean # settings, but only vim_mode's settings can be set/displayed. @@ -150,8 +158,8 @@ # # Installation: # -# As always copy the script into .irssi/scripts and load it with -# /script load # vim_mode.pl +# As always, copy the script into .irssi/scripts and load it with +# /script load vim_mode.pl # # Use the following command to get a statusbar item that shows which mode # you're in. @@ -165,7 +173,7 @@ # # Dependencies: # -# For proper :ex mode support, requires the installation of uberprompt.pl +# For proper :ex mode support, vim-mode requires the installation of uberprompt.pl # Uberprompt can be downloaded from: # # http://github.com/shabble/irssi-scripts/raw/master/prompt_info/uberprompt.pl @@ -208,6 +216,7 @@ # # * estragib: a lot of testing and many bug reports and feature requests # * iaj: testing +# * tmr: explaining how various bits of vim work # # LICENCE: # -- cgit v1.2.3 From 4d83ae6e3f6044e3e4c9bf1d87054c13ce5751a6 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Wed, 6 Apr 2011 11:18:11 +0100 Subject: vim_mode: C-c cancels ex mode. Start of variable support. --- vim-mode/vim_mode.pl | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'vim-mode') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index e247e35..d04324e 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -538,6 +538,8 @@ my $settings ex_history_size => { type => S_INT, value => 100 }, # prompt_leading_space prompt_leading_space => { type => S_BOOL, value => 1 }, + # value for prepending to commands. + map_leader => { type => S_STR, value => '\\' }, }; sub DEBUG { $settings->{debug}->{value} } @@ -2040,6 +2042,7 @@ sub _parse_mapping { my ($string) = @_; $string =~ s/<([^>]+)>/_parse_mapping_bracket($1)/ge; + _warn("Parse mapping: $string"); if (index($string, '') != -1) { return undef; } @@ -2065,6 +2068,8 @@ sub _parse_mapping_bracket { # } elsif ($string eq 'bs') { $string = chr(127); + } elsif ($string eq 'leader') { + $string = $settings->{map_leader}->{value}; # Invalid char, return special string to recognize the error. } else { $string = ''; @@ -2074,6 +2079,9 @@ sub _parse_mapping_bracket { sub _parse_mapping_reverse { my ($string) = @_; + my $escaped_leader = quotemeta($settings->{map_leader}->{value}); + $string =~ s/$escaped_leader//g; + # Convert char to . $string =~ s/ //g; $string =~ s/\n//g; @@ -2088,6 +2096,9 @@ sub _parse_mapping_reverse { sub _parse_partial_command_reverse { my ($string) = @_; + my $escaped_leader = quotemeta($settings->{map_leader}->{value}); + $string =~ s/$escaped_leader//g; + # Convert Ctrl-X to ^X. $string =~ s/([\x01-\x1A])/"^" . chr(ord($1) + 64)/ge; # Convert Ctrl-6 and Ctrl-^ to . @@ -2327,8 +2338,8 @@ sub got_key { $input_buf_timer = Irssi::timeout_add_once(10, \&handle_input_buffer, undef); print "Buffer Timer tag: $input_buf_timer" if DEBUG; - } elsif ($mode == M_INS) { - if ($key == 3) { # Ctrl-C enter command mode + } elsif ($mode == M_INS or $mode == M_EX) { + if ($key == 3) { # Ctrl-C enters command mode, or cancels ex mode. _update_mode(M_CMD); _stop(); return; @@ -3032,7 +3043,7 @@ sub delete_map { } push @add, $keys; - # Restore default keybindings in case we :unmaped a or a remapped + # Restore default keybindings in case we :unmapped a or a remapped # key. foreach my $key (@add) { if (exists $commands->{$key}) { -- cgit v1.2.3 From 05c157bad1b47d1e861708c581c5c2620909d007 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Thu, 7 Apr 2011 00:47:47 +0100 Subject: vim-mode/vim_mode: cleanup of commands, and fix bug preventing ex mode from working (oops). --- vim-mode/vim_mode.pl | 78 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 32 deletions(-) (limited to 'vim-mode') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index d04324e..906905f 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -319,19 +319,19 @@ my $commands repeatable => 1 }, # arrow like movement - h => { char => 'h', func => \&cmd_h, type => C_NORMAL }, - l => { char => 'l', func => \&cmd_l, type => C_NORMAL }, + h => { char => 'h', func => \&cmd_h, type => C_NORMAL }, + l => { char => 'l', func => \&cmd_l, type => C_NORMAL }, "\x7F" => { char => '', func => \&cmd_h, type => C_NORMAL }, ' ' => { char => '', func => \&cmd_l, type => C_NORMAL }, # history movement - j => { char => 'j', func => \&cmd_j, type => C_NORMAL, - no_operator => 1 }, - k => { char => 'k', func => \&cmd_k, type => C_NORMAL, - no_operator => 1 }, - gg => { char => 'gg', func => \&cmd_gg, type => C_NORMAL, - no_operator => 1 }, - G => { char => 'G', func => \&cmd_G, type => C_NORMAL, - needs_count => 1, no_operator => 1 }, + j => { char => 'j', func => \&cmd_j, type => C_NORMAL, + no_operator => 1 }, + k => { char => 'k', func => \&cmd_k, type => C_NORMAL, + no_operator => 1 }, + gg => { char => 'gg', func => \&cmd_gg, type => C_NORMAL, + no_operator => 1 }, + G => { char => 'G', func => \&cmd_G, type => C_NORMAL, + needs_count => 1, no_operator => 1 }, # char movement, take an additional parameter and use $movement f => { char => 'f', func => \&cmd_f, type => C_NEEDSKEY, selection_needs_move_right => 1 }, @@ -354,11 +354,11 @@ my $commands gE => { char => 'gE', func => \&cmd_gE, type => C_NORMAL, selection_needs_move_right => 1 }, # text-objects, leading _ means can't be mapped! - _i => { char => 'i', func => \&cmd__i, type => C_TEXTOBJECT }, - _a => { char => 'a', func => \&cmd__a, type => C_TEXTOBJECT }, + _i => { char => 'i', func => \&cmd__i, type => C_TEXTOBJECT }, + _a => { char => 'a', func => \&cmd__a, type => C_TEXTOBJECT }, # line movement - '0' => { char => '0', func => \&cmd_0, type => C_NORMAL }, - '^' => { char => '^', func => \&cmd_caret, type => C_NORMAL }, + '0' => { char => '0', func => \&cmd_0, type => C_NORMAL }, + '^' => { char => '^', func => \&cmd_caret, type => C_NORMAL }, '$' => { char => '$', func => \&cmd_dollar, type => C_NORMAL }, # delete chars x => { char => 'x', func => \&cmd_x, type => C_NORMAL, @@ -433,7 +433,7 @@ my $commands my $commands_ex = { # arrow keys - not actually used, see handle_input_buffer() - + # TODO: make these work. "\e[A" => { char => ':exprev', func => \&ex_history_back, type => C_EX }, "\e[B" => { char => ':exnext', func => \&ex_history_fwd, @@ -518,6 +518,16 @@ my $commands_ex # default command mode mappings my $maps = {}; +# current imap still pending (first character entered) +my $imap = undef; + +# maps for insert mode +my $imaps + = { + # CTRL-R, insert register + "\x12" => { map => undef, func => \&insert_ctrl_r }, + }; + # GLOBAL VARIABLES @@ -604,19 +614,6 @@ my $registers '*' => '', # same '_' => '', # black hole register, always empty }; -foreach my $char ('a' .. 'z') { - $registers->{$char} = ''; -} - -# current imap still pending (first character entered) -my $imap = undef; - -# maps for insert mode -my $imaps - = { - # CTRL-R, insert register - "\x12" => { map => undef, func => \&insert_ctrl_r }, - }; # index into the history list (for j,k) my $history_index = undef; @@ -647,8 +644,10 @@ sub script_is_loaded { sub insert_ctrl_r { my ($key) = @_; - + _debug("ctrl-r called"); my $char = chr($key); + _debug("ctrl-r called with $char"); + return if not defined $registers->{$char} or $registers->{$char} eq ''; my $pos = _insert_at_position($registers->{$char}, 1, _input_pos()); @@ -2338,8 +2337,10 @@ sub got_key { $input_buf_timer = Irssi::timeout_add_once(10, \&handle_input_buffer, undef); print "Buffer Timer tag: $input_buf_timer" if DEBUG; - } elsif ($mode == M_INS or $mode == M_EX) { - if ($key == 3) { # Ctrl-C enters command mode, or cancels ex mode. + + } elsif ($mode == M_INS) { + + if ($key == 3) { # Ctrl-C enters command mode _update_mode(M_CMD); _stop(); return; @@ -2399,6 +2400,13 @@ sub got_key { Irssi::statusbar_items_redraw("vim_mode"); } elsif ($mode == M_EX) { + + if ($key == 3) { # C-c cancels Ex mdoe as well. + _update_mode(M_CMD); + _stop(); + return; + } + handle_command_ex($key); } } @@ -2833,7 +2841,7 @@ sub _tab_complete { sub vim_mode_init { Irssi::signal_add_first 'gui key pressed' => \&got_key; - Irssi::statusbar_item_register ('vim_mode', 0, 'vim_mode_cb'); + Irssi::statusbar_item_register ('vim_mode', 0, 'vim_mode_cb'); Irssi::statusbar_item_register ('vim_windows', 0, 'b_windows_cb'); # Register all available settings. @@ -2841,6 +2849,10 @@ sub vim_mode_init { _setting_register($name); } + foreach my $char ('a' .. 'z') { + $registers->{$char} = ''; + } + setup_changed(); Irssi::signal_add 'setup changed' => \&setup_changed; @@ -2859,6 +2871,8 @@ sub vim_mode_init { if ($settings->{start_cmd}->{value}) { _update_mode(M_CMD); + } else { + _update_mode(M_INS); } } -- cgit v1.2.3 From 9ae4aa07f5b14a7add1b58684513218f46f80767 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Fri, 8 Apr 2011 23:49:31 +0100 Subject: vim-mode: minimal ex-mode tab-completion. Completes provided only the current prefix allows only 1 unique completion. --- vim-mode/vim_mode.pl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'vim-mode') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index e247e35..6ce4d22 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -2074,6 +2074,10 @@ sub _parse_mapping_bracket { sub _parse_mapping_reverse { my ($string) = @_; + if (not defined $string) { + _warn("Unable to reverse-map command: " . join('', @ex_buf)); + return; + } # Convert char to . $string =~ s/ //g; $string =~ s/\n//g; @@ -2789,7 +2793,11 @@ sub handle_command_ex { print "Tab pressed" if DEBUG; print "Ex buf contains: " . join('', @ex_buf) if DEBUG; @tab_candidates = _tab_complete(join('', @ex_buf), [keys %$commands_ex]); - + _debug("Candidates: " . join(", ", @tab_candidates)); + if (@tab_candidates == 1) { + @ex_buf = ( split('', $tab_candidates[0]), ' '); + _set_prompt(':' . join '', @ex_buf); + } # Ignore control characters for now. } elsif ($key > 0 && $key < 32) { # TODO: use them later, e.g. completion -- cgit v1.2.3 From baeb1f7beb2a80179fb79e1e38518c99845988ef Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Mon, 18 Apr 2011 09:29:35 +0100 Subject: vim-mode/vim_mode: podified help --- vim-mode/vim_mode.pl | 656 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 412 insertions(+), 244 deletions(-) (limited to 'vim-mode') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index b279790..3e844e5 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -1,247 +1,415 @@ -# A script to emulate some of the vi(m) features for the Irssi inputline. -# -# It should work fine with at least 0.8.12 and later versions. However some -# features are disabled in older versions (see below for details). Perl >= -# 5.8.1 is recommended for UTF-8 support (which can be disabled if necessary). -# Please report bugs in older versions as well, we'll try to fix them. -# -# Any behavior different from Vim (unless explicitly documented) should be -# considered a bug and reported. -# -# NOTE: This script is still under heavy development, and there may be bugs. -# Please submit reproducible sequences to the bug-tracker at: -# http://github.com/shabble/irssi-scripts/issues -# -# or contact rudi_s or shabble on irc.freenode.net (#irssi and #irssi_vim) -# -# -# Features: -# -# It supports most commonly used command mode features: -# -# * Insert/Command mode. Escape and Ctrl-C enter command mode. -# /set vim_mode_cmd_seq j allows to use jj as Escape (any other character -# can be used as well). -# * Cursor motion: h l 0 ^ $ f t F T -# * History motion: j k gg G -# gg moves to the oldest (first) history line. -# G without a count moves to the current input line, with a count it goes to -# the count-th history line (1 is the oldest). -# * Cursor word motion: w b ge e W gE B E -# * Word objects (only the following work yet): aw aW -# * Yank and paste: y p P -# * Change and delete: c d -# * Delete at cursor: x X -# * Replace at cursor: r -# * Insert mode: i a I A -# * Switch case: ~ -# * Repeat change: . -# * Repeat ftFT: ; , -# * Registers: "a-"z "" "0 "* "+ "_ (black hole) -# Appending to register with "A-"Z -# "" is the default yank/delete register. -# "0 contains the last yank (if no register was specified). -# The special registers "* "+ contain both irssi's cut-buffer. -# * Line-wise shortcuts: dd cc yy -# * Shortcuts: s S C D -# * Scroll the scrollback buffer: Ctrl-E Ctrl-D Ctrl-Y Ctrl-U Ctrl-F Ctrl-B -# * Switch to last active window: Ctrl-6/Ctrl-^ -# * Switch split windows: Ctrl-W j Ctrl-W k -# * Undo/Redo: u Ctrl-R -# -# Counts and combinations work as well, e.g. d5fx or 3iabc. Counts also -# work with mapped ex-commands (see below), e.g. if you map gb to do :bn, then -# 2gb will switch to the second next buffer. -# Repeat also supports counts. -# -# The following insert mode mappings are supported: -# -# * Insert register content: Ctrl-R x (where x is the register to insert) -# -# Ex-mode supports (activated by : in command mode) the following commands: -# -# * Command History: , -# :eh - show ex history -# * Switching buffers: :[N]b [N] - switch to channel number -# :b# - switch to last channel -# :b -# :b / -# :buffer {args} (same as :b) -# :[N]bn[ext] [N] - switch to next window -# :[N]bp[rev] [N] - switch to previous window -# * Close window: :[N]bd[elete] [N] -# * Display windows: :ls :buffers -# * Display registers: :reg[isters] {args} :di[splay] {args} -# * Display undolist: :undol[ist] (mostly used for debugging) -# * Source files :so[urce] - only sources vim_moderc at the moment, -# {file} not supported -# * Mappings: :map - display custom mappings -# :map {lhs} - display mappings starting with {lhs} -# :map {lhs} {rhs} - add mapping -# :unm[ap] {lhs} - remove custom mapping -# * Save mappings: :mkv[imrc][!] - like in Vim, but [file] not supported -# * Substitute: :s/// - i and g are supported as flags, only /// can be -# used as separator, uses Perl regex instead of -# Vim regex -# * Settings: :se[t] - display all options -# :se[t] {option} - display all matching options -# :se[t] {option} {value} - change option to value -# -# -# Mappings: -# -# {lhs} is the key combination to be mapped, {rhs} the target. The <> notation -# is used (e.g. is Ctrl-F), case is ignored. Supported <> keys: -# -, , , , , , . Mapping ex-mode and -# irssi commands is supported. When mapping ex-mode commands the trailing -# is not necessary. Only default mappings can be used in {rhs}. -# Examples: -# :map w W - to remap w to work like W -# :map gb :bnext - to map gb to call :bnext -# :map gB :bprev -# :map g1 :b 1 - to map g1 to switch to buffer 1 -# :map gb :b - to map gb to :b, 1gb switches to buffer 1, 5gb to 5 -# :map /clear - map Ctrl-L to irssi command /clear -# :map /window goto 1 -# :map - disable , it does nothing now -# :unmap - restore default behavior of after disabling it -# -# Note that you must use / for irssi commands (like /clear), the current value -# of cmdchars does _not_ work! This is necessary do differentiate between -# ex-commands and irssi commands. -# -# -# Settings: -# -# The settings are stored as irssi settings and can be set using /set as usual -# (prepend vim_mode_ to setting name) or using the :set ex-command. The -# following settings are available: -# -# * utf8: support UTF-8 characters, boolean, default on -# * debug: enable debug output, boolean, default off -# * cmd_seq: char that when double-pressed simulates , -# string, default '' -# * start_cmd: start every line in command mode, boolean, default off -# * max_undo_lines: size of the undo buffer. Integer, default 50 items. -# * ex_history_size: number of items stored in the ex-mode history. -# Integer, default 100. -# * prompt_leading_space: determines whether ex mode prepends a space to the -# displayed input. Boolean, default on -# -# In contrast to irssi's settings, :set accepts 0 and 1 as values for boolean -# settings, but only vim_mode's settings can be set/displayed. -# Examples: -# :set cmd_seq=j # set cmd_seq to j -# :set cmd_seq= # disable cmd_seq -# :set debug=on # enable debug -# :set debug=off # disable debug -# -# -# The following statusbar items are available: -# -# * vim_mode: displays current mode -# * vim_windows: displays windows selected with :b -# -# -# Configuration -# -# Additionally to the irssi settings described above vim_mode can be -# configured through an external configuration file named "vim_moderc" located -# in ~/.irssi/vim_moderc. If available it's loaded on startup and every -# supported ex-command is run. It's syntax is similar to "vimrc". To (re)load -# it while vim_mode is running use :so[urce]. -# -# Supported ex-commands: -# -# * :map -# -# -# Installation: -# -# As always, copy the script into .irssi/scripts and load it with -# /script load vim_mode.pl -# -# Use the following command to get a statusbar item that shows which mode -# you're in. -# -# /statusbar window add vim_mode -# -# And the following to let :b name display a list of matching channels -# -# /statusbar window add vim_windows -# -# -# Dependencies: -# -# For proper :ex mode support, vim-mode requires the installation of uberprompt.pl -# Uberprompt can be downloaded from: -# -# http://github.com/shabble/irssi-scripts/raw/master/prompt_info/uberprompt.pl -# -# and follow the instructions at the top of that file for installation. -# -# If you don't need Ex-mode, you can run vim_mode.pl without the -# uberprompt.pl script, but it is recommended. -# -# -# Irssi requirements: -# -# 0.8.12 and above should work fine. However the following features are -# disabled in irssi < 0.8.13: -# -# * j k (only with count, they work fine without count in older versions) -# * gg G -# -# -# Known bugs: -# -# * count before register doesn't work: e.g. 3"ap doesn't work, but "a3p does -# * mapping an incomplete ex-command doesn't open the ex-mode with the partial -# command (e.g. :map gb :b causes an error instead of opening the ex-mode -# and displaying :b) -# * undo/redo positions are mostly wrong -# -# -# TODO: -# * History: -# * /,?,n,N to search through history (like history_search.pl) -# * Window switching (:b) -# * Tab completion of window(-item) names -# * non-sequential matches(?) -# -# WONTFIX - things we're not ever likely to do -# * Macros -# -# THANKS: -# -# * estragib: a lot of testing and many bug reports and feature requests -# * iaj: testing -# * tmr: explaining how various bits of vim work -# -# LICENCE: -# -# Copyright (c) 2010 Tom Feist & Simon Ruderich -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# -# -# Have fun! +=pod + +=head1 NAME + +vim_mode.pl + +=head1 DESCRIPTION + +An Irssi script to emulate some of the vi(m) features for the Irssi inputline. + +=head1 INSTALLATION + +Copy into your F<~/.irssi/scripts/> directory and load with +C. You may wish to have it autoload in one of the +L. + +=head2 DEPENDENCIES + +For proper :ex mode support, vim-mode requires the installation of F +Uberprompt can be downloaded from: + +L + +and follow the instructions at the top of that file for installation. + +If you don't need Ex-mode, you can run vim_mode.pl without the +uberprompt.pl script, but it is recommended. + +=head3 Irssi requirements + +0.8.12 and above should work fine. However the following features are +disabled in irssi < 0.8.13: + +=over 4 + +=item C C (only with count, they work fine without count in older versions) + +=item C, C + +=back + +It is intended to work with at Irssi 0.8.12 and later versions. However some +features are disabled in older versions (see below for details). + +Perl >= 5.8.1 is recommended for UTF-8 support (which can be disabled if +necessary). Please report bugs in older versions as well, we'll try to fix +them. Later versions of Perl are also faster, which is probably beneficial +to a script of this size and complexity. + +=head2 SETUP + +Use the following command to get a statusbar item that shows which mode +you're in. + +C + +And the following to let C<:b I> display a list of matching channels + +C + +B Remember to C after adding these statusbar items to make them +permanent. + + +=head3 FILE-BASED CONFIGURATION + +Additionally to the irssi settings described in L, vim_mode +can be configured through an external configuration file named "vim_moderc" +located in F<~/.irssi/vim_moderc>. If available it's loaded on startup and every +supported ex-command is run. Its syntax is similar to "vimrc". To (re)load it +while vim_mode is running use C<:so[urce]>. + +Currently Supported ex-commands: + +=over 4 + +=item C<:map> + +=back + +=head1 USAGE + +=head2 COMMAND MODE + +It supports most commonly used command mode features: + +=over 4 + +=item Insert/Command mode. Escape and Ctrl-C enter command mode. + /set vim_mode_cmd_seq j allows to use jj as Escape (any other character + can be used as well). + +=item Cursor motion: h l 0 ^ $ f t F T + +=item History motion: j k gg G + gg moves to the oldest (first) history line. + G without a count moves to the current input line, with a count it goes to + the count-th history line (1 is the oldest). + +=item Cursor word motion: C + +=item Word objects (only the following work yet): C + +=item Yank and paste: C + +=item Change and delete: C + +=item Delete at cursor: C + +=item Replace at cursor: C + +=item Insert mode: C + +=item Switch case: C<~> + +=item Repeat change: C<.> + +=item Repeat C + +=item Registers: C<"a-"z "" "0 "* "+ "_> (black hole) + +=over 4 + +=item Appending to register with C<"A-"Z> + +=item C<""> is the default yank/delete register. + +=item C<"0> contains the last yank (if no register was specified). + +=item The special registers C<"* "+> both contain irssi's internal cut-buffer. + +=back + +=item Line-wise shortcuts: C
+ +=item Shortcuts: C + +=item Scroll the scrollback buffer: C + +=item Switch to last active window: C + +=item Switch split windows: + +=item Undo/Redo: C + +=back + +Counts and combinations work as well, e.g. C or C<3iabcEescE>. +Counts also work with mapped ex-commands (see below), e.g. if you map C to do +C<:bn>, then C<2gb> will switch to the second next buffer. Repeat also supports +counts. + +=head2 INSERT MODE + +The following insert mode mappings are supported: + +=over 4 + +=item Insert register content: Ctrl-R x (where x is the register to insert) + +=back + +=head2 EX-MODE + +Ex-mode (activated by C<:> in command mode) supports the following commands: + +=over 4 + +=item Command History: CuparrowE>, C> + C<:eh> - show ex history + +=item Switching buffers: C<:[N]b [N]> - switch to channel number + C<:b#> - switch to last channel + C<:b> Epartial-channel-nameE + C<:b> / + C<:buffer {args}> (same as C<:b>) + C<:[N]bn[ext] [N]> - switch to next window + C<:[N]bp[rev] [N]> - switch to previous window + +=item Close window: C<:[N]bd[elete] [N]> + +=item Display windows: C<:ls>, C<:buffers> + +=item Display registers: C<:reg[isters] {args}>, C<:di[splay] {args}> + +=item Display undolist: C<:undol[ist]> (mostly used for debugging) + +=item Source files C<:so[urce]> - only sources vim_moderc at the moment, + F<{file}> not supported + +=item Mappings: C<:map> - display custom mappings + +=over 4 + +=item C<:map {lhs}> - display mappings starting with {lhs} + +=item C<:map {lhs} {rhs}> - add mapping + +=item C<:unm[ap] {lhs}> - remove custom mapping + +=back + +=item Save mappings: C<:mkv[imrc][!]> - like in Vim, but [file] not supported + +=item Substitute: C<:s///> - I and I are supported as flags, only /// can + be used as separator, uses Perl regex instead of + Vim regex + +=item Settings: C<:se[t]> - display all options + C<:se[t] {option}> - display all matching options + C<:se[t] {option} {value}> - change option to value + +=back + +=head3 MAPPINGS + +C<{lhs}> is the key combination to be mapped, C<{rhs}> the target. The +CE>> notation is used + +(e.g. CC-FE> is Ctrl-F), case is ignored. Supported CE> keys: + +=over 4 + +=item CC-AE> - CC-ZE>, + +=item CC-^E> + +=item CC-6E> + +=item CSpaceE> + +=item CCRE> + +=item CBSE> + +=item CNopE> + +=back + +Mapping ex-mode and irssi commands is supported. When mapping ex-mode commands +the trailing CCrE> is not necessary. Only default mappings can be used +in {rhs}. + +Examples: + +=over 4 + +=item C<:map w W> - to remap w to work like W + +=item C<:map gb :bnext> - to map gb to call :bnext + +=item C<:map gB :bprev> + +=item C<:map g1 :b 1> - to map g1 to switch to buffer 1 + +=item C<:map gb :b> - to map gb to :b, 1gb switches to buffer 1, 5gb to 5 + +=item C<:map /clear> - map Ctrl-L to irssi command /clear + +=item C<:map /window goto 1> + +=item C<:map > - disable , it does nothing now + +=item C<:unmap > - restore default behavior of after disabling it + +=back + +Note that you must use C for irssi commands (like C), the current value +of Irssi's cmdchars does B work! This is necessary do differentiate between +ex-commands and irssi commands. + +=head2 SETTINGS + +The settings are stored as irssi settings and can be set using C as usual +(prepend C to setting name) or using the C<:set> ex-command. The +following settings are available: + +=over 4 + +=item utf8: support UTF-8 characters, boolean, default on + +=item debug: enable debug output, boolean, default off + +=item cmd_seq: char that when double-pressed simulates , + string, default '' +=item start_cmd: start every line in command mode, boolean, default off + +=item max_undo_lines: size of the undo buffer. Integer, default 50 items. + +=item ex_history_size: number of items stored in the ex-mode history. + Integer, default 100. + +=item prompt_leading_space: determines whether ex mode prepends a space to the + displayed input. Boolean, default on + +=back + +In contrast to irssi's settings, C<:set> accepts 0 and 1 as values for boolean +settings, but only vim_mode's settings can be set/displayed. + +Examples: + + :set cmd_seq=j # set cmd_seq to j + :set cmd_seq= # disable cmd_seq + :set debug=on # enable debug + :set debug=off # disable debug + +=head1 SUPPORT + +Any behavior different from Vim (unless explicitly documented) should be +considered a bug and reported. + +B This script is still under heavy development, and there may be bugs. +Please submit reproducible sequences to the bug-tracker at: +L + +or contact rudi_s or shabble on irc.freenode.net (#irssi and #irssi_vim) + +=head1 AUTHORS + +Copyright E 2010-2011 Tom Feist Cshabble+irssi@metavore.orgE> and +Copyright E 2010-2011 Simon Ruderich Csimon@ruderich.org> + +=head1 THANKS + +Particular thanks go to + +=over 4 + +=item estragib: a lot of testing and many bug reports and feature requests + +=item iaj: testing + +=item tmr: explaining how various bits of vim work + +=back + +as well as the rest of C<#irssi> and C<#irssi_vim> on Freenode IRC. + +=head1 LICENCE + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +=head1 BUGS + +=over 4 + +=item count before register doesn't work: e.g. 3"ap doesn't work, but "a3p does + +=item mapping an incomplete ex-command doesn't open the ex-mode with the partial + command (e.g. C<:map gb :b> causes an error instead of opening the ex-mode and + displaying C<:bEcursorE>) + +=item undo/redo cursor positions are mostly wrong + +=back + +=head1 TODO + +=over 4 + +=item History: + +=over 4 + +=item C< * /,?,n,N> to search through history (like rl_history_search.pl) + +=back + +=item Window switching (C<:b>) + +=over 4 + +=item Tab completion of window(-item) names + +=item non-sequential matches(?) + +=back + +=back + +See also the TODO file at +L for +many many more things. + +=head2 WONTFIX + +Things we're not ever likely to do: + +=over 4 + +=item Macros + +=back + +=cut use strict; use warnings; -- cgit v1.2.3 From 478803016aa92b48d40010e942cd5a5cd7bd7e5d Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Mon, 18 Apr 2011 09:42:28 +0100 Subject: added vim-mode genereated readme --- vim-mode/README.md | 284 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 284 insertions(+) create mode 100644 vim-mode/README.md (limited to 'vim-mode') diff --git a/vim-mode/README.md b/vim-mode/README.md new file mode 100644 index 0000000..a59691a --- /dev/null +++ b/vim-mode/README.md @@ -0,0 +1,284 @@ +# NAME + +vim_mode.pl + +# DESCRIPTION + +An Irssi script to emulate some of the vi(m) features for the Irssi inputline. + +# INSTALLATION + +Copy into your `~/.irssi/scripts/` directory and load with +`/SCRIPT LOAD vim_mode.pl`. You may wish to have it autoload in one of the +[usual ways](https://github.com/shabble/irssi-docs/wiki/Guide#Autorunning_Scripts). + +## DEPENDENCIES + +For proper :ex mode support, vim-mode requires the installation of `uberprompt.pl` +Uberprompt can be downloaded from: + +[https://github.com/shabble/irssi-scripts/raw/master/prompt_info/uberprompt.pl](https://github.com/shabble/irssi-scripts/raw/master/prompt_info/uberprompt.pl) + +and follow the instructions at the top of that file for installation. + +If you don't need Ex-mode, you can run vim_mode.pl without the +uberprompt.pl script, but it is recommended. + +### Irssi requirements + +0.8.12 and above should work fine. However the following features are +disabled in irssi < 0.8.13: + +- `j` `k` (only with count, they work fine without count in older versions) +- `gg`, `G` + +It is intended to work with at Irssi 0.8.12 and later versions. However some +features are disabled in older versions (see below for details). + +Perl >= 5.8.1 is recommended for UTF-8 support (which can be disabled if +necessary). Please report bugs in older versions as well, we'll try to fix +them. Later versions of Perl are also faster, which is probably beneficial +to a script of this size and complexity. + +## SETUP + +Use the following command to get a statusbar item that shows which mode +you're in. + +`/statusbar window add vim_mode` + +And the following to let `:b _name_` display a list of matching channels + +`/statusbar window add vim_windows` + +__Note:__ Remember to `/save` after adding these statusbar items to make them +permanent. + + + +### FILE-BASED CONFIGURATION + +Additionally to the irssi settings described in [SETTINGS](#pod_SETTINGS), vim_mode +can be configured through an external configuration file named "vim_moderc" +located in `~/.irssi/vim_moderc`. If available it's loaded on startup and every +supported ex-command is run. Its syntax is similar to "vimrc". To (re)load it +while vim_mode is running use `:so[urce]`. + +Currently Supported ex-commands: + +- `:map` + +# USAGE + +## COMMAND MODE + +It supports most commonly used command mode features: + + - Insert/Command mode. Escape and Ctrl-C enter command mode. + /set vim_mode_cmd_seq j allows to use jj as Escape (any other character + can be used as well). + - Cursor motion: h l 0 ^ $ f t F T + - History motion: j k gg G + gg moves to the oldest (first) history line. + G without a count moves to the current input line, with a count it goes to + the count-th history line (1 is the oldest). + - Cursor word motion: `w b ge e W gE B E` + - Word objects (only the following work yet): `aw aW` + - Yank and paste: `y p P` + - Change and delete: `c d` + - Delete at cursor: `x X` + - Replace at cursor: `r` + - Insert mode: `i a I A` + - Switch case: `~` + - Repeat change: `.` + - Repeat `ftFT: ; ,` + - Registers: `"a-"z "" "0 "* "+ "_` (black hole) + - Appending to register with `"A-"Z` + - `""` is the default yank/delete register. + - `"0` contains the last yank (if no register was specified). + - The special registers `"* "+` both contain irssi's internal cut-buffer. + +- Line-wise shortcuts: `dd cc yy` +- Shortcuts: `s S C D` +- Scroll the scrollback buffer: `Ctrl-E Ctrl-D Ctrl-Y Ctrl-U Ctrl-F Ctrl-B` +- Switch to last active window: `Ctrl-6/Ctrl-^` +- Switch split windows: +- Undo/Redo: `u Ctrl-R` + +Counts and combinations work as well, e.g. `d5fx` or `3iabc`. +Counts also work with mapped ex-commands (see below), e.g. if you map `gb` to do +`:bn`, then `2gb` will switch to the second next buffer. Repeat also supports +counts. + +## INSERT MODE + +The following insert mode mappings are supported: + +- Insert register content: Ctrl-R x (where x is the register to insert) + +## EX-MODE + +Ex-mode (activated by `:` in command mode) supports the following commands: + + - Command History: ``, `<` + `:eh` - show ex history + - Switching buffers: `:[N]b [N]` - switch to channel number + `:b#` - switch to last channel + `:b` + `:b` / + `:buffer {args}` (same as `:b`) + `:[N]bn[ext] [N]` - switch to next window + `:[N]bp[rev] [N]` - switch to previous window + - Close window: `:[N]bd[elete] [N]` + - Display windows: `:ls`, `:buffers` + - Display registers: `:reg[isters] {args}`, `:di[splay] {args}` + - Display undolist: `:undol[ist]` (mostly used for debugging) + - Source files `:so[urce]` - only sources vim_moderc at the moment, + `{file}` not supported + - Mappings: `:map` - display custom mappings + - `:map {lhs}` - display mappings starting with {lhs} + - `:map {lhs} {rhs}` - add mapping + - `:unm[ap] {lhs}` - remove custom mapping + +- Save mappings: `:mkv[imrc][!]` - like in Vim, but [file] not supported +- Substitute: `:s///` - _i_ and _g_ are supported as flags, only /// can + be used as separator, uses Perl regex instead of + Vim regex +- Settings: `:se[t]` - display all options + `:se[t] {option}` - display all matching options + `:se[t] {option} {value}` - change option to value + +### MAPPINGS + +`{lhs}` is the key combination to be mapped, `{rhs}` the target. The +`<>`> notation is used + +(e.g. `` is Ctrl-F), case is ignored. Supported `<>` keys: + +- `` - ``, +- `` +- `` +- `` +- `<CR>` +- `<BS>` +- `` + +Mapping ex-mode and irssi commands is supported. When mapping ex-mode commands +the trailing `` is not necessary. Only default mappings can be used +in {rhs}. + +Examples: + +- `:map w W` - to remap w to work like W +- `:map gb :bnext` - to map gb to call :bnext +- `:map gB :bprev` +- `:map g1 :b 1` - to map g1 to switch to buffer 1 +- `:map gb :b` - to map gb to :b, 1gb switches to buffer 1, 5gb to 5 +- `:map - map Ctrl-L to irssi command /clear +- `:map +- `:map > - disable , it does nothing now +- `:unmap - restore default behavior of after disabling it + +Note that you must use `/` for irssi commands (like `/clear`), the current value +of Irssi's cmdchars does __not__ work! This is necessary do differentiate between +ex-commands and irssi commands. + +## SETTINGS + +The settings are stored as irssi settings and can be set using `/set` as usual +(prepend `vim_mode_` to setting name) or using the `:set` ex-command. The +following settings are available: + +- utf8: support UTF-8 characters, boolean, default on +- debug: enable debug output, boolean, default off +- cmd_seq: char that when double-pressed simulates , + string, default '' +=item start_cmd: start every line in command mode, boolean, default off +- max_undo_lines: size of the undo buffer. Integer, default 50 items. +- ex_history_size: number of items stored in the ex-mode history. + Integer, default 100. +- prompt_leading_space: determines whether ex mode prepends a space to the + displayed input. Boolean, default on + +In contrast to irssi's settings, `:set` accepts 0 and 1 as values for boolean +settings, but only vim_mode's settings can be set/displayed. + +Examples: + + :set cmd_seq=j # set cmd_seq to j + :set cmd_seq= # disable cmd_seq + :set debug=on # enable debug + :set debug=off # disable debug + +# SUPPORT + +Any behavior different from Vim (unless explicitly documented) should be +considered a bug and reported. + +__NOTE:__ This script is still under heavy development, and there may be bugs. +Please submit reproducible sequences to the bug-tracker at: +[http://github.com/shabble/irssi-scripts/issues](http://github.com/shabble/irssi-scripts/issues) + +or contact rudi_s or shabble on irc.freenode.net (#irssi and #irssi_vim) + +# AUTHORS + +Copyright © 2010-2011 Tom Feist `` and +Copyright © 2010-2011 Simon Ruderich ` + +# THANKS + +Particular thanks go to + +- estragib: a lot of testing and many bug reports and feature requests +- iaj: testing +- tmr: explaining how various bits of vim work + +as well as the rest of `#irssi` and `#irssi_vim` on Freenode IRC. + +# LICENCE + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +# BUGS + +- count before register doesn't work: e.g. 3"ap doesn't work, but "a3p does +- mapping an incomplete ex-command doesn't open the ex-mode with the partial + command (e.g. `:map gb :b` causes an error instead of opening the ex-mode and + displaying `:b`) +- undo/redo cursor positions are mostly wrong + +# TODO + + - History: + - ` * /,?,n,N` to search through history (like rl_history_search.pl) + + - Window switching (`:b`) + - Tab completion of window(-item) names + - non-sequential matches(?) + +See also the TODO file at +[github](https://github.com/shabble/irssi-scripts/blob/master/vim-mode/TODO) for +many many more things. + +## WONTFIX + +Things we're not ever likely to do: + +- Macros \ No newline at end of file -- cgit v1.2.3 From 8f2c0f48264fd91477c0d2b049b964d9088bbb6c Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Mon, 18 Apr 2011 10:27:56 +0100 Subject: vim-mode/vim_mode: more changes to docs and generator. Starting to look almost readable now. --- vim-mode/README.md | 203 +++++++++++++++++++++++++++++++-------------------- vim-mode/vim_mode.pl | 187 ++++++++++++++++++++++++++++------------------- 2 files changed, 233 insertions(+), 157 deletions(-) (limited to 'vim-mode') diff --git a/vim-mode/README.md b/vim-mode/README.md index a59691a..593d39d 100644 --- a/vim-mode/README.md +++ b/vim-mode/README.md @@ -22,7 +22,7 @@ Uberprompt can be downloaded from: and follow the instructions at the top of that file for installation. If you don't need Ex-mode, you can run vim_mode.pl without the -uberprompt.pl script, but it is recommended. +uberprompt.pl script, but it is strongly recommended that you use it. ### Irssi requirements @@ -42,12 +42,13 @@ to a script of this size and complexity. ## SETUP -Use the following command to get a statusbar item that shows which mode +Run the following command to add a statusbar item that shows which mode you're in. `/statusbar window add vim_mode` -And the following to let `:b _name_` display a list of matching channels +And the following to let `:b [str]` display a list of channels matching your +search string. `/statusbar window add vim_windows` @@ -70,34 +71,28 @@ Currently Supported ex-commands: # USAGE +The following section is divided into the different modes as supported by Vim itself: + ## COMMAND MODE It supports most commonly used command mode features: - - Insert/Command mode. Escape and Ctrl-C enter command mode. - /set vim_mode_cmd_seq j allows to use jj as Escape (any other character - can be used as well). - - Cursor motion: h l 0 ^ $ f t F T - - History motion: j k gg G - gg moves to the oldest (first) history line. - G without a count moves to the current input line, with a count it goes to - the count-th history line (1 is the oldest). - - Cursor word motion: `w b ge e W gE B E` - - Word objects (only the following work yet): `aw aW` - - Yank and paste: `y p P` - - Change and delete: `c d` - - Delete at cursor: `x X` - - Replace at cursor: `r` - - Insert mode: `i a I A` - - Switch case: `~` - - Repeat change: `.` - - Repeat `ftFT: ; ,` - - Registers: `"a-"z "" "0 "* "+ "_` (black hole) - - Appending to register with `"A-"Z` - - `""` is the default yank/delete register. - - `"0` contains the last yank (if no register was specified). - - The special registers `"* "+` both contain irssi's internal cut-buffer. - +- Insert/Command mode. `Escape` and `Ctrl-C` enter command mode. `/set +vim_mode_cmd_seq j` allows to use `jj` as Escape (any other character can be used as well). +- Cursor motion: `h l 0 ^ $ f t F T` +- History motion: `j k gg G` `gg` moves to the oldest (first) history +line. `G` without a count moves to the current input line, with a count it goes to the _count-th_ history line (1 is the oldest). +- Cursor word motion: `w b ge e W gE B E` +- Word objects (only the following work yet): `aw aW` +- Yank and paste: `y p P` +- Change and delete: `c d` +- Delete at cursor: `x X` +- Replace at cursor: `r` +- Insert mode: `i a I A` +- Switch case: `~` +- Repeat change: `.` +- Repeat `ftFT: ; ,` +- Registers: `"a-"z "" "0 "* "+ "_` (black hole) - Line-wise shortcuts: `dd cc yy` - Shortcuts: `s S C D` - Scroll the scrollback buffer: `Ctrl-E Ctrl-D Ctrl-Y Ctrl-U Ctrl-F Ctrl-B` @@ -105,10 +100,14 @@ It supports most commonly used command mode features: - Switch split windows: - Undo/Redo: `u Ctrl-R` -Counts and combinations work as well, e.g. `d5fx` or `3iabc`. -Counts also work with mapped ex-commands (see below), e.g. if you map `gb` to do -`:bn`, then `2gb` will switch to the second next buffer. Repeat also supports -counts. +Counts and combinations work as well, e.g. `d5fx` or `3iabc`. Counts also work with mapped ex-commands (see below), e.g. if you map `gb` to do `:bn`, then `2gb` will switch to the second next buffer. Repeat also supports counts. + +### REGISTERS + +- Appending to register with `"A-"Z` +- `""` is the default yank/delete register. +- `"0` contains the last yank (if no register was specified). +- The special registers `"* "+` both contain irssi's internal cut-buffer. ## INSERT MODE @@ -120,52 +119,98 @@ The following insert mode mappings are supported: Ex-mode (activated by `:` in command mode) supports the following commands: - - Command History: ``, `<` - `:eh` - show ex history - - Switching buffers: `:[N]b [N]` - switch to channel number - `:b#` - switch to last channel - `:b` - `:b` / - `:buffer {args}` (same as `:b`) - `:[N]bn[ext] [N]` - switch to next window - `:[N]bp[rev] [N]` - switch to previous window - - Close window: `:[N]bd[elete] [N]` - - Display windows: `:ls`, `:buffers` - - Display registers: `:reg[isters] {args}`, `:di[splay] {args}` - - Display undolist: `:undol[ist]` (mostly used for debugging) - - Source files `:so[urce]` - only sources vim_moderc at the moment, - `{file}` not supported - - Mappings: `:map` - display custom mappings - - `:map {lhs}` - display mappings starting with {lhs} - - `:map {lhs} {rhs}` - add mapping - - `:unm[ap] {lhs}` - remove custom mapping - -- Save mappings: `:mkv[imrc][!]` - like in Vim, but [file] not supported -- Substitute: `:s///` - _i_ and _g_ are supported as flags, only /// can - be used as separator, uses Perl regex instead of - Vim regex -- Settings: `:se[t]` - display all options - `:se[t] {option}` - display all matching options - `:se[t] {option} {value}` - change option to value +- Command History: + +`` - cycle backwards through history + +`` - cycle forwards through history + +`:eh` - show ex history + +- Switching buffers: + +`:[N]b [N]` - switch to channel number + +`:b#` - switch to last channel + +`:b` + +`:b` / + +`:buffer {args}` (same as `:b`) + +`:[N]bn[ext] [N]` - switch to next window + +`:[N]bp[rev] [N]` - switch to previous window + +- Close window: + +`:[N]bd[elete] [N]` + +- Display windows: + +`:ls`, `:buffers` + +- Display registers: + +<:reg[isters] {args}>, `:di[splay] {args}` + +- Display undolist: + +`:undol[ist]` (mostly used for debugging) + +- Source files: + +`:so[urce]` - only sources vim_moderc at the moment, + `{file}` not supported + +- Mappings: + +`:map` - display custom mappings + +- Save mappings: + +`:mkv[imrc][!]` - like in Vim, but [file] not supported + +- Substitute: + +`:s///` - _i_ and _g_ are supported as flags, only /// can be used as + separator, uses Perl regex instead of Vim regex + +- Settings: + +`:se[t]` - display all options + +`:se[t] {option}` - display all matching options + +`:se[t] {option} {value}` - change option to value ### MAPPINGS -`{lhs}` is the key combination to be mapped, `{rhs}` the target. The -`<>`> notation is used +#### Commands + +- `:map {lhs}` - display mappings starting with {lhs} +- `:map {lhs} {rhs}` - add mapping +- `:unm[ap] {lhs}` - remove custom mapping + +#### Parameters + +_{lhs}_ is the key combination to be mapped, _{rhs}_ the target. The +`<>` notation is used -(e.g. `` is Ctrl-F), case is ignored. Supported `<>` keys: +(e.g. `` is _Ctrl-F_), case is ignored. + Supported `<>` keys are: - `` - ``, -- `` -- `` +- ``, `` - `` -- `<CR>` -- `<BS>` -- `` +- `` - Enter +- `` - Backspace +- `` - No-op (Do Nothing). Mapping ex-mode and irssi commands is supported. When mapping ex-mode commands the trailing `` is not necessary. Only default mappings can be used -in {rhs}. +in _{rhs}_. Examples: @@ -174,10 +219,11 @@ Examples: - `:map gB :bprev` - `:map g1 :b 1` - to map g1 to switch to buffer 1 - `:map gb :b` - to map gb to :b, 1gb switches to buffer 1, 5gb to 5 -- `:map - map Ctrl-L to irssi command /clear -- `:map -- `:map > - disable , it does nothing now -- `:unmap - restore default behavior of after disabling it +- `:map /clear` - map Ctrl-L to irssi command /clear +- `:map /window goto 1` +- `:map - disable , it does nothing now +- `:unmap ` - restore default behavior of `` +after disabling it Note that you must use `/` for irssi commands (like `/clear`), the current value of Irssi's cmdchars does __not__ work! This is necessary do differentiate between @@ -191,14 +237,11 @@ following settings are available: - utf8: support UTF-8 characters, boolean, default on - debug: enable debug output, boolean, default off -- cmd_seq: char that when double-pressed simulates , - string, default '' -=item start_cmd: start every line in command mode, boolean, default off +- cmd_seq: char that when double-pressed simulates ``, string, default '' (disabled) +- start_cmd: start every line in command mode, boolean, default off - max_undo_lines: size of the undo buffer. Integer, default 50 items. -- ex_history_size: number of items stored in the ex-mode history. - Integer, default 100. -- prompt_leading_space: determines whether ex mode prepends a space to the - displayed input. Boolean, default on +- ex_history_size: number of items stored in the ex-mode history. Integer, default 100. +- prompt_leading_space: determines whether ex mode prepends a space to the displayed input. Boolean, default on In contrast to irssi's settings, `:set` accepts 0 and 1 as values for boolean settings, but only vim_mode's settings can be set/displayed. @@ -217,14 +260,14 @@ considered a bug and reported. __NOTE:__ This script is still under heavy development, and there may be bugs. Please submit reproducible sequences to the bug-tracker at: -[http://github.com/shabble/irssi-scripts/issues](http://github.com/shabble/irssi-scripts/issues) +[http://github.com/shabble/irssi-scripts/issues/new](http://github.com/shabble/irssi-scripts/issues/new) or contact rudi_s or shabble on irc.freenode.net (#irssi and #irssi_vim) # AUTHORS Copyright © 2010-2011 Tom Feist `` and -Copyright © 2010-2011 Simon Ruderich ` +Copyright © 2010-2011 Simon Ruderich `` # THANKS diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 3e844e5..4c63bf1 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -24,7 +24,7 @@ L and follow the instructions at the top of that file for installation. If you don't need Ex-mode, you can run vim_mode.pl without the -uberprompt.pl script, but it is recommended. +uberprompt.pl script, but it is strongly recommended that you use it. =head3 Irssi requirements @@ -49,12 +49,13 @@ to a script of this size and complexity. =head2 SETUP -Use the following command to get a statusbar item that shows which mode +Run the following command to add a statusbar item that shows which mode you're in. C -And the following to let C<:b I> display a list of matching channels +And the following to let C<:b [str]> display a list of channels matching your +search string. C @@ -80,22 +81,21 @@ Currently Supported ex-commands: =head1 USAGE +The following section is divided into the different modes as supported by Vim itself: + =head2 COMMAND MODE It supports most commonly used command mode features: -=over 4 +=over 2 -=item Insert/Command mode. Escape and Ctrl-C enter command mode. - /set vim_mode_cmd_seq j allows to use jj as Escape (any other character - can be used as well). +=item Insert/Command mode. C and C enter command mode. C allows to use C as Escape (any other character can be used as well). -=item Cursor motion: h l 0 ^ $ f t F T +=item Cursor motion: CSpaceE EBSE f t F T> -=item History motion: j k gg G - gg moves to the oldest (first) history line. - G without a count moves to the current input line, with a count it goes to - the count-th history line (1 is the oldest). +=item History motion: C C moves to the oldest (first) history +line. C without a count moves to the current input line, with a count it goes to the I history line (1 is the oldest). =item Cursor word motion: C @@ -119,18 +119,6 @@ It supports most commonly used command mode features: =item Registers: C<"a-"z "" "0 "* "+ "_> (black hole) -=over 4 - -=item Appending to register with C<"A-"Z> - -=item C<""> is the default yank/delete register. - -=item C<"0> contains the last yank (if no register was specified). - -=item The special registers C<"* "+> both contain irssi's internal cut-buffer. - -=back - =item Line-wise shortcuts: C
=item Shortcuts: C @@ -145,10 +133,21 @@ It supports most commonly used command mode features: =back -Counts and combinations work as well, e.g. C or C<3iabcEescE>. -Counts also work with mapped ex-commands (see below), e.g. if you map C to do -C<:bn>, then C<2gb> will switch to the second next buffer. Repeat also supports -counts. +Counts and combinations work as well, e.g. C or C<3iabcEescE>. Counts also work with mapped ex-commands (see below), e.g. if you map C to do C<:bn>, then C<2gb> will switch to the second next buffer. Repeat also supports counts. + +=head3 REGISTERS + +=over 4 + +=item Appending to register with C<"A-"Z> + +=item C<""> is the default yank/delete register. + +=item C<"0> contains the last yank (if no register was specified). + +=item The special registers C<"* "+> both contain irssi's internal cut-buffer. + +=back =head2 INSERT MODE @@ -166,80 +165,115 @@ Ex-mode (activated by C<:> in command mode) supports the following commands: =over 4 -=item Command History: CuparrowE>, C> - C<:eh> - show ex history +=item Command History: + +CuparrowE> - cycle backwards through history + +CdownarrowE> - cycle forwards through history + +C<:eh> - show ex history + +=item Switching buffers: + +C<:[N]b [N]> - switch to channel number -=item Switching buffers: C<:[N]b [N]> - switch to channel number - C<:b#> - switch to last channel - C<:b> Epartial-channel-nameE - C<:b> / - C<:buffer {args}> (same as C<:b>) - C<:[N]bn[ext] [N]> - switch to next window - C<:[N]bp[rev] [N]> - switch to previous window +C<:b#> - switch to last channel -=item Close window: C<:[N]bd[elete] [N]> +C<:b> Epartial-channel-nameE -=item Display windows: C<:ls>, C<:buffers> +C<:b> / -=item Display registers: C<:reg[isters] {args}>, C<:di[splay] {args}> +C<:buffer {args}> (same as C<:b>) -=item Display undolist: C<:undol[ist]> (mostly used for debugging) +C<:[N]bn[ext] [N]> - switch to next window -=item Source files C<:so[urce]> - only sources vim_moderc at the moment, +C<:[N]bp[rev] [N]> - switch to previous window + +=item Close window: + +C<:[N]bd[elete] [N]> + +=item Display windows: + +C<:ls>, C<:buffers> + +=item Display registers: + +<:reg[isters] {args}>, C<:di[splay] {args}> + +=item Display undolist: + +C<:undol[ist]> (mostly used for debugging) + +=item Source files: + +C<:so[urce]> - only sources vim_moderc at the moment, F<{file}> not supported -=item Mappings: C<:map> - display custom mappings +=item Mappings: -=over 4 +C<:map> - display custom mappings -=item C<:map {lhs}> - display mappings starting with {lhs} +=item Save mappings: -=item C<:map {lhs} {rhs}> - add mapping +C<:mkv[imrc][!]> - like in Vim, but [file] not supported -=item C<:unm[ap] {lhs}> - remove custom mapping +=item Substitute: -=back +C<:s///> - I and I are supported as flags, only /// can be used as + separator, uses Perl regex instead of Vim regex -=item Save mappings: C<:mkv[imrc][!]> - like in Vim, but [file] not supported +=item Settings: -=item Substitute: C<:s///> - I and I are supported as flags, only /// can - be used as separator, uses Perl regex instead of - Vim regex +C<:se[t]> - display all options -=item Settings: C<:se[t]> - display all options - C<:se[t] {option}> - display all matching options - C<:se[t] {option} {value}> - change option to value +C<:se[t] {option}> - display all matching options + +C<:se[t] {option} {value}> - change option to value =back =head3 MAPPINGS -C<{lhs}> is the key combination to be mapped, C<{rhs}> the target. The -CE>> notation is used +=head4 Commands + +=over 4 + +=item C<:map {lhs}> - display mappings starting with {lhs} + +=item C<:map {lhs} {rhs}> - add mapping -(e.g. CC-FE> is Ctrl-F), case is ignored. Supported CE> keys: +=item C<:unm[ap] {lhs}> - remove custom mapping + +=back + +=head4 Parameters + +I<{lhs}> is the key combination to be mapped, I<{rhs}> the target. The +CE> notation is used + +(e.g. CC-FE> is I), case is ignored. + Supported CE> keys are: =over 4 =item CC-AE> - CC-ZE>, -=item CC-^E> - -=item CC-6E> +=item CC-^E>, CC-6E> =item CSpaceE> -=item CCRE> +=item CCRE> - Enter -=item CBSE> +=item CBSE> - Backspace -=item CNopE> +=item CNopE> - No-op (Do Nothing). =back Mapping ex-mode and irssi commands is supported. When mapping ex-mode commands the trailing CCrE> is not necessary. Only default mappings can be used -in {rhs}. +in I<{rhs}>. Examples: @@ -255,13 +289,14 @@ Examples: =item C<:map gb :b> - to map gb to :b, 1gb switches to buffer 1, 5gb to 5 -=item C<:map /clear> - map Ctrl-L to irssi command /clear +=item C<:map EC-LE /clear> - map Ctrl-L to irssi command /clear -=item C<:map /window goto 1> +=item C<:map EC-GE /window goto 1> -=item C<:map > - disable , it does nothing now +=item C<:map EC-EE > - disable , it does nothing now -=item C<:unmap > - restore default behavior of after disabling it +=item C<:unmap EC-EE> - restore default behavior of CC-EE> +after disabling it =back @@ -281,17 +316,15 @@ following settings are available: =item debug: enable debug output, boolean, default off -=item cmd_seq: char that when double-pressed simulates , - string, default '' +=item cmd_seq: char that when double-pressed simulates CEscE>, string, default '' (disabled) + =item start_cmd: start every line in command mode, boolean, default off =item max_undo_lines: size of the undo buffer. Integer, default 50 items. -=item ex_history_size: number of items stored in the ex-mode history. - Integer, default 100. +=item ex_history_size: number of items stored in the ex-mode history. Integer, default 100. -=item prompt_leading_space: determines whether ex mode prepends a space to the - displayed input. Boolean, default on +=item prompt_leading_space: determines whether ex mode prepends a space to the displayed input. Boolean, default on =back @@ -312,14 +345,14 @@ considered a bug and reported. B This script is still under heavy development, and there may be bugs. Please submit reproducible sequences to the bug-tracker at: -L +L or contact rudi_s or shabble on irc.freenode.net (#irssi and #irssi_vim) =head1 AUTHORS Copyright E 2010-2011 Tom Feist Cshabble+irssi@metavore.orgE> and -Copyright E 2010-2011 Simon Ruderich Csimon@ruderich.org> +Copyright E 2010-2011 Simon Ruderich Csimon@ruderich.orgE> =head1 THANKS -- cgit v1.2.3 From dd243797725c9e6d95bb38a9ff9cd9e82430b39f Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Mon, 18 Apr 2011 15:28:57 +0100 Subject: removed original markdown readmes --- vim-mode/README.md | 327 ----------------------------------------------------- 1 file changed, 327 deletions(-) delete mode 100644 vim-mode/README.md (limited to 'vim-mode') diff --git a/vim-mode/README.md b/vim-mode/README.md deleted file mode 100644 index 593d39d..0000000 --- a/vim-mode/README.md +++ /dev/null @@ -1,327 +0,0 @@ -# NAME - -vim_mode.pl - -# DESCRIPTION - -An Irssi script to emulate some of the vi(m) features for the Irssi inputline. - -# INSTALLATION - -Copy into your `~/.irssi/scripts/` directory and load with -`/SCRIPT LOAD vim_mode.pl`. You may wish to have it autoload in one of the -[usual ways](https://github.com/shabble/irssi-docs/wiki/Guide#Autorunning_Scripts). - -## DEPENDENCIES - -For proper :ex mode support, vim-mode requires the installation of `uberprompt.pl` -Uberprompt can be downloaded from: - -[https://github.com/shabble/irssi-scripts/raw/master/prompt_info/uberprompt.pl](https://github.com/shabble/irssi-scripts/raw/master/prompt_info/uberprompt.pl) - -and follow the instructions at the top of that file for installation. - -If you don't need Ex-mode, you can run vim_mode.pl without the -uberprompt.pl script, but it is strongly recommended that you use it. - -### Irssi requirements - -0.8.12 and above should work fine. However the following features are -disabled in irssi < 0.8.13: - -- `j` `k` (only with count, they work fine without count in older versions) -- `gg`, `G` - -It is intended to work with at Irssi 0.8.12 and later versions. However some -features are disabled in older versions (see below for details). - -Perl >= 5.8.1 is recommended for UTF-8 support (which can be disabled if -necessary). Please report bugs in older versions as well, we'll try to fix -them. Later versions of Perl are also faster, which is probably beneficial -to a script of this size and complexity. - -## SETUP - -Run the following command to add a statusbar item that shows which mode -you're in. - -`/statusbar window add vim_mode` - -And the following to let `:b [str]` display a list of channels matching your -search string. - -`/statusbar window add vim_windows` - -__Note:__ Remember to `/save` after adding these statusbar items to make them -permanent. - - - -### FILE-BASED CONFIGURATION - -Additionally to the irssi settings described in [SETTINGS](#pod_SETTINGS), vim_mode -can be configured through an external configuration file named "vim_moderc" -located in `~/.irssi/vim_moderc`. If available it's loaded on startup and every -supported ex-command is run. Its syntax is similar to "vimrc". To (re)load it -while vim_mode is running use `:so[urce]`. - -Currently Supported ex-commands: - -- `:map` - -# USAGE - -The following section is divided into the different modes as supported by Vim itself: - -## COMMAND MODE - -It supports most commonly used command mode features: - -- Insert/Command mode. `Escape` and `Ctrl-C` enter command mode. `/set -vim_mode_cmd_seq j` allows to use `jj` as Escape (any other character can be used as well). -- Cursor motion: `h l 0 ^ $ f t F T` -- History motion: `j k gg G` `gg` moves to the oldest (first) history -line. `G` without a count moves to the current input line, with a count it goes to the _count-th_ history line (1 is the oldest). -- Cursor word motion: `w b ge e W gE B E` -- Word objects (only the following work yet): `aw aW` -- Yank and paste: `y p P` -- Change and delete: `c d` -- Delete at cursor: `x X` -- Replace at cursor: `r` -- Insert mode: `i a I A` -- Switch case: `~` -- Repeat change: `.` -- Repeat `ftFT: ; ,` -- Registers: `"a-"z "" "0 "* "+ "_` (black hole) -- Line-wise shortcuts: `dd cc yy` -- Shortcuts: `s S C D` -- Scroll the scrollback buffer: `Ctrl-E Ctrl-D Ctrl-Y Ctrl-U Ctrl-F Ctrl-B` -- Switch to last active window: `Ctrl-6/Ctrl-^` -- Switch split windows: -- Undo/Redo: `u Ctrl-R` - -Counts and combinations work as well, e.g. `d5fx` or `3iabc`. Counts also work with mapped ex-commands (see below), e.g. if you map `gb` to do `:bn`, then `2gb` will switch to the second next buffer. Repeat also supports counts. - -### REGISTERS - -- Appending to register with `"A-"Z` -- `""` is the default yank/delete register. -- `"0` contains the last yank (if no register was specified). -- The special registers `"* "+` both contain irssi's internal cut-buffer. - -## INSERT MODE - -The following insert mode mappings are supported: - -- Insert register content: Ctrl-R x (where x is the register to insert) - -## EX-MODE - -Ex-mode (activated by `:` in command mode) supports the following commands: - -- Command History: - -`` - cycle backwards through history - -`` - cycle forwards through history - -`:eh` - show ex history - -- Switching buffers: - -`:[N]b [N]` - switch to channel number - -`:b#` - switch to last channel - -`:b` - -`:b` / - -`:buffer {args}` (same as `:b`) - -`:[N]bn[ext] [N]` - switch to next window - -`:[N]bp[rev] [N]` - switch to previous window - -- Close window: - -`:[N]bd[elete] [N]` - -- Display windows: - -`:ls`, `:buffers` - -- Display registers: - -<:reg[isters] {args}>, `:di[splay] {args}` - -- Display undolist: - -`:undol[ist]` (mostly used for debugging) - -- Source files: - -`:so[urce]` - only sources vim_moderc at the moment, - `{file}` not supported - -- Mappings: - -`:map` - display custom mappings - -- Save mappings: - -`:mkv[imrc][!]` - like in Vim, but [file] not supported - -- Substitute: - -`:s///` - _i_ and _g_ are supported as flags, only /// can be used as - separator, uses Perl regex instead of Vim regex - -- Settings: - -`:se[t]` - display all options - -`:se[t] {option}` - display all matching options - -`:se[t] {option} {value}` - change option to value - -### MAPPINGS - -#### Commands - -- `:map {lhs}` - display mappings starting with {lhs} -- `:map {lhs} {rhs}` - add mapping -- `:unm[ap] {lhs}` - remove custom mapping - -#### Parameters - -_{lhs}_ is the key combination to be mapped, _{rhs}_ the target. The -`<>` notation is used - -(e.g. `` is _Ctrl-F_), case is ignored. - Supported `<>` keys are: - -- `` - ``, -- ``, `` -- `` -- `` - Enter -- `` - Backspace -- `` - No-op (Do Nothing). - -Mapping ex-mode and irssi commands is supported. When mapping ex-mode commands -the trailing `` is not necessary. Only default mappings can be used -in _{rhs}_. - -Examples: - -- `:map w W` - to remap w to work like W -- `:map gb :bnext` - to map gb to call :bnext -- `:map gB :bprev` -- `:map g1 :b 1` - to map g1 to switch to buffer 1 -- `:map gb :b` - to map gb to :b, 1gb switches to buffer 1, 5gb to 5 -- `:map /clear` - map Ctrl-L to irssi command /clear -- `:map /window goto 1` -- `:map - disable , it does nothing now -- `:unmap ` - restore default behavior of `` -after disabling it - -Note that you must use `/` for irssi commands (like `/clear`), the current value -of Irssi's cmdchars does __not__ work! This is necessary do differentiate between -ex-commands and irssi commands. - -## SETTINGS - -The settings are stored as irssi settings and can be set using `/set` as usual -(prepend `vim_mode_` to setting name) or using the `:set` ex-command. The -following settings are available: - -- utf8: support UTF-8 characters, boolean, default on -- debug: enable debug output, boolean, default off -- cmd_seq: char that when double-pressed simulates ``, string, default '' (disabled) -- start_cmd: start every line in command mode, boolean, default off -- max_undo_lines: size of the undo buffer. Integer, default 50 items. -- ex_history_size: number of items stored in the ex-mode history. Integer, default 100. -- prompt_leading_space: determines whether ex mode prepends a space to the displayed input. Boolean, default on - -In contrast to irssi's settings, `:set` accepts 0 and 1 as values for boolean -settings, but only vim_mode's settings can be set/displayed. - -Examples: - - :set cmd_seq=j # set cmd_seq to j - :set cmd_seq= # disable cmd_seq - :set debug=on # enable debug - :set debug=off # disable debug - -# SUPPORT - -Any behavior different from Vim (unless explicitly documented) should be -considered a bug and reported. - -__NOTE:__ This script is still under heavy development, and there may be bugs. -Please submit reproducible sequences to the bug-tracker at: -[http://github.com/shabble/irssi-scripts/issues/new](http://github.com/shabble/irssi-scripts/issues/new) - -or contact rudi_s or shabble on irc.freenode.net (#irssi and #irssi_vim) - -# AUTHORS - -Copyright © 2010-2011 Tom Feist `` and -Copyright © 2010-2011 Simon Ruderich `` - -# THANKS - -Particular thanks go to - -- estragib: a lot of testing and many bug reports and feature requests -- iaj: testing -- tmr: explaining how various bits of vim work - -as well as the rest of `#irssi` and `#irssi_vim` on Freenode IRC. - -# LICENCE - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - -# BUGS - -- count before register doesn't work: e.g. 3"ap doesn't work, but "a3p does -- mapping an incomplete ex-command doesn't open the ex-mode with the partial - command (e.g. `:map gb :b` causes an error instead of opening the ex-mode and - displaying `:b`) -- undo/redo cursor positions are mostly wrong - -# TODO - - - History: - - ` * /,?,n,N` to search through history (like rl_history_search.pl) - - - Window switching (`:b`) - - Tab completion of window(-item) names - - non-sequential matches(?) - -See also the TODO file at -[github](https://github.com/shabble/irssi-scripts/blob/master/vim-mode/TODO) for -many many more things. - -## WONTFIX - -Things we're not ever likely to do: - -- Macros \ No newline at end of file -- cgit v1.2.3 From ce375dbf92cd89780138cff01deae6fbefb71cf6 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Mon, 18 Apr 2011 15:42:10 +0100 Subject: updated a whole bunch of README files. --- vim-mode/README.pod | 444 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 444 insertions(+) create mode 100644 vim-mode/README.pod (limited to 'vim-mode') diff --git a/vim-mode/README.pod b/vim-mode/README.pod new file mode 100644 index 0000000..fc52701 --- /dev/null +++ b/vim-mode/README.pod @@ -0,0 +1,444 @@ +=pod + +=head1 NAME + +vim_mode.pl + +=head1 DESCRIPTION + +An Irssi script to emulate some of the vi(m) features for the Irssi inputline. + +=head1 INSTALLATION + +Copy into your F<~/.irssi/scripts/> directory and load with +C. You may wish to have it autoload in one of the +L. + +=head2 DEPENDENCIES + +For proper :ex mode support, vim-mode requires the installation of F +Uberprompt can be downloaded from: + +L + +and follow the instructions at the top of that file for installation. + +If you don't need Ex-mode, you can run vim_mode.pl without the +uberprompt.pl script, but it is strongly recommended that you use it. + +=head3 Irssi requirements + +0.8.12 and above should work fine. However the following features are +disabled in irssi < 0.8.13: + +=over 4 + +=item C C (only with count, they work fine without count in older versions) + +=item C, C + +=back + +It is intended to work with at Irssi 0.8.12 and later versions. However some +features are disabled in older versions (see below for details). + +Perl >= 5.8.1 is recommended for UTF-8 support (which can be disabled if +necessary). Please report bugs in older versions as well, we'll try to fix +them. Later versions of Perl are also faster, which is probably beneficial +to a script of this size and complexity. + +=head2 SETUP + +Run the following command to add a statusbar item that shows which mode +you're in. + +C + +And the following to let C<:b [str]> display a list of channels matching your +search string. + +C + +B Remember to C after adding these statusbar items to make them +permanent. + + +=head3 FILE-BASED CONFIGURATION + +Additionally to the irssi settings described in L, vim_mode +can be configured through an external configuration file named "vim_moderc" +located in F<~/.irssi/vim_moderc>. If available it's loaded on startup and every +supported ex-command is run. Its syntax is similar to "vimrc". To (re)load it +while vim_mode is running use C<:so[urce]>. + +Currently Supported ex-commands: + +=over 4 + +=item C<:map> + +=back + +=head1 USAGE + +The following section is divided into the different modes as supported by Vim itself: + +=head2 COMMAND MODE + +It supports most commonly used command mode features: + +=over 2 + +=item Insert/Command mode. C and C enter command mode. C allows to use C as Escape (any other character can be used as well). + +=item Cursor motion: CSpaceE EBSE f t F T> + +=item History motion: C C moves to the oldest (first) history +line. C without a count moves to the current input line, with a count it goes to the I history line (1 is the oldest). + +=item Cursor word motion: C + +=item Word objects (only the following work yet): C + +=item Yank and paste: C + +=item Change and delete: C + +=item Delete at cursor: C + +=item Replace at cursor: C + +=item Insert mode: C + +=item Switch case: C<~> + +=item Repeat change: C<.> + +=item Repeat C + +=item Registers: C<"a-"z "" "0 "* "+ "_> (black hole) + +=item Line-wise shortcuts: C
+ +=item Shortcuts: C + +=item Scroll the scrollback buffer: C + +=item Switch to last active window: C + +=item Switch split windows: + +=item Undo/Redo: C + +=back + +Counts and combinations work as well, e.g. C or C<3iabcEescE>. Counts also work with mapped ex-commands (see below), e.g. if you map C to do C<:bn>, then C<2gb> will switch to the second next buffer. Repeat also supports counts. + +=head3 REGISTERS + +=over 4 + +=item Appending to register with C<"A-"Z> + +=item C<""> is the default yank/delete register. + +=item C<"0> contains the last yank (if no register was specified). + +=item The special registers C<"* "+> both contain irssi's internal cut-buffer. + +=back + +=head2 INSERT MODE + +The following insert mode mappings are supported: + +=over 4 + +=item Insert register content: Ctrl-R x (where x is the register to insert) + +=back + +=head2 EX-MODE + +Ex-mode (activated by C<:> in command mode) supports the following commands: + +=over 4 + +=item Command History: + +CuparrowE> - cycle backwards through history + +CdownarrowE> - cycle forwards through history + +C<:eh> - show ex history + +=item Switching buffers: + +C<:[N]b [N]> - switch to channel number + +C<:b#> - switch to last channel + +C<:b> Epartial-channel-nameE + +C<:b> / + +C<:buffer {args}> (same as C<:b>) + +C<:[N]bn[ext] [N]> - switch to next window + +C<:[N]bp[rev] [N]> - switch to previous window + +=item Close window: + +C<:[N]bd[elete] [N]> + +=item Display windows: + +C<:ls>, C<:buffers> + +=item Display registers: + +<:reg[isters] {args}>, C<:di[splay] {args}> + +=item Display undolist: + +C<:undol[ist]> (mostly used for debugging) + +=item Source files: + +C<:so[urce]> - only sources vim_moderc at the moment, + F<{file}> not supported + +=item Mappings: + +C<:map> - display custom mappings + +=item Save mappings: + +C<:mkv[imrc][!]> - like in Vim, but [file] not supported + +=item Substitute: + +C<:s///> - I and I are supported as flags, only /// can be used as + separator, uses Perl regex instead of Vim regex + +=item Settings: + +C<:se[t]> - display all options + +C<:se[t] {option}> - display all matching options + +C<:se[t] {option} {value}> - change option to value + +=back + +=head3 MAPPINGS + +=head4 Commands + +=over 4 + +=item C<:map {lhs}> - display mappings starting with {lhs} + +=item C<:map {lhs} {rhs}> - add mapping + +=item C<:unm[ap] {lhs}> - remove custom mapping + +=back + +=head4 Parameters + +I<{lhs}> is the key combination to be mapped, I<{rhs}> the target. The +CE> notation is used + +(e.g. CC-FE> is I), case is ignored. + Supported CE> keys are: + +=over 4 + +=item CC-AE> - CC-ZE>, + +=item CC-^E>, CC-6E> + +=item CSpaceE> + +=item CCRE> - Enter + +=item CBSE> - Backspace + +=item CNopE> - No-op (Do Nothing). + +=back + +Mapping ex-mode and irssi commands is supported. When mapping ex-mode commands +the trailing CCrE> is not necessary. Only default mappings can be used +in I<{rhs}>. + +Examples: + +=over 4 + +=item C<:map w W> - to remap w to work like W + +=item C<:map gb :bnext> - to map gb to call :bnext + +=item C<:map gB :bprev> + +=item C<:map g1 :b 1> - to map g1 to switch to buffer 1 + +=item C<:map gb :b> - to map gb to :b, 1gb switches to buffer 1, 5gb to 5 + +=item C<:map EC-LE /clear> - map Ctrl-L to irssi command /clear + +=item C<:map EC-GE /window goto 1> + +=item C<:map EC-EE > - disable , it does nothing now + +=item C<:unmap EC-EE> - restore default behavior of CC-EE> +after disabling it + +=back + +Note that you must use C for irssi commands (like C), the current value +of Irssi's cmdchars does B work! This is necessary do differentiate between +ex-commands and irssi commands. + +=head2 SETTINGS + +The settings are stored as irssi settings and can be set using C as usual +(prepend C to setting name) or using the C<:set> ex-command. The +following settings are available: + +=over 4 + +=item utf8: support UTF-8 characters, boolean, default on + +=item debug: enable debug output, boolean, default off + +=item cmd_seq: char that when double-pressed simulates CEscE>, string, default '' (disabled) + +=item start_cmd: start every line in command mode, boolean, default off + +=item max_undo_lines: size of the undo buffer. Integer, default 50 items. + +=item ex_history_size: number of items stored in the ex-mode history. Integer, default 100. + +=item prompt_leading_space: determines whether ex mode prepends a space to the displayed input. Boolean, default on + +=back + +In contrast to irssi's settings, C<:set> accepts 0 and 1 as values for boolean +settings, but only vim_mode's settings can be set/displayed. + +Examples: + + :set cmd_seq=j # set cmd_seq to j + :set cmd_seq= # disable cmd_seq + :set debug=on # enable debug + :set debug=off # disable debug + +=head1 SUPPORT + +Any behavior different from Vim (unless explicitly documented) should be +considered a bug and reported. + +B This script is still under heavy development, and there may be bugs. +Please submit reproducible sequences to the bug-tracker at: +L + +or contact rudi_s or shabble on irc.freenode.net (#irssi and #irssi_vim) + +=head1 AUTHORS + +Copyright E 2010-2011 Tom Feist Cshabble+irssi@metavore.orgE> and +Copyright E 2010-2011 Simon Ruderich Csimon@ruderich.orgE> + +=head1 THANKS + +Particular thanks go to + +=over 4 + +=item estragib: a lot of testing and many bug reports and feature requests + +=item iaj: testing + +=item tmr: explaining how various bits of vim work + +=back + +as well as the rest of C<#irssi> and C<#irssi_vim> on Freenode IRC. + +=head1 LICENCE + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +=head1 BUGS + +=over 4 + +=item count before register doesn't work: e.g. 3"ap doesn't work, but "a3p does + +=item mapping an incomplete ex-command doesn't open the ex-mode with the partial + command (e.g. C<:map gb :b> causes an error instead of opening the ex-mode and + displaying C<:bEcursorE>) + +=item undo/redo cursor positions are mostly wrong + +=back + +=head1 TODO + +=over 4 + +=item History: + +=over 4 + +=item C< * /,?,n,N> to search through history (like rl_history_search.pl) + +=back + +=item Window switching (C<:b>) + +=over 4 + +=item Tab completion of window(-item) names + +=item non-sequential matches(?) + +=back + +=back + +See also the TODO file at +L for +many many more things. + +=head2 WONTFIX + +Things we're not ever likely to do: + +=over 4 + +=item Macros + +=back + -- cgit v1.2.3 From 23b75ab5c2aba863531eb9df34452ee979653180 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Mon, 18 Apr 2011 15:59:43 +0100 Subject: vim-mode/vim_mode: updated docs (only partially, to see how it looks) --- vim-mode/README.pod | 106 +++++++++++++++++++++++++++++++++----------------- vim-mode/vim_mode.pl | 108 ++++++++++++++++++++++++++++++++------------------- 2 files changed, 139 insertions(+), 75 deletions(-) (limited to 'vim-mode') diff --git a/vim-mode/README.pod b/vim-mode/README.pod index fc52701..4783c23 100644 --- a/vim-mode/README.pod +++ b/vim-mode/README.pod @@ -239,11 +239,11 @@ C<:se[t] {option} {value}> - change option to value =over 4 -=item C<:map {lhs}> - display mappings starting with {lhs} +=item * C<:map {lhs}> - display mappings starting with {lhs} -=item C<:map {lhs} {rhs}> - add mapping +=item * C<:map {lhs} {rhs}> - add mapping -=item C<:unm[ap] {lhs}> - remove custom mapping +=item * C<:unm[ap] {lhs}> - remove custom mapping =back @@ -257,17 +257,17 @@ CE> notation is used =over 4 -=item CC-AE> - CC-ZE>, +=item * CC-AE> - CC-ZE>, -=item CC-^E>, CC-6E> +=item * CC-^E>, CC-6E> -=item CSpaceE> +=item * CSpaceE> -=item CCRE> - Enter +=item * CCRE> - Enter -=item CBSE> - Backspace +=item * CBSE> - Backspace -=item CNopE> - No-op (Do Nothing). +=item * CNopE> - No-op (Do Nothing). =back @@ -279,23 +279,23 @@ Examples: =over 4 -=item C<:map w W> - to remap w to work like W +=item * C<:map w W> - to remap w to work like W -=item C<:map gb :bnext> - to map gb to call :bnext +=item * C<:map gb :bnext> - to map gb to call :bnext -=item C<:map gB :bprev> +=item * C<:map gB :bprev> -=item C<:map g1 :b 1> - to map g1 to switch to buffer 1 +=item * C<:map g1 :b 1> - to map g1 to switch to buffer 1 -=item C<:map gb :b> - to map gb to :b, 1gb switches to buffer 1, 5gb to 5 +=item * C<:map gb :b> - to map gb to :b, 1gb switches to buffer 1, 5gb to 5 -=item C<:map EC-LE /clear> - map Ctrl-L to irssi command /clear +=item * C<:map EC-LE /clear> - map Ctrl-L to irssi command /clear -=item C<:map EC-GE /window goto 1> +=item * C<:map EC-GE /window goto 1> -=item C<:map EC-EE > - disable , it does nothing now +=item * C<:map EC-EE > - disable , it does nothing now -=item C<:unmap EC-EE> - restore default behavior of CC-EE> +=item * C<:unmap EC-EE> - restore default behavior of CC-EE> after disabling it =back @@ -312,19 +312,33 @@ following settings are available: =over 4 -=item utf8: support UTF-8 characters, boolean, default on +=item * utf8 -=item debug: enable debug output, boolean, default off +Support UTF-8 characters, boolean, default on -=item cmd_seq: char that when double-pressed simulates CEscE>, string, default '' (disabled) +=item debug -=item start_cmd: start every line in command mode, boolean, default off +Enable debug output, boolean, default off -=item max_undo_lines: size of the undo buffer. Integer, default 50 items. +=item cmd_seq -=item ex_history_size: number of items stored in the ex-mode history. Integer, default 100. +Char that when double-pressed simulates CEscE>, string, default '' (disabled) -=item prompt_leading_space: determines whether ex mode prepends a space to the displayed input. Boolean, default on +=item start_cmd + +Start every line in command mode, boolean, default off + +=item max_undo_lines + +Sze of the undo buffer. Integer, default 50 items. + +=item ex_history_size + +Number of items stored in the ex-mode history. Integer, default 100. + +=item prompt_leading_space + +Ddetermines whether ex mode prepends a space to the displayed input. Boolean, default on =back @@ -394,13 +408,19 @@ THE SOFTWARE. =over 4 -=item count before register doesn't work: e.g. 3"ap doesn't work, but "a3p does +=item * + +count before register doesn't work: e.g. 3"ap doesn't work, but "a3p does + +=item * -=item mapping an incomplete ex-command doesn't open the ex-mode with the partial - command (e.g. C<:map gb :b> causes an error instead of opening the ex-mode and - displaying C<:bEcursorE>) +mapping an incomplete ex-command doesn't open the ex-mode with the partial +command (e.g. C<:map gb :b> causes an error instead of opening the ex-mode and +displaying C<:bEcursorE>) -=item undo/redo cursor positions are mostly wrong +=item * + + undo/redo cursor positions are mostly wrong =back @@ -408,21 +428,31 @@ THE SOFTWARE. =over 4 -=item History: +=item * + +History: =over 4 -=item C< * /,?,n,N> to search through history (like rl_history_search.pl) +=item * + + C< * /,?,n,N> to search through history (like rl_history_search.pl) =back -=item Window switching (C<:b>) +=item * + +Window switching (C<:b>) =over 4 -=item Tab completion of window(-item) names +=item * + +Tab completion of window(-item) names -=item non-sequential matches(?) +=item * + +non-sequential matches(?) =back @@ -438,7 +468,11 @@ Things we're not ever likely to do: =over 4 -=item Macros +=item * Macros =back + + +=cut + diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 4c63bf1..ae43d6b 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -239,11 +239,11 @@ C<:se[t] {option} {value}> - change option to value =over 4 -=item C<:map {lhs}> - display mappings starting with {lhs} +=item * C<:map {lhs}> - display mappings starting with {lhs} -=item C<:map {lhs} {rhs}> - add mapping +=item * C<:map {lhs} {rhs}> - add mapping -=item C<:unm[ap] {lhs}> - remove custom mapping +=item * C<:unm[ap] {lhs}> - remove custom mapping =back @@ -257,17 +257,17 @@ CE> notation is used =over 4 -=item CC-AE> - CC-ZE>, +=item * CC-AE> - CC-ZE>, -=item CC-^E>, CC-6E> +=item * CC-^E>, CC-6E> -=item CSpaceE> +=item * CSpaceE> -=item CCRE> - Enter +=item * CCRE> - Enter -=item CBSE> - Backspace +=item * CBSE> - Backspace -=item CNopE> - No-op (Do Nothing). +=item * CNopE> - No-op (Do Nothing). =back @@ -279,23 +279,23 @@ Examples: =over 4 -=item C<:map w W> - to remap w to work like W +=item * C<:map w W> - to remap w to work like W -=item C<:map gb :bnext> - to map gb to call :bnext +=item * C<:map gb :bnext> - to map gb to call :bnext -=item C<:map gB :bprev> +=item * C<:map gB :bprev> -=item C<:map g1 :b 1> - to map g1 to switch to buffer 1 +=item * C<:map g1 :b 1> - to map g1 to switch to buffer 1 -=item C<:map gb :b> - to map gb to :b, 1gb switches to buffer 1, 5gb to 5 +=item * C<:map gb :b> - to map gb to :b, 1gb switches to buffer 1, 5gb to 5 -=item C<:map EC-LE /clear> - map Ctrl-L to irssi command /clear +=item * C<:map EC-LE /clear> - map Ctrl-L to irssi command /clear -=item C<:map EC-GE /window goto 1> +=item * C<:map EC-GE /window goto 1> -=item C<:map EC-EE > - disable , it does nothing now +=item * C<:map EC-EE > - disable , it does nothing now -=item C<:unmap EC-EE> - restore default behavior of CC-EE> +=item * C<:unmap EC-EE> - restore default behavior of CC-EE> after disabling it =back @@ -312,19 +312,33 @@ following settings are available: =over 4 -=item utf8: support UTF-8 characters, boolean, default on +=item * utf8 -=item debug: enable debug output, boolean, default off +Support UTF-8 characters, boolean, default on -=item cmd_seq: char that when double-pressed simulates CEscE>, string, default '' (disabled) +=item debug -=item start_cmd: start every line in command mode, boolean, default off +Enable debug output, boolean, default off -=item max_undo_lines: size of the undo buffer. Integer, default 50 items. +=item cmd_seq -=item ex_history_size: number of items stored in the ex-mode history. Integer, default 100. +Char that when double-pressed simulates CEscE>, string, default '' (disabled) -=item prompt_leading_space: determines whether ex mode prepends a space to the displayed input. Boolean, default on +=item start_cmd + +Start every line in command mode, boolean, default off + +=item max_undo_lines + +Sze of the undo buffer. Integer, default 50 items. + +=item ex_history_size + +Number of items stored in the ex-mode history. Integer, default 100. + +=item prompt_leading_space + +Ddetermines whether ex mode prepends a space to the displayed input. Boolean, default on =back @@ -394,13 +408,19 @@ THE SOFTWARE. =over 4 -=item count before register doesn't work: e.g. 3"ap doesn't work, but "a3p does +=item * + +count before register doesn't work: e.g. 3"ap doesn't work, but "a3p does -=item mapping an incomplete ex-command doesn't open the ex-mode with the partial - command (e.g. C<:map gb :b> causes an error instead of opening the ex-mode and - displaying C<:bEcursorE>) +=item * -=item undo/redo cursor positions are mostly wrong +mapping an incomplete ex-command doesn't open the ex-mode with the partial +command (e.g. C<:map gb :b> causes an error instead of opening the ex-mode and +displaying C<:bEcursorE>) + +=item * + + undo/redo cursor positions are mostly wrong =back @@ -408,21 +428,31 @@ THE SOFTWARE. =over 4 -=item History: +=item * + +History: =over 4 -=item C< * /,?,n,N> to search through history (like rl_history_search.pl) +=item * + + C< * /,?,n,N> to search through history (like rl_history_search.pl) =back -=item Window switching (C<:b>) +=item * + +Window switching (C<:b>) =over 4 -=item Tab completion of window(-item) names +=item * + +Tab completion of window(-item) names -=item non-sequential matches(?) +=item * + +non-sequential matches(?) =back @@ -438,7 +468,7 @@ Things we're not ever likely to do: =over 4 -=item Macros +=item * Macros =back @@ -455,9 +485,9 @@ use Irssi::TextUI; # for sbar_items_redraw use Irssi::Irc; # necessary for 0.8.14 -use vars qw($VERSION %IRSSI); -$VERSION = "1.0.1"; -%IRSSI = + +our $VERSION = "1.0.2"; +our %IRSSI = ( authors => "Tom Feist (shabble), Simon Ruderich (rudi_s)", contact => 'shabble+irssi@metavore.org, ' -- cgit v1.2.3 From 283ae224e4dee7b2dce7a81d9554570675ab0d3a Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Mon, 18 Apr 2011 16:02:03 +0100 Subject: vim-mode/vim_mode: more docs update. Grar. --- vim-mode/README.pod | 30 ++++++++---------------------- vim-mode/vim_mode.pl | 30 ++++++++---------------------- 2 files changed, 16 insertions(+), 44 deletions(-) (limited to 'vim-mode') diff --git a/vim-mode/README.pod b/vim-mode/README.pod index 4783c23..af6ddf2 100644 --- a/vim-mode/README.pod +++ b/vim-mode/README.pod @@ -199,7 +199,7 @@ C<:ls>, C<:buffers> =item Display registers: -<:reg[isters] {args}>, C<:di[splay] {args}> +C<:reg[isters] {args}>, C<:di[splay] {args}> =item Display undolist: @@ -312,33 +312,19 @@ following settings are available: =over 4 -=item * utf8 +=item * utf8 - Support UTF-8 characters, boolean, default on -Support UTF-8 characters, boolean, default on +=item * debug - Enable debug output, boolean, default off -=item debug +=item * cmd_seq - Char that when double-pressed simulates CEscE>, string, default '' (disabled) -Enable debug output, boolean, default off +=item * start_cmd - Start every line in command mode, boolean, default off -=item cmd_seq +=item * max_undo_lines - Sze of the undo buffer. Integer, default 50 items. -Char that when double-pressed simulates CEscE>, string, default '' (disabled) +=item * ex_history_size - Number of items stored in the ex-mode history. Integer, default 100. -=item start_cmd - -Start every line in command mode, boolean, default off - -=item max_undo_lines - -Sze of the undo buffer. Integer, default 50 items. - -=item ex_history_size - -Number of items stored in the ex-mode history. Integer, default 100. - -=item prompt_leading_space - -Ddetermines whether ex mode prepends a space to the displayed input. Boolean, default on +=item * prompt_leading_space - Ddetermines whether ex mode prepends a space to the displayed input. Boolean, default on =back diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index ae43d6b..d68f974 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -199,7 +199,7 @@ C<:ls>, C<:buffers> =item Display registers: -<:reg[isters] {args}>, C<:di[splay] {args}> +C<:reg[isters] {args}>, C<:di[splay] {args}> =item Display undolist: @@ -312,33 +312,19 @@ following settings are available: =over 4 -=item * utf8 +=item * utf8 - Support UTF-8 characters, boolean, default on -Support UTF-8 characters, boolean, default on +=item * debug - Enable debug output, boolean, default off -=item debug +=item * cmd_seq - Char that when double-pressed simulates CEscE>, string, default '' (disabled) -Enable debug output, boolean, default off +=item * start_cmd - Start every line in command mode, boolean, default off -=item cmd_seq +=item * max_undo_lines - Sze of the undo buffer. Integer, default 50 items. -Char that when double-pressed simulates CEscE>, string, default '' (disabled) +=item * ex_history_size - Number of items stored in the ex-mode history. Integer, default 100. -=item start_cmd - -Start every line in command mode, boolean, default off - -=item max_undo_lines - -Sze of the undo buffer. Integer, default 50 items. - -=item ex_history_size - -Number of items stored in the ex-mode history. Integer, default 100. - -=item prompt_leading_space - -Ddetermines whether ex mode prepends a space to the displayed input. Boolean, default on +=item * prompt_leading_space - Ddetermines whether ex mode prepends a space to the displayed input. Boolean, default on =back -- cgit v1.2.3 From c967d19adca4d812d21cff3bef4f496697a30707 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Mon, 18 Apr 2011 16:08:31 +0100 Subject: vim-mode/vim_mode: all bullet points finally fired. I hope. --- vim-mode/README.pod | 134 +++++++++++++++++++++++++++++++++------------------ vim-mode/vim_mode.pl | 134 +++++++++++++++++++++++++++++++++------------------ 2 files changed, 176 insertions(+), 92 deletions(-) (limited to 'vim-mode') diff --git a/vim-mode/README.pod b/vim-mode/README.pod index af6ddf2..c6de881 100644 --- a/vim-mode/README.pod +++ b/vim-mode/README.pod @@ -33,9 +33,9 @@ disabled in irssi < 0.8.13: =over 4 -=item C C (only with count, they work fine without count in older versions) +=item * C C (only with count, they work fine without count in older versions) -=item C, C +=item * C, C =back @@ -75,7 +75,7 @@ Currently Supported ex-commands: =over 4 -=item C<:map> +=item * C<:map> =back @@ -89,47 +89,88 @@ It supports most commonly used command mode features: =over 2 -=item Insert/Command mode. C and C enter command mode. C allows to use C as Escape (any other character can be used as well). +=item * Insert/Command mode. -=item Cursor motion: CSpaceE EBSE f t F T> +C and C enter command mode. C allows +to use C as Escape (any other character can be used as well). -=item History motion: C C moves to the oldest (first) history -line. C without a count moves to the current input line, with a count it goes to the I history line (1 is the oldest). +=item * Cursor motion: -=item Cursor word motion: C +CSpaceE EBSE f t F T> -=item Word objects (only the following work yet): C +=item * History motion: -=item Yank and paste: C +C C moves to the oldest (first) history line. C without a +count moves to the current input line, with a count it goes to the I +history line (1 is the oldest). -=item Change and delete: C +=item * Cursor word motion: -=item Delete at cursor: C +C -=item Replace at cursor: C +=item * Word objects (only the following work yet): -=item Insert mode: C +C -=item Switch case: C<~> +=item * Yank and paste: -=item Repeat change: C<.> + C -=item Repeat C +=item * Change and delete: -=item Registers: C<"a-"z "" "0 "* "+ "_> (black hole) +C -=item Line-wise shortcuts: C
+=item * Delete at cursor: -=item Shortcuts: C +C -=item Scroll the scrollback buffer: C +=item * Replace at cursor: -=item Switch to last active window: C +C -=item Switch split windows: +=item * Insert mode: -=item Undo/Redo: C +C + +=item * Switch case: + +C<~> + +=item * Repeat change: + +C<.> + +=item * Repeat + +C + +=item * Registers: + +C<"a-"z "" "0 "* "+ "_> (black hole) + +=item * Line-wise shortcuts: + +C
+ +=item * Shortcuts: + +C + +=item * Scroll the scrollback buffer: + +C + +=item * Switch to last active window: + +C + +=item * Switch split windows: + + + +=item * Undo/Redo: + +C =back @@ -139,13 +180,13 @@ Counts and combinations work as well, e.g. C or C<3iabcEescE>. Cou =over 4 -=item Appending to register with C<"A-"Z> +=item * Appending to register with C<"A-"Z> -=item C<""> is the default yank/delete register. +=item * C<""> is the default yank/delete register. -=item C<"0> contains the last yank (if no register was specified). +=item * C<"0> contains the last yank (if no register was specified). -=item The special registers C<"* "+> both contain irssi's internal cut-buffer. +=item * The special registers C<"* "+> both contain irssi's internal cut-buffer. =back @@ -155,7 +196,7 @@ The following insert mode mappings are supported: =over 4 -=item Insert register content: Ctrl-R x (where x is the register to insert) +=item * Insert register content: Ctrl-R x (where x is the register to insert) =back @@ -165,7 +206,7 @@ Ex-mode (activated by C<:> in command mode) supports the following commands: =over 4 -=item Command History: +=item * Command History: CuparrowE> - cycle backwards through history @@ -173,7 +214,7 @@ CdownarrowE> - cycle forwards through history C<:eh> - show ex history -=item Switching buffers: +=item * Switching buffers: C<:[N]b [N]> - switch to channel number @@ -189,41 +230,41 @@ C<:[N]bn[ext] [N]> - switch to next window C<:[N]bp[rev] [N]> - switch to previous window -=item Close window: +=item * Close window: C<:[N]bd[elete] [N]> -=item Display windows: +=item * Display windows: C<:ls>, C<:buffers> -=item Display registers: +=item * Display registers: C<:reg[isters] {args}>, C<:di[splay] {args}> -=item Display undolist: +=item * Display undolist: C<:undol[ist]> (mostly used for debugging) -=item Source files: +=item * Source files: C<:so[urce]> - only sources vim_moderc at the moment, F<{file}> not supported -=item Mappings: +=item * Mappings: C<:map> - display custom mappings -=item Save mappings: +=item * Saving mappings: C<:mkv[imrc][!]> - like in Vim, but [file] not supported -=item Substitute: +=item * Substitution: -C<:s///> - I and I are supported as flags, only /// can be used as - separator, uses Perl regex instead of Vim regex +C<:s///> - I and I are supported as flags, only C can be used as +eparator, and it uses Perl regex syntax instead of Vim syntax. -=item Settings: +=item * Settings: C<:se[t]> - display all options @@ -352,6 +393,7 @@ or contact rudi_s or shabble on irc.freenode.net (#irssi and #irssi_vim) =head1 AUTHORS Copyright E 2010-2011 Tom Feist Cshabble+irssi@metavore.orgE> and + Copyright E 2010-2011 Simon Ruderich Csimon@ruderich.orgE> =head1 THANKS @@ -360,11 +402,11 @@ Particular thanks go to =over 4 -=item estragib: a lot of testing and many bug reports and feature requests +=item * estragib: a lot of testing and many bug reports and feature requests -=item iaj: testing +=item * iaj: testing -=item tmr: explaining how various bits of vim work +=item * tmr: explaining how various bits of vim work =back diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index d68f974..8132ebd 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -33,9 +33,9 @@ disabled in irssi < 0.8.13: =over 4 -=item C C (only with count, they work fine without count in older versions) +=item * C C (only with count, they work fine without count in older versions) -=item C, C +=item * C, C =back @@ -75,7 +75,7 @@ Currently Supported ex-commands: =over 4 -=item C<:map> +=item * C<:map> =back @@ -89,47 +89,88 @@ It supports most commonly used command mode features: =over 2 -=item Insert/Command mode. C and C enter command mode. C allows to use C as Escape (any other character can be used as well). +=item * Insert/Command mode. -=item Cursor motion: CSpaceE EBSE f t F T> +C and C enter command mode. C allows +to use C as Escape (any other character can be used as well). -=item History motion: C C moves to the oldest (first) history -line. C without a count moves to the current input line, with a count it goes to the I history line (1 is the oldest). +=item * Cursor motion: -=item Cursor word motion: C +CSpaceE EBSE f t F T> -=item Word objects (only the following work yet): C +=item * History motion: -=item Yank and paste: C +C C moves to the oldest (first) history line. C without a +count moves to the current input line, with a count it goes to the I +history line (1 is the oldest). -=item Change and delete: C +=item * Cursor word motion: -=item Delete at cursor: C +C -=item Replace at cursor: C +=item * Word objects (only the following work yet): -=item Insert mode: C +C -=item Switch case: C<~> +=item * Yank and paste: -=item Repeat change: C<.> + C -=item Repeat C +=item * Change and delete: -=item Registers: C<"a-"z "" "0 "* "+ "_> (black hole) +C -=item Line-wise shortcuts: C
+=item * Delete at cursor: -=item Shortcuts: C +C -=item Scroll the scrollback buffer: C +=item * Replace at cursor: -=item Switch to last active window: C +C -=item Switch split windows: +=item * Insert mode: -=item Undo/Redo: C +C + +=item * Switch case: + +C<~> + +=item * Repeat change: + +C<.> + +=item * Repeat + +C + +=item * Registers: + +C<"a-"z "" "0 "* "+ "_> (black hole) + +=item * Line-wise shortcuts: + +C
+ +=item * Shortcuts: + +C + +=item * Scroll the scrollback buffer: + +C + +=item * Switch to last active window: + +C + +=item * Switch split windows: + + + +=item * Undo/Redo: + +C =back @@ -139,13 +180,13 @@ Counts and combinations work as well, e.g. C or C<3iabcEescE>. Cou =over 4 -=item Appending to register with C<"A-"Z> +=item * Appending to register with C<"A-"Z> -=item C<""> is the default yank/delete register. +=item * C<""> is the default yank/delete register. -=item C<"0> contains the last yank (if no register was specified). +=item * C<"0> contains the last yank (if no register was specified). -=item The special registers C<"* "+> both contain irssi's internal cut-buffer. +=item * The special registers C<"* "+> both contain irssi's internal cut-buffer. =back @@ -155,7 +196,7 @@ The following insert mode mappings are supported: =over 4 -=item Insert register content: Ctrl-R x (where x is the register to insert) +=item * Insert register content: Ctrl-R x (where x is the register to insert) =back @@ -165,7 +206,7 @@ Ex-mode (activated by C<:> in command mode) supports the following commands: =over 4 -=item Command History: +=item * Command History: CuparrowE> - cycle backwards through history @@ -173,7 +214,7 @@ CdownarrowE> - cycle forwards through history C<:eh> - show ex history -=item Switching buffers: +=item * Switching buffers: C<:[N]b [N]> - switch to channel number @@ -189,41 +230,41 @@ C<:[N]bn[ext] [N]> - switch to next window C<:[N]bp[rev] [N]> - switch to previous window -=item Close window: +=item * Close window: C<:[N]bd[elete] [N]> -=item Display windows: +=item * Display windows: C<:ls>, C<:buffers> -=item Display registers: +=item * Display registers: C<:reg[isters] {args}>, C<:di[splay] {args}> -=item Display undolist: +=item * Display undolist: C<:undol[ist]> (mostly used for debugging) -=item Source files: +=item * Source files: C<:so[urce]> - only sources vim_moderc at the moment, F<{file}> not supported -=item Mappings: +=item * Mappings: C<:map> - display custom mappings -=item Save mappings: +=item * Saving mappings: C<:mkv[imrc][!]> - like in Vim, but [file] not supported -=item Substitute: +=item * Substitution: -C<:s///> - I and I are supported as flags, only /// can be used as - separator, uses Perl regex instead of Vim regex +C<:s///> - I and I are supported as flags, only C can be used as +eparator, and it uses Perl regex syntax instead of Vim syntax. -=item Settings: +=item * Settings: C<:se[t]> - display all options @@ -352,6 +393,7 @@ or contact rudi_s or shabble on irc.freenode.net (#irssi and #irssi_vim) =head1 AUTHORS Copyright E 2010-2011 Tom Feist Cshabble+irssi@metavore.orgE> and + Copyright E 2010-2011 Simon Ruderich Csimon@ruderich.orgE> =head1 THANKS @@ -360,11 +402,11 @@ Particular thanks go to =over 4 -=item estragib: a lot of testing and many bug reports and feature requests +=item * estragib: a lot of testing and many bug reports and feature requests -=item iaj: testing +=item * iaj: testing -=item tmr: explaining how various bits of vim work +=item * tmr: explaining how various bits of vim work =back -- cgit v1.2.3 From d07463ffc3dce119438403f52b8b21095b1742f4 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Mon, 18 Apr 2011 18:36:38 +0100 Subject: vim-mode/vim_mode: added '$vim_cmd_mode' expando that contains the same info as the vim_mode sbar item. Needs some cleanup though --- vim-mode/vim_mode.pl | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'vim-mode') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 8132ebd..30b2e9e 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -2519,9 +2519,9 @@ sub _matching_windows { # STATUS ITEMS -# vi mode status item. -sub vim_mode_cb { - my ($sb_item, $get_size_only) = @_; +#TODO: give these things better names. +sub vim_mode_cmd { + my $mode_str = ''; if ($mode == M_INS) { $mode_str = 'Insert'; @@ -2530,7 +2530,7 @@ sub vim_mode_cb { } else { $mode_str = '%_Command%_'; if ($register ne '"' or $numeric_prefix or $operator or $movement or - $pending_map) { + $pending_map) { my $partial = ''; if ($register ne '"') { $partial .= '"' . $register; @@ -2552,6 +2552,18 @@ sub vim_mode_cb { $mode_str .= " ($partial)"; } } + return $mode_str; +} + +sub vim_exp_mode { + my ($server, $witem, $arg) = @_; + return vim_mode_cmd(); +} + +# vi mode status item. +sub vim_mode_cb { + my ($sb_item, $get_size_only) = @_; + my $mode_str = vim_mode_cmd(); $sb_item->default_handler($get_size_only, "{sb $mode_str}", '', 0); } @@ -3112,6 +3124,8 @@ sub vim_mode_init { Irssi::statusbar_item_register ('vim_mode', 0, 'vim_mode_cb'); Irssi::statusbar_item_register ('vim_windows', 0, 'b_windows_cb'); + Irssi::expando_create('vim_cmd_mode' => \&vim_exp_mode, {}); + # Register all available settings. foreach my $name (keys %$settings) { _setting_register($name); @@ -3459,6 +3473,8 @@ sub _update_mode { } Irssi::statusbar_items_redraw("vim_mode"); + Irssi::statusbar_items_redraw ('uberprompt'); + } sub _set_prompt { -- cgit v1.2.3 From 10f7e62c5f4ac6f2d524d8fdef754efc70b62d7f Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Fri, 22 Apr 2011 01:36:54 +0100 Subject: vim-mode/vim_mode: added a new $vim_wins expando to be used instead of the vim_windows statusbar item if desired. --- vim-mode/vim_mode.pl | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) (limited to 'vim-mode') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 30b2e9e..fb818dd 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -2555,22 +2555,7 @@ sub vim_mode_cmd { return $mode_str; } -sub vim_exp_mode { - my ($server, $witem, $arg) = @_; - return vim_mode_cmd(); -} - -# vi mode status item. -sub vim_mode_cb { - my ($sb_item, $get_size_only) = @_; - my $mode_str = vim_mode_cmd(); - $sb_item->default_handler($get_size_only, "{sb $mode_str}", '', 0); -} - -# :b window list item. -sub b_windows_cb { - my ($sb_item, $get_size_only) = @_; - +sub vim_wins_data { my $windows = ''; # A little code duplication of cmd_ex_command(), but \s+ instead of \s* so @@ -2590,6 +2575,31 @@ sub b_windows_cb { } } } + return $windows; +} + +sub vim_exp_mode { + my ($server, $witem, $arg) = @_; + return vim_mode_cmd(); +} + +sub vim_exp_wins { + my ($server, $witem, $arg) = @_; + return vim_wins_data(); +} + +# vi mode status item. +sub vim_mode_cb { + my ($sb_item, $get_size_only) = @_; + my $mode_str = vim_mode_cmd(); + $sb_item->default_handler($get_size_only, "{sb $mode_str}", '', 0); +} + +# :b window list item. +sub b_windows_cb { + my ($sb_item, $get_size_only) = @_; + + my $windows = vim_wins_data(); $sb_item->default_handler($get_size_only, "{sb $windows}", '', 0); } @@ -3125,6 +3135,8 @@ sub vim_mode_init { Irssi::statusbar_item_register ('vim_windows', 0, 'b_windows_cb'); Irssi::expando_create('vim_cmd_mode' => \&vim_exp_mode, {}); + Irssi::expando_create('vim_wins' => \&vim_exp_wins, {}); + # Register all available settings. foreach my $name (keys %$settings) { -- cgit v1.2.3 From 5b03835bdda9b7580760c0a98261c64a66e302f6 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Fri, 22 Apr 2011 02:52:47 +0100 Subject: vim-mode/vim_mode: more documentation on how to use uberprompt hooks and expandos to get vim_mode sbar items or variables. --- vim-mode/README.pod | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++- vim-mode/vim_mode.pl | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 136 insertions(+), 2 deletions(-) (limited to 'vim-mode') diff --git a/vim-mode/README.pod b/vim-mode/README.pod index c6de881..dbb7d07 100644 --- a/vim-mode/README.pod +++ b/vim-mode/README.pod @@ -49,6 +49,15 @@ to a script of this size and complexity. =head2 SETUP +Vim Mode provides certain feedback to the user, such as the currently active +mode (command, insert, ex), and if switching buffers, which buffer(s) currently +match the search terms. + +There are two ways to go about displaying this information, as described in +the following sections: + +=head3 Statusbar Items + Run the following command to add a statusbar item that shows which mode you're in. @@ -62,6 +71,64 @@ C B Remember to C after adding these statusbar items to make them permanent. +B If you would rather have these statusbar items on your prompt +line rather than thte window statusbar, please follow these steps. + +For I items (that is, after the input field: + +=over 4 + +=item 1 C + +=item 2 C + +=item 3 C + +=item 4 C + +=back + +For I items (before the prompt): + +=over 4 + +=item 1 C + +=item 2 C + +=item 3 C + +=item 4 C + +=back + +If you wish to add both C and C items, replace steps 1 and 2 +with the following: + +=over 4 + +=item 1 C + +=item 2 C + +=back + +and then complete stages 3 and 4 as above. Replace the C<-after> and C<-alignment> +to suit your location preferences. + +=head3 Expando Variables + +Vim mode augments the existing Irssi expando (automatic variables) with two +additional ones: C<$vim_cmd_mode> and C<$vim_wins>. + +C<$vim_cmd_mode> is the equivalent of the C statusbar item, and +C<$vim_wins> is the counterpart of C. + +They can be added to your theme, or inserted into your uberprompt using +the + +"C" command. + =head3 FILE-BASED CONFIGURATION @@ -334,7 +401,7 @@ Examples: =item * C<:map EC-GE /window goto 1> -=item * C<:map EC-EE > - disable , it does nothing now +=item * C<:map EC-EE > - disable EC-EE, it does nothing now =item * C<:unmap EC-EE> - restore default behavior of CC-EE> after disabling it diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index fb818dd..e2bfed0 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -49,6 +49,15 @@ to a script of this size and complexity. =head2 SETUP +Vim Mode provides certain feedback to the user, such as the currently active +mode (command, insert, ex), and if switching buffers, which buffer(s) currently +match the search terms. + +There are two ways to go about displaying this information, as described in +the following sections: + +=head3 Statusbar Items + Run the following command to add a statusbar item that shows which mode you're in. @@ -62,6 +71,64 @@ C B Remember to C after adding these statusbar items to make them permanent. +B If you would rather have these statusbar items on your prompt +line rather than thte window statusbar, please follow these steps. + +For I items (that is, after the input field: + +=over 4 + +=item 1 C + +=item 2 C + +=item 3 C + +=item 4 C + +=back + +For I items (before the prompt): + +=over 4 + +=item 1 C + +=item 2 C + +=item 3 C + +=item 4 C + +=back + +If you wish to add both C and C items, replace steps 1 and 2 +with the following: + +=over 4 + +=item 1 C + +=item 2 C + +=back + +and then complete stages 3 and 4 as above. Replace the C<-after> and C<-alignment> +to suit your location preferences. + +=head3 Expando Variables + +Vim mode augments the existing Irssi expando (automatic variables) with two +additional ones: C<$vim_cmd_mode> and C<$vim_wins>. + +C<$vim_cmd_mode> is the equivalent of the C statusbar item, and +C<$vim_wins> is the counterpart of C. + +They can be added to your theme, or inserted into your uberprompt using +the + +"C" command. + =head3 FILE-BASED CONFIGURATION @@ -334,7 +401,7 @@ Examples: =item * C<:map EC-GE /window goto 1> -=item * C<:map EC-EE > - disable , it does nothing now +=item * C<:map EC-EE > - disable EC-EE, it does nothing now =item * C<:unmap EC-EE> - restore default behavior of CC-EE> after disabling it -- cgit v1.2.3 From 931b7cfecbd06c59936670ff1ed42f36c4464fdd Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Fri, 22 Apr 2011 03:03:38 +0100 Subject: vim-mode/vim_mode: more doc updates about hooks and sbar items. --- vim-mode/README.pod | 47 +++++++++++++++++++++++++++++------------------ vim-mode/vim_mode.pl | 49 ++++++++++++++++++++++++++++++------------------- 2 files changed, 59 insertions(+), 37 deletions(-) (limited to 'vim-mode') diff --git a/vim-mode/README.pod b/vim-mode/README.pod index dbb7d07..dd3b61a 100644 --- a/vim-mode/README.pod +++ b/vim-mode/README.pod @@ -74,7 +74,14 @@ permanent. B If you would rather have these statusbar items on your prompt line rather than thte window statusbar, please follow these steps. -For I items (that is, after the input field: +For technical reasons, I must occasionally call C, which will remove or deactivate any manually added items on the prompt +statusbar. To get around this, uberprompt provides two command hooks, +C and C. Both of these settings +can contain one (or more, using C commands to be executed when the prompt +is enabled and disabled, respectively. + +For I items (that is, after the input field: =over 4 @@ -88,7 +95,8 @@ For I items (that is, after the input field: =back -For I items (before the prompt): +For I items (before the prompt): + =over 4 @@ -116,6 +124,9 @@ with the following: and then complete stages 3 and 4 as above. Replace the C<-after> and C<-alignment> to suit your location preferences. +B It is also possible to place the items between the prompt and input field, +by specifying C<-after prompt> or C<-before input> as appropriate. + =head3 Expando Variables Vim mode augments the existing Irssi expando (automatic variables) with two @@ -171,11 +182,11 @@ C C moves to the oldest (first) history line. C without a count moves to the current input line, with a count it goes to the I history line (1 is the oldest). -=item * Cursor word motion: +=item * Cursor word motion: C -=item * Word objects (only the following work yet): +=item * Word objects (only the following work yet): C @@ -183,59 +194,59 @@ C C -=item * Change and delete: +=item * Change and delete: C -=item * Delete at cursor: +=item * Delete at cursor: C -=item * Replace at cursor: +=item * Replace at cursor: C -=item * Insert mode: +=item * Insert mode: C -=item * Switch case: +=item * Switch case: C<~> -=item * Repeat change: +=item * Repeat change: C<.> -=item * Repeat +=item * Repeat C -=item * Registers: +=item * Registers: C<"a-"z "" "0 "* "+ "_> (black hole) -=item * Line-wise shortcuts: +=item * Line-wise shortcuts: C
-=item * Shortcuts: +=item * Shortcuts: C -=item * Scroll the scrollback buffer: +=item * Scroll the scrollback buffer: C -=item * Switch to last active window: +=item * Switch to last active window: C -=item * Switch split windows: +=item * Switch split windows: -=item * Undo/Redo: +=item * Undo/Redo: C diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index e2bfed0..7d364a1 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -74,7 +74,14 @@ permanent. B If you would rather have these statusbar items on your prompt line rather than thte window statusbar, please follow these steps. -For I items (that is, after the input field: +For technical reasons, I must occasionally call C, which will remove or deactivate any manually added items on the prompt +statusbar. To get around this, uberprompt provides two command hooks, +C and C. Both of these settings +can contain one (or more, using C commands to be executed when the prompt +is enabled and disabled, respectively. + +For I items (that is, after the input field: =over 4 @@ -88,7 +95,8 @@ For I items (that is, after the input field: =back -For I items (before the prompt): +For I items (before the prompt): + =over 4 @@ -116,6 +124,9 @@ with the following: and then complete stages 3 and 4 as above. Replace the C<-after> and C<-alignment> to suit your location preferences. +B It is also possible to place the items between the prompt and input field, +by specifying C<-after prompt> or C<-before input> as appropriate. + =head3 Expando Variables Vim mode augments the existing Irssi expando (automatic variables) with two @@ -171,11 +182,11 @@ C C moves to the oldest (first) history line. C without a count moves to the current input line, with a count it goes to the I history line (1 is the oldest). -=item * Cursor word motion: +=item * Cursor word motion: C -=item * Word objects (only the following work yet): +=item * Word objects (only the following work yet): C @@ -183,59 +194,59 @@ C C -=item * Change and delete: +=item * Change and delete: C -=item * Delete at cursor: +=item * Delete at cursor: C -=item * Replace at cursor: +=item * Replace at cursor: C -=item * Insert mode: +=item * Insert mode: C -=item * Switch case: +=item * Switch case: C<~> -=item * Repeat change: +=item * Repeat change: C<.> -=item * Repeat +=item * Repeat C -=item * Registers: +=item * Registers: C<"a-"z "" "0 "* "+ "_> (black hole) -=item * Line-wise shortcuts: +=item * Line-wise shortcuts: C
-=item * Shortcuts: +=item * Shortcuts: C -=item * Scroll the scrollback buffer: +=item * Scroll the scrollback buffer: C -=item * Switch to last active window: +=item * Switch to last active window: C -=item * Switch split windows: +=item * Switch split windows: -=item * Undo/Redo: +=item * Undo/Redo: C @@ -2622,7 +2633,7 @@ sub vim_mode_cmd { return $mode_str; } -sub vim_wins_data { +sub vim_wins_data { my $windows = ''; # A little code duplication of cmd_ex_command(), but \s+ instead of \s* so -- cgit v1.2.3 From ea5c61881c31ce7420ebb377888d56943dd40648 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Fri, 22 Apr 2011 03:05:55 +0100 Subject: vim-mode/vim_mode: docs: missed a bracket. --- vim-mode/README.pod | 2 +- vim-mode/vim_mode.pl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'vim-mode') diff --git a/vim-mode/README.pod b/vim-mode/README.pod index dd3b61a..e814e6d 100644 --- a/vim-mode/README.pod +++ b/vim-mode/README.pod @@ -78,7 +78,7 @@ For technical reasons, I must occasionally call C, which will remove or deactivate any manually added items on the prompt statusbar. To get around this, uberprompt provides two command hooks, C and C. Both of these settings -can contain one (or more, using C commands to be executed when the prompt +can contain one (or more, using C) commands to be executed when the prompt is enabled and disabled, respectively. For I items (that is, after the input field: diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 7d364a1..cb11600 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -78,7 +78,7 @@ For technical reasons, I must occasionally call C, which will remove or deactivate any manually added items on the prompt statusbar. To get around this, uberprompt provides two command hooks, C and C. Both of these settings -can contain one (or more, using C commands to be executed when the prompt +can contain one (or more, using C) commands to be executed when the prompt is enabled and disabled, respectively. For I items (that is, after the input field: -- cgit v1.2.3 From 9676393d054a2a1c9b047b166204f229f51cd8a4 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Fri, 22 Apr 2011 03:12:49 +0100 Subject: vim-mode/vim_mode: FINAL doc update for now. Or Else. --- vim-mode/README.pod | 10 +++++----- vim-mode/vim_mode.pl | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'vim-mode') diff --git a/vim-mode/README.pod b/vim-mode/README.pod index e814e6d..83962ff 100644 --- a/vim-mode/README.pod +++ b/vim-mode/README.pod @@ -81,6 +81,8 @@ C and C. Both of these settings can contain one (or more, using C) commands to be executed when the prompt is enabled and disabled, respectively. +See the L for further details. + For I items (that is, after the input field: =over 4 @@ -97,7 +99,6 @@ For I items (that is, after the input field: For I items (before the prompt): - =over 4 =item 1 C @@ -111,7 +112,7 @@ For I items (before the prompt): =back If you wish to add both C and C items, replace steps 1 and 2 -with the following: +above with the following (right-aligned): =over 4 @@ -136,10 +137,9 @@ C<$vim_cmd_mode> is the equivalent of the C statusbar item, and C<$vim_wins> is the counterpart of C. They can be added to your theme, or inserted into your uberprompt using -the - -"C" command. +a command such as: +"C" =head3 FILE-BASED CONFIGURATION diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index cb11600..b0f739f 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -81,6 +81,8 @@ C and C. Both of these settings can contain one (or more, using C) commands to be executed when the prompt is enabled and disabled, respectively. +See the L for further details. + For I items (that is, after the input field: =over 4 @@ -97,7 +99,6 @@ For I items (that is, after the input field: For I items (before the prompt): - =over 4 =item 1 C @@ -111,7 +112,7 @@ For I items (before the prompt): =back If you wish to add both C and C items, replace steps 1 and 2 -with the following: +above with the following (right-aligned): =over 4 @@ -136,10 +137,9 @@ C<$vim_cmd_mode> is the equivalent of the C statusbar item, and C<$vim_wins> is the counterpart of C. They can be added to your theme, or inserted into your uberprompt using -the - -"C" command. +a command such as: +"C" =head3 FILE-BASED CONFIGURATION -- cgit v1.2.3