* Take a string and turn it into a formatted_string. * * @param s The input string: e.g. " foo ". * @param main_colour The initial & default text colour. * @return A formatted string corresponding to the input. */
| 76 | * @return A formatted string corresponding to the input. |
| 77 | */ |
| 78 | formatted_string formatted_string::parse_string(const string &s, |
| 79 | int main_colour) |
| 80 | { |
| 81 | // main_colour will usually be LIGHTGREY (default). |
| 82 | vector<int> colour_stack(1, main_colour); |
| 83 | // background will not change anything by default |
| 84 | vector<int> bg_stack(1, BLACK); |
| 85 | |
| 86 | formatted_string fs; |
| 87 | |
| 88 | parse_string1(s, fs, colour_stack, bg_stack); |
| 89 | if (colour_stack.back() != colour_stack.front()) |
| 90 | fs.textcolour(colour_stack.front()); // XXX: this does nothing |
| 91 | // if the bg colours are unbalanced, reset to black |
| 92 | if (bg_stack.back() != bg_stack.front()) |
| 93 | fs.textbackground(bg_stack.back()); |
| 94 | return fs; |
| 95 | } |
| 96 | |
| 97 | // Parses a formatted string in much the same way as parse_string, but |
| 98 | // handles \n by creating a new formatted_string. |
nothing calls this directly
no test coverage detected