Padre
view release on metacpan or search on metacpan
lib/Padre/DB/LastPositionInFile.pm view on Meta::CPAN
package Padre::DB::LastPositionInFile;
# NOTE: This class is loaded automatically by Padre::DB, overlaying the
# code already auto-generated by Padre::DB. Do not load manually, as this
# module will not function standalone.
=pod
=head1 NAME
Padre::DB::LastPositionInFile - Storage class for stateful cursor positions
=head1 SYNOPSIS
Padre::DB::LastPositionInFile->set_last_pos($file, $pos);
my $pos = Padre::DB::LastPositionInFile->get_last_pos($file);
=head1 DESCRIPTION
This class allows storing in L<Padre>'s database the last cursor position
in a file. This is useful in order to put the cursor back to where it
was when re-opening this file later on.
Please note that due to limitations in the way we generate the class,
imposed by L<ORLite>, automatic translation for Portable Perl is only
applied if you use the C<set_last_pos> and C<get_last_pos> methods.
=head1 METHODS
=cut
use 5.008;
use strict;
use warnings;
use Padre::Constant ();
use Padre::Current ();
BEGIN {
require Padre::Portable if Padre::Constant::PORTABLE;
}
our $VERSION = '1.02';
=pod
=head2 set_last_pos
set_last_pos( $file, $pos )
Record C<$pos> as the last known cursor position in C<$file>.
Applies appropriate path translation if we are running in Portable Perl.
=cut
sub get_last_pos {
my $class = shift;
my $file = Padre::Constant::PORTABLE ? Padre::Portable::freeze(shift) : shift;
# Find the position in the file
Padre::DB->selectcol_arrayref(
"select position from last_position_in_file where name = ?",
{}, $file,
( run in 0.999 second using v1.01-cache-2.11-cpan-39bf76dae61 )