Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6375


Ignore:
Timestamp:
Dec 18, 2009, 12:11:16 AM (15 years ago)
Author:
rgrieder
Message:

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.

Location:
code/branches/presentation2/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/libraries/core/IOConsole.cc

    r6350 r6375  
    6060    void IOConsole::executed()
    6161    {
    62         this->shell_->addOutputLine(this->promptString_ + this->shell_->getInput(), Shell::Command);
     62        this->shell_->addOutput(this->promptString_ + this->shell_->getInput() + '\n', Shell::Command);
    6363    }
    6464
     
    509509        std::cout.flush();
    510510        if (!this->origCout_.str().empty())
    511             this->shell_->addOutputLine(this->origCout_.str(), Shell::None);
     511            this->shell_->addOutput(this->origCout_.str(), Shell::None);
    512512
    513513        this->shell_->unregisterListener(this);
     
    602602        if (!this->origCout_.str().empty())
    603603        {
    604             this->shell_->addOutputLine(this->origCout_.str(), Shell::None);
     604            this->shell_->addOutput(this->origCout_.str(), Shell::None);
    605605            this->origCout_.str("");
    606606        }
  • code/branches/presentation2/src/libraries/core/Shell.cc

    r6374 r6375  
    189189    }
    190190
    191     void Shell::addOutputLine(const std::string& line, LineType type)
    192     {
    193         // Make sure we really only have one line per line (no new lines!)
    194         SubString lines(line, '\n');
    195         for (unsigned i = 0; i < lines.size(); ++i)
    196         {
    197             this->outputLines_.push_front(std::make_pair(lines[i], type));
    198 
    199             if (this->scrollPosition_)
    200                 this->scrollPosition_++;
    201             else
    202                 this->scrollIterator_ = this->outputLines_.begin();
    203 
    204             this->bFinishedLastLine_ = true;
    205             if (!this->scrollPosition_)
    206                 this->updateListeners<&ShellListener::lineAdded>();
    207         }
     191    void Shell::addOutput(const std::string& text, LineType type)
     192    {
     193        this->outputBuffer_ << text;
     194        this->outputChanged(type);
    208195    }
    209196
     
    248235    }
    249236
    250     void Shell::outputChanged(int level)
     237    void Shell::outputChanged(int lineType)
    251238    {
    252239        bool newline = false;
     
    268255
    269256            if (this->bFinishedLastLine_)
    270                 this->addOutputLine(output, static_cast<LineType>(level));
     257            {
     258                this->outputLines_.push_front(std::make_pair(output, static_cast<LineType>(lineType)));
     259
     260                if (this->scrollPosition_)
     261                    this->scrollPosition_++;
     262                else
     263                    this->scrollIterator_ = this->outputLines_.begin();
     264
     265                this->bFinishedLastLine_ = newline;
     266
     267                if (!this->scrollPosition_)
     268                    this->updateListeners<&ShellListener::lineAdded>();
     269            }
    271270            else
    272271            {
    273272                this->outputLines_.front().first += output;
     273                this->bFinishedLastLine_ = newline;
    274274                this->updateListeners<&ShellListener::onlyLastLineChanged>();
    275275            }
     
    308308
    309309        if (!CommandExecutor::execute(this->inputBuffer_->get()))
    310             this->addOutputLine("Error: Can't execute \"" + this->inputBuffer_->get() + "\".", Error);
     310        {
     311            this->outputBuffer_ << "Error: Can't execute \"" << this->inputBuffer_->get() << "\"." << std::endl;
     312            this->outputChanged(Error);
     313        }
    311314
    312315        this->clearInput();
     
    316319    {
    317320        this->inputBuffer_->set(CommandExecutor::complete(this->inputBuffer_->get()));
    318         this->addOutputLine(CommandExecutor::hint(this->inputBuffer_->get()), Hint);
     321        this->outputBuffer_ << CommandExecutor::hint(this->inputBuffer_->get()) << std::endl;
     322        this->outputChanged(Hint);
    319323
    320324        this->inputChanged();
  • code/branches/presentation2/src/libraries/core/Shell.h

    r6374 r6375  
    103103            LineList::const_iterator getEndIterator() const;
    104104
    105             void addOutputLine(const std::string& line, LineType type = None);
     105            void addOutput(const std::string& text, LineType type = None);
    106106            void clearOutput();
    107107
  • code/branches/presentation2/src/orxonox/overlays/InGameConsole.cc

    r6223 r6375  
    340340    void InGameConsole::executed()
    341341    {
    342         this->shell_->addOutputLine(this->shell_->getInput(), Shell::Command);
     342        this->shell_->addOutput(this->shell_->getInput() + '\n', Shell::Command);
    343343    }
    344344
Note: See TracChangeset for help on using the changeset viewer.