Created
December 5, 2019 00:08
-
-
Save bwedding/18fb41b46b4af8b72d405b9490a9c83f to your computer and use it in GitHub Desktop.
ASCII Progress Deedle Class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <thread> | |
enum DeedleType | |
{ | |
Sticks, | |
Bubbles, | |
Rect, | |
LineBoxes, | |
Boxes | |
}; | |
void ShowProgress(DeedleType type) | |
{ | |
const char* deedle = nullptr; | |
int deedleSize = 0; | |
static int cnt = 0; | |
static const char DeedleSticks[] = { '|','/','-','\\' }; | |
static const char DeedleBubbles[] = { '.','o','O','o' }; | |
static const char DeedleRect[] = { 176,177,178,177 }; | |
static const char DeedleLineBoxes[] = { 187,188,200,201 }; | |
static const char DeedleBoxes[] = { 221,220,222,223 }; | |
switch (type) | |
{ | |
case Boxes: | |
deedle = DeedleBoxes; | |
deedleSize = sizeof(DeedleBoxes); | |
break; | |
case Sticks: | |
deedle = DeedleSticks; | |
deedleSize = sizeof(DeedleSticks); | |
break; | |
case Rect: | |
deedle = DeedleRect; | |
deedleSize = sizeof(DeedleRect); | |
break; | |
default: | |
case Bubbles: | |
deedle = DeedleBubbles; | |
deedleSize = sizeof(DeedleBubbles); | |
break; | |
case LineBoxes: | |
deedle = DeedleLineBoxes; | |
deedleSize = sizeof(DeedleLineBoxes); | |
break; | |
} | |
printf("%c\b", deedle[cnt++ % deedleSize]); | |
} | |
int main() | |
{ | |
int i = 0; | |
while(i++ < 10) | |
{ | |
std::this_thread::sleep_for(100ms); | |
ShowProgress(Boxes); | |
} | |
while (i++ < 20) | |
{ | |
std::this_thread::sleep_for(100ms); | |
ShowProgress(Rect); | |
} | |
while (i++ < 30) | |
{ | |
std::this_thread::sleep_for(100ms); | |
ShowProgress(Bubbles); | |
} | |
while (i++ < 40) | |
{ | |
std::this_thread::sleep_for(100ms); | |
ShowProgress(Sticks); | |
} | |
while (i++ < 50) | |
{ | |
std::this_thread::sleep_for(100ms); | |
ShowProgress(LineBoxes); | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment