App::VOJournal::VOTL - deal with vimoutliner files
Version v0.4.7
use App::VOJournal::VOTL; my $votl = App::VOJournal::VOTL->new(); $votl->fetch_line($pos); $votl->insert_line($pos,$line); $votl->read_file($infilename); $votl->write_file($outfilename); $votl->write_file($outfilename, \&filter); $votl->write_file_no_checked_boxes($outfilename); $votl->write_file_unchecked_boxes($outfilename);
Creates a new object.
my $votl = App::VOJournal::VOTL->new();
$votl->fetch_line( $pos );
Fetches the value of the object at position $pos. That means the line as it would appear in the Vimoutliner file.
$pos
The available positions start at 0 and at 1 before the number of objects.
If $pos is outside the available positions the function returns nothing.
At the moment you can only retrieve the objcects in the top level.
$votl->delete_line($pos);
Deletes an object from the Vimoutliner file. That means the line itself and all immediately following lines that are more indented.
At the moment you can only delete objects in the top level.
Inserts a line into a vimoutliner data structure.
$votl->insert_line( $pos, $line );
determines the position where the object shall be inserted.
This could be a number telling the position:
means at the last position, i.e. after the last already existing element.
means at position 0, i.e. before the first already existing element.
means at that position. All already existing objects at that and the following positions will be shifted to the next position.
If the argument $pos exceeds the number of already existing objects, the object is inserted immediately following the last already existing object.
At the moment all lines are inserted at the top level.
$line
This may be a string which is inserted as is.
Reads a vimoutliner file.
$votl->read_file( $filename ); sub filter { ... } $votl->read_file( $filename, \&filter );
$filename is the name of the file read.
$filename
It is possible to give a reference to a filter function that decides, which objects / lines to read. This filter function is called back with the content of the current line (after the indentation) and the depth of indentation as arguments. If you need to manage some state you can use closures like this:
my $in_checked_box = 0; my $cbl = 0; my $filter = sub { my ($object,$indent) = @_; if ($in_checked_box && $indent > $cbl) { return 0; } elsif (_checked_box($object)) { $in_checked_box = 1; $cbl = $indent; return 0; } else { $in_checked_box = 0; return 1; } }; $votl->read_file( $filename, $filter );
This is a convenience function that reads all lines except checked boxes (lines starting with [X]).
[X]
$votl->read_file_no_checked_boxes( $filename );
This is a convenience function that reads all lines with unchecked boxes (lines starting with [_]).
[_]
$votl->read_file_unchecked_boxes( $filename );
Writes a vimoutliner file.
$votl->write_file( $filename ); sub filter { ... } $votl->write_file( $filename, \&filter);
It is possible to give a reference to a filter function that decides, which objects to write. This filter function is called back with the content of the current line and the depth of indentation as arguments. If you need to manage some state you can use closures as shown with the read_file() function.
read_file()
Writes a vimoutliner file that contains no checked boxes.
$votl->write_file_no_checked_boxes( $filename );
This is a convenience function using write_file() and a predifined filter.
write_file()
Writes a vimoutliner file that only consists of unchecked boxes at level zero and their descendants.
$votl->write_file_unchecked_boxes( $filename );
Vimoutliner files are text files with a hierarchical structure.
The hierarchical structure is characterized by the number of tabulator signs (0x09) at the beginning of the line.
A line can be a simple-heading or an object, depending on the first nontabulator sign of the line.
A simple heading starts with any non-whitespace character except : ; | < >. A checkbox is a special form of a heading that starts with either [_] or [X] after the leading tabulator signs. A checkbox may contain a percent sign (%) as a placeholder for the percentage completed. This percent sign must follow the initial [_] after a separating whitespace.
: ; | < >
%
The following text objects are defined for vimoutliner files:
:
The text following the : will be wrapped automatically.
;
This text won't be wrapped automatically.
|
The table headings can be marked with ||.
||
>
This text will also be wrapped automatically.
<
Mathias Weidner, <mamawe at cpan.org>
<mamawe at cpan.org>
Please report any bugs or feature requests to bug-app-vojournal at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=App-VOJournal. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-app-vojournal at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc App::VOJournal::VOTL
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=App-VOJournal
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/App-VOJournal
CPAN Ratings
http://cpanratings.perl.org/d/App-VOJournal
Search CPAN
http://search.cpan.org/dist/App-VOJournal/
Copyright 2015 Mathias Weidner.
This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:
http://www.perlfoundation.org/artistic_license_2_0
Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.
If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.
This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.
This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
To install App::VOJournal, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::VOJournal
CPAN shell
perl -MCPAN -e shell install App::VOJournal
For more information on module installation, please visit the detailed CPAN module installation guide.