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

  1. # NOTE: Derived from ..\blib\lib\Tk\Text.pm.  Changes made here will be lost.
  2. package Tk::Text;
  3.  
  4. # KeySelect
  5. # This procedure is invoked when stroking out selections using the
  6. # keyboard. It moves the cursor to a new position, then extends
  7. # the selection to that position.
  8. #
  9. # Arguments:
  10. # w - The text window.
  11. # new - A new position for the insertion cursor (the cursor has not
  12. # actually been moved to this position yet).
  13. sub KeySelect
  14. {
  15.  my $w = shift;
  16.  my $new = shift;
  17.  my ($first,$last);
  18.  if (!defined $w->tag("nextrange","sel","1.0","end"))
  19.   {
  20.    if ($w->compare($new,"<","insert"))
  21.     {
  22.      $w->tag("add","sel",$new,"insert")
  23.     }
  24.    else
  25.     {
  26.      $w->tag("add","sel","insert",$new)
  27.     }
  28.   }
  29.  else
  30.   {
  31.    if ($w->compare($new,"<","anchor"))
  32.     {
  33.      $first = $new;
  34.      $last = "anchor"
  35.     }
  36.    else
  37.     {
  38.      $first = "anchor";
  39.      $last = $new
  40.     }
  41.    $w->tag("remove","sel","1.0",$first);
  42.    $w->tag("add","sel",$first,$last);
  43.    $w->tag("remove","sel",$last,"end")
  44.   }
  45.  $w->mark("set","insert",$new);
  46.  $w->see("insert");
  47.  $w->idletasks;
  48. }
  49.  
  50. 1;
  51.