Skip to content

Simple yet functional progressbar in ANSI C for ascii terminals

License

Notifications You must be signed in to change notification settings

oysteijo/progressbar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Progress bar in ANSI C for ascii terminals

progreesbar.png

This is a really simple progressbar implementation in ANSI C99. I want it to be beautiful yet simple. General yet not requiring much configuration.

Super simple API. Only one function:

#include "progress.h"
#define MAX_COUNT 100
int main()
{
    for(int i=0; i <= MAX_COUNT; i++ ){
        /* Do something */
        progress_ascii( i, MAX_COUNT, "Some text: ");
    }
    return 0;
}

I have added some flexibility in the leading text by having the function variadic, just like a printf() You can hence call the function like:

        progress_ascii( i, maxvalue, "(%4d/%4d) ", i, maxvalue);

Estimated time

I have added the feature to estimate the ETA of a long process. This feature sets a start time when the call to progress_ascii() gets 0 as it first argument.

Please note that you probably want to call the function with a final 100% value as well. In that case the total spent time is reported.

So... Make sure that you call the function with both 0 at start and 100%-value at the end.

About

Simple yet functional progressbar in ANSI C for ascii terminals

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published