AnyEvent::EditText - An easy way to startup a text editor
Version 0.2
my $content = "Hello There!"; AnyEvent::EditText::edit ($content, sub { my ($newcontent, $has_changed) = @_; if ($has_changed) { print "the content was edited"; } });
This little module will start a text editor in a seperate process without stopping the current process. Usually something like a terminal with a vim instance running in it will be started, but also a graphical editor could be used (like gedit or gvim).
The editor will get the content passed to the edit routine as temporary file, and after you are done editing it (closed the editor) the callback will be called with the possibly new content.
edit
This function configures the editor used. @sysargs is a list of arguments for the system function, which will be called like this by edit:
@sysargs
system
system (@sysargs, $filename);
The default editor used will be:
AnyEvent::EditText::set_editor ("rxvt", "-e", "vim");
This routine will write $content to a temporary file, fork and call the editing process. After the process terminates the temporary file is read and erased.
$content
After that the content is sent back to the calling process, where the $callback is called with two arguments: The first will be the new content and the second a flag indicating whether the content has changed.
$callback
Robin Redeker, <elmex at ta-sa.org>
<elmex at ta-sa.org>
This module should probably first look in the environment to determine which editor and terminal to use. This will be fixed in the next release.
Please report any bugs or feature requests to bug-text-edit at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Text-Edit. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-text-edit at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc AnyEvent::EditText
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Text-Edit
CPAN Ratings
http://cpanratings.perl.org/d/Text-Edit
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Text-Edit
Search CPAN
http://search.cpan.org/dist/Text-Edit
Copyright 2007 Robin Redeker, all rights reserved. Copyright 2008 Robin Redeker, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install AnyEvent::EditText, copy and paste the appropriate command in to your terminal.
cpanm
cpanm AnyEvent::EditText
CPAN shell
perl -MCPAN -e shell install AnyEvent::EditText
For more information on module installation, please visit the detailed CPAN module installation guide.