diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-08-02 08:21:29 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-08-02 08:21:29 +0000 |
| commit | 61bfe2d70cae6be8c4086a210a5451135ccca9ea (patch) | |
| tree | 62bf7808b1b2bfe5f56fe1e329871fb0991d0687 /docs/tool/Modules/NaturalDocs/StatusMessage.pm | |
| parent | a13b94f9e0bca8ea892311d9d9e0c0bc48616ea7 (diff) | |
| download | zcatch-61bfe2d70cae6be8c4086a210a5451135ccca9ea.tar.gz zcatch-61bfe2d70cae6be8c4086a210a5451135ccca9ea.zip | |
added doc tool
Diffstat (limited to 'docs/tool/Modules/NaturalDocs/StatusMessage.pm')
| -rw-r--r-- | docs/tool/Modules/NaturalDocs/StatusMessage.pm | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/docs/tool/Modules/NaturalDocs/StatusMessage.pm b/docs/tool/Modules/NaturalDocs/StatusMessage.pm new file mode 100644 index 00000000..7d3de079 --- /dev/null +++ b/docs/tool/Modules/NaturalDocs/StatusMessage.pm @@ -0,0 +1,102 @@ +############################################################################### +# +# Package: NaturalDocs::StatusMessage +# +############################################################################### +# +# A package to handle status message updates. Automatically handles <NaturalDocs::Settings->IsQuiet()>. +# +############################################################################### + +# This file is part of Natural Docs, which is Copyright (C) 2003-2008 Greg Valure +# Natural Docs is licensed under the GPL + +use strict; +use integer; + +package NaturalDocs::StatusMessage; + + +# +# var: message +# The message to display. +# +my $message; + +# +# var: total +# The number of items to work through. +# +my $total; + +# +# var: completed +# The number of items completed. +# +my $completed; + +# +# var: lastMessageTime +# The time the last message was posted. +# +my $lastMessageTime; + + +# +# constant: TIME_BETWEEN_UPDATES +# The number of seconds that should occur between updates. +# +use constant TIME_BETWEEN_UPDATES => 10; + + + +# +# Function: Start +# +# Starts the status message. +# +# Parameters: +# +# message - The message to post. +# total - The number of items that are going to be worked through. +# +sub Start #(message, total) + { + my $self = shift; + + if (!NaturalDocs::Settings->IsQuiet()) + { + ($message, $total) = @_; + $completed = 0; + + print $message . "\n"; + + $lastMessageTime = time(); + }; + }; + + +# +# Function: CompletedItem +# +# Should be called every time an item is completed. +# +sub CompletedItem + { + my $self = shift; + + if (!NaturalDocs::Settings->IsQuiet()) + { + # We scale completed by 100 since we need to anyway to get the percentage. + + $completed += 100; + + if (time() >= $lastMessageTime + TIME_BETWEEN_UPDATES && $completed != $total * 100) + { + print $message . ' (' . ($completed / $total) . '%)' . "\n"; + $lastMessageTime = time(); + }; + }; + }; + +1; |