From d04f647d2a64423af89b497c4daab8b452e7bf1c Mon Sep 17 00:00:00 2001 From: dshaligram Date: Tue, 20 Mar 2007 16:54:00 +0000 Subject: Tutorial tweaks: * Fixed status display commentary wiping out the status display on curses. * Fixed doubled %% on Unix (a plague on whoever wrote cprintf() in libw32c.cc). * Fixed reference to get_number_of_cols() before curses initialisation. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1073 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/format.cc | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'crawl-ref/source/format.cc') diff --git a/crawl-ref/source/format.cc b/crawl-ref/source/format.cc index 3de867c8ee..d8942e5d08 100644 --- a/crawl-ref/source/format.cc +++ b/crawl-ref/source/format.cc @@ -31,6 +31,29 @@ int formatted_string::get_colour(const std::string &tag) return (colour != -1? colour : LIGHTGREY); } +formatted_string formatted_string::parse_block( + const std::string &s, + bool eol_ends_format, + bool (*process)(const std::string &tag)) +{ + std::vector lines = split_string("\n", s, false, true); + + formatted_string fs; + for (int i = 0, size = lines.size(); i < size; ++i) + { + if (i) + { + // Artificial newline - some terms erase to eol when printing a + // newline. + fs.gotoxy(1, -1); // CR + fs.movexy(0, 1); // LF + } + fs += parse_string(lines[i], eol_ends_format, process); + } + + return (fs); +} + formatted_string formatted_string::parse_string( const std::string &s, bool eol_ends_format, @@ -103,12 +126,12 @@ formatted_string formatted_string::parse_string( } const int new_colour = invert_colour? LIGHTGREY : get_colour(tagtext); - if (new_colour != curr_colour) + if (!currs.empty()) { fs.cprintf(currs); currs.clear(); - fs.textcolor( curr_colour = new_colour ); } + fs.textcolor( curr_colour = new_colour ); tag += tagtext.length() + 1; } if (currs.length()) -- cgit v1.2.3-54-g00ecf