Padre::Task::Outline - Generic background processing task to gather structure info on the current document
package Padre::Task::Outline::MyLanguage; use base 'Padre::Task::Outline'; sub run { my $self = shift; my $doc_text = $self->{text}; # black magic here $self->{outline} = ...; return 1; }; 1; # elsewhere: # by default, the text of the current document # will be fetched as will the document's notebook page. my $task = Padre::Task::Outline::MyLanguage->new(); $task->schedule; my $task2 = Padre::Task::Outline::MyLanguage->new( text => Padre::Current->document->text_get, editor => Padre::Current->editor, ); $task2->schedule;
This is a base class for all tasks that need to do expensive structure info gathering in a background task.
You can either let Padre::Task::Outline fetch the Perl code for parsing from the current document or specify it as the "text" parameter to the constructor.
Padre::Task::Outline
text
To create a outline gatherer for a given document type Foo, you create a subclass Padre::Task::Outline::Foo and implement the run method which uses the $self->{text} attribute of the task object for its nefarious structure info gathering purposes and then stores the result in the $self->{outline} attribute of the object. The result should be a data structure of the form defined in the documentation of the Padre::Document::get_outline method. See Padre::Document.
Foo
Padre::Task::Outline::Foo
run
$self->{text}
$self->{outline}
Padre::Document::get_outline
This base class requires all logic necessary to update the GUI with the structure info in a method update_gui of the derived class. That method is called in the finish() hook.
update_gui
finish()
This class inherits from Padre::Task and its instances can be scheduled using Padre::TaskManager.
Padre::Task
Padre::TaskManager
The transfer of the objects to and from the worker threads is implemented with Storable.
Steffen Mueller C<smueller@cpan.org> Heiko Jansen C<heiko_jansen@web.de>
Copyright 2008-2009 The Padre development team as listed in Padre.pm.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5 itself.
To install Padre, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Padre
CPAN shell
perl -MCPAN -e shell install Padre
For more information on module installation, please visit the detailed CPAN module installation guide.