instead of a string. See example in StashSearchMenu::draw_title. If you want everything in cyan, you might want to figure out who sets the StashSearchMenu's title->color and change that, too.
Added formatted_string::substr(). Lightly tested, seems to work fine.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4091 c06c8d41-db1a-0410-9941-cceddc491573
3NUVKRHPHENI7JNHDDIHZ4FESSZ2Z5XJZVB56ZCXPGMP7O3JCM3QC bool Menu::draw_title_suffix( const formatted_string &fs, bool titlefirst ){int oldx = wherex(), oldy = wherey();if (titlefirst)draw_title();int x = wherex();if (x > get_number_of_cols() || x < 1){cgotoxy(oldx, oldy);return false;}// Note: 1 <= x <= get_number_of_cols(); we have no fear of overflow.const unsigned int avail_width = get_number_of_cols() - x + 1;const unsigned int fs_length = fs.length();if (fs_length > avail_width){formatted_string fs_trunc = fs.substr(0, avail_width);fs_trunc.display();}else{fs.display();if (fs_length < avail_width){char fmt[20];sprintf(fmt, "%%%ds", avail_width-fs_length);cprintf(fmt, " ");}}cgotoxy( oldx, oldy );return true;}
}formatted_string formatted_string::substr(size_t start, size_t substr_length) const{const unsigned int NONE = (unsigned int)-1;unsigned int last_FSOP_COLOUR = NONE;unsigned int last_FSOP_CURSOR = NONE;// Find the first string to copyunsigned int i;for (i=0; i<ops.size(); ++i){const fs_op& op = ops[i];if (op.type == FSOP_COLOUR)last_FSOP_CURSOR = i;else if (op.type == FSOP_CURSOR)last_FSOP_CURSOR = i;else if (op.type == FSOP_TEXT)if (op.text.length() > start)break;elsestart -= op.text.length();}if (i == ops.size())return formatted_string();formatted_string result;// set up the stateif (last_FSOP_COLOUR != NONE)result.ops.push_back(ops[last_FSOP_COLOUR]);if (last_FSOP_CURSOR != NONE)result.ops.push_back(ops[last_FSOP_CURSOR]);// Copy the textfor ( ; i<ops.size(); i++){const fs_op& op = ops[i];if (op.type == FSOP_TEXT){result.ops.push_back(op);std::string& new_string = result.ops[result.ops.size()-1].text;if (start > 0 || op.text.length() > substr_length)new_string = new_string.substr(start, substr_length);substr_length -= new_string.length();if (substr_length == 0)break;}else{result.ops.push_back(op);}}return result;