comparison 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
comparison
equal deleted inserted replaced
37:f88d47a4bf87 38:658272d883ed
88 } 88 }
89 void TextStream::Add(const char* str) { 89 void TextStream::Add(const char* str) {
90 TextElem elem; 90 TextElem elem;
91 for (; *str; str++) { 91 for (; *str; str++) {
92 if (*str >= 0x20) { 92 if (*str >= 0x20) {
93 if (*str == '#') { // Commands
94 str++;
95 char command = (*str)|32;
96 str++;
97 const char *tmp = str;
98 while (isdigit(*str)) {
99 str++;
100 }
101 char *args = new char[str+1-tmp];
102 strncpy(args, tmp, str-tmp);
103 args[str-tmp] = 0;
104 // Different commands:
105 switch(command) {
106 case 'c':
107 /*TODO: int r, g, b; char key[17];
108 sprintf(key, "#COLOR_TABLE.%03d", args);
109 if (config.GetParam(key, 3, &r, &g, &b)) { // color not found
110 r = g = b = 0;
111 }
112 elem.type = TextElem::color;
113 elem.impl.Color.r = r;
114 elem.impl.Color.g = g;
115 elem.impl.Color.b = b;*/
116 break;
117 }
118 delete[] args;
119 }
93 elem.type = TextElem::glyph; 120 elem.type = TextElem::glyph;
94 elem.impl.Glyph.code = *str; 121 elem.impl.Glyph.code = *str;
95 } else if (*str < 0 && str[1] != 0) { 122 } else if (*str < 0 && str[1] != 0) {
96 elem.type = TextElem::glyph; 123 elem.type = TextElem::glyph;
97 elem.impl.Glyph.code = ((int(*(unsigned char*)str))<<8) | int(*(unsigned char*)(str+1)); 124 elem.impl.Glyph.code = ((int(*(unsigned char*)str))<<8) | int(*(unsigned char*)(str+1));