diff font/text_stream.cc @ 38:658272d883ed

* Support (more or less) button style selects (fuuko's ones) * Strip text objects from strings (may support object text objects later)
author thib
date Tue, 17 Mar 2009 20:35:08 +0000
parents b753afeb3f34
children 15a18fbe6f21
line wrap: on
line diff
--- a/font/text_stream.cc
+++ b/font/text_stream.cc
@@ -90,6 +90,33 @@ void TextStream::Add(const char* str) {
 	TextElem elem;
 	for (; *str; str++) {
 		if (*str >= 0x20) {
+			if (*str == '#') { // Commands
+				str++;
+				char command = (*str)|32;
+				str++;
+				const char *tmp = str;
+				while (isdigit(*str)) {
+					str++;
+				}
+				char *args = new char[str+1-tmp];
+				strncpy(args, tmp, str-tmp);
+				args[str-tmp] = 0;
+				// Different commands:
+				switch(command) {
+					case 'c':
+						/*TODO: int r, g, b; char key[17];
+						sprintf(key, "#COLOR_TABLE.%03d", args);
+						if (config.GetParam(key, 3, &r, &g, &b)) { // color not found
+							r = g = b = 0;
+						}
+						elem.type = TextElem::color;
+						elem.impl.Color.r = r;
+						elem.impl.Color.g = g;
+						elem.impl.Color.b = b;*/
+						break;
+				}
+				delete[] args;
+			}
 			elem.type = TextElem::glyph;
 			elem.impl.Glyph.code = *str;
 		} else if (*str < 0 && str[1] != 0) {