| 340 | } |
| 341 | |
| 342 | std::string capitalize_string_words(const std::string& str) |
| 343 | { // Cleaned up from g_src/basics.cpp, and returns new string |
| 344 | std::string out = str; |
| 345 | bool starting = true; |
| 346 | int32_t bracket_count = 0; |
| 347 | bool conf; |
| 348 | |
| 349 | for (size_t s = 0; s < out.length(); s++) |
| 350 | { |
| 351 | if (out[s] == '[') { ++bracket_count; continue; } |
| 352 | else if (out[s] == ']') { --bracket_count; continue; } |
| 353 | else if (bracket_count > 0) continue; |
| 354 | |
| 355 | conf = false; |
| 356 | if (!starting) |
| 357 | { |
| 358 | if (out[s - 1] == ' ' || out[s - 1] == '\"') |
| 359 | conf = true; |
| 360 | // Discount single quote if it isn't preceded by space, comma, or nothing |
| 361 | else if (out[s - 1] == '\'' && s >= 2 && (out[s - 2] == ' ' || out[s - 2] == ',')) |
| 362 | conf = true; |
| 363 | } |
| 364 | |
| 365 | if (starting || conf) |
| 366 | { // Capitalize |
| 367 | out[s] = toupper_cp437(out[s]); |
| 368 | starting = false; |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | return out; |
| 373 | } |
| 374 | |
| 375 | bool word_wrap(std::vector<std::string> *out, const std::string &str, size_t line_length, |
| 376 | word_wrap_whitespace_mode mode) |
no test coverage detected