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

  1. # NOTE: Derived from ..\blib\lib\Tk\Text.pm.  Changes made here will be lost.
  2. package Tk::Text;
  3.  
  4. # Insert --
  5. # Insert a string into a text at the point of the insertion cursor.
  6. # If there is a selection in the text, and it covers the point of the
  7. # insertion cursor, then delete the selection before inserting.
  8. #
  9. # Arguments:
  10. # w - The text window in which to insert the string
  11. # s - The string to insert (usually just a single character)
  12. sub Insert
  13. {
  14.  my $w = shift;
  15.  my $s = shift;
  16.  return unless (defined $s && $s ne "");
  17.  Tk::catch
  18.   {
  19.    if ($w->compare("sel.first","<=","insert") && 
  20.        $w->compare("sel.last",">=","insert"))
  21.      {
  22.       $w->delete("sel.first","sel.last")
  23.      }
  24.   };
  25.  $w->insert("insert",$s);
  26.  $w->see("insert")
  27. }
  28.  
  29. 1;
  30.