libite
Macros | Functions
progress.c File Reference
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include "conio.h"
Include dependency graph for progress.c:

Macros

#define SPINNER_THROB   ".oOo"
 
#define SPINNER_PULSAR   ".oO°Oo."
 
#define SPINNER_ARROW   "v<^>"
 
#define SPINNER_STAR   ".oO@*"
 
#define SPINNER_DEFAULT   "|/-\\"
 

Functions

void progress (int percent, int max_width)
 Advanced ASCII progress bar with spinner. More...
 
void progress_simple (int percent)
 Alternative progress bar on systems where progress() doesn't work. More...
 

Detailed Description

Author
Joachim Wiberg
Date
2012-2021

Function Documentation

◆ progress()

void progress ( int  percent,
int  max_width 
)

Advanced ASCII progress bar with spinner.

Parameters
percentStart first call with this set to 0, end with 100
max_widthMax width of progress bar, in total characters.

This function draws an advanced ASCII progressbar at the current line. It always start from the first column.

The progress bar will hide the cursor if started with percent 0 and show it again at the end, when called with percent 100.

While being called with the same percentage the spinner will spin, to show the user the process hasn't frozen.

If the output TTY cannot interpret control characters, like \r, it is advised to instead used the progress_simple() function.

◆ progress_simple()

void progress_simple ( int  percent)

Alternative progress bar on systems where progress() doesn't work.

Parameters
percentStart first call with this set to 0, end with 100