progress_bar.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Inria
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
19 #ifndef PROGRESS_BAR_H
20 #define PROGRESS_BAR_H
21 
22 #include <stdlib.h>
23 #include <inttypes.h>
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
32 #ifndef PROGRESS_BAR_LENGTH
33 #define PROGRESS_BAR_LENGTH (25U)
34 #endif
35 
39 #ifndef PROGRESS_BAR_FULL_CHARACTER
40 #define PROGRESS_BAR_FULL_CHARACTER "█"
41 #endif
42 
46 #ifndef PROGRESS_BAR_EMPTY_CHARACTER
47 #define PROGRESS_BAR_EMPTY_CHARACTER " "
48 #endif
49 
53 #ifndef PROGRESS_BAR_PREFIX_CHARACTER
54 #define PROGRESS_BAR_PREFIX_CHARACTER "|"
55 #endif
56 
60 #ifndef PROGRESS_BAR_SUFFIX_CHARACTER
61 #define PROGRESS_BAR_SUFFIX_CHARACTER "|"
62 #endif
63 
67 #ifndef PROGRESS_BAR_PREFIX_MAX_LENGTH
68 #define PROGRESS_BAR_PREFIX_MAX_LENGTH (32U)
69 #endif
70 
74 #ifndef PROGRESS_BAR_SUFFIX_MAX_LENGTH
75 #define PROGRESS_BAR_SUFFIX_MAX_LENGTH (32U)
76 #endif
77 
81 typedef struct {
83  uint8_t value;
89 
97 void progress_bar_print(char *prefix, char *suffix, uint8_t value);
98 
104 void progress_bar_update(progress_bar_t *progress_bar);
105 
117 void progress_bar_prepare_multi(uint8_t len);
118 
125 void progress_bar_update_multi(progress_bar_t *progress_bar_list, uint8_t len);
126 
127 #ifdef __cplusplus
128 }
129 #endif
130 
132 #endif /* PROGRESS_BAR_H */
progress_bar_t::value
uint8_t value
Current value of the progress bar.
Definition: progress_bar.h:83
progress_bar_update
void progress_bar_update(progress_bar_t *progress_bar)
Update the progress bar display in the terminal.
PROGRESS_BAR_SUFFIX_MAX_LENGTH
#define PROGRESS_BAR_SUFFIX_MAX_LENGTH
Progress bar suffix max length.
Definition: progress_bar.h:75
progress_bar_prepare_multi
void progress_bar_prepare_multi(uint8_t len)
Prepare the output for displaying multiple progress bars.
progress_bar_t
Progress bar descriptor.
Definition: progress_bar.h:81
progress_bar_print
void progress_bar_print(char *prefix, char *suffix, uint8_t value)
Print a progress bar in the terminal.
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.
inttypes.h
Adds include for missing inttype definitions.
PROGRESS_BAR_PREFIX_MAX_LENGTH
#define PROGRESS_BAR_PREFIX_MAX_LENGTH
Progress bar prefix max length.
Definition: progress_bar.h:68