[Orxonox-commit 1286] r6004 - in code/branches/console/src: libraries/core libraries/util orxonox/overlays
rgrieder at orxonox.net
rgrieder at orxonox.net
Fri Oct 30 12:39:52 CET 2009
Author: rgrieder
Date: 2009-10-30 12:39:51 +0100 (Fri, 30 Oct 2009)
New Revision: 6004
Modified:
code/branches/console/src/libraries/core/Core.cc
code/branches/console/src/libraries/core/Core.h
code/branches/console/src/libraries/core/IOConsole.cc
code/branches/console/src/libraries/core/IOConsole.h
code/branches/console/src/libraries/core/Shell.cc
code/branches/console/src/libraries/core/Shell.h
code/branches/console/src/libraries/util/OutputHandler.cc
code/branches/console/src/libraries/util/OutputHandler.h
code/branches/console/src/orxonox/overlays/InGameConsole.cc
code/branches/console/src/orxonox/overlays/InGameConsole.h
Log:
De-singletonised Shell so that both consoles have their own Shell instance. However they share the history.
Also modified IOConsole to hopefully work with status lines.
Modified: code/branches/console/src/libraries/core/Core.cc
===================================================================
--- code/branches/console/src/libraries/core/Core.cc 2009-10-28 16:58:11 UTC (rev 6003)
+++ code/branches/console/src/libraries/core/Core.cc 2009-10-30 11:39:51 UTC (rev 6004)
@@ -66,7 +66,6 @@
#include "IOConsole.h"
#include "LuaState.h"
#include "ScopedSingletonManager.h"
-#include "Shell.h"
#include "TclBind.h"
#include "TclThreadManager.h"
#include "input/InputManager.h"
@@ -232,8 +231,6 @@
this->tclBind_.reset(new TclBind(PathConfig::getDataPathString()));
this->tclThreadManager_.reset(new TclThreadManager(tclBind_->getTclInterpreter()));
- // create a shell
- this->shell_.reset(new Shell());
// create persistent io console
this->ioConsole_.reset(new IOConsole());
Modified: code/branches/console/src/libraries/core/Core.h
===================================================================
--- code/branches/console/src/libraries/core/Core.h 2009-10-28 16:58:11 UTC (rev 6003)
+++ code/branches/console/src/libraries/core/Core.h 2009-10-30 11:39:51 UTC (rev 6004)
@@ -93,7 +93,6 @@
scoped_ptr<CoreConfiguration> configuration_;
scoped_ptr<TclBind> tclBind_;
scoped_ptr<TclThreadManager> tclThreadManager_;
- scoped_ptr<Shell> shell_;
scoped_ptr<IOConsole> ioConsole_;
// graphical
scoped_ptr<GraphicsManager> graphicsManager_; //!< Interface to OGRE
Modified: code/branches/console/src/libraries/core/IOConsole.cc
===================================================================
--- code/branches/console/src/libraries/core/IOConsole.cc 2009-10-28 16:58:11 UTC (rev 6003)
+++ code/branches/console/src/libraries/core/IOConsole.cc 2009-10-30 11:39:51 UTC (rev 6004)
@@ -51,7 +51,7 @@
IOConsole* IOConsole::singletonPtr_s = NULL;
const std::string promptString_g = "orxonox>";
-#if 1//def ORXONOX_PLATFORM_UNIX
+#ifdef ORXONOX_PLATFORM_UNIX
termios* IOConsole::originalTerminalSettings_;
@@ -66,17 +66,17 @@
}
IOConsole::IOConsole()
- : shell_(Shell::getInstance())
- , buffer_(Shell::getInstance().getInputBuffer())
+ : shell_(new Shell("IOConsole", false))
+ , buffer_(shell_->getInputBuffer())
+ , originalTerminalSettings_(new termios())
, bStatusPrinted_(false)
{
- this->originalTerminalSettings_ = new termios;
this->setTerminalMode();
- this->shell_.registerListener(this);
+ this->shell_->registerListener(this);
-
// Manually set the widths of the individual status lines
- this->statusLineWidths_.push_back(20);
+ this->statusLineWidths_.push_back(6);
+ this->statusLineMaxWidth_ = 6;
}
IOConsole::~IOConsole()
@@ -85,6 +85,7 @@
std::cout.flush();
resetTerminalMode();
delete this->originalTerminalSettings_;
+ this->shell_->destroy();
}
void IOConsole::setTerminalMode()
@@ -188,7 +189,9 @@
if (escapeMode == EscapeMode::First)
this->buffer_->buttonPressed(KeyEvent(KeyCode::Escape, '\033', 0));
- // Print input line
+ // Clear screen below the last output line by first moving the cursor to the beginning of the first status line
+ std::cout << "\033[" << (this->bStatusPrinted_ ? this->statusLineWidths_.size() : 0) << "F\033[J";
+ this->printStatusLines();
this->printInputLine();
}
@@ -232,14 +235,12 @@
{
// Set cursor to the beginning of the line and erase the line
std::cout << "\033[1G\033[K";
- // Print status line
- //std::cout << std::fixed << std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgFPS() << " fps, " << std::setprecision(2) << std::setw(5) << Game::getInstance().getAvgTickTime() << " ms avg ticktime # ";
// Indicate a command prompt
std::cout << promptString_g;
// Save cursor position
std::cout << "\033[s";
// Print command line buffer
- std::cout << this->shell_.getInput();
+ std::cout << this->shell_->getInput();
// Restore cursor position and move it to the right
std::cout << "\033[u";
if (this->buffer_->getCursorPosition() > 0)
@@ -251,20 +252,16 @@
{
if (!this->statusLineWidths_.empty())
{
- if (this->bStatusPrinted_)
- {
- // Erase the status lines first (completely, including new lines!)
-
- }
// Check terminal size
- /*
int x, y;
- if (this->getTerminalSize(&x, &y) && (x < statusTextWidth_g || y < (2 + statusTextHeight_g)))
+ if (this->getTerminalSize(&x, &y) && (x < (int)this->statusLineMaxWidth_ || y < (int)(this->minOutputLines_ + this->statusLineWidths_.size())))
{
this->bStatusPrinted_ = false;
return;
}
- */
+ std::cout << "Status" << std::endl;
+ std::cout.flush();
+ this->bStatusPrinted_ = true;
}
}
@@ -306,8 +303,8 @@
#elif defined(ORXONOX_PLATFORM_WINDOWS)
IOConsole::IOConsole()
- : shell_(Shell::getInstance())
- , buffer_(Shell::getInstance().getInputBuffer())
+ : shell_(new Shell("IOConsole", false))
+ , buffer_(shell_->getInputBuffer())
{
this->setTerminalMode();
}
@@ -328,7 +325,7 @@
{
}
- void IOConsole::print(const std::string& text)
+ void IOConsole::printLogText(const std::string& text)
{
}
@@ -359,11 +356,11 @@
void IOConsole::onlyLastLineChanged()
{
// Save cursor position and move it to the beginning of the first output line
- std::cout << "\033[s\033[" << (1 + 0/*statusTextHeight_g*/) << "F";
+ std::cout << "\033[s\033[" << (1 + this->statusLineWidths_.size()) << "F";
// Erase the line
std::cout << "\033[K";
// Reprint the last output line
- this->printLogText(*(this->shell_.getNewestLineIterator()));
+ this->printLogText(*(this->shell_->getNewestLineIterator()));
// Restore cursor
std::cout << "\033[u";
std::cout.flush();
@@ -375,15 +372,13 @@
*/
void IOConsole::lineAdded()
{
- // Save cursor and move it to the beginning of the first status line
- std::cout << "\033[s\033[" << 0/*statusTextHeight_g*/ << "F";
- // Create a new line and move cursor to the beginning of it (one cell up)
- std::cout << std::endl << "\033[1F";
+ // Move cursor to the beginning of the first status line and erase screen from there
+ std::cout << "\033[" << this->statusLineWidths_.size() << "F\033[J";
// Print the new output line
- this->printLogText(*(this->shell_.getNewestLineIterator()));
- // Restore cursor (for horizontal position) and move it down again (just in case the lines were shifted)
- std::cout << "\033[u\033[" << (1 + 0/*statusTextHeight_g*/) << "B";
- std::cout.flush();
+ this->printLogText(*(this->shell_->getNewestLineIterator()));
+ std::cout << std::endl;
+ this->printStatusLines();
+ this->printInputLine();
}
/**
@@ -413,7 +408,7 @@
// Move cursor the beginning of the line
std::cout << "\033[1G";
// Print command so the user knows what he has typed
- std::cout << promptString_g << this->shell_.getInput() << std::endl;
+ std::cout << promptString_g << this->shell_->getInput() << std::endl;
this->printInputLine();
}
Modified: code/branches/console/src/libraries/core/IOConsole.h
===================================================================
--- code/branches/console/src/libraries/core/IOConsole.h 2009-10-28 16:58:11 UTC (rev 6003)
+++ code/branches/console/src/libraries/core/IOConsole.h 2009-10-30 11:39:51 UTC (rev 6004)
@@ -69,12 +69,14 @@
void cursorChanged();
void executed();
void exit();
- Shell& shell_;
+ Shell* shell_;
InputBuffer* buffer_;
static termios* originalTerminalSettings_;
bool bPrintStatusLine_;
bool bStatusPrinted_;
std::vector<unsigned> statusLineWidths_;
+ unsigned int statusLineMaxWidth_;
+ static const unsigned minOutputLines_ = 3;
static IOConsole* singletonPtr_s;
};
Modified: code/branches/console/src/libraries/core/Shell.cc
===================================================================
--- code/branches/console/src/libraries/core/Shell.cc 2009-10-28 16:58:11 UTC (rev 6003)
+++ code/branches/console/src/libraries/core/Shell.cc 2009-10-30 11:39:51 UTC (rev 6004)
@@ -33,24 +33,21 @@
#include "CommandExecutor.h"
#include "CoreIncludes.h"
#include "ConfigValueIncludes.h"
-#include "Core.h"
#include "ConsoleCommand.h"
namespace orxonox
{
- SetConsoleCommand(Shell, clearShell, true);
- SetConsoleCommand(Shell, history, true);
-
SetConsoleCommandShortcut(OutputHandler, log);
SetConsoleCommandShortcut(OutputHandler, error);
SetConsoleCommandShortcut(OutputHandler, warning);
SetConsoleCommandShortcut(OutputHandler, info);
SetConsoleCommandShortcut(OutputHandler, debug);
- Shell* Shell::singletonPtr_s = 0;
-
- Shell::Shell()
- : OutputListener("shell")
+ Shell::Shell(const std::string& consoleName, bool bScrollable)
+ : inputBuffer_(new InputBuffer())
+ , OutputListener(consoleName)
+ , consoleName_(consoleName)
+ , bScrollable_(bScrollable)
{
RegisterRootObject(Shell);
@@ -62,8 +59,6 @@
this->bAddOutputLevel_ = false;
this->clearLines();
-
- this->inputBuffer_ = new InputBuffer();
this->configureInputBuffer();
// Get a config file for the command history
@@ -78,7 +73,13 @@
// Get the previous output and add it to the Shell
for (OutputHandler::OutputVectorIterator it = OutputHandler::getInstance().getOutputVectorBegin();
it != OutputHandler::getInstance().getOutputVectorEnd(); ++it)
- this->addLine(it->second, it->first);
+ {
+ if (it->first <= this->getSoftDebugLevel())
+ {
+ this->outputBuffer_ << it->second;
+ this->outputChanged(it->first);
+ }
+ }
// Register the shell as output listener
OutputHandler::getInstance().registerOutputListener(this);
@@ -92,9 +93,9 @@
void Shell::setConfigValues()
{
- SetConfigValueGeneric(commandHistoryConfigFileType_, maxHistoryLength_, "maxHistoryLength_", "Shell", 100)
+ SetConfigValue(maxHistoryLength_, 100)
.callback(this, &Shell::commandHistoryLengthChanged);
- SetConfigValueGeneric(commandHistoryConfigFileType_, historyOffset_, "historyOffset_", "Shell", 0)
+ SetConfigValue(historyOffset_, 0)
.callback(this, &Shell::commandHistoryOffsetChanged);
SetConfigValueVectorGeneric(commandHistoryConfigFileType_, commandHistory_, std::vector<std::string>());
@@ -103,9 +104,9 @@
#else
const unsigned int defaultLevel = 3;
#endif
- SetConfigValueGeneric(ConfigFileType::Settings, softDebugLevel_, "softDebugLevelShell", "OutputHandler", defaultLevel)
+ SetConfigValueGeneric(ConfigFileType::Settings, softDebugLevel_, "softDebugLevel" + this->consoleName_, "OutputHandler", defaultLevel)
.description("The maximal level of debug output shown in the Shell");
- OutputHandler::getInstance().setSoftDebugLevel("shell", this->softDebugLevel_);
+ this->setSoftDebugLevel(this->softDebugLevel_);
}
void Shell::commandHistoryOffsetChanged()
@@ -148,11 +149,7 @@
this->inputBuffer_->registerListener(this, &Shell::history_search_down, KeyCode::AltPageDown);
}
- void Shell::clearShell()
- {
- Shell::getInstance().clearLines();
- }
-
+ /*
void Shell::history()
{
Shell& instance = Shell::getInstance();
@@ -162,6 +159,7 @@
for (unsigned int i = 0; i < instance.historyOffset_; ++i)
instance.addLine(instance.commandHistory_[i], -1);
}
+ */
void Shell::registerListener(ShellListener* listener)
{
@@ -194,14 +192,14 @@
void Shell::addLine(const std::string& line, int level)
{
if (level <= this->softDebugLevel_)
- this->lines_.push_front(line);
+ this->outputLines_.push_front(line);
this->updateListeners<&ShellListener::lineAdded>();
}
void Shell::clearLines()
{
- this->lines_.clear();
- this->scrollIterator_ = this->lines_.begin();
+ this->outputLines_.clear();
+ this->scrollIterator_ = this->outputLines_.begin();
this->scrollPosition_ = 0;
this->finishedLastLine_ = true;
@@ -214,12 +212,12 @@
if (this->scrollPosition_)
return this->scrollIterator_;
else
- return this->lines_.begin();
+ return this->outputLines_.begin();
}
std::list<std::string>::const_iterator Shell::getEndIterator() const
{
- return this->lines_.end();
+ return this->outputLines_.end();
}
void Shell::addToHistory(const std::string& command)
@@ -238,12 +236,12 @@
return "";
}
- void Shell::outputChanged()
+ void Shell::outputChanged(int level)
{
- std::string output;
- bool newline;
+ bool newline = false;
do
{
+ std::string output;
std::getline(this->outputBuffer_, output);
bool eof = this->outputBuffer_.eof();
@@ -260,14 +258,14 @@
if (this->finishedLastLine_)
{
if (this->bAddOutputLevel_)
- output.insert(0, 1, static_cast<char>(OutputHandler::getInstance().getOutputLevel()));
+ output.insert(0, 1, static_cast<char>(level));
- this->lines_.push_front(output);
+ this->outputLines_.push_front(output);
if (this->scrollPosition_)
this->scrollPosition_++;
else
- this->scrollIterator_ = this->lines_.begin();
+ this->scrollIterator_ = this->outputLines_.begin();
this->finishedLastLine_ = newline;
@@ -278,7 +276,7 @@
}
else
{
- (*this->lines_.begin()) += output;
+ (*this->outputLines_.begin()) += output;
this->finishedLastLine_ = newline;
this->updateListeners<&ShellListener::onlyLastLineChanged>();
}
@@ -412,7 +410,7 @@
void Shell::scroll_up()
{
- if (this->scrollIterator_ != this->lines_.end())
+ if (this->scrollIterator_ != this->outputLines_.end())
{
++this->scrollIterator_;
++this->scrollPosition_;
@@ -423,7 +421,7 @@
void Shell::scroll_down()
{
- if (this->scrollIterator_ != this->lines_.begin())
+ if (this->scrollIterator_ != this->outputLines_.begin())
{
--this->scrollIterator_;
--this->scrollPosition_;
@@ -442,7 +440,7 @@
this->clear();
this->scrollPosition_ = 0;
- this->scrollIterator_ = this->lines_.begin();
+ this->scrollIterator_ = this->outputLines_.begin();
this->updateListeners<&ShellListener::exit>();
}
Modified: code/branches/console/src/libraries/core/Shell.h
===================================================================
--- code/branches/console/src/libraries/core/Shell.h 2009-10-28 16:58:11 UTC (rev 6003)
+++ code/branches/console/src/libraries/core/Shell.h 2009-10-30 11:39:51 UTC (rev 6004)
@@ -31,16 +31,15 @@
#include "CorePrereqs.h"
-#include <cassert>
#include <list>
#include <sstream>
#include <string>
#include <vector>
#include "util/OutputHandler.h"
-#include "input/InputBuffer.h"
#include "OrxonoxClass.h"
#include "ConfigFileManager.h"
+#include "input/InputBuffer.h"
namespace orxonox
{
@@ -61,16 +60,12 @@
virtual void exit() {}
};
- class _CoreExport Shell : public Singleton<Shell>, virtual public OrxonoxClass, public OutputListener
+ class _CoreExport Shell : virtual public OrxonoxClass, public OutputListener
{
- friend class Singleton<Shell>;
public:
- Shell();
+ Shell(const std::string& consoleName, bool bScrollable);
virtual ~Shell();
- static void clearShell();
- static void history();
-
void setConfigValues();
void commandHistoryOffsetChanged();
void commandHistoryLengthChanged();
@@ -99,7 +94,7 @@
void clearLines();
inline unsigned int getNumLines() const
- { return this->lines_.size(); }
+ { return this->outputLines_.size(); }
inline unsigned int getScrollPosition() const
{ return this->scrollPosition_; }
@@ -114,7 +109,7 @@
void addToHistory(const std::string& command);
std::string getFromHistory() const;
- virtual void outputChanged();
+ virtual void outputChanged(int level);
void inputChanged();
void execute();
@@ -145,19 +140,20 @@
InputBuffer* inputBuffer_;
std::stringstream outputBuffer_;
bool finishedLastLine_;
- std::list<std::string> lines_;
+ std::list<std::string> outputLines_;
std::list<std::string>::const_iterator scrollIterator_;
unsigned int scrollPosition_;
- std::vector<std::string> commandHistory_;
- unsigned int maxHistoryLength_;
unsigned int historyPosition_;
- unsigned int historyOffset_;
bool bAddOutputLevel_;
- int softDebugLevel_;
-
ConfigFileType commandHistoryConfigFileType_;
+ const std::string consoleName_;
+ const bool bScrollable_;
- static Shell* singletonPtr_s;
+ // Config values
+ unsigned int maxHistoryLength_;
+ unsigned int historyOffset_;
+ std::vector<std::string> commandHistory_;
+ int softDebugLevel_;
};
}
Modified: code/branches/console/src/libraries/util/OutputHandler.cc
===================================================================
--- code/branches/console/src/libraries/util/OutputHandler.cc 2009-10-28 16:58:11 UTC (rev 6003)
+++ code/branches/console/src/libraries/util/OutputHandler.cc 2009-10-30 11:39:51 UTC (rev 6004)
@@ -92,7 +92,7 @@
this->outputStream_ = &this->logFile_;
// Use default level until we get the configValue from the Core
- outputHandler.setSoftDebugLevel(this->getOutputListenerName(), OutputLevel::Debug);
+ this->setSoftDebugLevel(OutputLevel::Debug);
outputHandler.registerOutputListener(this);
}
@@ -151,15 +151,15 @@
{
this->outputStream_ = &this->buffer_;
// We capture as much input as the listener with the highest level
- outputHandler.setSoftDebugLevel(this->getOutputListenerName(), OutputHandler::getSoftDebugLevel());
+ this->setSoftDebugLevel(OutputHandler::getSoftDebugLevel());
outputHandler.registerOutputListener(this);
}
//! Pushed the just written output to the internal array
- void outputChanged()
+ void outputChanged(int level)
{
// Read ostringstream and store it
- this->output_.push_back(std::make_pair(OutputHandler::getInstance().getOutputLevel(), this->buffer_.str()));
+ this->output_.push_back(std::make_pair(level, this->buffer_.str()));
// Clear content and flags
this->buffer_.str(std::string());
this->buffer_.clear();
@@ -209,6 +209,8 @@
}
}
this->listeners_.push_back(listener);
+ // Update global soft debug level
+ this->setSoftDebugLevel(listener->getOutputListenerName(), listener->getSoftDebugLevel());
}
void OutputHandler::unregisterOutputListener(OutputListener* listener)
Modified: code/branches/console/src/libraries/util/OutputHandler.h
===================================================================
--- code/branches/console/src/libraries/util/OutputHandler.h 2009-10-28 16:58:11 UTC (rev 6003)
+++ code/branches/console/src/libraries/util/OutputHandler.h 2009-10-30 11:39:51 UTC (rev 6004)
@@ -141,7 +141,7 @@
static int getSoftDebugLevel() { return softDebugLevel_s; }
//! Returns the soft debug level for a device by its name @return The level or -1 if the listener was not found
int getSoftDebugLevel(const std::string& name) const;
- //! Sets the soft debug level for a listener by its name
+ //! Sets the soft debug level for a listener by its name @remarks Only works for registered listeners!
void setSoftDebugLevel(const std::string& name, int level);
/**
@@ -230,13 +230,22 @@
OutputListener(const std::string& name)
: outputStream_(NULL)
, name_(name)
+ , softDebugLevel_(OutputLevel::Info)
{}
virtual ~OutputListener() {}
//! Gets called whenever output is put into the stream
- virtual void outputChanged() {}
+ virtual void outputChanged(int level) {}
//! Returns the name of this output listener
const std::string& getOutputListenerName() const { return this->name_; }
+ //! Returns the soft debug level of the listener
+ int getSoftDebugLevel() const { return this->softDebugLevel_; }
+ //! Sets the soft debug level of the listener
+ void setSoftDebugLevel(int level)
+ {
+ this->softDebugLevel_ = level;
+ OutputHandler::getInstance().setSoftDebugLevel(this->name_, level);
+ }
protected:
std::ostream* outputStream_; //!< Pointer to the associated output stream, can be NULL
@@ -256,7 +265,7 @@
std::ostream& stream = *((*it)->outputStream_);
stream << output;
stream.flush();
- (*it)->outputChanged();
+ (*it)->outputChanged(this->outputLevel_);
}
}
Modified: code/branches/console/src/orxonox/overlays/InGameConsole.cc
===================================================================
--- code/branches/console/src/orxonox/overlays/InGameConsole.cc 2009-10-28 16:58:11 UTC (rev 6003)
+++ code/branches/console/src/orxonox/overlays/InGameConsole.cc 2009-10-30 11:39:51 UTC (rev 6004)
@@ -67,7 +67,7 @@
@brief Constructor: Creates and initializes the InGameConsole.
*/
InGameConsole::InGameConsole()
- : shell_(Shell::getInstance())
+ : shell_(new Shell("InGameConsole", true))
, consoleOverlay_(0)
, consoleOverlayContainer_(0)
, consoleOverlayNoise_(0)
@@ -100,6 +100,9 @@
// destroy the input state previously created (InputBuffer gets destroyed by the Shell)
InputManager::getInstance().destroyState("console");
+ // destroy the underlaying shell
+ this->shell_->destroy();
+
Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
if (ovMan)
{
@@ -174,7 +177,7 @@
{
// create the corresponding input state
inputState_ = InputManager::getInstance().createInputState("console", false, false, InputStatePriority::Console);
- inputState_->setKeyHandler(this->shell_.getInputBuffer());
+ inputState_->setKeyHandler(this->shell_->getInputBuffer());
bHidesAllInputChanged();
// create overlay and elements
@@ -252,7 +255,7 @@
// we take -1.2 because the border makes the panel bigger
this->consoleOverlayContainer_->setTop(-1.2 * this->relativeHeight);
- this->shell_.addOutputLevel(true);
+ this->shell_->addOutputLevel(true);
COUT(4) << "Info: InGameConsole initialized" << std::endl;
}
@@ -266,11 +269,11 @@
*/
void InGameConsole::linesChanged()
{
- std::list<std::string>::const_iterator it = this->shell_.getNewestLineIterator();
+ std::list<std::string>::const_iterator it = this->shell_->getNewestLineIterator();
int max = 0;
for (int i = 1; i < LINES; ++i)
{
- if (it != this->shell_.getEndIterator())
+ if (it != this->shell_->getEndIterator())
{
++it;
max = i;
@@ -295,7 +298,7 @@
void InGameConsole::onlyLastLineChanged()
{
if (LINES > 1)
- this->print(*this->shell_.getNewestLineIterator(), 1);
+ this->print(*this->shell_->getNewestLineIterator(), 1);
}
/**
@@ -314,9 +317,9 @@
void InGameConsole::inputChanged()
{
if (LINES > 0)
- this->print(this->shell_.getInput(), 0);
+ this->print(this->shell_->getInput(), 0);
- if (this->shell_.getInput() == "" || this->shell_.getInput().size() == 0)
+ if (this->shell_->getInput() == "" || this->shell_->getInput().size() == 0)
this->inputWindowStart_ = 0;
}
@@ -325,7 +328,7 @@
*/
void InGameConsole::cursorChanged()
{
- unsigned int pos = this->shell_.getCursorPosition() - inputWindowStart_;
+ unsigned int pos = this->shell_->getCursorPosition() - inputWindowStart_;
if (pos > maxCharsPerLine_)
pos = maxCharsPerLine_;
@@ -482,10 +485,10 @@
{
if (output.size() > this->maxCharsPerLine_)
{
- if (this->shell_.getInputBuffer()->getCursorPosition() < this->inputWindowStart_)
- this->inputWindowStart_ = this->shell_.getInputBuffer()->getCursorPosition();
- else if (this->shell_.getInputBuffer()->getCursorPosition() >= (this->inputWindowStart_ + this->maxCharsPerLine_ - 1))
- this->inputWindowStart_ = this->shell_.getInputBuffer()->getCursorPosition() - this->maxCharsPerLine_ + 1;
+ if (this->shell_->getInputBuffer()->getCursorPosition() < this->inputWindowStart_)
+ this->inputWindowStart_ = this->shell_->getInputBuffer()->getCursorPosition();
+ else if (this->shell_->getInputBuffer()->getCursorPosition() >= (this->inputWindowStart_ + this->maxCharsPerLine_ - 1))
+ this->inputWindowStart_ = this->shell_->getInputBuffer()->getCursorPosition() - this->maxCharsPerLine_ + 1;
output = output.substr(this->inputWindowStart_, this->maxCharsPerLine_);
}
@@ -506,7 +509,7 @@
{
this->bActive_ = true;
InputManager::getInstance().enterState("console");
- this->shell_.registerListener(this);
+ this->shell_->registerListener(this);
this->windowResized(this->windowW_, this->windowH_);
this->linesChanged();
@@ -528,7 +531,7 @@
{
this->bActive_ = false;
InputManager::getInstance().leaveState("console");
- this->shell_.unregisterListener(this);
+ this->shell_->unregisterListener(this);
// scroll up
this->scroll_ = -1;
Modified: code/branches/console/src/orxonox/overlays/InGameConsole.h
===================================================================
--- code/branches/console/src/orxonox/overlays/InGameConsole.h 2009-10-28 16:58:11 UTC (rev 6003)
+++ code/branches/console/src/orxonox/overlays/InGameConsole.h 2009-10-30 11:39:51 UTC (rev 6004)
@@ -80,7 +80,7 @@
void bHidesAllInputChanged();
private: // variables
- Shell& shell_;
+ Shell* shell_;
bool bActive_;
int windowW_;
int windowH_;
More information about the Orxonox-commit
mailing list