Short:        Simple progress bar display for CLI
Author:       Joseph Werle
Uploader:     Carsten Larsen (carsten larsen mail com)
Type:         dev/c
Version:      0.0.4
Architecture: generic; m68k-amigaos
URL:          https://github.com/jwerle/progress.c

About

    Simple progress bar display for the terminal inspired by node-progress:

    progress [======---------------------------------------------] 10% 0.0s

Example

    #include <progress.h>

    void
    on_progress (progress_data_t *data);

    int
    main (void) {
        progress_t *progress = progress_new(100, 60);
        progress->fmt = "progress [:bar] :percent :elapsed";

        // listen for progress
        progress_on(progress, PROGRESS_EVENT_PROGRESS, on_progress);

        // tick progress
        progress_tick(progress, 10);
    }

    void
    on_progress (progress_data_t *data) {
        progress_write(data->holder);
    }

API

    Create a new progress_t* pointer with a given int total and
    progress bar size_t width.

        int total = 100;
        size_t width = 20;
        progress_t *progress = progress_new

    You can define the output to stdout by setting the `char * fmt`
    member on the progress_t* pointer. Available tokens in the
    format string are:

    * :bar     - represents progress bar
    * :percent - represents current progress percent
    * :elapsed - represents current elapsed time in seconds as a float

    progress->fmt = "  downloading :percent (:elapsed) :bar";

    The characters used to draw the complete and incomplete parts of the
    progress bar can be set too.

        progress->bar_char = ".";
        progress->bg_bar_char = " ";


    Bind function callbacks to events where an `progress_event_type_t`
    event is:

        * PROGRESS_EVENT_START    - represents an event type for when
                                    progress has begun
        * PROGRESS_EVENT_PROGRESS - represents an event type for when
                                    progress has ticked
        * PROGRESS_EVENT_END -      represents an event type for when
                                    progress has completed

    A valid callback has the following signature which accepts a
    progress_data_t* pointer.

        void callback (progress_data_t *data);

        progress_on(progress, PROGRESS_EVENT_START, on_progress_start);
        progress_on(progress, PROGRESS_EVENT_PROGRESS, on_progress);
        progress_on(progress, PROGRESS_EVENT_END, on_progress_end);

    To increment progress the progress_t* pointer must be passed to
    progress_tick(). If the total has been met then any function pointer
    bound to PROGRESS_EVENT_END will be called in the order they were
    bound.

        progress_tick(progress, 42);

    To set the progress bar to specific value you can call. If the total
    has been met then any function pointer bound to PROGRESS_EVENT_END
    will be called in the order they were bound.

        progress_value(progress, 20);

License

    MIT
