The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Padre - Perl Application Development and Refactoring Environment

SYNOPSIS

Padre is a text editor aimed to be an IDE for Perl.

You should be able to just type in

  padre

and get the editor working.

While I have been using this editor since version 0.01 myself there are still lots of missing features.

Not only it is missing several important feature, everything is in a constant flux. Menus, shortcuts and the way they work will change from version to version.

Configuration options are also changing which means if you configure it in one version you might need to configure it again.

Having said that you can already use it for serious editing and you can even get involved and add the missing features.

You should also know that I am mostly working on Linux and I have been using vi for many years now. This means that I am not that familiar with the expectations of people using Windows.

Getting Started

After installing Padre you can start it by typing padre on the command line. On Windows that would be Start/Run padre.bat

(TODO) By default Padre starts with an editor containing a simple Perl script and instructions.

You can edit the file and save it using File/Save (Ctrl-S ).

You can run the script by pressing Run/Run Script (F5)

You can start new files File/New (Ctrl-N) or open existing files File/Open (Ctrl-O).

By default Padre uses the same perl interpreter fo executing code that it uses for itself but this will be configurable later.

FEATURES

Instead of duplicating all the text here, let me point you to the web site of Padre http://padre.perlide.org/ where we keep a list of existing and planned features.

DESCRIPTION

Configuration

The application maintains its configuration information in a directory called .padre.

Files operations

File/New creates a new empty file. By default Padre assumes this is a perl script. (TODO later this default will be configurable).

File/Open allows you to select brows for a file and select it for opening.

File/Open Selection, (Ctrl-Shift-O) if there is a selected text this will try to locate files that match the selction. If the selection looks like a path Padre will try to open that path either absolute or relative. If it looks like a module name (Some::Thing) it will try to find the appropriate file Some/Thing.pm in @INC and open it. currently this feature opens the firs file encountered. (TODO it should find all the possibilities and if there are multiple hits offer the user to choose. This will be especially important if we are working on a module that is also already installed. Padre might find the installed version first while we might want to open the development version.)

(TODO: when the file is not of perl type we should have other ways to recognize files from internal naming and have pathes to search. Surprise, not every language uses @INC.)

File/Close checks if the file is saved, if it is closes the current tab.

File/Close All closes all the file (in case they are not saved yet ask for instructions).

File/Close All but Current Document.

File/Reload File is interesting if you either made changes and want to discard them and/or if the file has changed on the disk. If there are unsaved changes Padre will ask you if you really want to throw them away. (TODO: make a backup of the file before discarding it)

File/Save Ctrl-S - save the current file. If the buffer has not yet save and has no filename associated with it, Padre will ask you for a filename.

File/Save As - Offer the user to select a new filename and save the content under that name.

File/Save All - Save all the currently opened files.

File/Convert - Convert line endings to Windows, Unix or Mac Classic style. (TODO stop the autoconversion of mixed files, just report them.)

Files/Recent Files - a list of recently opened files to open them easily. (TODO: update the list when we open a file, not only when opening padre) (TODO: allow the user to configure size of history)

File/Doc Stats - just random statistics about the current document. (TODO: If you miss anything important let us know!)

File/Quit also called exit.

Simple editing

The simple editing features (should) provide the expected behavior for Windows users.

Edit/Undo Ctrl-Z

Edit/Redo

Edit/Select All Ctrl-A , select all the characters in the current document

Edit/Copy Ctrl-C

Edit/Cut Ctrl-X

Edit/Paste Ctrl-V

(TODO What is Ctrl-D ?, duplicate the current line?)

Mouse right click

Click on the right button of the mouse brings up a context sensitive menu. It provides the basic editing functions and will provide other context sensitive options.

Projects (TODO)

Padre will have the notion of a Perl project. As we would like to make things as natural as possible for the perl developer and we think the distribution methods used for CPAN module are a good way to handle any project Padre will understand a project as a CPAN module. This does not mean that you project needs to end up on CPAN of course. But if your projects directory structure follows that of the modules on CPAN, Padre will be automtically recognize it.

Module::Starter

As a first step in the direction of supporting CPAN-style perl projects we integrated into Padre the use of Module::Starter

File/New.../Perl Distribution will bring up a dialog box where you can select some of the parameters your new project has such as Name of the Project (e.g. My::Widgets), Author - that is probably your name, e-mail (your e-mail).

Builder is the tool that you project is going to use to package itself and then your user will use to install the project. Currently Module::Build and ExtUtils::MakeMaker are supported. (TODO add Module::Install as well).

License is one of the keywords currently listed in the META.yml spec of Module::Build. (TODO: update the list or make it dynamic)

Once you click OK, Module::Starter will create a new directory called My-Widgets in the parent directory you selected in the last field.

Other

On Strawberry Perl you can associate .pl file extension with C:\strawberry\perl\bin\wxperl and then you can start double clicking on the application. It should work...

  Run This (F5) - run the current buffer with the current perl
  this currently only works with files with .pl  extensions.
  
  Run Any (Ctr-F5) - run any external application
  First time it will prompt you to a command line that you have to
  type in such as
  
  perl /full/path/to/my/script.pl

...then it will execute this every time you press Ctrl-F5 or the menu option. Currently Ctrl-F5 does not save any file. (This will be added later.)

You can edit the command line using the Run/Setup menu item.

Bookmarks

View/Set Bookmark (Ctrl-B) brings up a window with a predefined text containing the file name and line number (TODO should be the content of the current line).

View/Goto Bookmark (Ctrl-Shift-B) brings up a window with the list of available bookmarks. You can select one and press OK to jump to that location. If the file where the bookmark belongs to is not open currently, it will be opened and the cursor will jump to the desired place.

In both cases while the window is open you can select existing bookmarks and press the Delete button to remove the selected one or press Delete All to remove all the existing bookmarks.

  Ctr-1          matching brace
  Ctr-P          Autocompletition
  Alt-N          Nth Pane
  Ctr-TAB        Next Pane
  Ctr-Shift-TAB  Previous Pane
  Alt-S          Jump to list of subs window
  
  
  Ctr-M Ctr-Shift-M  comment/uncomment selected lines of code
  
  Ctr-H opens a help window where you can see the documentation of 
  any perl module. Just use open (in the help window) and type in the name
  of a module.
  
  Ctr-Shift-H Highlight the name of a module in the editor and then 
  press Ctr-Shift-H. IT will open the help window for the module 
  whose name was highlighted.
  
  In the help window you can also start typing the name of a module. When the
  list of the matching possible modules is small enough you'll be able
  to open the drop-down list and select the name.
  The "small enough" is controled by two configuration options in the 
  Edit/Setup menu: 
  
  Max Number of modules
  Min Number of modules
  
  This feature only works after you have indexed all the modules 
  on your computer. Indexing is currently done by running the following command:
  
  padre --index
  

Parrot integration

This is an experimentatl feature.

Download Parrot (or check it out from its version control)

Configure PARROT_PATH to point to the root of parrot

Configure LD_LIBRARY_PATH

 export LD_LIBRARY_PATH=$PARROT_PATH/blib/lib/
 

Build Parrot

 cd $PARROT_PATH
 svn up
 make realclean
 perl Configure.pl
 make
 make test

Build Parrot::Embed

 cd ext/Parrot-Embed/
 ./Build realclean
 perl Build.PL
 ./Build
 ./Build test

Now if you run Padre it will come with an embedded Parrot interpreter.

You can get the interpreter by calling

 Padre->ide->parrot

Rectangular Text Selection

Simple text editors usually only allow you to select contiguous lines of text with your mouse. Somtimes, however, it is handy to be able to select a rectangular area of text for more precise cutting/copying/pasting or performing search/replace on. You can select a rectangular area in Padre by holding down Ctr-Alt whilst selecting text with your mouse.

For example, imagine you have the following nicely formatted hash assignment in a perl source file:

 my %hash = (
        key1 => 'value1',
        key2 => 'value2',
        key3 => 'value3',
 );

With a rectangular text selection you can select only the keys, only the values, etc..

Syntax highlighting

Padre is using Wx (aka wxPerl), wxWidgtes for GUI and Scintilla for the editor. Scintiall provides very good syntax highlighting for many languages but Padre is still bound by the version of Scintilla included.

The share/styles/default.yml file is the mapping between the Scintialla defined constants for various syntactical elements of each language and the RGB values of the color to be used to highlight them.

We plan to allow the user to switch between styles.

Adding new syntax highlighting

Need to define constanst in Padre::Util to be in the Px:: namespace.

Need to add the color mapping to share/styles/default.yml

Need to implement the Padre::Document::Language class.

Need to define the mime-type mapping in Padre::Document

For examples see Padre::Document::Pasm, Padre::Document::Pir, Padre::Document::Perl.

Command line options

 --index   will go over the @INC and list all the available modules in the database
 
 a list of filenames can be given to be opened
 

Preferences

There are several types of preferences we can think of. There are the current view orinted preferences such as Show newlines or Show Line numbers and there are the project and file oriented preferences such as the use of TAB or whitespace for indentation.

We would like to achive that the

Currently some of the preferences are accesible via the Edit/Preferences menu options, others via the View menu option.

We have to make sure that when changing the preferences via the GUI it change for the correct things.

e.g. When changing the Use TABs preference it currently applyes to all the files open currently or in the future. It should probably apply to the current file and/or the current project. Such options - when changing them - might even be applied "retroactively". That is when I change the TAB/space mode of a file or a project it should ask if I want to reflow the file with the new method of indentation?

On the other hand the "TAB display size" is purely a local, edior oriented preference. It should probably apply to all files currently open.

There are other aspects of preferences as well that might not exactly overlap with the above set:

The developer might work on the same project on different machines. In such case some of the personal preferences should apply only only on one computer while others apply in both places.

In particular if Padre is installed in a Portable Perl it might run on machines with different parameters. Screen size and resolution might be different along other parameters. We would like to make sure the relevant preferences are separated from those that are constant even when moving betwen computers.

Editor or view oriented preferences

Size and location of windows
Show/Hide various windows, Status bar, Toolbar
Files recently opened
Files that were open last time, cursor location
Show newlines
Show Line numbers
Show indentation guide

View/Show Indentation Guide

When set, Padre will display a thin vertical line at every indentation level on every row with are indented more than one level.

Highlight indentation guide (TODO)

This should be a separate option available only if the Show indentation guide and brace matching is on.

If SetHighlightGuide is set to 8 then when the user reaches one side of a pair of praces the indentation guide - if there is one on column 8 - will be highlighted. (in green).

As I understand Padre should constantly adjust the SetHighlightGuide so that in every block the "correct" indentation guide is highlighted.

Show Call Tips
TAB display size
Allow experimental features

In order to allow the experimental features one needs to manually turn on the experimental flag to 1 in config.yml. As Padre keeps overwriting this file you'll have to make this change with another editor and while Padre is not open.

The config.yml file is in ~/.padre/ on Linux/Unix and in general in your home directory on Windows. In any case the Help/About box will show you the path of the .padrfe directory of Padre.

Once you set the experimental flag when you start Padre you will see a new menu on the right side of the menu bar called Experimental.

Open file policy

What files to open when launchin Padre? nothing, new, those that were open last time?

Max/Min number of modules to display in podviewer
Autoindentation

Possible values: no/same level/deep

There are at least two levels of autoindentation:

1) when ENTER is pressed indent to exactly the same level as the previous line

2) if there is an opening brace { on the previous line, indent one level more

Brace matching

When the cursor reaches an opening or closing brace { }, square bracket [ ] or parentheses ( ), Padre automatically highlight the pair of the braces.

TODO make this optional, let the user set the color

Autosave on/off?

File and Project oriented preferences

Indentation should be by TABs or spaces
In case of using spaces for indentation, the width of every indentation level

Other features

Autobackup (Planned)

See Padre::Autosave

When Padre opens a file it automatically creates a copy of the original in ~/.padre/backup/PATH where PATH is the same PATH as the full PATH of the file. On Windows the initial drive letter is converted to another subdirectory so c:\dir\file.txt will be saved as ~/padre/backup/dir/file.txt

When a new file is created no need for autobackup.

When a remote file is opened the backup will probably go to ~/padre/backup_remote/

Configurable options: on/off

Autosave files (Planned)

Every N seconds all the files changed since the last autosave are saved to a temporary place maybe ~/.padre/save.

When the user closes the file, the autosaved file is removed.

Configurable options: on/off, frequency in seconds

SQLite

Padre is using an SQLite database (~/.padre/config.db) for two things. Part of the preferences/configuration information is kept there and it is used for the podreader.

Documentation POD reader

Padre currently can index (the names of) all the modules on your system and it was planned to have a search capability for modules/functions/etc.

Plugins

There is a highly experimental but quite simple plugin system.

A plugin is a module in the Padre::Plugin::* namespace.

At startup time Padre looks for all such modules in @INC and loads them. Every plugin must have a menu method that returns its menu items which is a list of lists:

 ( 
   [ Name_1, \&callback_1 ],
   [ Name_2, \&callback_2 ],
 )

Padre will add a menu entry for every plugin under the Plugins menu item. For each plugin menu item it will add all the Name_1, Name_2 subitems.

If the menu_name method is provided its return value will be the displayed entry in the Plugins/ menu. If this method is omitted the name of the plugin without the Padre::Plugin part will be used.

See also Padre::PluginManager and Padre::PluginBuilder

Editing tools

Case Changes

Change the case of the selected text or if there is no selection all the text in the current file.

Change all characters to upper or lower case

Change the first character ot every word to upper/lower case leaving the rest as they were.

Tab and space conversion

Tab to Space and Space to Tab conversions ask the number of spaces each tab should substitute. It currently works everywhere. We probably should add a mode to operate only at the beginning of the lines or better yet only at the indentation levels.

Delete All Ending space does just what it sais.

Delete Leading Space will ask How many leading spaces and act accordingly.

Search, Find and Replace

(planning)

Search

Ctrl-F opens the search window, if something was selected then that is given as the search text. Otherwise the last search string should be displayed.

Provide option to search backwards

Limit action to current block, current subroutine, current file (should be the default) current project, current directory with some file filters.

When the user presses Find

  1. We find the first hit and the search window disappears. F3 jumps to next one.

  2. The first match is highlighted and focused but the window stays When the user clicks on the Find button again, we jump to the next hit In this case the user must be able to edit the document while the search window is on.

  3. All the matches are highlighted and we go to the first match, window disappears. F3 jumps to next one

  4. All the matches are highlighted and we go to the first one, window stays open user can edit text

Find and Replace

Find - find the next occurance

Replace all - do just that

Replace - if currently a match is selected then replace it find the next occurance and select it

TODO describe what to do if we have to deal with files that are not in the editor

if "Replace all" was pressed then do just that 1) without opening editors for the files. 2) opening an editor for each file and keep it in unsaved state (sounds carzy having 1000 editors open...) if Search or Replace is clicked then we might show the next location in the lower pane. If the user then presses Replace we open the file in an editor window and go on. If the user presses Search then we show the next occurance. Opened and edited files will be left in a not saved state.

Code layout

Padre.pm is the main module.

Padre::Config reads/writes the configuration files.

There is an SQLite database and a yml file to keep various pices of information The SQLite database holds the list of modules available on the system. It will also contain indexing of the documentation Looking at the entries of modules List of functions

The yml file contains individual configuration options

Padre::Document is an abstraction class to deal with a single document.

Padre::Documents aggregated the list of all currently open documents.

Padre::DB is the database abstraction for SQLite.

Padre::PluginManager locates and loads the plugins.

Padre::PluginBuilder

Padre::PPI

Wx GUI

The Padre::WX::* namespace is supposed to deal with all the wx related code. Outside of that the code is not supposed to know about wx, but currently it still does.

Padre::Wx::Dialog is the parent class of all the major dialogs that are all implemented in modules in the Padre::Wx::Dialog::* namespace.

Padre::Wx::App is the Wx::App subclass

Padre::Wx::MainWindow is the main frame, most of the code is currently there.

Padre::Wx::Editor holds an editor text control instance (one for each buffer/file).

Padre::Wx::Menu handles everythin the menu should know and do.

Padre::Wx::ToolBar handles everythin the toolbar should know and do.

Padre::Wx::Output - the output window.

POD viewer

Padre::Pod::* are there to index and show documentation written in pod. TODO: One day we might be able to factor it out into a separate pod-viewer class.

BUGS

Please submit your bugs at http://padre.perlide.org/

SUPPORT

I hope the http://www.perlmonks.org/ will be ready to take upon themself supporting this application.

See also http://padre.perlide.org/

COPYRIGHT

Copyright 2008 Gabor Szabo. http://www.szabgab.com/

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5 itself.

The icons were taken from http://tango.freedesktop.org/Tango_Desktop_Project The Tango base icon theme is licensed under the Creative Commons Attribution Share-Alike license. Using tango-icon-theme-0.8.1.tar.gz

WARRANTY

There is no warranty whatsoever. If you lose data or your hair because of this program, that's your problem.

CREDITS and THANKS

To Mattia Barbon for providing WxPerl. Part of the code was copied from his Wx::Demo application.

To Adam Kennedy for lots of refactoring.

To Steffen Muller for PAR plugins.

To Patrick Donelan, Fayland Lam, Brian Cassidy, Heiko Jansen

To Herbert Breunung for letting me work on Kephra.

To Octavian Rasnita for early testing and bug reports.