sources/interface.cpp

changeset 100
d301ead29d7c
parent 96
5314ebdcb38d
child 101
71f1cd8154a9
--- a/sources/interface.cpp	Fri Jul 24 00:43:16 2015 +0300
+++ b/sources/interface.cpp	Fri Jul 24 04:24:38 2015 +0300
@@ -260,7 +260,7 @@
 {
 	int x = x0;
 
-	for (int i = 0; i < line.length(); ++i)
+	for (int i = 0; i < line.data().size(); ++i)
 	{
 		int byte = line.data()[i];
 
@@ -273,35 +273,13 @@
 			++y;
 		}
 
-		if (isprint (byte))
+		if (byte < 256 && isprint (byte))
 		{
 			mvaddch (y, x, char (byte));
 			++x;
 		}
 		else switch (byte)
 		{
-		case RLINE_ON_BLACK:
-		case RLINE_ON_RED:
-		case RLINE_ON_GREEN:
-		case RLINE_ON_YELLOW:
-		case RLINE_ON_BLUE:
-		case RLINE_ON_MAGENTA:
-		case RLINE_ON_CYAN:
-		case RLINE_ON_WHITE:
-			attron (color_pair (Color (byte - RLINE_ON_BLACK), DEFAULT));
-			break;
-
-		case RLINE_OFF_BLACK:
-		case RLINE_OFF_RED:
-		case RLINE_OFF_GREEN:
-		case RLINE_OFF_YELLOW:
-		case RLINE_OFF_BLUE:
-		case RLINE_OFF_MAGENTA:
-		case RLINE_OFF_CYAN:
-		case RLINE_OFF_WHITE:
-			attroff (color_pair (Color (byte - RLINE_OFF_BLACK), DEFAULT));
-			break;
-
 		case RLINE_ON_BOLD:
 			attron (A_BOLD);
 			break;
@@ -309,6 +287,13 @@
 		case RLINE_OFF_BOLD:
 			attroff (A_BOLD);
 			break;
+
+		default:
+			if (byte < 256)
+				break;
+
+			(byte < RLINE_OFF_COLOR ? attron : attroff) (color_pair (Color ((byte - RLINE_ON_COLOR) & 7), DEFAULT));
+			break;
 		}
 	}
 

mercurial