diff options
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/menu.cc | 28 | ||||
-rw-r--r-- | crawl-ref/source/menu.h | 3 |
2 files changed, 24 insertions, 7 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]); diff --git a/crawl-ref/source/menu.h b/crawl-ref/source/menu.h index 88c1d00d0d..de060b354f 100644 --- a/crawl-ref/source/menu.h +++ b/crawl-ref/source/menu.h @@ -273,7 +273,8 @@ protected: int last_selected; protected: - void check_add_formatted_line(int col, std::string &line, bool check_eol); + void check_add_formatted_line(int firstcol, int nextcol, + std::string &line, bool check_eol); void do_menu(); virtual void draw_select_count(int count, bool force = false); virtual void draw_item( int index ) const; |