| Padre-Plugin-Vi documentation | Contained in the Padre-Plugin-Vi distribution. |
Padre::Plugin::Vi - vi keyboard for Padre
Once installed and enabled the user is in full vi-emulation mode, which was partially implemented.
The 3 basic modes of vi are in development:
When you turn on vi-mode, or load Padre with vi-mode already enabled you reach the normal navigation mode of vi.
We don't plan to implement many of the configuration options of vi. Even parts that are going to be implemented will not use the same method of configuration.
That said, we are planning to add looking for vi configuration options in the source file so the editor can set its own configuration based on the vi configuration options.
The following are implemented:
Better indication that Padre is in vi-mode.
Change the cursor for navigation mode and back to insert mode. (fix i)
Integrate command line pop-up move it to the bottom of the window make it come up faster (show/hide instead of create/destroy?) (maybe actually we should have it integrated it into the main GUI and add it as another window under or above the output window?) Most importantly, make it faster to come up
/ and search connect it to the new (and yet experimental search)
r for replacing current character :q! - discard changes and exit
:e! :ls and
| Padre-Plugin-Vi documentation | Contained in the Padre-Plugin-Vi distribution. |
package Padre::Plugin::Vi; use strict; use warnings; use 5.008005; use base 'Padre::Plugin'; use Scalar::Util qw(refaddr); use Padre::Util ('_T'); use Padre::Constant (); our $VERSION = '0.23';
sub padre_interfaces { 'Padre::Plugin' => 0.43; } sub plugin_enable { my ($self) = @_; require Padre::Plugin::Vi::Editor; require Padre::Plugin::Vi::CommandLine; # foreach my $editor ( Padre->ide->wx->main->pages ) { # $self->editor_enable($editor); # } } sub plugin_disable { my ($self) = @_; foreach my $editor ( Padre->ide->wx->main->pages ) { $self->editor_stop($editor); } delete $INC{"Padre/Plugin/Vi/Editor.pm"}; delete $INC{"Padre/Plugin/Vi/CommandLine.pm"}; return; } sub editor_enable { my ( $self, $editor, $doc ) = @_; $self->{editor}{ refaddr $editor} = Padre::Plugin::Vi::Editor->new($editor); Wx::Event::EVT_KEY_DOWN( $editor, sub { $self->evt_key_down(@_) } ); Wx::Event::EVT_CHAR( $editor, sub { $self->evt_char(@_) } ); return 1; } sub editor_stop { my ( $self, $editor, $doc ) = @_; delete $self->{editor}{ refaddr $editor}; Wx::Event::EVT_KEY_DOWN( $editor, undef ); Wx::Event::EVT_CHAR( $editor, undef ); return 1; } sub menu_plugins_simple { return ( "Vi mode" => [ _T('About') => \&about ] ); } sub about { my ($main) = @_; my $about = Wx::AboutDialogInfo->new; $about->SetName("Padre::Plugin::Vi"); $about->SetDescription("Try to emulate the vi modes of operation\n"); $about->SetVersion($Padre::Plugin::Vi::VERSION); $about->SetCopyright( _T("Copyright 2008 Gabor Szabo") ); # Only Unix/GTK native about box supports websites if (Padre::Constant::WXGTK) { $about->SetWebSite("http://padre.perlide.org/"); } $about->AddDeveloper("Gabor Szabo"); Wx::AboutBox($about); return; } sub evt_key_down { my ( $self, $editor, $event ) = @_; my $mod = $event->GetModifiers || 0; my $code = $event->GetKeyCode; #print("key: '$mod', '$code'\n"); if ( 32 <= $code and $code <= 127 ) { $event->Skip; return; } my $skip = $self->{editor}{ refaddr $editor}->key_down( $mod, $code ); $event->Skip($skip); return; } sub evt_char { my ( $self, $editor, $event ) = @_; my $mod = $event->GetModifiers || 0; my $code = $event->GetKeyCode; #printf("char: '$mod', '$code' '%s'\n", chr($code)); if ( 32 <= $code and $code <= 127 ) { my $skip = $self->{editor}{ refaddr $editor}->get_char( $mod, $code, chr($code) ); $event->Skip($skip); } return; } 1; # Copyright 2008-2010 Gabor Szabo. # LICENSE # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl 5 itself.