Helper for the other parse_ methods.
| 140 | |
| 141 | // Helper for the other parse_ methods. |
| 142 | void formatted_string::parse_string1(const string &s, formatted_string &fs, |
| 143 | vector<int> &colour_stack, |
| 144 | vector<int> &bg_stack) |
| 145 | { |
| 146 | // FIXME: This is a lame mess, just good enough for the task on hand |
| 147 | // (keyboard help). |
| 148 | string::size_type tag = string::npos; |
| 149 | string::size_type length = s.length(); |
| 150 | |
| 151 | string currs; |
| 152 | |
| 153 | for (tag = 0; tag < length; ++tag) |
| 154 | { |
| 155 | bool revert_colour = false; |
| 156 | bool bg = false; |
| 157 | string::size_type endpos = string::npos; |
| 158 | |
| 159 | // Break string up if it gets too big. |
| 160 | // XX why is 999 "too big"??? |
| 161 | if (currs.size() >= 999) |
| 162 | { |
| 163 | // Break the string at the end of a line, if possible, so |
| 164 | // that none of the broken string ends up overwritten. |
| 165 | string::size_type bound = currs.rfind("\n", 999); |
| 166 | if (bound != endpos) |
| 167 | bound++; |
| 168 | else |
| 169 | bound = 999; |
| 170 | |
| 171 | fs.cprintf(currs.substr(0, bound)); |
| 172 | if (currs.size() > bound) |
| 173 | currs = currs.substr(bound); |
| 174 | else |
| 175 | currs.clear(); |
| 176 | tag--; |
| 177 | continue; |
| 178 | } |
| 179 | |
| 180 | if (s[tag] != '<' || tag >= length - 1) |
| 181 | { |
| 182 | currs += s[tag]; |
| 183 | continue; |
| 184 | } |
| 185 | |
| 186 | // Is this a << escape? |
| 187 | if (s[tag + 1] == '<') |
| 188 | { |
| 189 | currs += s[tag]; |
| 190 | tag++; |
| 191 | continue; |
| 192 | } |
| 193 | |
| 194 | // trying to parse a color tag below here |
| 195 | endpos = s.find('>', tag + 1); |
| 196 | // No closing >? |
| 197 | if (endpos == string::npos) |
| 198 | { |
| 199 | currs += s[tag]; |
nothing calls this directly
no test coverage detected