1 ###############################################################################
3 # Package: NaturalDocs::StatusMessage
5 ###############################################################################
7 # A package to handle status message updates. Automatically handles <NaturalDocs::Settings->IsQuiet()>.
9 ###############################################################################
11 # This file is part of Natural Docs, which is Copyright © 2003-2010 Greg Valure
12 # Natural Docs is licensed under version 3 of the GNU Affero General Public License (AGPL)
13 # Refer to License.txt for the complete details
18 package NaturalDocs::StatusMessage;
23 # The message to display.
29 # The number of items to work through.
35 # The number of items completed.
40 # var: lastMessageTime
41 # The time the last message was posted.
47 # constant: TIME_BETWEEN_UPDATES
48 # The number of seconds that should occur between updates.
50 use constant TIME_BETWEEN_UPDATES => 10;
57 # Starts the status message.
61 # message - The message to post.
62 # total - The number of items that are going to be worked through.
64 sub Start #(message, total)
68 if (!NaturalDocs::Settings->IsQuiet())
70 ($message, $total) = @_;
73 print $message . "\n";
75 $lastMessageTime = time();
81 # Function: CompletedItem
83 # Should be called every time an item is completed.
89 if (!NaturalDocs::Settings->IsQuiet())
91 # We scale completed by 100 since we need to anyway to get the percentage.
95 if (time() >= $lastMessageTime + TIME_BETWEEN_UPDATES && $completed != $total * 100)
97 print $message . ' (' . ($completed / $total) . '%)' . "\n";
98 $lastMessageTime = time();