add loading bar
This commit is contained in:
parent
82f5a40a87
commit
b38ad16d13
15
src/main.c
15
src/main.c
@ -8,7 +8,7 @@ void get_data(int *speed, int *capacity)
|
|||||||
*capacity = rand() % 101;
|
*capacity = rand() % 101;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update(WINDOW *win, int data)
|
void update(WINDOW *win, int data, int max)
|
||||||
{
|
{
|
||||||
int win_y, win_x;
|
int win_y, win_x;
|
||||||
char message[64];
|
char message[64];
|
||||||
@ -18,7 +18,12 @@ void update(WINDOW *win, int data)
|
|||||||
box(win, 0, 0);
|
box(win, 0, 0);
|
||||||
|
|
||||||
getmaxyx(win, win_y, win_x);
|
getmaxyx(win, win_y, win_x);
|
||||||
mvwprintw(win, win_y/2, win_x/2 - strlen(message)/2, "%s", message);
|
mvwprintw(win, win_y/2, win_x/4 - strlen(message)/2, "%s", message);
|
||||||
|
mvwprintw(win, win_y/2, win_x/2, "x");
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < ((data * (win_x / 3)) / max); i++) {
|
||||||
|
wprintw(win, "x");
|
||||||
|
}
|
||||||
wrefresh(win);
|
wrefresh(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,7 +33,7 @@ int main()
|
|||||||
noecho();
|
noecho();
|
||||||
cbreak();
|
cbreak();
|
||||||
curs_set(0);
|
curs_set(0);
|
||||||
nodelay(stdscr, true);
|
nodelay(stdscr, TRUE);
|
||||||
|
|
||||||
int y,x;
|
int y,x;
|
||||||
getmaxyx(stdscr, y, x);
|
getmaxyx(stdscr, y, x);
|
||||||
@ -51,8 +56,8 @@ int main()
|
|||||||
while(ch == ERR)
|
while(ch == ERR)
|
||||||
{
|
{
|
||||||
get_data(&speed, &capacity);
|
get_data(&speed, &capacity);
|
||||||
update(top_win, speed);
|
update(top_win, speed, 200);
|
||||||
update(bottom_win, capacity);
|
update(bottom_win, capacity, 100);
|
||||||
ch = getch();
|
ch = getch();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user