Linux SoftwareProgrammingLibrariesData::Page::Viewport 1.02

Data::Page::Viewport 1.02


Data::Page::Viewport is a Perl module to scroll thru data a page, or just an item, at a time. Synopsis This is a complete, test
Developer:   Ron Savage
      more software by author →
Price:  0.00
License:   Perl Artistic License
File size:   7K
Language:   
OS:   
Rating:   0 /5 (0 votes)
Your vote:  
enlarge screenshot


Data::Page::Viewport is a Perl module to scroll thru data a page, or just an item, at a time.

Synopsis

This is a complete, tested, runnable program.
#!/usr/bin/perl

use strict;
use warnings;

use Data::Page::Viewport;

# -----------------------------------------------

my(@data) = (qw/zero one two three four five six
seven eight nine ten eleven twelve thirteen fourteen/);
my($page) = Data::Page::Viewport -> new
(
data_size => scalar @data,
page_size => 4
);

print "Data bounds: 0 .. $#data. n";
print "Data: ", join(', ', @data), ". n";
print "Page bounds: 0 .. 3. n";
print "Page data: ", join(', ', @data[0 .. 3]), ". n";
print "n";

my(@bound);

for (-2, 1, 4, 4, 1, 3, 3, -2, 1, 2, 1, -4, -4,
-1, 1, 2, -1, -2, -2, -1, -4, 4, 4, 4)
{
print "Offset: $_. n";

@bound = $page -> offset($_) -> bounds();

print "Page bounds: $bound[0] .. $bound[1]. n";
print 'Page data: ',
join(', ', @data[$bound[0] .. $bound[1] ]),
". n";
print '-' x 50, "n";
}

Data::Page::Viewport is a pure Perl module.

This module keeps track of what items are on the 'current' page, when you scroll forwards or backwards within a data set.

Similarly to Data::Page, you can call sub offset(N), for + or - N, to scroll thru the data a page at a time.

And, like Set::Window, you can call sub offset(N), for + or - 1, to scroll thru the data an item at a time.

Clearly, N does not have to be fixed.

The viewport provides access to the 'current' page, and the code shifts indexes into and out of the viewport, according to the parameter passed to sub offset().

Note that the data is not passed into this module. The module only keeps track of the indexes within the viewport, i.e. indexes on the 'current' page.

You call sub bounds() on the object (of type Set::Window) returned by sub offset(), to determine what indexes are on the 'current' page at any particular point in time.

Also note that, unlike Set::Window, the boundaries of the viewport are rigid, so that changes to the indexes caused by sub offset() are limited by the size of the data set.

This means, if you do this:

my($page) = Data::Page::Viewport -> new
(
data_size => $#data, # 0 .. $#data.
page_size => $page_size, # 1 .. N.
);

my(@bound) = $page -> offset(- 1) -> bounds();

the call to sub offset(- 1) will have no effect.

That is, when trying to go back past the beginning of the data set, the bounds will be locked to values within 0 .. data_size.

Similarly, a call which would go beyond the other end of the data set, will lock the bounds to the same range.

In short, you can't fall off the edge by calling sub offset().

This in turn means that the values returned by sub bounds() will always be valid indexes within the range 0 .. data_size.

The module implements this by building 2 objects of type Set::Window, one for the original data set (which never changes), and one for the 'current' page, which changes each time sub offset() is called (until the boundaries are hit, of course).

Note: No range checking is performed on the parameters to sub new().

Note: It should be obvious by now that this module differs from Data::Page, and indeed all such modules, in that they never change the items which are on a given page. They only allow you to change the page known as the 'current' page. This module differs, in that, by calling sub offset(+ or - N), you are effectively changing the items which are deemed to be on the 'current' page.

Requirements:
  • Perl
    tags sub offset  data page  current page  the current  the data  page viewport  data set  print page  data size  the viewport  set window  page data  this module  

    Download Data::Page::Viewport 1.02


     http://ftp.hostingromania.ro/Linux/mirrors/ftp.cpan.org/authors/id/R/RS/RSAVAGE/Data-Page-Viewport-1.02.tgz


    Authors software

    DBIx::HTML::ClientDB 1.05 (by Ron Savage)
    DBIx::HTML::ClientDB is a Perl module to convert sql into a client-side db with keyed access.

    Synopsis

    use DBIx::HTML::

    Data::Page::Viewport 1.02 (by Ron Savage)
    Data::Page::Viewport is a Perl module to scroll thru data a page, or just an item, at a time.

    Synopsis

    This is a complete, test

    CGI::Explorer 2.07 (by Ron Savage)
    CGI::Explorer is a class to manage displaying a hash tree of data, for use in CGI scripts.

    Synopsis

    Install /assets/css/explore

    Getopt::Simple 1.48 (by Ron Savage)
    Getopt::Simple is a Perl module that provides a simple wrapper around Getopt::Long.

    SYNOPSIS

    use Getopt::Simple;


    Similar software

    Data::Page::Viewport 1.02 (by Ron Savage)
    Data::Page::Viewport is a Perl module to scroll thru data a page, or just an item, at a time.

    Synopsis

    This is a complete, test

    Data::Page 2.00 (by Leon Brocard)
    Data::Page is a Perl module that helps when paging through sets of results.

    SYNOPSIS

    use Data::Page;

    my $page = Data::Pa

    Template::Tutorial 2.15 (by Andy Wardley)
    Template::Tutorial are template toolkit tutorials.

    This section includes tutorials on using the Template Toolkit

    Template::Plugin::Page 0.10 (by Leon Brocard)
    Template::Plugin::Page is a plugin to help when paging through sets of results.

    SYNOPSIS

    [% USE page = Page($total_entries, $

    Template::Plugin::Pagination 0.90 (by Tony Bowden)
    Template::Plugin::Pagination is a plugin to help paginate pages of results.

    SYNOPSIS

    [% USE page = Pagination(items, current_

    Time::Zone 1.16 (by Graham Barr)
    Time::Zone is a miscellaneous timezone manipulations routines.

    SYNOPSIS

    use Time::Zone;
    print tz2zone();

    Web Secretary 1.9.0 (by Baruch Even)
    Web Secretary is a web page monitoring software

    WWW::Patent::Page::Response 0.07 (by Wanda B. Anon)
    WWW::Patent::Page::Response is an object holding a patent page or document (e.g

    Gimp::Data 1.211 (by Marc Lehmann)
    Gimp::Data is a Perl module to set and get state data.

    SYNOPSIS

    use Gimp::Data;

    $Gimp::Data{'value1'} = "Hello";
    pr

    CGI::Application::Plugin::ValidateRM 2.1 (by Mark Stosberg)
    CGI::Application::Plugin::ValidateRM is a Perl module to help validate CGI::Application run modes using Data::FormValidator.

    SYNOP


    Other software in this category

    zlib 1.2.3 (by Jean-loup Gailly)
    zlib is designed to be a free, general-purpose, legally unencumbered, lossless data-compression library for use on virtually any comp

    libjpeg v6b (by Independent JPEG Group)
    libjpeg is a library for handling the JPEG (JFIF) image format

    OpenSSL 0.9.7c (by The OpenSSL Project Team)
    The OpenSSL Project is a collaborative effort to develop a robust, commercial-grade, full-featured, and Open Source toolkit implement

    libxml2 2.6.27 (by DV)
    Libxml2 is the XML C parser and toolkit developed for the Gnome project (but usable outside of the Gnome platform), libxml2 library i

    GNU C library 2.4 (by Andreas Jaeger)
    GNU C library (glibc) is one of the most important components of GNU Hurd and most modern Linux distributions.

    GNU C library is us

  •     search


    Featured Software

    jEdit 4.3 pre8
    jEdit is an Open Source text editor written in Java

    Opera 9.02
    Surf the Internet in a safer, faster, and easier way with Opera browser

    GNU Aspell 0.60.4
    GNU Aspell is a Free and Open Source spell checker designed to eventually replace Ispell


    Subscribe in Rojo
    Google Reader
    Add to My Yahoo!

    Add to My AOL
    Subscribe with Bloglines
    Subscribe in NewsGator Online
    Add 'nixbit linux software' to Newsburst from CNET News.com
    del.icio.us nixbit linux software


    Top tags