summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/format.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-03-20 16:54:00 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-03-20 16:54:00 +0000
commitd04f647d2a64423af89b497c4daab8b452e7bf1c (patch)
treeef6202b2386fdcacdd4a16015ad2c383815c8ff2 /crawl-ref/source/format.cc
parent3548833cfbab7a46fe339542183fa65f276ea167 (diff)
downloadcrawl-ref-d04f647d2a64423af89b497c4daab8b452e7bf1c.tar.gz
crawl-ref-d04f647d2a64423af89b497c4daab8b452e7bf1c.zip
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
Diffstat (limited to 'crawl-ref/source/format.cc')
-rw-r--r--crawl-ref/source/format.cc27
1 files changed, 25 insertions, 2 deletions
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<std::string> 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())