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

NAME

App::VOJournal::VOTL - deal with vimoutliner files

VERSION

Version v0.4.7

SYNOPSIS

    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);

SUBROUTINES/METHODS

new

Creates a new object.

    my $votl = App::VOJournal::VOTL->new();

fetch_line

  $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.

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.

delete_line

  $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.

insert_line

Inserts a line into a vimoutliner data structure.

    $votl->insert_line( $pos, $line );
$pos

determines the position where the object shall be inserted.

This could be a number telling the position:

-1

means at the last position, i.e. after the last already existing element.

0

means at position 0, i.e. before the first already existing element.

n

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.

read_file

Reads a vimoutliner file.

    $votl->read_file( $filename );

    sub filter { ... }
    
    $votl->read_file( $filename, \&filter );

$filename is the name of the file read.

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 );

read_file_no_checked_boxes

This is a convenience function that reads all lines except checked boxes (lines starting with [X]).

    $votl->read_file_no_checked_boxes( $filename );

read_file_unchecked_boxes

This is a convenience function that reads all lines with unchecked boxes (lines starting with [_]).

    $votl->read_file_unchecked_boxes( $filename );

write_file

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.

write_file_no_checked_boxes

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_unchecked_boxes

Writes a vimoutliner file that only consists of unchecked boxes at level zero and their descendants.

    $votl->write_file_unchecked_boxes( $filename );

This is a convenience function using write_file() and a predifined filter.

FORMAT OF VIMOUTLINER FILES

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:

: - body text

The text following the : will be wrapped automatically.

; - preformatted body text

This text won't be wrapped automatically.

| - table

The table headings can be marked with ||.

> - user defined text.

This text will also be wrapped automatically.

< - user defined preformatted text.

This text won't be wrapped automatically.

AUTHOR

Mathias Weidner, <mamawe at cpan.org>

BUGS

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.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc App::VOJournal::VOTL

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

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.