Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 17, 2008, 3:58:19 AM (16 years ago)
Author:
landauf
Message:
  • implemented Shell, but not yet linked with the graphical console
  • added new features (cursor, OIS::KeyCode listener) to InputBuffer
  • changed some includes to avoid circular header-dependencies in OrxonoxClass and Shell
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/console/src/core/Shell.h

    r1312 r1313  
    3030#define _Shell_H__
    3131
     32#include <list>
     33#include <vector>
     34
    3235#include "CorePrereqs.h"
    3336
     
    3841namespace orxonox
    3942{
    40     class ShellListener
     43    class _CoreExport ShellListener
    4144    {
    42         virtual void outputChanged() = 0;
    43         virtual void lastLineChanged() = 0;
    44         virtual void inputChanged() = 0;
    45         virtual void exit() = 0;
    46     }
     45        friend class Shell;
     46
     47        virtual void linesChanged() {}
     48        virtual void onlyLastLineChanged() {}
     49        virtual void lineAdded() {}
     50        virtual void inputChanged() {}
     51        virtual void cursorChanged() {}
     52        virtual void exit() {}
     53    };
    4754
    4855    class _CoreExport Shell : virtual public OrxonoxClass, public InputBufferListener, public OutputBufferListener
     
    5360            virtual void setConfigValues();
    5461
     62            void registerListener(ShellListener* listener);
     63            void unregisterListener(ShellListener* listener);
     64
     65            inline InputBuffer& getInputBuffer()
     66                { return this->inputBuffer_; }
     67            inline OutputBuffer& getOutputBuffer()
     68                { return this->outputBuffer_; }
     69
     70            void setCursorPosition(unsigned int cursor);
     71            inline unsigned int getCursorPosition() const
     72                { return this->inputBuffer_.getCursorPosition(); }
     73
     74            void setInput(const std::string& input);
     75
     76            inline void clearInput()
     77                { this->setInput(""); }
     78            inline std::string getInput() const
     79                { return this->inputBuffer_.get(); }
     80
     81            inline std::list<std::string>::const_iterator getNewestLineIterator() const;
     82            inline std::list<std::string>::const_iterator getEndIterator() const;
     83
     84            void addLine(const std::string& line, unsigned int level);
     85            void clearLines();
     86
     87            inline unsigned int getNumLines() const
     88                { return this->lines_.size(); }
     89            inline unsigned int getScrollPosition() const
     90                { return this->scrollPosition_; }
     91
    5592        private:
    5693            Shell();
    5794            Shell(const Shell& other);
    58             ~Shell() {}
     95            virtual ~Shell() {}
     96
     97            void addToHistory(const std::string& command);
     98            std::string getFromHistory() const;
    5999
    60100            virtual void outputChanged();
     
    63103            void hintandcomplete();
    64104            void backspace();
     105            void deletechar();
     106            void clear();
    65107            void cursor_right();
    66108            void cursor_left();
     109            void cursor_end();
     110            void cursor_home();
    67111            void history_up();
    68112            void history_down();
     
    71115            void exit();
    72116
     117            std::list<ShellListener*> listeners_;
    73118            InputBuffer inputBuffer_;
    74             OutputBuffer OutputBuffer_;
     119            OutputBuffer outputBuffer_;
    75120            std::list<std::string> lines_;
    76             unsigned int cursor_;
     121            std::list<std::string>::const_iterator scrollIterator_;
     122            unsigned int scrollPosition_;
    77123            std::vector<std::string> commandHistory_;
    78124            unsigned int maxHistoryLength_;
     125            unsigned int historyPosition_;
     126            unsigned int historyOffset_;
    79127    };
    80128}
Note: See TracChangeset for help on using the changeset viewer.