This commit is contained in:
Your Name 2024-01-03 18:27:09 +03:00
parent 2fac712297
commit f9ccaaa80b
6 changed files with 38 additions and 8 deletions

View file

@ -257,19 +257,40 @@ int GetAVG(const char *title, const FETCH fetch) {
#endif
}
void DrawBar(char *color, int cur, int max) {
printf("[");
void DrawBar(int cur, int max) {
int bar = max / BAR_WIDTH;
#ifdef FIRA_CODE
char *start = "";
if (cur * bar > 0)
start = "";
char *end = "";
if (cur < max)
end = "";
char *bar_filled = "";
char *bar_void = "";
#else
char *start = "[";
char *end = "]";
char *bar_filled = "#";
char *bar_void = ".";
#endif
printf("%s", start);
for (int i = 0; i < BAR_WIDTH; i++) {
if (i * bar < cur)
printf("%s-\033[0m", color);
printf("%s", bar_filled);
else
printf("\033[1;30m-\033[0m");
printf("%s", bar_void);
}
printf("]");
printf("%s", end);
}
int GetBattery(const char *title, const FETCH fetch) {
@ -285,8 +306,7 @@ int GetBattery(const char *title, const FETCH fetch) {
return 1;
printf("%s%s%s", fetch.color, title, fetch.font_color);
DrawBar(fetch.color, capacity, 100);
DrawBar(capacity, 100);
return 0;
}