X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FEditable.pm;h=3dd7cff97b5eccdf418e402a737f692cb73c633a;hb=417f55d271551683dfe1a49fb754024ba4731363;hp=b0b4e2627cbcf6d08f4789e1ce6b263635af8073;hpb=2ea216bfaf03964488c54d88fad75ce6cd5a5612;p=spider.git diff --git a/perl/Editable.pm b/perl/Editable.pm index b0b4e262..3dd7cff9 100644 --- a/perl/Editable.pm +++ b/perl/Editable.pm @@ -13,18 +13,69 @@ package Editable; +use strict; + use vars qw($VERSION $BRANCH); $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ ); $BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ ) || 0; $main::build += $VERSION; $main::branch += $BRANCH; +use DXChannel; +use DXDebug; +use BadWords; + sub new { my $pkg = shift; my $class = ref $pkg || $pkg; - return {}, $class; + return {@_}, $class; +} + +sub copy +{ + my $self = shift; + return $self->new(%$self); +} + +sub addline +{ + my $self = shift; + my $dxchan = shift; + my $line = shift; + + if (my @ans = BadWord::check($line)) { + return ($dxchan->msg('e17', @ans)); + } + push @{$self->{lines}}, $line; + return (); +} + +sub modline +{ + my $self = shift; + my $dxchan = shift; + my $no = shift; + my $line = shift; + + if (my @ans = BadWord::check($line)) { + return ($dxchan->msg('e17', @ans)); + } + ${$self->{lines}}[$no], $line; + return (); +} + +sub lines +{ + my $self = shift; + return exists $self->{lines} ? (@{$self->{lines}}) : (); +} + +sub nolines +{ + my $self = shift; + return exists $self->{lines} ? scalar @{$self->{lines}} : 0; } 1;