diff options
author | Neil Moore <neil@s-z.org> | 2011-12-15 17:38:38 -0500 |
---|---|---|
committer | Neil Moore <neil@s-z.org> | 2011-12-15 17:56:37 -0500 |
commit | afe45422f6408046e81f0b85cfbef748684b7345 (patch) | |
tree | 0c590cd4ded9b0c53724c0c99d8dc9eaf1b07137 /crawl-ref/source/process_desc.h | |
parent | 8b9a73b867c37c8872da89ba38d7cb0b9d4c72f3 (diff) | |
download | crawl-ref-afe45422f6408046e81f0b85cfbef748684b7345.tar.gz crawl-ref-afe45422f6408046e81f0b85cfbef748684b7345.zip |
Truncate descriptions rather than omitting them.
If it would not fit, print "..." instead of the last visible line; this
line might be overwritten by the toggle message (console), or might
push the toggle message off the screen (tiles).
This should really only happen in FULLDEBUG mode with small terminals.
Fixes #5055.
Diffstat (limited to 'crawl-ref/source/process_desc.h')
-rw-r--r-- | crawl-ref/source/process_desc.h | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/crawl-ref/source/process_desc.h b/crawl-ref/source/process_desc.h index 30bbcf519d..4d1043ae2f 100644 --- a/crawl-ref/source/process_desc.h +++ b/crawl-ref/source/process_desc.h @@ -33,22 +33,19 @@ inline void process_description(T &proc, const describe_info &inf) const int footer_lines = count_desc_lines(inf.footer, line_width) + (inf.footer.empty() ? 0 : 1); - // Maybe skip the body if body + title would be too many lines. if (inf.title.empty()) { desc = inf.body.str(); // There is a default 1 line addition for some reason. num_lines = body_lines + 1; } - else if (body_lines + num_lines + 2 <= height) + else { desc = inf.title + "\n\n"; desc += inf.body.str(); // Got 2 lines from the two \ns that weren't counted yet. num_lines += body_lines + 2; } - else - desc = inf.title + "\n"; // Prefer the footer over the suffix. if (num_lines + suffix_lines + footer_lines <= height) @@ -77,11 +74,25 @@ inline void process_description(T &proc, const describe_info &inf) } } + // Display as many lines as will fit. + int lineno = 0; while (!desc.empty()) { - proc.print(wordwrap_line(desc, line_width)); - if (!desc.empty()) - proc.nextline(); + const std::string line = wordwrap_line(desc, line_width); + + // If this is the bottom line of the display but not + // the last line of text, print an ellipsis instead. + if (++lineno < height || desc.empty()) + { + proc.print(line); + if (!desc.empty()) + proc.nextline(); + } + else + { + proc.print("..."); + break; + } } } |