summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/menu.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-01-25 11:45:39 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-01-25 11:45:39 +0000
commit46f47615625e1a81d15df96d4ccfe5ac6f697888 (patch)
tree0456ce60f740205d4dd8906c929b7d2540697339 /crawl-ref/source/menu.cc
parent137d900672cf15df2d5f3cf5988aff20d33620f7 (diff)
downloadcrawl-ref-46f47615625e1a81d15df96d4ccfe5ac6f697888.tar.gz
crawl-ref-46f47615625e1a81d15df96d4ccfe5ac6f697888.zip
Fixed mutation menu miscolouring mutations.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3332 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/menu.cc')
-rw-r--r--crawl-ref/source/menu.cc28
1 files changed, 22 insertions, 6 deletions
diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc
index 81a16be254..58a3b1d450 100644
--- a/crawl-ref/source/menu.cc
+++ b/crawl-ref/source/menu.cc
@@ -51,19 +51,35 @@ Menu::Menu( const formatted_string &fs )
colour = op.x;
break;
case FSOP_TEXT:
+ {
line += op.text;
- if (op.text.find_first_not_of(" \t\r\n") != std::string::npos)
+
+ const std::string::size_type nonblankp =
+ op.text.find_first_not_of(" \t\r\n");
+ const bool nonblank = nonblankp != std::string::npos;
+ const std::string::size_type eolp = op.text.find(EOL);
+ const bool starts_with_eol =
+ nonblank && eolp != std::string::npos
+ && eolp < nonblankp;
+
+ if (nonblank && !starts_with_eol)
+ last_text_colour = colour;
+
+ check_add_formatted_line(last_text_colour, colour, line, true);
+
+ if (nonblank && starts_with_eol)
last_text_colour = colour;
- check_add_formatted_line(last_text_colour, line, true);
break;
+ }
default:
break;
}
}
- check_add_formatted_line(colour, line, false);
+ check_add_formatted_line(last_text_colour, colour, line, false);
}
-void Menu::check_add_formatted_line(int col, std::string &line, bool check_eol)
+void Menu::check_add_formatted_line(int firstcol, int nextcol,
+ std::string &line, bool check_eol)
{
if (line.empty())
return;
@@ -81,8 +97,8 @@ void Menu::check_add_formatted_line(int col, std::string &line, bool check_eol)
line = lines[--size];
else
line.clear();
-
- for (int i = 0; i < size; ++i)
+
+ for (int i = 0, col = firstcol; i < size; ++i, col = nextcol)
{
std::string &s(lines[i]);