home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Editores / Perl5 / perl / lib / site / auto / Tk / Text / ScrollPages.al < prev    next >
Encoding:
Text File  |  1997-08-10  |  940 b   |  31 lines

  1. # NOTE: Derived from ..\blib\lib\Tk\Text.pm.  Changes made here will be lost.
  2. package Tk::Text;
  3.  
  4. # ScrollPages --
  5. # This is a utility procedure used in bindings for moving up and down
  6. # pages and possibly extending the selection along the way. It scrolls
  7. # the view in the widget by the number of pages, and it returns the
  8. # index of the character that is at the same position in the new view
  9. # as the insertion cursor used to be in the old view.
  10. #
  11. # Arguments:
  12. # w - The text window in which the cursor is to move.
  13. # count - Number of pages forward to scroll; may be negative
  14. # to scroll backwards.
  15. sub ScrollPages
  16. {
  17.  my $w = shift;
  18.  my $count = shift;
  19.  my @bbox = $w->bbox("insert");
  20.  $w->yview("scroll",$count,"pages");
  21.  if (!@bbox)
  22.   {
  23.    return $w->index("@" . int($w->height/2) . "," . 0);
  24.   }
  25.  $x = int($bbox[0]+$bbox[2]/2);
  26.  $y = int($bbox[1]+$bbox[3]/2);
  27.  return $w->index("@" . $x . "," . $y);
  28. }
  29.  
  30. 1;
  31.