From 4b7bb49dcd1031097b8918b45552a20a7a638617 Mon Sep 17 00:00:00 2001 From: milkbone57 Date: Tue, 12 Aug 2003 03:44:21 +0000 Subject: [PATCH] "" --- docs/VERSION.txt | 1 + mb.conf | 2 +- plugins/Log.pl | 50 ++++++++++++++++++++++----------- plugins/Tk-Convo/Tk-Convo.pl | 2 ++ plugins/Tk-GUI/Tk/BrowseEdit.pm | 40 ++++++++++++++++++++------ 5 files changed, 69 insertions(+), 26 deletions(-) diff --git a/docs/VERSION.txt b/docs/VERSION.txt index 7a6e8e8..c0bfa64 100644 --- a/docs/VERSION.txt +++ b/docs/VERSION.txt @@ -1,6 +1,7 @@ 0.356 -- +* Multiple stules in BrowseEdit * More font-tweaking * Fixed the %a - %s bug (thanks Dan) * A little more cleaning in XAMP diff --git a/mb.conf b/mb.conf index 50c808a..7e58b70 100644 --- a/mb.conf +++ b/mb.conf @@ -2,7 +2,7 @@ Goodbye sorry, gotta, go Modules Tk-PluginsConf, Net-OSCAR, Tk-GUI, Tk-Logon, Tk-BList, Tk-Profile, Tk-File, Tk-About, Tk-Convo, Tk-Conf, Tk-AddBuddy -Plugins XAMP, Monitor, Counterstrike, Win32X, Win32-Tray, Sound +Plugins XAMP, Monitor, Counterstrike, Win32X, Win32-Tray, Sound, Log Port 5190 HeavyLogging 0 SoundsWhileAway 0 diff --git a/plugins/Log.pl b/plugins/Log.pl index 0f1ab08..7a4027a 100644 --- a/plugins/Log.pl +++ b/plugins/Log.pl @@ -16,40 +16,56 @@ register_hook("buddy_out", \&on_buddy_out); sub on_msg_in { - my ($day, $month, $year, $hour, $min, $sec) = (localtime)[4, 3, 5, 2, 1, 0]; - $year += 1900; - $month++; - - mkdir "$logdir/$ARS{-user}" unless -e "$logdir/$ARS{-user}/; - log_item("$logdir/$ARS{-user}/$day-$month-$year", $ARGS{-user} . " ($day-$month-$year $hour:$min:$sec) " . - ": $ARGS{-msg} \n"); + my ($hour, $min, $sec) = (localtime)[2,1,0]; + log_item(user_log_file($ARGS{-user}), "" . + $ARGS{-user} . " ($hour:$min:$sec) " . + ": $ARGS{-msg}
\n"); } sub on_buddy_in { + return unless -e user_file("log") . "/$ARGS{-buddy}"; + my ($hour, $min, $sec) = (localtime)[2,1,0]; + log_item(user_log_file($ARGS{-buddy}), "" . + $ARGS{-buddy} . " signed in at $hour:$min:$sec.
\n\n"); } sub on_buddy_out { + return unless -e user_log_file($ARGS{-buddy}); + my ($hour, $min, $sec) = (localtime)[2,1,0]; + log_item(user_log_file($ARGS{-buddy}), "" . + $ARGS{-buddy} . " signed out at $hour:$min:$sec.
\n\n"); } sub on_protocol_send_im { - my ($day, $month, $year, $hour, $min, $sec) = (localtime)[4, 3, 5, 2, 1, 0]; - $year += 1900; - $month++; - - log_item("$logdir/$ARS{-user}/$day-$month-$year", data("me") . " ($day-$month-$year $hour:$min:$sec) " . - ": $ARGS{-msg} \n"); + my ($hour, $min, $sec) = (localtime)[2,1,0]; + log_item(user_log_file($ARGS{-dest}), "" . + data("me") . " ($hour:$min:$sec) " . + ": $ARGS{-msg}
\n"); } sub log_item { - my ($file, $text) = @_; + my ($file, $text) = @_; + + open(LOG, ">>$file"); + print LOG $text; + close(LOG); +} + +sub user_log_file +{ + my ($user) = @_; + my ($month, $day, $year) = (localtime)[4, 3, 5]; + $month++; + $year %= 100; + + my $path = user_file("log/$user/"); + mkpath $path; - open(LOG, ">>$file"); - print LOG $text; - close(LOG); + return "$path/$month-$day-$year.html"; } 1; diff --git a/plugins/Tk-Convo/Tk-Convo.pl b/plugins/Tk-Convo/Tk-Convo.pl index 3dc104d..124841a 100644 --- a/plugins/Tk-Convo/Tk-Convo.pl +++ b/plugins/Tk-Convo/Tk-Convo.pl @@ -10,6 +10,7 @@ use warnings; my $mw = hook("tk_getmain"); my %convos; +my $last_convo; register_hook("create_convo", sub { my $buddy = $ARGS{-user}; @@ -56,6 +57,7 @@ register_hook("create_convo", sub { }); register_hook("remove_convo", sub { + i deregister_hook("msg_in_$ARGS{-user}"); deregister_hook("buddy_in_$ARGS{-user}"); deregister_hook("buddy_out_$ARGS{-user}"); diff --git a/plugins/Tk-GUI/Tk/BrowseEdit.pm b/plugins/Tk-GUI/Tk/BrowseEdit.pm index a67f01a..497ab60 100644 --- a/plugins/Tk-GUI/Tk/BrowseEdit.pm +++ b/plugins/Tk-GUI/Tk/BrowseEdit.pm @@ -1,15 +1,20 @@ package Tk::BrowseEdit; + use Tk; use Tk::Font; use base 'Tk::Frame'; + use strict; use warnings; + Construct Tk::Widget 'BrowseEdit'; + sub ClassInit { my ($class, $mw) = @_; $class->SUPER::ClassInit($mw); } + sub Populate { my ($self, $args) = @_; @@ -48,7 +53,10 @@ $self]); -font => $self->Font(-family => 'times', -size => '8'), -command => [sub { my ($self) = @_; - $self->toggleTag(''); + my $color = $self->chooseColor( + -initialcolor => 'black', -parent => $self, + -title => 'Choose Background Color'); + $self->toggleTag("", ''); }, $self] )->pack(-pady => 0, -side => 'left', -fill => 'both'); $self->bind('', [sub { shift->{''}->invoke; }, $self]); @@ -63,13 +71,16 @@ $self]); 'to_html' => $self, ); } + sub insert { shift->{text}->insert(@_); } + sub toggleTag { - my ($self, $tag) = @_; + my ($self, $tag, $button) = @_; + $button = defined($button) ? $button : $tag; if(!defined($self->{text}->tagRanges('sel'))) { # no selection - modify current position @@ -88,7 +99,7 @@ sub toggleTag print "tag created\n"; $self->insert('insert', '%%%ignore%%%', [$cur_tag, 'elide']); $self->tagAdd($cur_tag, 'insert'); - $self->{$tag}->configure(-relief => 'flat'); + $self->{$button}->configure(-relief => 'flat'); print "done\n"; } else @@ -99,11 +110,16 @@ sub toggleTag $self->create_tag($cur_tag); $self->insert('insert', '%%%ignore%%%', [$cur_tag, 'elide']); $self->tagAdd($cur_tag, 'insert'); - $self->{$tag}->configure(-relief => 'sunken'); + $self->{$button}->configure(-relief => 'sunken'); } } else { + my $removed; + my $new_tag; + for my $wholetag ($self->{text}->tagNames()) + { + next unless $wholetag =~ /$tag/; my ($selstart, $selend) = $self->{text}->tagRanges('sel'); my @tags = $self->{text}->tagRanges($tag); my (@starts, @ends); @@ -118,16 +134,24 @@ sub toggleTag { if($selstart >= $start and $selend <= $end) { - $self->{text}->tagRemove($tag, $self->{text}->tagRanges('sel')); - $self->{$tag}->configure(-relief => 'flat'); - return; + $new_tag .= $tag; + $self->{$tag}->configure(-relief => 'flat'); + $removed = 1; + return; } } } - $self->{text}->tagAdd($tag, $self->{text}->tagRanges('sel')); + } + + unless($removed) + { + $self->create_tag($new_tag); + $self->{text}->tagAdd($tag, $self->{text}->tagRanges('sel')); $self->{$tag}->configure(-relief => 'sunken'); + } } } + sub create_tag { my ($self, $tag) = @_;