CBars, a small c99 library for progress bars in the terminal.
cbar_t bar = cbar(48, "Loading Level: [$F'-'$F$N' '$N] $P%");
cbar_hide_cursor();
while(loading()){
bar.progress = load();
cbar_display_bar(&bar);
}
cbar_show_cursor();
printf("\n");
Loading Level: [------------------------------------ ] 76%
CBars uses a custom syntax to define how a bar is rendered.
- $F and $N is used to render the bar (E.G.
"$F'-'$F$N' '$N"
).
- $F (Fill) is where the filled part of the bar is rendered.
- $N (None) is where the rest of the bar is rendered.
- The character between the
''
will be used to print that part of the bar.
- $P is used to render the percentage of completion (0-100).
- $E is used to set effects (E.G.
"$E BOLD;256(6); $E"
).
- Everything is separated with a semi-colon.
256(n)
andBG256(n)
is used for 256 colors.RGB(r, g, b)
andBGRGB(r, g, b)
is used for rgb colors.- To see all possible effects go to
include/cbars/cbars.h
and look at thecbar_effect_t
enum.
Cursor Controls (Although you can use ANSII escape sequences in the bar string)