console1.c

00001 /*
00002  * Copyright (c) 2008 Jiri Svoboda
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  * - Redistributions in binary form must reproduce the above copyright
00012  *   notice, this list of conditions and the following disclaimer in the
00013  *   documentation and/or other materials provided with the distribution.
00014  * - The name of the author may not be used to endorse or promote products
00015  *   derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00019  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00020  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00022  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00023  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00024  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 
00029 #include <stdio.h>
00030 #include <stdlib.h>
00031 #include <io/console.h>
00032 #include <io/color.h>
00033 #include <io/style.h>
00034 #include <vfs/vfs.h>
00035 #include <async.h>
00036 #include "../tester.h"
00037 
00038 static const char *color_name[] = {
00039         [COLOR_BLACK] = "black",
00040         [COLOR_BLUE] = "blue",
00041         [COLOR_GREEN] = "green",
00042         [COLOR_CYAN] = "cyan",
00043         [COLOR_RED] = "red",
00044         [COLOR_MAGENTA] = "magenta",
00045         [COLOR_YELLOW] = "yellow",
00046         [COLOR_WHITE] = "white"
00047 };
00048 
00049 const char *test_console1(void)
00050 {
00051         if (!test_quiet) {
00052                 printf("Style test: ");
00053                 fflush(stdout);
00054                 console_set_style(fphone(stdout), STYLE_NORMAL);
00055                 printf(" normal ");
00056                 fflush(stdout);
00057                 console_set_style(fphone(stdout), STYLE_EMPHASIS);
00058                 printf(" emphasized ");
00059                 fflush(stdout);
00060                 console_set_style(fphone(stdout), STYLE_INVERTED);
00061                 printf(" inverted ");
00062                 fflush(stdout);
00063                 console_set_style(fphone(stdout), STYLE_SELECTED);
00064                 printf(" selected ");
00065                 fflush(stdout);
00066                 console_set_style(fphone(stdout), STYLE_NORMAL);
00067                 printf("\n");
00068                 
00069                 unsigned int i;
00070                 unsigned int j;
00071                 
00072                 printf("\nForeground color test:\n");
00073                 for (j = 0; j < 2; j++) {
00074                         for (i = COLOR_BLACK; i <= COLOR_WHITE; i++) {
00075                                 fflush(stdout);
00076                                 console_set_color(fphone(stdout), i, COLOR_WHITE,
00077                                     j ? CATTR_BRIGHT : 0);
00078                                 printf(" %s ", color_name[i]);
00079                         }
00080                         fflush(stdout);
00081                         console_set_style(fphone(stdout), STYLE_NORMAL);
00082                         putchar('\n');
00083                 }
00084                 
00085                 printf("\nBackground color test:\n");
00086                 for (j = 0; j < 2; j++) {
00087                         for (i = COLOR_BLACK; i <= COLOR_WHITE; i++) {
00088                                 fflush(stdout);
00089                                 console_set_color(fphone(stdout), COLOR_WHITE, i,
00090                                     j ? CATTR_BRIGHT : 0);
00091                                 printf(" %s ", color_name[i]);
00092                         }
00093                         fflush(stdout);
00094                         console_set_style(fphone(stdout), STYLE_NORMAL);
00095                         putchar('\n');
00096                 }
00097                 
00098                 printf("\nRGB colors test:\n");
00099                 
00100                 for (i = 0; i < 255; i += 16) {
00101                         fflush(stdout);
00102                         console_set_rgb_color(fphone(stdout), (255 - i) << 16, i << 16);
00103                         putchar('X');
00104                 }
00105                 fflush(stdout);
00106                 console_set_color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0);
00107                 putchar('\n');
00108                 
00109                 for (i = 0; i < 255; i += 16) {
00110                         fflush(stdout);
00111                         console_set_rgb_color(fphone(stdout), (255 - i) << 8, i << 8);
00112                         putchar('X');
00113                 }
00114                 fflush(stdout);
00115                 console_set_color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0);
00116                 putchar('\n');
00117                 
00118                 for (i = 0; i < 255; i += 16) {
00119                         fflush(stdout);
00120                         console_set_rgb_color(fphone(stdout), 255 - i, i);
00121                         putchar('X');
00122                 }
00123                 fflush(stdout);
00124                 console_set_style(fphone(stdout), STYLE_NORMAL);
00125                 putchar('\n');
00126         }
00127         
00128         return NULL;
00129 }

Generated on Thu Jun 2 07:45:43 2011 for HelenOS/USB by  doxygen 1.4.7