Index: uspace/srv/hid/fb/serial_console.c
===================================================================
--- uspace/srv/hid/fb/serial_console.c	(revision 53e197fcf936bbd9cd02e201dd6207d617f86a4f)
+++ uspace/srv/hid/fb/serial_console.c	(revision 32e7411d91ec6dee974bc14d61061d3c3a0a8f7b)
@@ -84,9 +84,7 @@
 	SGR_RESET       = 0,
 	SGR_BOLD        = 1,
+	SGR_UNDERLINE   = 4,
 	SGR_BLINK       = 5,
 	SGR_REVERSE     = 7,
-	SGR_NORMAL_INT  = 22,
-	SGR_BLINK_OFF   = 25,
-	SGR_REVERSE_OFF = 27,
 	SGR_FGCOLOR     = 30,
 	SGR_BGCOLOR     = 40
@@ -153,6 +151,6 @@
 	switch (style) {
 	case STYLE_EMPHASIS:
+		serial_sgr(SGR_RESET);
 		if (color) {
-			serial_sgr(SGR_RESET);
 			serial_sgr(SGR_FGCOLOR + CI_RED);
 			serial_sgr(SGR_BGCOLOR + CI_WHITE);
@@ -161,30 +159,25 @@
 		break;
 	case STYLE_INVERTED:
+		serial_sgr(SGR_RESET);
 		if (color) {
-			serial_sgr(SGR_RESET);
 			serial_sgr(SGR_FGCOLOR + CI_WHITE);
 			serial_sgr(SGR_BGCOLOR + CI_BLACK);
-			serial_sgr(SGR_NORMAL_INT);
 		} else
 			serial_sgr(SGR_REVERSE);
 		break;
 	case STYLE_SELECTED:
+		serial_sgr(SGR_RESET);
 		if (color) {
-			serial_sgr(SGR_RESET);
 			serial_sgr(SGR_FGCOLOR + CI_WHITE);
 			serial_sgr(SGR_BGCOLOR + CI_RED);
-			serial_sgr(SGR_NORMAL_INT);
-		} else {
-			serial_sgr(SGR_BOLD);
-			serial_sgr(SGR_REVERSE);
-		}
+		} else
+			serial_sgr(SGR_UNDERLINE);
 		break;
 	default:
+		serial_sgr(SGR_RESET);
 		if (color) {
-			serial_sgr(SGR_RESET);
 			serial_sgr(SGR_FGCOLOR + CI_BLACK);
 			serial_sgr(SGR_BGCOLOR + CI_WHITE);
 		}
-		serial_sgr(SGR_NORMAL_INT);
 	}
 }
@@ -193,14 +186,14 @@
     uint8_t flags)
 {
+	serial_sgr(SGR_RESET);
 	if (color) {
-		serial_sgr(SGR_RESET);
-		serial_sgr(SGR_FGCOLOR + color_map[fgcolor]);
-		serial_sgr(SGR_BGCOLOR + color_map[bgcolor]);
+		serial_sgr(SGR_FGCOLOR + color_map[fgcolor & 7]);
+		serial_sgr(SGR_BGCOLOR + color_map[bgcolor & 7]);
+		if (flags & CATTR_BRIGHT)
+			serial_sgr(SGR_BOLD);
 	} else {
-		if (fgcolor < bgcolor)
-			serial_sgr(SGR_RESET);
-		else
+		if (fgcolor >= bgcolor)
 			serial_sgr(SGR_REVERSE);
-	}	
+	}
 }
 
@@ -209,7 +202,5 @@
 	serial_sgr(SGR_RESET);
 	
-	if (fgcolor < bgcolor)
-		serial_sgr(SGR_REVERSE_OFF);
-	else
+	if (fgcolor >= bgcolor)
 		serial_sgr(SGR_REVERSE);
 }
@@ -283,38 +274,34 @@
 }
 
-
-
 /** Draw text data to viewport.
  *
- * @param vport Viewport id
- * @param data  Text data.
- * @param x     Leftmost column of the area.
- * @param y     Topmost row of the area.
- * @param w     Number of rows.
- * @param h     Number of columns.
+ * @param vport  Viewport id
+ * @param data   Text data.
+ * @param x0     Leftmost column of the area.
+ * @param y0     Topmost row of the area.
+ * @param width  Number of rows.
+ * @param height Number of columns.
  *
  */
-static void draw_text_data(keyfield_t *data, ipcarg_t x, ipcarg_t y,
-    ipcarg_t w, ipcarg_t h)
-{
-	serial_goto(x, y);
-	ipcarg_t i;
-	ipcarg_t j;
-	
+static void draw_text_data(keyfield_t *data, ipcarg_t x0, ipcarg_t y0,
+    ipcarg_t width, ipcarg_t height)
+{
 	attrs_t *a0 = &data[0].attrs;
-	
-	for (j = 0; j < h; j++) {
-		if ((j > 0) && (w != scr_width))
-			serial_goto(x, j);
+	serial_set_attrs(a0);
+	
+	ipcarg_t y;
+	for (y = 0; y < height; y++) {
+		serial_goto(x0, y0 + y);
 		
-		for (i = 0; i < w; i++) {
-			attrs_t *a1 = &data[j * w + i].attrs;
-			
-			if (!attrs_same(*a0, *a1)) {
-				serial_set_attrs(a1);
-				a0 = a1;
+		ipcarg_t x;
+		for (x = 0; x < width; x++) {
+			attrs_t *attr = &data[y * width + x].attrs;
+			
+			if (!attrs_same(*a0, *attr)) {
+				serial_set_attrs(attr);
+				a0 = attr;
 			}
 			
-			serial_putchar(data[j * w + i].character);
+			serial_putchar(data[y * width + x].character);
 		}
 	}
