Changeset fb69f39 in mainline
- Timestamp:
- 2009-01-01T19:47:54Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8b4d6cb
- Parents:
- 7122bc7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fb/serial_console.c
r7122bc7 rfb69f39 44 44 #include <bool.h> 45 45 #include <errno.h> 46 #include <console/color.h> 46 47 #include <console/style.h> 47 48 … … 49 50 50 51 #define MAX_CONTROL 20 52 53 static void serial_sgr(const unsigned int mode); 51 54 52 55 static int width; 53 56 static int height; 57 static bool color = true; /** True if producing color output. */ 54 58 static putc_function_t putc_function; 55 59 … … 57 61 static int client_connected = 0; 58 62 63 enum sgr_color_index { 64 CI_BLACK = 0, 65 CI_RED = 1, 66 CI_GREEN = 2, 67 CI_BROWN = 3, 68 CI_BLUE = 4, 69 CI_MAGENTA = 5, 70 CI_CYAN = 6, 71 CI_WHITE = 7, 72 }; 73 74 enum sgr_command { 75 SGR_RESET = 0, 76 SGR_BOLD = 1, 77 SGR_BLINK = 5, 78 SGR_REVERSE = 7, 79 SGR_NORMAL_INT = 22, 80 SGR_BLINK_OFF = 25, 81 SGR_REVERSE_OFF = 27, 82 SGR_FGCOLOR = 30, 83 SGR_BGCOLOR = 40 84 }; 85 86 static int color_map[] = { 87 [COLOR_BLACK] = CI_BLACK, 88 [COLOR_BLUE] = CI_RED, 89 [COLOR_GREEN] = CI_GREEN, 90 [COLOR_CYAN] = CI_CYAN, 91 [COLOR_RED] = CI_RED, 92 [COLOR_MAGENTA] = CI_MAGENTA, 93 [COLOR_YELLOW] = CI_BROWN, 94 [COLOR_WHITE] = CI_WHITE 95 }; 96 59 97 void serial_puts(char *str) 60 98 { … … 68 106 return; 69 107 70 char control[ 20];71 snprintf(control, 20, "\033[%u;%uf", row + 1, col + 1);108 char control[MAX_CONTROL]; 109 snprintf(control, MAX_CONTROL, "\033[%u;%uf", row + 1, col + 1); 72 110 serial_puts(control); 73 111 } … … 75 113 void serial_clrscr(void) 76 114 { 115 /* Initialize graphic rendition attributes. */ 116 serial_sgr(SGR_RESET); 117 if (color) { 118 serial_sgr(SGR_FGCOLOR + CI_BLACK); 119 serial_sgr(SGR_BGCOLOR + CI_WHITE); 120 } 121 77 122 serial_puts("\033[2J"); 78 123 } … … 191 236 case FB_SET_STYLE: 192 237 style = IPC_GET_ARG1(call); 193 if (style == STYLE_EMPHASIS) 194 serial_sgr(1); 195 else 196 serial_sgr(0); 238 if (style == STYLE_EMPHASIS) { 239 if (color) { 240 serial_sgr(SGR_RESET); 241 serial_sgr(SGR_FGCOLOR + CI_RED); 242 serial_sgr(SGR_BGCOLOR + CI_WHITE); 243 } 244 serial_sgr(SGR_BOLD); 245 } else { 246 if (color) { 247 serial_sgr(SGR_RESET); 248 serial_sgr(SGR_FGCOLOR + CI_BLACK); 249 serial_sgr(SGR_BGCOLOR + CI_WHITE); 250 } 251 serial_sgr(SGR_NORMAL_INT); 252 } 197 253 retval = 0; 198 254 break; … … 200 256 fgcolor = IPC_GET_ARG1(call); 201 257 bgcolor = IPC_GET_ARG2(call); 202 if (fgcolor < bgcolor) 203 serial_sgr(0); 204 else 205 serial_sgr(7); 258 259 if (color) { 260 serial_sgr(SGR_RESET); 261 serial_sgr(SGR_FGCOLOR + color_map[fgcolor]); 262 serial_sgr(SGR_BGCOLOR + color_map[bgcolor]); 263 } else { 264 if (fgcolor < bgcolor) 265 serial_sgr(SGR_RESET); 266 else 267 serial_sgr(SGR_REVERSE); 268 } 206 269 retval = 0; 207 270 break; … … 210 273 bgcolor = IPC_GET_ARG2(call); 211 274 if (fgcolor < bgcolor) 212 serial_sgr( 0);275 serial_sgr(SGR_REVERSE_OFF); 213 276 else 214 serial_sgr( 7);277 serial_sgr(SGR_REVERSE); 215 278 retval = 0; 216 279 break;
Note:
See TracChangeset
for help on using the changeset viewer.