Creating and maintaining progress-bars to be printed to the console.
Source for this file: /ConsoleTools/src/progressbar.php
Version: | //autogen// |
int | read/write |
$max
The maximum progress value to reach. |
ezcConsoleProgressbarOptions | read/write |
$options
Contains the options for this class. |
protected int |
$currentStep
= 0
The current step the progress bar should show. |
protected array(string=>int) |
$measures
= array(
Stores the bar utilization. This array saves how much space a specific part of the bar utilizes to not recalculate those on every step. |
protected int |
$numSteps
= 0
The maximum number of steps to go. Calculated once from the settings. |
protected ezcConsoleOutput |
$output
The ezcConsoleOutput object to use. |
protected array(string=>mixed) |
$properties
Container to hold the properties |
protected bool |
$started
= false
Indicates if the starting point for the bar has been stored. Per default this is false to indicate that no start position has been stored, yet. |
protected array(string=>string) |
$valueMap
= array(
Storage for actual values to be replaced in the format string. Actual values are stored here and will be inserted into the bar before printing it. |
public ezcConsoleProgressbar |
__construct(
$outHandler
, $max
, [ $options
= array()] )
Creates a new progress bar. |
public void |
advance(
[ $redraw
= true] , [ $step
= 1] )
Advance the progress bar. |
protected void |
calculateMeasures(
)
Calculate several measures necessary to generate a bar. |
public void |
finish(
)
Finish the progress bar. |
protected void |
generateValues(
)
Generate all values to be replaced in the format string. |
public ezcConsoleProgressbarOptions |
getOptions(
)
Returns the current options. |
protected void |
insertValues(
)
Insert values into bar format string. |
public void |
output(
)
Draw the progress bar. |
public void |
setOptions(
$options
)
Set new options. |
public void |
start(
)
Start the progress bar Starts the progress bar and sticks it to the current line. |
protected void |
stripEscapeSequences(
$str
)
Strip all escape sequences from a string to measure it's size correctly. |
Creates a new progress bar.
Name | Type | Description |
---|---|---|
$outHandler |
ezcConsoleOutput | Handler to utilize for output |
$max |
int | Maximum value, where progressbar reaches 100%. |
$options |
array(string=>string) | Options |
Advance the progress bar.
Advances the progress bar by $step steps. Redraws the bar by default, using the ezcConsoleProgressbar::output() method.
Name | Type | Description |
---|---|---|
$redraw |
bool | Whether to redraw the bar immediately. |
$step |
int | How many steps to advance. |
Calculate several measures necessary to generate a bar.
Finish the progress bar.
Finishes the bar (jump to 100% if not happened yet,...) and jumps to the next line to allow new output. Also resets the values of the output handler used, if changed.
Generate all values to be replaced in the format string.
Returns the current options.
Returns the options currently set for this progressbar.
Insert values into bar format string.
Draw the progress bar.
Prints the progress-bar to the screen. If start() has not been called yet, the current line is used for ezcConsolProgressbar::start().
Set new options.
This method allows you to change the options of progressbar.
Name | Type | Description |
---|---|---|
$options |
ezcConsoleProgresbarOptions | The options to set. |
Type | Description |
---|---|
ezcBaseSettingNotFoundException |
If you tried to set a non-existent option value. |
ezcBaseSettingValueException |
If the value is not valid for the desired option. |
ezcBaseValueException |
If you submit neither an array nor an instance of ezcConsoleProgresbarOptions. |
Start the progress bar Starts the progress bar and sticks it to the current line.
No output will be done yet. Call ezcConsoleProgressbar::output() to print the bar.
Strip all escape sequences from a string to measure it's size correctly.
Name | Type | Description |
---|---|---|
$str |
mixed |