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

  1. # NOTE: Derived from ..\blib\lib\Tk\Text.pm.  Changes made here will be lost.
  2. package Tk::Text;
  3.  
  4. sub ClassInit
  5. {
  6.  my ($class,$mw) = @_;
  7.  
  8.  $class->bindRdOnly($mw);
  9.  
  10.  $mw->bind($class,"<Tab>", sub { my $w = shift; $w->Insert("\t"); $w->focus; $w->break});
  11.  
  12.  $mw->bind($class,"<Control-i>", ['Insert',"\t"]);
  13.  $mw->bind($class,"<Return>", ['Insert',"\n"]);
  14.  $mw->bind($class,"<Delete>",'Delete');
  15.  $mw->bind($class,"<BackSpace>",'Backspace');
  16.  
  17.  $class->clipboardKeysyms($mw,"F16","F20","F18");
  18.  
  19.  $mw->bind($class,"<Insert>",
  20.             sub
  21.             {
  22.              my $w = shift;
  23.              Tk::catch { $w->Insert($w->SelectionGet) }
  24.             }
  25.            )
  26.  ;
  27.  $mw->bind($class,"<KeyPress>",['Insert',Ev('A')]);
  28.  # Additional emacs-like bindings:
  29.  
  30.  if (!$Tk::strictMotif)
  31.   {
  32.  
  33.    $mw->bind($class,"<Control-d>",['delete','insert']);
  34.    $mw->bind($class,"<Control-k>",
  35.               sub
  36.               {
  37.                my $w = shift;
  38.                if ($w->compare("insert","==","insert lineend"))
  39.                 {
  40.                  $w->delete("insert")
  41.                 }
  42.                else
  43.                 {
  44.                  $w->delete("insert","insert lineend")
  45.                 }
  46.               }
  47.              )
  48.    ;
  49.    $mw->bind($class,"<Control-o>",
  50.               sub
  51.               {
  52.                my $w = shift;
  53.                $w->insert("insert","\n");
  54.                $w->mark("set","insert","insert-1c")
  55.               }
  56.              )
  57.    ;
  58.    $mw->bind($class,"<Control-t>",'Transpose');
  59.    $mw->bind($class,"<Meta-d>",['delete','insert','insert wordend']);
  60.    $mw->bind($class,"<Meta-BackSpace>",['delete','insert-1c wordstart','insert']);
  61.  
  62.    $class->clipboardKeysyms($mw,"Meta-w","Control-w","Control-y");
  63.    # A few additional bindings of my own.
  64.    $mw->bind($class,"<Control-h>",
  65.               sub
  66.               {
  67.                my $w = shift;
  68.                if ($w->compare("insert","!=","1.0"))
  69.                 {
  70.                  $w->delete("insert-1c");
  71.                  $w->see("insert")
  72.                 }
  73.               }
  74.              )
  75.    ;
  76.    $mw->bind($class,"<Control-v>",
  77.               sub
  78.               {
  79.                my $w = shift;
  80.                Tk::catch
  81.                 {
  82.                  $w->insert("insert",$w->SelectionGet);
  83.                  $w->see("insert")
  84.                 }
  85.               }
  86.              )
  87.    ;
  88.    $mw->bind($class,"<Control-x>",
  89.               sub
  90.               {
  91.                my $w = shift;
  92.                Tk::catch { $w->delete("sel.first","sel.last") }
  93.               }
  94.              )
  95.    ;
  96.    $mw->bind($class,"<ButtonRelease-2>",
  97.               sub
  98.               {
  99.                my $w = shift;
  100.                my $Ev = $w->XEvent;
  101.                if (!$Tk::mouseMoved)
  102.                 {
  103.                  Tk::catch
  104.                   {
  105.                    $w->insert($Ev->xy,$w->SelectionGet);
  106.                   }
  107.                 }
  108.               }
  109.              )
  110.  
  111.  
  112.   }
  113.  $Tk::prevPos = undef;
  114.  return $class;
  115. }
  116.  
  117. 1;
  118.