Hi,
I'm trying to write a function that prints text to the console in a custom format. I'm trying to make it cross-platform, and I am developing on Windows. Right now, all I really care about is that the text is underlined. So far, I have:
Code:
void print_underlined(char* str) {
#ifdef _WIN32
static HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(handle,COMMON_LVB_UNDERSCORE|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
printf("%s",str);
SetConsoleTextAttribute(handle,FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
#else
printf("\033[4;37;40m%s\033[4;37;40m",str);
#endif
}
By playing with some of the arguments in SetConsoleTextAttribute in the first block, I can get different colored font, but for some reason it just is never underlined.
Also, the #else code doesn't work for me (it oughtn't to; as before, I'm on Windows). I was hoping perhaps someone could let me know if it does.
Thanks!
Ian