Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/console.cc54
1 files changed, 45 insertions, 9 deletions
diff --git a/src/client/console.cc b/src/client/console.cc
index fae402c..914d32f 100644
--- a/src/client/console.cc
+++ b/src/client/console.cc
@@ -171,17 +171,52 @@ void draw()
std::deque<std::string> lines;
for (std::deque<std::string>::iterator it = text.begin(); it != text.end() && current_line < bottom; it++) {
if (current_line >= bottom - height) {
- std::string line(*it);
- line.erase(0,2);
-
- while (line.size() > width) {
- lines.push_back(line.substr(0, width));
- line.erase(0, width);
+ std::string linedata(*it);
+ linedata += '\n';
+
+ std::string word;
+ std::string line;
+ const char *c = linedata.c_str();
+
+ while (*c) {
+ // new word, wrap if necessary
+ if ((*c == '\n' ) || ( *c == ' ')) {
+
+ if (line.size() + word.size() > width) {
+ if (line.size()) {
+ lines.push_back(line);
+ line.clear();
+ }
+ }
+
+ line.append(word);
+ word.clear();
+
+ // force break words longer than width
+ while (line.size() > width) {
+ lines.push_back(line.substr(0, width));
+ line.erase(0, width);
+ }
+
+ // new line
+ if (*c == '\n' ) {
+ lines.push_back(line);
+ line.clear();
+ // new word
+ } else if (*c == ' ' ) {
+ line += ' ';
+ }
+ // new character
+ } else {
+
+ word += *c;
+ }
+
+ c++;
}
- if (line.size())
- lines.push_back(line);
+
}
- current_line++;
+ current_line++;
}
float y = video::height*con_height-2*Text::fontheight()-4;
@@ -387,6 +422,7 @@ void Console::flush()
{
console::flush();
}
+
std::ostream & Console::messagestream()
{
return (buffer << ". ");