Originally Posted by
Woobly
2) Colours!
As I've only been outputting to the Cygwin window, so far everything has been in black and white text. I don't have a problem with the 'text' part of it, but I'd like to be able to control how *each character* looks in terms of colour when it's outputted - blue text on a green background for the first character, for instance, but then to be able to change that for subsequent ones. You get the idea.
I know of two ways to do that. I think cygwin includes the bash shell, so you should be able to use ANSI "escape sequences":
ANSI escape code - Wikipedia, the free encyclopedia
If this works, you are ANSI compatible:
Code:
#include <stdio.h>
#define BOLDMAGENTA "\033[1;35m"
#define GREEN "\033[0;32m"
int main(void) {
printf("%sHello %sworld!\n", BOLDMAGENTA, GREEN);
return 0;
}
The other option is some kind of console library such as ncurses, but I think you will find that is not worth it just for some color.
3) Charactersets.
I was previously just using the default cygwin characterset, which I understand is 'standard' ASCII.
Cygwin should be able to provide unicode (aka, UTF-8) support, which is, eg, the norm on the web. Pretty much every character you've ever seen on a screen is available in unicode.
If this code gives you ☺Hello↔world! you have UTF8 available (it has to be compiled std=c99):
Code:
#include <stdio.h>
#define HAPPYFACE "\u263a"
#define LEFTRIGHT_ARROW "\u2194"
int main(void) {
printf("%sHello%sworld!\n", HAPPYFACE, LEFTRIGHT_ARROW);
return 0;
}