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

  1. # NOTE: Derived from ..\blib\lib\Tk\Text.pm.  Changes made here will be lost.
  2. package Tk::Text;
  3.  
  4. # NextPara --
  5. # Returns the index of the beginning of the paragraph just after a given
  6. # position in the text (the beginning of a paragraph is the first non-blank
  7. # character after a blank line).
  8. #
  9. # Arguments:
  10. # w - The text window in which the cursor is to move.
  11. # start - Position at which to start search.
  12. sub NextPara
  13. {
  14.  my $w = shift;
  15.  my $start = shift;
  16.  $pos = $w->index("$start linestart + 1 line");
  17.  while ($w->get($pos) ne "\n")
  18.   {
  19.    if ($w->compare($pos,"==","end"))
  20.     {
  21.      return $w->index("end - 1c");
  22.     }
  23.    $pos = $w->index("$pos + 1 line")
  24.   }
  25.  while ($w->get($pos) eq "\n" )
  26.   {
  27.    $pos = $w->index("$pos + 1 line");
  28.    if ($w->compare($pos,"==","end"))
  29.     {
  30.      return $w->index("end - 1c");
  31.     }
  32.   }
  33.  my $string = $w->get($pos,"$pos lineend");
  34.  if ($string =~ /^(\s+)/)
  35.   {
  36.    my $off = length($1);
  37.    return $w->index("$pos + $off chars");
  38.   }
  39.  return $pos;
  40. }
  41.  
  42. 1;
  43.