Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/network/src/core/Shell.h @ 1486

Last change on this file since 1486 was 1486, checked in by rgrieder, 16 years ago
  • fixed the InputBufferListener bug in a proper way It looks a little bit ugly, but at least it's got a new feature: You don't need to derive from InputBufferListener (removed it)
  • commented the shader hack in Model.cc
File size: 4.6 KB
RevLine 
[1312]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#ifndef _Shell_H__
30#define _Shell_H__
31
[1313]32#include <list>
33#include <vector>
34
[1312]35#include "CorePrereqs.h"
36
37#include "OrxonoxClass.h"
38#include "InputBuffer.h"
39#include "OutputBuffer.h"
40
41namespace orxonox
42{
[1313]43    class _CoreExport ShellListener
[1312]44    {
[1313]45        friend class Shell;
[1312]46
[1424]47        public:
48            virtual ~ShellListener() {}
49
50        private:
51            virtual void linesChanged() {}
52            virtual void onlyLastLineChanged() {}
53            virtual void lineAdded() {}
54            virtual void inputChanged() {}
55            virtual void cursorChanged() {}
56            virtual void exit() {}
[1313]57    };
58
[1486]59    class _CoreExport Shell : virtual public OrxonoxClass, public OutputBufferListener
[1312]60    {
61        public:
62            static Shell& getInstance();
[1326]63            static Shell& createShell();
[1312]64
[1424]65            static void clearShell();
66            static void history();
67
[1312]68            virtual void setConfigValues();
69
[1313]70            void registerListener(ShellListener* listener);
71            void unregisterListener(ShellListener* listener);
72
[1446]73            void setInputBuffer(InputBuffer* buffer);
[1313]74            inline InputBuffer& getInputBuffer()
[1446]75                { return (*this->inputBuffer_); }
[1313]76            inline OutputBuffer& getOutputBuffer()
77                { return this->outputBuffer_; }
78
79            void setCursorPosition(unsigned int cursor);
80            inline unsigned int getCursorPosition() const
[1446]81                { return this->inputBuffer_->getCursorPosition(); }
[1313]82
83            void setInput(const std::string& input);
84
85            inline void clearInput()
86                { this->setInput(""); }
87            inline std::string getInput() const
[1446]88                { return this->inputBuffer_->get(); }
[1313]89
[1317]90            std::list<std::string>::const_iterator getNewestLineIterator() const;
91            std::list<std::string>::const_iterator getEndIterator() const;
[1313]92
[1424]93            void addLine(const std::string& line, int level = 0);
[1313]94            void clearLines();
95
96            inline unsigned int getNumLines() const
97                { return this->lines_.size(); }
98            inline unsigned int getScrollPosition() const
99                { return this->scrollPosition_; }
100
[1334]101            inline void addOutputLevel(bool bAddOutputLevel)
102                { this->bAddOutputLevel_ = bAddOutputLevel; }
103
[1312]104        private:
105            Shell();
106            Shell(const Shell& other);
[1313]107            virtual ~Shell() {}
[1312]108
[1313]109            void addToHistory(const std::string& command);
110            std::string getFromHistory() const;
111
[1312]112            virtual void outputChanged();
113            void inputChanged();
114            void execute();
115            void hintandcomplete();
116            void backspace();
[1313]117            void deletechar();
118            void clear();
[1312]119            void cursor_right();
120            void cursor_left();
[1313]121            void cursor_end();
122            void cursor_home();
[1312]123            void history_up();
124            void history_down();
125            void scroll_up();
126            void scroll_down();
127            void exit();
128
[1313]129            std::list<ShellListener*> listeners_;
[1446]130            InputBuffer* inputBuffer_;
[1313]131            OutputBuffer outputBuffer_;
[1322]132            bool finishedLastLine_;
[1312]133            std::list<std::string> lines_;
[1313]134            std::list<std::string>::const_iterator scrollIterator_;
135            unsigned int scrollPosition_;
[1312]136            std::vector<std::string> commandHistory_;
137            unsigned int maxHistoryLength_;
[1313]138            unsigned int historyPosition_;
139            unsigned int historyOffset_;
[1334]140            bool bAddOutputLevel_;
[1312]141    };
142}
143
144#endif /* _Shell_H__ */
Note: See TracBrowser for help on using the repository browser.