Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)

Sat, 16 Mar 2013 00:05:39 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Sat, 16 Mar 2013 00:05:39 +0200
changeset 11
323390a03294
parent 10
5b0579997e9b
child 12
8f6de46a27e2

Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)

gui.cpp file | annotate | diff | comparison | revisions
io.cpp file | annotate | diff | comparison | revisions
ldtypes.cpp file | annotate | diff | comparison | revisions
ldtypes.h file | annotate | diff | comparison | revisions
--- a/gui.cpp	Fri Mar 15 22:27:38 2013 +0200
+++ b/gui.cpp	Sat Mar 16 00:05:39 2013 +0200
@@ -374,9 +374,14 @@
 			QStringList (zText.chars()), 0);
 		item->setIcon (0, IconForObjectType (obj));
 		
+		// Color gibberish red
+		if (obj->getType() == OBJ_Gibberish) {
+			item->setBackgroundColor (0, "#AA0000");
+			item->setForeground (0, QColor ("#FFAA00"));
+		}
+		
 		qaItems.append (item);
 	}
 	
-	printf ("insert top level items\n");
 	qObjList->insertTopLevelItems (0, qaItems);
 }
\ No newline at end of file
--- a/io.cpp	Fri Mar 15 22:27:38 2013 +0200
+++ b/io.cpp	Sat Mar 16 00:05:39 2013 +0200
@@ -88,6 +88,9 @@
 	char c = zLine[0];
 	vector<str> tokens = zLine / " ";
 	
+	if (~tokens[0] != 1)
+		return new LDGibberish (zLine, "Illogical line code");
+	
 	switch (c - '0') {
 	case 0:
 		{
@@ -162,9 +165,7 @@
 	default:
 		{
 			// Strange line we couldn't parse
-			LDGibberish* obj = new LDGibberish;
-			obj->zContent = zLine;
-			return obj;
+			return new LDGibberish (zLine, "Unknown line code number");
 		}
 	}
 }
\ No newline at end of file
--- a/ldtypes.cpp	Fri Mar 15 22:27:38 2013 +0200
+++ b/ldtypes.cpp	Sat Mar 16 00:05:39 2013 +0200
@@ -25,6 +25,11 @@
 	
 }
 
+LDGibberish::LDGibberish (str _zContent, str _zReason) {
+	zContent = _zContent;
+	zReason = _zReason;
+}
+
 LDEmpty::LDEmpty () {
 	
 }
--- a/ldtypes.h	Fri Mar 15 22:27:38 2013 +0200
+++ b/ldtypes.h	Sat Mar 16 00:05:39 2013 +0200
@@ -58,8 +58,13 @@
 public:
 	IMPLEMENT_LDTYPE (Gibberish)
 	
+	LDGibberish (str _zContent, str _zReason);
+	
 	// Content of this unknown line
 	str zContent;
+	
+	// Why is this gibberish?
+	str zReason;
 };
 
 // =============================================================================

mercurial