Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 29, 2009, 10:43:43 PM (14 years ago)
Author:
rgrieder
Message:

Extended Shell line colouring in order to distinguish output from COUT, entered commands and hints.

File:
1 edited

Legend:

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

    r6139 r6180  
    4545    SetConsoleCommandShortcut(OutputHandler, debug);
    4646
    47     Shell::Shell(const std::string& consoleName, bool bScrollable, bool bPrependOutputLevel)
     47    Shell::Shell(const std::string& consoleName, bool bScrollable)
    4848        : OutputListener(consoleName)
    4949        , inputBuffer_(new InputBuffer())
    5050        , consoleName_(consoleName)
    51         , bPrependOutputLevel_(bPrependOutputLevel)
    5251        , bScrollable_(bScrollable)
    5352    {
     
    191190    }
    192191
    193     void Shell::addOutputLine(const std::string& line, int level)
     192    void Shell::addOutputLine(const std::string& line, LineType type)
    194193    {
    195194        // Make sure we really only have one line per line (no new lines!)
     
    197196        for (unsigned i = 0; i < lines.size(); ++i)
    198197        {
    199             if (level <= this->softDebugLevel_)
    200                 this->outputLines_.push_front(lines[i]);
     198            this->outputLines_.push_front(std::make_pair(lines[i], type));
    201199            this->updateListeners<&ShellListener::lineAdded>();
    202200        }
     
    214212    }
    215213
    216     std::list<std::string>::const_iterator Shell::getNewestLineIterator() const
     214    Shell::LineList::const_iterator Shell::getNewestLineIterator() const
    217215    {
    218216        if (this->scrollPosition_)
     
    222220    }
    223221
    224     std::list<std::string>::const_iterator Shell::getEndIterator() const
     222    Shell::LineList::const_iterator Shell::getEndIterator() const
    225223    {
    226224        return this->outputLines_.end();
     
    264262            if (this->bFinishedLastLine_)
    265263            {
    266                 if (this->bPrependOutputLevel_)
    267                 {
    268                     if (level == 0)
    269                         output.insert(0, 1, static_cast<char>(-1));
    270                     else
    271                         output.insert(0, 1, static_cast<char>(level));
    272                 }
    273 
    274                 this->outputLines_.push_front(output);
     264                this->outputLines_.push_front(std::make_pair(output, static_cast<LineType>(level)));
    275265
    276266                if (this->scrollPosition_)
     
    288278            else
    289279            {
    290                 (*this->outputLines_.begin()) += output;
     280                this->outputLines_.front().first += output;
    291281                this->bFinishedLastLine_ = newline;
    292282                this->updateListeners<&ShellListener::onlyLastLineChanged>();
     
    325315
    326316        if (!CommandExecutor::execute(this->inputBuffer_->get()))
    327             this->addOutputLine("Error: Can't execute \"" + this->inputBuffer_->get() + "\".", 1);
     317            this->addOutputLine("Error: Can't execute \"" + this->inputBuffer_->get() + "\".", Error);
    328318
    329319        this->clearInput();
     
    333323    {
    334324        this->inputBuffer_->set(CommandExecutor::complete(this->inputBuffer_->get()));
    335         this->addOutputLine(CommandExecutor::hint(this->inputBuffer_->get()), -1);
     325        this->addOutputLine(CommandExecutor::hint(this->inputBuffer_->get()), Hint);
    336326
    337327        this->inputChanged();
Note: See TracChangeset for help on using the changeset viewer.