SHOW:
|
|
- or go back to the newest paste.
| 1 | #include <windows.h> | |
| 2 | #include <string.h> | |
| 3 | ||
| 4 | bool setConsoleFontSize(HANDLE console, COORD dwFontSize){
| |
| 5 | CONSOLE_FONT_INFOEX info{ sizeof(CONSOLE_FONT_INFOEX) };
| |
| 6 | if (!GetCurrentConsoleFontEx(console, false, &info)) | |
| 7 | return false; | |
| 8 | info.dwFontSize = dwFontSize; | |
| 9 | return SetCurrentConsoleFontEx(console, false, &info); | |
| 10 | } | |
| 11 | ||
| 12 | void getConsoleSize(HANDLE console, short & width, short & height){
| |
| 13 | CONSOLE_SCREEN_BUFFER_INFO bufferInfo; | |
| 14 | ||
| 15 | GetConsoleScreenBufferInfo(console, &bufferInfo); | |
| 16 | width = bufferInfo.srWindow.Right; | |
| 17 | height = bufferInfo.srWindow.Bottom; | |
| 18 | } | |
| 19 | ||
| 20 | void niceText(const char * text, unsigned short baseColor = 0x07, unsigned short specialColor = 0x07){
| |
| 21 | - | int length = strlen(text); |
| 21 | + | // ... |
| 22 | - | unsigned short * attributes = new unsigned short[length]; |
| 22 | + | |
| 23 | - | unsigned short * highLightAttributes = new unsigned short[length]; |
| 23 | + | |
| 24 | setConsoleFontSize(console, {12, 16});
| |
| 25 | - | for (int i = 0; i < length; i++){
|
| 25 | + | |
| 26 | - | if (text[i] >= 0x20){
|
| 26 | + | |
| 27 | - | attributes[i] = baseColor; |
| 27 | + | |
| 28 | - | highLightAttributes[i] = baseColor | FOREGROUND_INTENSITY | BACKGROUND_INTENSITY; |
| 28 | + | |
| 29 | - | } |
| 29 | + | |
| 30 | - | else{
|
| 30 | + | |
| 31 | - | attributes[i] = specialColor; |
| 31 | + | |
| 32 | - | highLightAttributes[i] = specialColor | FOREGROUND_INTENSITY | BACKGROUND_INTENSITY; |
| 32 | + | |
| 33 | - | } |
| 33 | + | |
| 34 | - | } |
| 34 | + | // ... |
| 35 | } | |
| 36 | ||
| 37 | int main(int argc, char ** argv, char ** env){
| |
| 38 | niceText("I \03 C++", 0x07, 0x04);
| |
| 39 | return 0; | |
| 40 | } |