NAME

Padre::Document - Padre Document Abstraction Layer

DESCRIPTION

This is an internal module of Padre that provides a logical document abstraction, allowing Padre to associate several Wx elements with the one document.

The objective would be to allow the use of this module without loading Wx.

Currently there are still interdependencies that need to be cleaned.

METHODS

new

 my $doc = Padre::Document->new(
     filename => $file,
 );

$file is optional and if given it will be loaded in the document

mime-type is defined by the guess_mimetype function

TODO describe

$editor is required and is a Padre::Wx::Editor object

load_file

$doc->load_file;

Loads the current file.

Sets the Encoding bit using Encode::Guess and tries to figure out what kind of newlines are in the file. Defaults to utf-8 if could not figure out the encoding.

Currently it autoconverts files with mixed newlines. TODO we should stop autoconverting.

Returns true on success false on failure. Sets $doc->errstr;

reload

Reload the current file discarding changes in the editor.

Returns true on success false on failure. Error message will be in $doc->errstr;

TODO: In the future it should backup the changes in case the user regrets the action.

can_check_syntax

Returns a true value if the class provides a method check_syntax for retrieving information on syntax errors and warnings in the current document.

The method in this base class returns false.

check_syntax ( [ FORCE ] )

NOT IMPLEMENTED IN THIS BASE CLASS

An implementation in a derived class needs to return an arrayref of syntax problems. Each entry in the array has to be an anonymous hash with the following keys:

  • line

    The line where the problem resides

  • msg

    A short description of the problem

  • severity

    A flag indicating the problem class: Either 'W' (warning) or 'E' (error)

  • desc

    A longer description with more information on the error (currently not used but intended to be)

Returns an empty arrayref if no problems can be found.

Returns undef if nothing has changed since the last invocation.

Must return the problem list even if nothing has changed when a param is present which evaluates to true.