Description | Perl tools for X-ray Absorption Spectroscopy |
Demeter::UI::Screen::Progress - On screen indicators for lengthy operations
This documentation refers to Demeter version 0.9.26.
A spinner indicating and ongoing operation:
$fitobject->start_spinner("Demeter is performing a fit");
...
$fitobject->stop_spinner;
A counter indicating an operation of known length:
$n = 100;
$object->start_counter("Demeter is doing something $n times", $n);
...
loop {
$object->count;
}
...
$object->stop_counter;
Both spinner and counter are disabled if screen disposal mode is turned on.
This role for a Demeter object provides some on-screen feedback for lengthy procedures. This role is imported when the UI mode is set to "screen". See "PRAGMATA" in Demeter. The idea is to provide either a spinny thing for the user to look at when running something time consuming from the command line or a counter for when the number of steps to the time consuming operation is known.
The spinner attributes of this role take their names from parameters for Term::Twiddle. Like all Moose attributes, their accessors take the same names.
thingy
An array with the sequence of text strings comprising the spinner. The default is a throbber that goes from "[ ]" to "-+-" and back.
rate
The speed at which the thingy changes. Default is 0.1.
progress
The text string which formats the progress meter. See Term::Sk for full details. The default is
Elapsed: %8t %30b (%c of %m)
This shows the elapsed time, a progress bar, and a count.
start_spinner
Start the spinner. This is typically called just before a time consuming operation.
$fitobject->start_spinner("Demeter is performing a fit");
The optional argument is some text to print to the screen in front of the spinner. This text would typically not include a new line.
stop_spinner
Stop the spinner. This is typically called at the end of a time consuming operation.
$fitobject->stop_spinner;
start_counter
Start the counter. This is typically called just before a time consuming operation of a known number of steps.
$object->start_spinner("Demeter is doing many things", 100);
The first argument is a bit of text describing what's going on. A new line will be appended if the text does not end in a newline. The second argument is the total number of steps in the operation.
count
Update the counter.
$object->count;
stop_counter
Stop the counter. This is typically called after the last step is completed.
$object->stop_counter;
Demeter's dependencies are in the Build.PL file. This module uses Term::Twiddle to generate the indicator and Term::Sk for the counter.
Configuring the form and rate of the twiddler would be nice.
A way to access the Term::Sk whisper method would be helpful.
Please report problems to the Ifeffit Mailing List (http://cars9.uchicago.edu/mailman/listinfo/ifeffit/)
Patches are welcome.
Bruce Ravel, http://bruceravel.github.io/home
http://bruceravel.github.io/demeter/
Copyright (c) 2006-2018 Bruce Ravel (http://bruceravel.github.io/home). All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlgpl.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.