Rev 4377 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4377 | Rev 4692 | ||
---|---|---|---|
Line 26... | Line 26... | ||
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | #include <stdio.h> |
29 | #include <stdio.h> |
30 | #include <stdlib.h> |
30 | #include <stdlib.h> |
- | 31 | #include <io/console.h> |
|
- | 32 | #include <io/color.h> |
|
31 | #include <io/stream.h> |
33 | #include <io/style.h> |
- | 34 | #include <vfs/vfs.h> |
|
32 | #include <async.h> |
35 | #include <async.h> |
33 | #include "../tester.h" |
36 | #include "../tester.h" |
34 | 37 | ||
35 | #include <console.h> |
- | |
36 | - | ||
37 | const char *color_name[] = { |
38 | const char *color_name[] = { |
38 | [COLOR_BLACK] = "black", |
39 | [COLOR_BLACK] = "black", |
39 | [COLOR_BLUE] = "blue", |
40 | [COLOR_BLUE] = "blue", |
40 | [COLOR_GREEN] = "green", |
41 | [COLOR_GREEN] = "green", |
41 | [COLOR_CYAN] = "cyan", |
42 | [COLOR_CYAN] = "cyan", |
Line 43... | Line 44... | ||
43 | [COLOR_MAGENTA] = "magenta", |
44 | [COLOR_MAGENTA] = "magenta", |
44 | [COLOR_YELLOW] = "yellow", |
45 | [COLOR_YELLOW] = "yellow", |
45 | [COLOR_WHITE] = "white" |
46 | [COLOR_WHITE] = "white" |
46 | }; |
47 | }; |
47 | 48 | ||
48 | char * test_console1(bool quiet) |
49 | char *test_console1(void) |
49 | { |
50 | { |
50 | int i, j; |
51 | if (!test_quiet) { |
51 | - | ||
52 | printf("Style test: "); |
52 | printf("Style test: "); |
- | 53 | fflush(stdout); |
|
53 | console_set_style(STYLE_NORMAL); |
54 | console_set_style(fphone(stdout), STYLE_NORMAL); |
54 | printf("normal "); |
55 | printf("normal "); |
- | 56 | fflush(stdout); |
|
55 | console_set_style(STYLE_EMPHASIS); |
57 | console_set_style(fphone(stdout), STYLE_EMPHASIS); |
56 | printf("emphasized"); |
58 | printf("emphasized"); |
- | 59 | fflush(stdout); |
|
57 | console_set_style(STYLE_NORMAL); |
60 | console_set_style(fphone(stdout), STYLE_NORMAL); |
58 | printf(".\n"); |
61 | printf(".\n"); |
59 | 62 | ||
- | 63 | unsigned int i; |
|
- | 64 | unsigned int j; |
|
- | 65 | ||
60 | printf("Foreground color test:\n"); |
66 | printf("\nForeground color test:\n"); |
61 | for (j = 0; j < 2; j++) { |
67 | for (j = 0; j < 2; j++) { |
62 | for (i = COLOR_BLACK; i <= COLOR_WHITE; i++) { |
68 | for (i = COLOR_BLACK; i <= COLOR_WHITE; i++) { |
- | 69 | fflush(stdout); |
|
63 | console_set_color(i, COLOR_WHITE, |
70 | console_set_color(fphone(stdout), i, COLOR_WHITE, |
- | 71 | j ? CATTR_BRIGHT : 0); |
|
- | 72 | printf(" %s ", color_name[i]); |
|
- | 73 | } |
|
- | 74 | fflush(stdout); |
|
- | 75 | console_set_color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0); |
|
- | 76 | putchar('\n'); |
|
- | 77 | } |
|
- | 78 | ||
- | 79 | printf("\nBackground color test:\n"); |
|
- | 80 | for (j = 0; j < 2; j++) { |
|
- | 81 | for (i = COLOR_BLACK; i <= COLOR_WHITE; i++) { |
|
- | 82 | fflush(stdout); |
|
- | 83 | console_set_color(fphone(stdout), COLOR_WHITE, i, |
|
64 | j ? CATTR_BRIGHT : 0); |
84 | j ? CATTR_BRIGHT : 0); |
65 | printf(" %s ", color_name[i]); |
85 | printf(" %s ", color_name[i]); |
- | 86 | } |
|
- | 87 | fflush(stdout); |
|
- | 88 | console_set_color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0); |
|
- | 89 | putchar('\n'); |
|
- | 90 | } |
|
- | 91 | ||
- | 92 | printf("\nRGB colors test:\n"); |
|
- | 93 | ||
- | 94 | for (i = 0; i < 255; i += 16) { |
|
- | 95 | fflush(stdout); |
|
- | 96 | console_set_rgb_color(fphone(stdout), 0xffffff, i << 16); |
|
- | 97 | putchar('X'); |
|
66 | } |
98 | } |
- | 99 | fflush(stdout); |
|
67 | console_set_color(COLOR_BLACK, COLOR_WHITE, 0); |
100 | console_set_color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0); |
68 | putchar('\n'); |
101 | putchar('\n'); |
69 | } |
102 | |
70 | - | ||
71 | printf("Background color test:\n"); |
- | |
72 | for (j = 0; j < 2; j++) { |
103 | for (i = 0; i < 255; i += 16) { |
73 | for (i = COLOR_BLACK; i <= COLOR_WHITE; i++) { |
104 | fflush(stdout); |
74 | console_set_color(COLOR_WHITE, i, |
105 | console_set_rgb_color(fphone(stdout), 0xffffff, i << 8); |
75 | j ? CATTR_BRIGHT : 0); |
- | |
76 | printf(" %s ", color_name[i]); |
106 | putchar('X'); |
77 | } |
107 | } |
- | 108 | fflush(stdout); |
|
78 | console_set_color(COLOR_BLACK, COLOR_WHITE, 0); |
109 | console_set_color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0); |
- | 110 | putchar('\n'); |
|
- | 111 | ||
- | 112 | for (i = 0; i < 255; i += 16) { |
|
- | 113 | fflush(stdout); |
|
- | 114 | console_set_rgb_color(fphone(stdout), 0xffffff, i); |
|
- | 115 | putchar('X'); |
|
- | 116 | } |
|
- | 117 | fflush(stdout); |
|
- | 118 | console_set_color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0); |
|
79 | putchar('\n'); |
119 | putchar('\n'); |
80 | } |
120 | } |
81 | - | ||
82 | printf("Now let's test RGB colors:\n"); |
- | |
83 | - | ||
84 | for (i = 0; i < 255; i += 16) { |
- | |
85 | console_set_rgb_color(0xffffff, i << 16); |
- | |
86 | putchar('X'); |
- | |
87 | } |
121 | |
88 | console_set_color(COLOR_BLACK, COLOR_WHITE, 0); |
- | |
89 | putchar('\n'); |
- | |
90 | - | ||
91 | for (i = 0; i < 255; i += 16) { |
- | |
92 | console_set_rgb_color(0xffffff, i << 8); |
- | |
93 | putchar('X'); |
- | |
94 | } |
- | |
95 | console_set_color(COLOR_BLACK, COLOR_WHITE, 0); |
- | |
96 | putchar('\n'); |
- | |
97 | - | ||
98 | for (i = 0; i < 255; i += 16) { |
- | |
99 | console_set_rgb_color(0xffffff, i); |
- | |
100 | putchar('X'); |
- | |
101 | } |
- | |
102 | console_set_color(COLOR_BLACK, COLOR_WHITE, 0); |
- | |
103 | putchar('\n'); |
- | |
104 | - | ||
105 | printf("[press a key]\n"); |
- | |
106 | getchar(); |
- | |
107 | - | ||
108 | return NULL; |
122 | return NULL; |
109 | } |
123 | } |