[Orxonox-commit 1657] r6375 - in code/branches/presentation2/src: libraries/core orxonox/overlays
rgrieder at orxonox.net
rgrieder at orxonox.net
Fri Dec 18 00:11:16 CET 2009
Author: rgrieder
Date: 2009-12-18 00:11:16 +0100 (Fri, 18 Dec 2009)
New Revision: 6375
Modified:
code/branches/presentation2/src/libraries/core/IOConsole.cc
code/branches/presentation2/src/libraries/core/Shell.cc
code/branches/presentation2/src/libraries/core/Shell.h
code/branches/presentation2/src/orxonox/overlays/InGameConsole.cc
Log:
Fixed a problem with output being written directly to the Shell.
Use Shell::addOutput instead of Shell:addOutputLine now and include a new line if you want to print a whole line.
Modified: code/branches/presentation2/src/libraries/core/IOConsole.cc
===================================================================
--- code/branches/presentation2/src/libraries/core/IOConsole.cc 2009-12-17 22:49:25 UTC (rev 6374)
+++ code/branches/presentation2/src/libraries/core/IOConsole.cc 2009-12-17 23:11:16 UTC (rev 6375)
@@ -59,7 +59,7 @@
//! Called if a command is about to be executed
void IOConsole::executed()
{
- this->shell_->addOutputLine(this->promptString_ + this->shell_->getInput(), Shell::Command);
+ this->shell_->addOutput(this->promptString_ + this->shell_->getInput() + '\n', Shell::Command);
}
//! Called if the console gets closed
@@ -508,7 +508,7 @@
// Process output written to std::cout in the meantime
std::cout.flush();
if (!this->origCout_.str().empty())
- this->shell_->addOutputLine(this->origCout_.str(), Shell::None);
+ this->shell_->addOutput(this->origCout_.str(), Shell::None);
this->shell_->unregisterListener(this);
@@ -601,7 +601,7 @@
std::cout.flush();
if (!this->origCout_.str().empty())
{
- this->shell_->addOutputLine(this->origCout_.str(), Shell::None);
+ this->shell_->addOutput(this->origCout_.str(), Shell::None);
this->origCout_.str("");
}
}
Modified: code/branches/presentation2/src/libraries/core/Shell.cc
===================================================================
--- code/branches/presentation2/src/libraries/core/Shell.cc 2009-12-17 22:49:25 UTC (rev 6374)
+++ code/branches/presentation2/src/libraries/core/Shell.cc 2009-12-17 23:11:16 UTC (rev 6375)
@@ -188,23 +188,10 @@
this->updateListeners<&ShellListener::cursorChanged>();
}
- void Shell::addOutputLine(const std::string& line, LineType type)
+ void Shell::addOutput(const std::string& text, LineType type)
{
- // Make sure we really only have one line per line (no new lines!)
- SubString lines(line, '\n');
- for (unsigned i = 0; i < lines.size(); ++i)
- {
- this->outputLines_.push_front(std::make_pair(lines[i], type));
-
- if (this->scrollPosition_)
- this->scrollPosition_++;
- else
- this->scrollIterator_ = this->outputLines_.begin();
-
- this->bFinishedLastLine_ = true;
- if (!this->scrollPosition_)
- this->updateListeners<&ShellListener::lineAdded>();
- }
+ this->outputBuffer_ << text;
+ this->outputChanged(type);
}
void Shell::clearOutput()
@@ -247,7 +234,7 @@
return "";
}
- void Shell::outputChanged(int level)
+ void Shell::outputChanged(int lineType)
{
bool newline = false;
do
@@ -267,10 +254,23 @@
break;
if (this->bFinishedLastLine_)
- this->addOutputLine(output, static_cast<LineType>(level));
+ {
+ this->outputLines_.push_front(std::make_pair(output, static_cast<LineType>(lineType)));
+
+ if (this->scrollPosition_)
+ this->scrollPosition_++;
+ else
+ this->scrollIterator_ = this->outputLines_.begin();
+
+ this->bFinishedLastLine_ = newline;
+
+ if (!this->scrollPosition_)
+ this->updateListeners<&ShellListener::lineAdded>();
+ }
else
{
this->outputLines_.front().first += output;
+ this->bFinishedLastLine_ = newline;
this->updateListeners<&ShellListener::onlyLastLineChanged>();
}
this->bFinishedLastLine_ = newline;
@@ -307,7 +307,10 @@
this->updateListeners<&ShellListener::executed>();
if (!CommandExecutor::execute(this->inputBuffer_->get()))
- this->addOutputLine("Error: Can't execute \"" + this->inputBuffer_->get() + "\".", Error);
+ {
+ this->outputBuffer_ << "Error: Can't execute \"" << this->inputBuffer_->get() << "\"." << std::endl;
+ this->outputChanged(Error);
+ }
this->clearInput();
}
@@ -315,7 +318,8 @@
void Shell::hintAndComplete()
{
this->inputBuffer_->set(CommandExecutor::complete(this->inputBuffer_->get()));
- this->addOutputLine(CommandExecutor::hint(this->inputBuffer_->get()), Hint);
+ this->outputBuffer_ << CommandExecutor::hint(this->inputBuffer_->get()) << std::endl;
+ this->outputChanged(Hint);
this->inputChanged();
}
Modified: code/branches/presentation2/src/libraries/core/Shell.h
===================================================================
--- code/branches/presentation2/src/libraries/core/Shell.h 2009-12-17 22:49:25 UTC (rev 6374)
+++ code/branches/presentation2/src/libraries/core/Shell.h 2009-12-17 23:11:16 UTC (rev 6375)
@@ -102,7 +102,7 @@
LineList::const_iterator getNewestLineIterator() const;
LineList::const_iterator getEndIterator() const;
- void addOutputLine(const std::string& line, LineType type = None);
+ void addOutput(const std::string& text, LineType type = None);
void clearOutput();
inline unsigned int getNumLines() const
Modified: code/branches/presentation2/src/orxonox/overlays/InGameConsole.cc
===================================================================
--- code/branches/presentation2/src/orxonox/overlays/InGameConsole.cc 2009-12-17 22:49:25 UTC (rev 6374)
+++ code/branches/presentation2/src/orxonox/overlays/InGameConsole.cc 2009-12-17 23:11:16 UTC (rev 6375)
@@ -339,7 +339,7 @@
*/
void InGameConsole::executed()
{
- this->shell_->addOutputLine(this->shell_->getInput(), Shell::Command);
+ this->shell_->addOutput(this->shell_->getInput() + '\n', Shell::Command);
}
/**
More information about the Orxonox-commit
mailing list