oga's tools
修订版 | 510732185c8683e888498366ccefa57c48a1abb5 (tree) |
---|---|
时间 | 2014-02-11 16:09:09 |
作者 | oga <oga@mxg....> |
Commiter | oga |
color change command
@@ -0,0 +1,55 @@ | ||
1 | +#include <windows.h> | |
2 | +#include <stdio.h> | |
3 | + | |
4 | +#if 0 | |
5 | +#define FOREGROUND_BLUE 0x0001 // text color contains blue. | |
6 | +#define FOREGROUND_GREEN 0x0002 // text color contains green. | |
7 | +#define FOREGROUND_RED 0x0004 // text color contains red. | |
8 | +#define FOREGROUND_INTENSITY 0x0008 // text color is intensified. | |
9 | +#define BACKGROUND_BLUE 0x0010 // background color contains blue. | |
10 | +#define BACKGROUND_GREEN 0x0020 // background color contains green. | |
11 | +#define BACKGROUND_RED 0x0040 // background color contains red. | |
12 | +#define BACKGROUND_INTENSITY 0x0080 // background color is intensified. | |
13 | +#define COMMON_LVB_LEADING_BYTE 0x0100 // Leading Byte of DBCS | |
14 | +#define COMMON_LVB_TRAILING_BYTE 0x0200 // Trailing Byte of DBCS | |
15 | +#define COMMON_LVB_GRID_HORIZONTAL 0x0400 // DBCS: Grid attribute: top horizontal. | |
16 | +#define COMMON_LVB_GRID_LVERTICAL 0x0800 // DBCS: Grid attribute: left vertical. | |
17 | +#define COMMON_LVB_GRID_RVERTICAL 0x1000 // DBCS: Grid attribute: right vertical. | |
18 | +#define COMMON_LVB_REVERSE_VIDEO 0x4000 // DBCS: Reverse fore/back ground attribute. | |
19 | +#define COMMON_LVB_UNDERSCORE 0x8000 // DBCS: Underscore. | |
20 | + | |
21 | +#define COMMON_LVB_SBCSDBCS 0x0300 // SBCS or DBCS flag. | |
22 | +#endif | |
23 | + | |
24 | + | |
25 | +int main(int a, char *b[]) | |
26 | +{ | |
27 | + int i; | |
28 | + WORD color = 7; /* white */ | |
29 | + | |
30 | + for (i = 1; i < a; i++) { | |
31 | + if (!strcmp(b[i], "-h")) { | |
32 | + printf("usage: color <color_code>\n"); | |
33 | + printf(" FG_BLUE : 0x0001\n"); | |
34 | + printf(" FG_GREEN: 0x0002\n"); | |
35 | + printf(" FG_RED : 0x0004\n"); | |
36 | + printf(" FG_INT : 0x0008 blightness\n"); | |
37 | + printf(" BG_BLUE : 0x0010\n"); | |
38 | + printf(" BG_GREEN: 0x0020\n"); | |
39 | + printf(" BG_RED : 0x0040\n"); | |
40 | + printf(" BG_INT : 0x0080 blightness\n"); | |
41 | + return 1; | |
42 | + } | |
43 | + color = atoi(b[i]); | |
44 | + } | |
45 | + | |
46 | + //SetConsoleTextAttribute( | |
47 | + // GetStdHandle(STD_OUTPUT_HANDLE), | |
48 | + // FOREGROUND_INTENSITY | FOREGROUND_RED | BACKGROUND_GREEN); | |
49 | + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color); | |
50 | + | |
51 | + //printf("Hello, World!\n"); | |
52 | + | |
53 | + return 0; | |
54 | +} | |
55 | + |