cctools
progress_bar.h File Reference
#include "list.h"
#include "timestamp.h"
#include <time.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  ProgressBarPart
 A part of a progress bar. More...
 
struct  ProgressBar
 Progress bar object. More...
 

Functions

struct ProgressBarprogress_bar_init (const char *label)
 Create a progress bar. More...
 
void progress_bar_set_update_interval (struct ProgressBar *bar, double update_interval_sec)
 Set the update interval for the progress bar. More...
 
struct ProgressBarPartprogress_bar_create_part (const char *label, uint64_t total)
 Create a new part. More...
 
void progress_bar_bind_part (struct ProgressBar *bar, struct ProgressBarPart *part)
 Bind a part to the progress bar. More...
 
void progress_bar_set_part_total (struct ProgressBar *bar, struct ProgressBarPart *part, uint64_t new_total)
 Set the total for a part. More...
 
void progress_bar_update_part (struct ProgressBar *bar, struct ProgressBarPart *part, uint64_t increment)
 Update the current value for a part, redraw if needed. More...
 
void progress_bar_set_start_time (struct ProgressBar *bar, timestamp_t start_time)
 Set the start time for the progress bar. More...
 
void progress_bar_finish (struct ProgressBar *bar)
 Finish the progress bar: draw once and print a newline. More...
 
void progress_bar_delete (struct ProgressBar *bar)
 Delete the progress bar and free all parts. More...
 

Detailed Description

Terminal progress bar API with multiple parts.

Function Documentation

◆ progress_bar_init()

struct ProgressBar* progress_bar_init ( const char *  label)

Create a progress bar.

Parameters
labelProgress bar label (internally duplicated).
Returns
New progress bar.

◆ progress_bar_set_update_interval()

void progress_bar_set_update_interval ( struct ProgressBar bar,
double  update_interval_sec 
)

Set the update interval for the progress bar.

Parameters
barProgress bar.
update_interval_secUpdate interval in seconds.

◆ progress_bar_create_part()

struct ProgressBarPart* progress_bar_create_part ( const char *  label,
uint64_t  total 
)

Create a new part.

Parameters
labelPart label (internally duplicated).
totalTotal units for the part.
Returns
New part.

◆ progress_bar_bind_part()

void progress_bar_bind_part ( struct ProgressBar bar,
struct ProgressBarPart part 
)

Bind a part to the progress bar.

Parameters
barProgress bar.
partPart to bind.

◆ progress_bar_set_part_total()

void progress_bar_set_part_total ( struct ProgressBar bar,
struct ProgressBarPart part,
uint64_t  new_total 
)

Set the total for a part.

Parameters
barProgress bar.
partPart to update.
new_totalNew total units.

◆ progress_bar_update_part()

void progress_bar_update_part ( struct ProgressBar bar,
struct ProgressBarPart part,
uint64_t  increment 
)

Update the current value for a part, redraw if needed.

Parameters
barProgress bar.
partPart to advance.
incrementAmount to add.

◆ progress_bar_set_start_time()

void progress_bar_set_start_time ( struct ProgressBar bar,
timestamp_t  start_time 
)

Set the start time for the progress bar.

Parameters
barProgress bar.
start_timeStart timestamp.

◆ progress_bar_finish()

void progress_bar_finish ( struct ProgressBar bar)

Finish the progress bar: draw once and print a newline.

Parameters
barProgress bar.

◆ progress_bar_delete()

void progress_bar_delete ( struct ProgressBar bar)

Delete the progress bar and free all parts.

Parameters
barProgress bar.