Last active
December 15, 2017 11:22
-
-
Save Kylmakalle/1fc1b17196ad3bfa83fb5e709aa132d5 to your computer and use it in GitHub Desktop.
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 <sys/ioctl.h> | |
#include <unistd.h> | |
#include <stdio.h> | |
void DeleteLine(int delay=10000){ | |
usleep(delay); | |
std::cout << "\033[A\033[2K"; | |
} | |
std::string shifted_str(std::string s, int indent, int width){ | |
std::string output; | |
for (int i = 0; i <= indent; i++) | |
output += " "; | |
output += s.substr(0, width - output.length()); | |
return output; | |
} | |
void ticker(std::string s){ | |
struct winsize size; | |
ioctl(STDOUT_FILENO,TIOCGWINSZ,&size); | |
for (int i = size.ws_col - 1; i > 0; i--){ | |
//for (int i = 0; i < size.ws_col - 1; i++){ // From left to right | |
std::cout << shifted_str(s, i, size.ws_col) << std::endl; | |
DeleteLine(20000); | |
} | |
std::cout << s; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment