Skip to content

NongusStudios/cbars

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cbars/cbars.h

CBars, a small c99 library for progress bars in the terminal.

Example

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");

Result

Loading Level: [------------------------------------            ] 76%

Usage

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) and BG256(n) is used for 256 colors.
  • RGB(r, g, b) and BGRGB(r, g, b) is used for rgb colors.
  • To see all possible effects go to include/cbars/cbars.h and look at the cbar_effect_t enum.

Missing features that I might implement when I feel like it

Cursor Controls (Although you can use ANSII escape sequences in the bar string)

Releases

No releases published

Packages

No packages published