summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl/lib/Tk/Text/Tag.pm
blob: 827278eb88c9a57791b731f0439afb0792d244b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package Tk::Text::Tag;
require Tk::Text;

use overload '""' => \&name;


use vars qw($VERSION);
$VERSION = '4.004'; # $Id: //depot/Tkutf8/Text/Text/Tag.pm#4 $

sub _apply
{
 my $self = shift;
 my $meth = shift;
 $self->widget->tag($meth => $self->name,@_);
}

sub name
{
 return shift->[0];
}

sub widget
{
 return shift->[1];
}

BEGIN
{
 my $meth;
 foreach $meth (qw(cget configure bind add))
  {
   *{$meth} = sub { shift->_apply($meth,@_) }
  }
}

sub new
{
 my $class  = shift;
 my $widget = shift;
 my $name   = shift;
 my $obj    = bless [$name,$widget],$class;
 $obj->configure(@_) if (@_);
 return $obj;
}

1;