2024-12-06 14:44:48 +04:00
|
|
|
#define _CRT_SECURE_NO_WARNINGS
|
2024-12-02 23:19:52 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <Windows.h>
|
2024-12-06 14:44:48 +04:00
|
|
|
#include <stdlib.h>
|
2024-12-02 23:19:52 +04:00
|
|
|
#include "../progressbar test/progressbar.h"
|
|
|
|
|
|
|
|
// \033[ = CSI, CSI ?25l hides the cursor, CSI ?25h shows the cursor
|
|
|
|
// see ANSI escape code wiki for more info
|
|
|
|
#define HIDE_CURSOR "\033[?25l"
|
|
|
|
#define SHOW_CURSOR "\033[?25h"
|
|
|
|
|
|
|
|
void wait(int seconds) {
|
|
|
|
clock_t t0 = clock();
|
|
|
|
clock_t t1;
|
|
|
|
while ((int)(((t1 = clock()) - t0) / CLOCKS_PER_SEC) < seconds) {
|
2024-12-03 12:31:42 +04:00
|
|
|
Sleep(1000);
|
2024-12-02 23:19:52 +04:00
|
|
|
}
|
|
|
|
printf(" wait for %d s is over, clock=%d", seconds, (int)t1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
printf("ITS WINDOWS!\n");
|
|
|
|
#endif
|
2024-12-06 14:44:48 +04:00
|
|
|
|
2024-12-02 23:19:52 +04:00
|
|
|
struct progressbar pb;
|
2024-12-06 14:44:48 +04:00
|
|
|
int n = 1, sl = 1;
|
2024-12-03 12:31:42 +04:00
|
|
|
printf(HIDE_CURSOR);
|
|
|
|
printf("\033[385;31m");
|
2024-12-02 23:19:52 +04:00
|
|
|
progressbar_start(&pb, n * sl);
|
|
|
|
|
|
|
|
clock_t start = clock();
|
|
|
|
|
2024-12-03 12:31:42 +04:00
|
|
|
for (int i = 1; i <= n; i++) {
|
|
|
|
int percentage = 100 * i / n;
|
|
|
|
if (percentage < 33) {
|
|
|
|
printf("\033[385;31m");
|
|
|
|
}
|
|
|
|
else if (33 < percentage && percentage < 66) {
|
|
|
|
printf("\033[385;33m");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("\033[385;32m");
|
|
|
|
}
|
2024-12-02 23:19:52 +04:00
|
|
|
wait(sl);
|
|
|
|
//printf("%d\n", i);
|
|
|
|
progressbar_add(&pb, sl);
|
|
|
|
}
|
|
|
|
//progressbar_clear();
|
2024-12-03 12:31:42 +04:00
|
|
|
printf("\033[0m");
|
2024-12-02 23:19:52 +04:00
|
|
|
printf(SHOW_CURSOR);
|
|
|
|
printf("\n");
|
|
|
|
printf_s("time = %.3lf seconds\nexpected %d seconds\n", (double)(clock() - start) / (double)CLOCKS_PER_SEC, n * sl);
|
2024-12-03 12:31:42 +04:00
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
for (int i = 40; i <= 47; i++) {
|
|
|
|
printf("\033[385;%dm", i);
|
|
|
|
for (int j = 30; j <= 37; j++) {
|
|
|
|
printf("\033[385;%dm", j);
|
2024-12-06 14:44:48 +04:00
|
|
|
printf("%02X ", count);
|
2024-12-03 12:31:42 +04:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
for (int j = 90; j <= 97; j++) {
|
|
|
|
printf("\033[385;%dm", j);
|
2024-12-06 14:44:48 +04:00
|
|
|
printf("%02X ", count);
|
2024-12-03 12:31:42 +04:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
printf("\n");
|
2024-12-02 23:19:52 +04:00
|
|
|
}
|
2024-12-03 12:31:42 +04:00
|
|
|
for (int i = 100; i <= 107; i++) {
|
|
|
|
printf("\033[385;%dm", i);
|
|
|
|
for (int j = 30; j <= 37; j++) {
|
|
|
|
printf("\033[385;%dm", j);
|
2024-12-06 14:44:48 +04:00
|
|
|
printf("%02X ", count);
|
2024-12-03 12:31:42 +04:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
for (int j = 90; j <= 97; j++) {
|
|
|
|
printf("\033[385;%dm", j);
|
2024-12-06 14:44:48 +04:00
|
|
|
printf("%02X ", count);
|
2024-12-03 12:31:42 +04:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
printf("\033[0m");
|
|
|
|
|
2024-12-02 23:19:52 +04:00
|
|
|
return 0;
|
2024-11-10 13:45:07 +04:00
|
|
|
}
|