An extremely lightweight alternative for ncurses etc. for windows and linux, wrapping functions for setting color, getting keypresses and getting/setting console size and cursor location (just compile and see the demo, it's pretty self-explanatory)... It provides just the most neccessary features and is just useful if you just need this kind of features... otherwise use something more 'complete'
I am now using this library within my application, but wanted to report a small problem that there is.
The enum that contains the colors, should be move dinto the heaer file instead, as it can't be accessed otherwise.
I also have made a minimal piece of code that allows me to reset the console. I kinda picked the code up from stackoverflow and MSDN, but maybe it turns out to be useful.
#ifndefAP_HELPER#defineAP_HELPER#ifdefWIN32#include<windows.h>// Console attributes.HANDLEhConsole;
WORDsaved_attributes;
CONSOLE_SCREEN_BUFFER_INFOconsoleInfo;
voidinitConsole() {
HANDLEhConsole=GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFOconsoleInfo;
WORDsaved_attributes;
/* Save current attributes */GetConsoleScreenBufferInfo(hConsole, &consoleInfo);
saved_attributes=consoleInfo.wAttributes;
}
voiddeinitConsole() {
/* Restore original attributes */SetConsoleTextAttribute(hConsole, saved_attributes);
}
#else#include<stdio.h>// Nothing to do herevoidinitConsole() {}
voiddeinitConsole() {
printf("\e[0m");
}
#endif#endif