summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/format.cc
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2010-03-11 10:40:17 +0100
committerRobert Vollmert <rvollmert@gmx.net>2010-03-11 11:09:40 +0100
commitae14e36f579438fb335b1536b89290cd15690b0e (patch)
tree16556beac9a541432f15e9ba496c4b743cf2ff5f /crawl-ref/source/format.cc
parent25d77ffbc1ef9aa55cf4c8f7424bb2746ebfeacd (diff)
downloadcrawl-ref-ae14e36f579438fb335b1536b89290cd15690b0e.tar.gz
crawl-ref-ae14e36f579438fb335b1536b89290cd15690b0e.zip
Replace formatted_string::parse_block by display_tagged_block.
The latter invokes parse_string_to_multiple and displays directly. This fixes line wrapping issues with full lines: on an 80 column terminal, an 80 character line could cause the cursor to wrap to the next line, causing extra blank lines due to the manual line feed in formatted_string::parse_block.
Diffstat (limited to 'crawl-ref/source/format.cc')
-rw-r--r--crawl-ref/source/format.cc44
1 files changed, 9 insertions, 35 deletions
diff --git a/crawl-ref/source/format.cc b/crawl-ref/source/format.cc
index 9c1e02cf81..3096eac0dc 100644
--- a/crawl-ref/source/format.cc
+++ b/crawl-ref/source/format.cc
@@ -40,48 +40,22 @@ int formatted_string::get_colour(const std::string &tag)
return (colour != -1? colour : LIGHTGREY);
}
-// Parses a formatted string in much the same way as parse_string, but
-// handles EOL by moving the cursor down to the next line instead of
-// using a literal EOL. This is important if the text is not supposed
+// Display a formatted string without printing literal EOL.
+// This is important if the text is not supposed
// to clobber existing text to the right of the lines being displayed
// (some of the tutorial messages need this).
-//
-// If eot_ends_format, the end of text will reset the color to default
-// (pop all elements on the color stack) -- this is only useful if the
-// string doesn't have balanced <color></color> tags.
-//
-formatted_string formatted_string::parse_block(
- const std::string &s,
- bool eot_ends_format,
- bool (*process)(const std::string &tag))
+void display_tagged_block(const std::string &s)
{
- // Safe assumption, that incoming color is LIGHTGREY
- std::vector<int> colour_stack;
- colour_stack.push_back(LIGHTGREY);
-
- std::vector<std::string> lines = split_string("\n", s, false, true);
-
- formatted_string fs;
+ std::vector<formatted_string> lines;
+ formatted_string::parse_string_to_multiple(s, lines);
for (int i = 0, size = lines.size(); i < size; ++i)
{
- if (i)
- {
- // Artificial newline - some terms erase to eol when printing a
- // newline.
- fs.cgotoxy(1, -1); // CR
- fs.movexy(0, 1); // LF
- }
- parse_string1(lines[i], fs, colour_stack, process);
+ int x = wherex();
+ int y = wherey();
+ lines[i].display();
+ cgotoxy(x, y+1);
}
-
- if (eot_ends_format)
- {
- if (colour_stack.back() != colour_stack.front())
- fs.textcolor(colour_stack.front());
- }
-
- return (fs);
}
formatted_string formatted_string::parse_string(