progress_bar.h File Reference

A simple CLI progress bar. More...

Detailed Description

A simple CLI progress bar.

Author
Alexandre Abadie alexa.nosp@m.ndre.nosp@m..abad.nosp@m.ie@i.nosp@m.nria..nosp@m.fr

Definition in file progress_bar.h.

#include <stdlib.h>
#include <inttypes.h>
+ Include dependency graph for progress_bar.h:

Go to the source code of this file.

Data Structures

struct  progress_bar_t
 Progress bar descriptor. More...
 
#define PROGRESS_BAR_LENGTH   (25U)
 Progress bar maximum characters length.
 
#define PROGRESS_BAR_FULL_CHARACTER   "█"
 Progress bar character.
 
#define PROGRESS_BAR_EMPTY_CHARACTER   " "
 Progress bar empty character.
 
#define PROGRESS_BAR_PREFIX_CHARACTER   "|"
 Character displayed on the left of the progress bar.
 
#define PROGRESS_BAR_SUFFIX_CHARACTER   "|"
 Character displayed on the left of the progress bar.
 
#define PROGRESS_BAR_PREFIX_MAX_LENGTH   (32U)
 Progress bar prefix max length.
 
#define PROGRESS_BAR_SUFFIX_MAX_LENGTH   (32U)
 Progress bar suffix max length.
 
void progress_bar_print (char *prefix, char *suffix, uint8_t value)
 Print a progress bar in the terminal. More...
 
void progress_bar_update (progress_bar_t *progress_bar)
 Update the progress bar display in the terminal. More...
 
void progress_bar_prepare_multi (uint8_t len)
 Prepare the output for displaying multiple progress bars. More...
 
void progress_bar_update_multi (progress_bar_t *progress_bar_list, uint8_t len)
 Update all progress bar displays of the given progress bars list. More...
 

Function Documentation

◆ progress_bar_prepare_multi()

void progress_bar_prepare_multi ( uint8_t  len)

Prepare the output for displaying multiple progress bars.

This function is just adding enough empty lines to give enough space to print the list of progress bars.

This function must be called only once and before starting the progress bar list updates with.

Parameters
[in]lenThe length of the progress bar array

◆ progress_bar_print()

void progress_bar_print ( char *  prefix,
char *  suffix,
uint8_t  value 
)

Print a progress bar in the terminal.

Parameters
[in]prefixString displayed on the left of the progress bar
[in]suffixString displayed on the right of the progress bar
[in]valueValue of the progress bar

◆ progress_bar_update()

void progress_bar_update ( progress_bar_t progress_bar)

Update the progress bar display in the terminal.

Parameters
[in]progress_barPointer to the progress bar descriptor

◆ progress_bar_update_multi()

void progress_bar_update_multi ( progress_bar_t progress_bar_list,
uint8_t  len 
)

Update all progress bar displays of the given progress bars list.

Parameters
[in]progress_bar_listAn array of progress bars
[in]lenThe length of the progress bar array