Padre::Plugin::Shell::Base - A base class for Padre plugins.
Base class for plugins that use the system shell to extend Padre.
Subclass Padre::Plugin::Shell::Base to create a plugin.
package Padre::Plugin::Shell::Foo; use base 'Padre::Plugin::Shell::Base'; use 5.008; use strict; use warnings; use Padre::Wx (); sub plugin_menu { my ($self) = @_; my @menu = (); push @menu, "Do Foo" => sub {$self->do_foo()}; push @menu, '---' => undef; push @menu, Wx::gettext("&Configure Foo") => sub { $self->edit_config_file() },; return @menu; } sub example_config { my ($self) = @_; my $config = "---\n"; # additional config return $config; } sub do_foo { my ( $self ) = @_; my %config = $self->get_config(); # additional foo } 1;
Subclass Padre::Plugin to wrap the plugin.
package Padre::Plugin::Foo; use base 'Padre::Plugin'; use 5.008; use strict; use warnings; use Padre::Plugin (); use Padre::Plugin::Shell::Foo; our $VERSION = '0.01'; my $foo_plugin; sub plugin_name { 'Foo'; } sub padre_interfaces { 'Padre::Plugin' => 0.43; } sub menu_plugins_simple { my ($self) = @_; $foo_plugin = Padre::Plugin::Shell::Foo->new(); 'Foo' => [$plugin->plugin_menu()]; } 1;
To provide additional information for the plugins, the following environment variables are set prior to performing the plugin action:
~/.padre
Takes the contents of $file_pathname and appends it to after the selection in the current editor tab.
$file_pathname
Creates a new document from the contents in $file_pathname. The (optional) $mimetype tells Padre what kind of document is being created. If no mimetype is specified the Padre will be attempt to guess the mimetype.
$mimetype
Takes the contents of $file_pathname and uses it to replace the selection in the current editor tab.
Creates a temporary file and returns the pathname of the temporary file.
Deletes a temporary file.
Returns the contents of the specified file.
NOTE: Plugin configurations are stored using YAML.
Returns the pathname of a plugin configuration file.
Opens the configuration file for a plugin for editing.
Returns an example configuration for a plugin. Is to be overwritten by plugins that subclass this package.
Returns a hash containing the configuration for a plugin.
Initializes a configuration file for a plugin using the return value from example_config.
example_config
Updates the environment variables supported by plugins that subclass this package. See the ENVIRONMENT VARIABLES section for details.
The cannonical new method.
Returns the menu for a plugin. Is to be overwritten by plugins that subclass this package.
Displays an error message.
Gregory Siems <gsiems@gmail.com>
Copyright (C) 2009 by Gregory Siems
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
To install Padre::Plugin::Shell::Base, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Padre::Plugin::Shell::Base
CPAN shell
perl -MCPAN -e shell install Padre::Plugin::Shell::Base
For more information on module installation, please visit the detailed CPAN module installation guide.